1 package org.apache.maven.it;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.it.util.ResourceExtractor;
23
24 import java.io.File;
25 import java.util.List;
26
27
28
29
30
31
32 public class MavenITmng3220ImportScopeTest
33 extends AbstractMavenIntegrationTestCase
34 {
35 public MavenITmng3220ImportScopeTest()
36 {
37 super( "(2.0.8,3.0-alpha-1),[3.0-alpha-3,)" );
38 }
39
40 public void testitMNG3220a()
41 throws Exception
42 {
43 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3220" );
44
45 testDir = new File( testDir, "imported-pom-depMgmt" );
46
47 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
48 verifier.setAutoclean( false );
49 verifier.deleteDirectory( "target" );
50 verifier.deleteArtifacts( "org.apache.maven.its.mng3220" );
51 verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
52 verifier.newDefaultFilterProperties() );
53 verifier.addCliOption( "--settings" );
54 verifier.addCliOption( "settings.xml" );
55 verifier.executeGoal( "validate" );
56 verifier.verifyErrorFreeLog();
57 verifier.resetStreams();
58 }
59
60 public void testitMNG3220b()
61 throws Exception
62 {
63 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3220" );
64
65 testDir = new File( testDir, "depMgmt-pom-module-notImported" );
66
67 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
68 verifier.setAutoclean( false );
69 verifier.deleteDirectory( "target" );
70 verifier.deleteArtifacts( "org.apache.maven.its.mng3220" );
71 verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8",
72 verifier.newDefaultFilterProperties() );
73 verifier.addCliOption( "--settings" );
74 verifier.addCliOption( "settings.xml" );
75
76 try
77 {
78 verifier.executeGoal( "validate" );
79 verifier.verifyErrorFreeLog();
80 fail( "Should fail to build with missing junit version." );
81 }
82 catch ( VerificationException e )
83 {
84
85 }
86
87 verifier.resetStreams();
88
89 List<String> lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
90
91 boolean found = false;
92 for ( String line : lines )
93 {
94 if ( line.contains( "\'dependencies.dependency.version\' is missing for junit:junit" ) || line.contains(
95 "\'dependencies.dependency.version\' for junit:junit:jar is missing" ) )
96 {
97 found = true;
98 break;
99 }
100 }
101
102 assertTrue( "Should have found validation error line in output.", found );
103 }
104
105 }