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 java.io.File;
23 import java.util.List;
24
25 import org.apache.maven.it.util.ResourceExtractor;
26
27
28
29
30
31
32
33
34 public class MavenITmng3023ReactorDependencyResolutionTest
35 extends AbstractMavenIntegrationTestCase
36 {
37
38 public MavenITmng3023ReactorDependencyResolutionTest()
39 {
40 super( "(2.1.0-M1,)" );
41 }
42
43
44
45
46
47
48
49
50
51
52
53 public void testitMNG3023A() throws Exception
54 {
55 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3023" );
56
57
58 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
59 verifier.setAutoclean( false );
60 verifier.setLogFileName( "log-a.txt" );
61
62 verifier.deleteDirectory( "dependency/dependency-classes" );
63 verifier.deleteArtifacts( "org.apache.maven.its.mng3023" );
64
65 try
66 {
67 verifier.executeGoal( "validate" );
68 fail( "Expected failure to resolve dependency artifact without at least calling 'compile' phase." );
69 }
70 catch ( VerificationException e )
71 {
72
73 }
74 finally
75 {
76 verifier.resetStreams();
77 }
78 }
79
80
81
82
83
84
85
86
87
88
89
90 public void testitMNG3023B()
91 throws Exception
92 {
93 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3023" );
94
95 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
96 verifier.setAutoclean( false );
97 verifier.setLogFileName( "log-b.txt" );
98
99 new File( testDir, "dependency/dependency-classes" ).mkdirs();
100 verifier.deleteDirectory( "consumer/target" );
101 verifier.deleteArtifacts( "org.apache.maven.its.mng3023" );
102
103 verifier.executeGoal( "initialize" );
104 verifier.verifyErrorFreeLog();
105 verifier.resetStreams();
106
107 List<String> compileClassPath = verifier.loadLines( "consumer/target/compile.classpath", "UTF-8" );
108 assertTrue( compileClassPath.toString(), compileClassPath.contains( "dependency-classes" ) );
109 assertFalse( compileClassPath.toString(), compileClassPath.contains( "dependency-1.jar" ) );
110 }
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126 public void testitMNG3023C()
127 throws Exception
128 {
129 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3023" );
130
131 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
132 verifier.setAutoclean( false );
133
134 verifier.deleteArtifacts( "org.apache.maven.its.mng3023" );
135
136 verifier.deleteDirectory( "consumer/target" );
137 verifier.setLogFileName( "log-c-1.txt" );
138 verifier.executeGoal( "generate-sources" );
139 verifier.verifyErrorFreeLog();
140 verifier.resetStreams();
141
142 List<String> compileClassPath = verifier.loadLines( "consumer/target/compile.classpath", "UTF-8" );
143 assertTrue( compileClassPath.toString(), compileClassPath.contains( "dependency-1.jar" ) );
144 assertFalse( compileClassPath.toString(), compileClassPath.contains( "dependency-classes" ) );
145
146 verifier.deleteDirectory( "dependency/dependency-classes" );
147 verifier.deleteDirectory( "consumer/target" );
148 verifier.setLogFileName( "log-c-2.txt" );
149 verifier.executeGoal( "validate" );
150 verifier.verifyErrorFreeLog();
151 verifier.resetStreams();
152
153 compileClassPath = verifier.loadLines( "consumer/target/compile.classpath", "UTF-8" );
154 assertTrue( compileClassPath.toString(), compileClassPath.contains( "dependency-1.jar" ) );
155 assertFalse( compileClassPath.toString(), compileClassPath.contains( "dependency-classes" ) );
156 }
157
158 }