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
24 import org.apache.maven.it.util.ResourceExtractor;
25
26
27
28
29
30
31 public class MavenITmng2576MakeLikeReactorTest
32 extends AbstractMavenIntegrationTestCase
33 {
34
35 public MavenITmng2576MakeLikeReactorTest()
36 {
37 super( "[2.1.0,)" );
38 }
39
40 private void clean( Verifier verifier )
41 throws Exception
42 {
43 verifier.deleteDirectory( "target" );
44 verifier.deleteDirectory( "sub-a/target" );
45 verifier.deleteDirectory( "sub-b/target" );
46 verifier.deleteDirectory( "sub-c/target" );
47 verifier.deleteDirectory( "sub-d/target" );
48 }
49
50
51
52
53
54
55 public void testitMakeOnlyList()
56 throws Exception
57 {
58 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
59
60 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
61 verifier.setAutoclean( false );
62 clean( verifier );
63 verifier.addCliOption( "-pl" );
64 verifier.addCliOption( "sub-b" );
65 verifier.setLogFileName( "log-only.txt" );
66 verifier.executeGoal( "validate" );
67 verifier.verifyErrorFreeLog();
68 verifier.resetStreams();
69
70 verifier.assertFileNotPresent( "target/touch.txt" );
71 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
72 verifier.assertFilePresent( "sub-b/target/touch.txt" );
73 verifier.assertFileNotPresent( "sub-c/target/touch.txt" );
74 verifier.assertFileNotPresent( "sub-d/target/touch.txt" );
75 }
76
77
78
79
80
81
82 public void testitMakeUpstream()
83 throws Exception
84 {
85 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
86
87 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
88 verifier.setAutoclean( false );
89 clean( verifier );
90 verifier.addCliOption( "-pl" );
91 verifier.addCliOption( "sub-b" );
92 verifier.addCliOption( "-am" );
93 verifier.setLogFileName( "log-upstream.txt" );
94 verifier.executeGoal( "validate" );
95 verifier.verifyErrorFreeLog();
96 verifier.resetStreams();
97
98 verifier.assertFilePresent( "target/touch.txt" );
99 verifier.assertFilePresent( "sub-a/target/touch.txt" );
100 verifier.assertFilePresent( "sub-b/target/touch.txt" );
101 verifier.assertFileNotPresent( "sub-c/target/touch.txt" );
102 verifier.assertFileNotPresent( "sub-d/target/touch.txt" );
103 }
104
105
106
107
108
109
110 public void testitMakeDownstream()
111 throws Exception
112 {
113 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
114
115 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
116 verifier.setAutoclean( false );
117 clean( verifier );
118 verifier.addCliOption( "-pl" );
119 verifier.addCliOption( "sub-b" );
120 verifier.addCliOption( "-amd" );
121 verifier.setLogFileName( "log-downstream.txt" );
122 verifier.executeGoal( "validate" );
123 verifier.verifyErrorFreeLog();
124 verifier.resetStreams();
125
126 verifier.assertFileNotPresent( "target/touch.txt" );
127 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
128 verifier.assertFilePresent( "sub-b/target/touch.txt" );
129 verifier.assertFilePresent( "sub-c/target/touch.txt" );
130 verifier.assertFileNotPresent( "sub-d/target/touch.txt" );
131 }
132
133
134
135
136
137
138 public void testitMakeBoth()
139 throws Exception
140 {
141 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
142
143 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
144 verifier.setAutoclean( false );
145 clean( verifier );
146 verifier.addCliOption( "-pl" );
147 verifier.addCliOption( "sub-b" );
148 verifier.addCliOption( "-am" );
149 verifier.addCliOption( "-amd" );
150 verifier.setLogFileName( "log-both.txt" );
151 verifier.executeGoal( "validate" );
152 verifier.verifyErrorFreeLog();
153 verifier.resetStreams();
154
155 verifier.assertFilePresent( "target/touch.txt" );
156 verifier.assertFilePresent( "sub-a/target/touch.txt" );
157 verifier.assertFilePresent( "sub-b/target/touch.txt" );
158 verifier.assertFilePresent( "sub-c/target/touch.txt" );
159 verifier.assertFileNotPresent( "sub-d/target/touch.txt" );
160 }
161
162
163
164
165
166
167 public void testitMatchesByBasedir()
168 throws Exception
169 {
170 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
171
172 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
173 verifier.setAutoclean( false );
174 clean( verifier );
175 verifier.assertFileNotPresent( "sub-d/pom.xml" );
176 verifier.addCliOption( "-pl" );
177 verifier.addCliOption( "sub-d" );
178 verifier.setLogFileName( "log-basedir.txt" );
179 verifier.executeGoal( "validate" );
180 verifier.verifyErrorFreeLog();
181 verifier.resetStreams();
182
183 verifier.assertFileNotPresent( "target/touch.txt" );
184 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
185 verifier.assertFileNotPresent( "sub-b/target/touch.txt" );
186 verifier.assertFileNotPresent( "sub-c/target/touch.txt" );
187 verifier.assertFilePresent( "sub-d/target/touch.txt" );
188 }
189
190
191
192
193
194
195 public void testitMatchesByBasedirPlus()
196 throws Exception
197 {
198
199 requiresMavenVersion( "[3.2,)" );
200
201 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
202
203 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
204 verifier.setAutoclean( false );
205 clean( verifier );
206 verifier.assertFileNotPresent( "sub-d/pom.xml" );
207 verifier.addCliOption( "-pl" );
208 verifier.addCliOption( "+sub-d" );
209 verifier.setLogFileName( "log-basedir-plus.txt" );
210 verifier.executeGoal( "validate" );
211 verifier.verifyErrorFreeLog();
212 verifier.resetStreams();
213
214 verifier.assertFileNotPresent( "target/touch.txt" );
215 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
216 verifier.assertFileNotPresent( "sub-b/target/touch.txt" );
217 verifier.assertFileNotPresent( "sub-c/target/touch.txt" );
218 verifier.assertFilePresent( "sub-d/target/touch.txt" );
219 }
220
221
222
223
224
225 public void testitMatchesById()
226 throws Exception
227 {
228 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
229
230 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
231 verifier.setAutoclean( false );
232 clean( verifier );
233 verifier.addCliOption( "-pl" );
234 verifier.addCliOption( "org.apache.maven.its.mng2576:sub-b" );
235 verifier.setLogFileName( "log-id.txt" );
236 verifier.executeGoal( "validate" );
237 verifier.verifyErrorFreeLog();
238 verifier.resetStreams();
239
240 verifier.assertFileNotPresent( "target/touch.txt" );
241 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
242 verifier.assertFilePresent( "sub-b/target/touch.txt" );
243 verifier.assertFileNotPresent( "sub-c/target/touch.txt" );
244 verifier.assertFileNotPresent( "sub-d/target/touch.txt" );
245 }
246
247
248
249
250
251
252 public void testitMatchesByArtifactId()
253 throws Exception
254 {
255
256 requiresMavenVersion( "[3.0-alpha-3,)" );
257
258 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
259
260 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
261 verifier.setAutoclean( false );
262 clean( verifier );
263 verifier.addCliOption( "-pl" );
264 verifier.addCliOption( ":sub-b" );
265 verifier.setLogFileName( "log-artifact-id.txt" );
266 verifier.executeGoal( "validate" );
267 verifier.verifyErrorFreeLog();
268 verifier.resetStreams();
269
270 verifier.assertFileNotPresent( "target/touch.txt" );
271 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
272 verifier.assertFilePresent( "sub-b/target/touch.txt" );
273 verifier.assertFileNotPresent( "sub-c/target/touch.txt" );
274 verifier.assertFileNotPresent( "sub-d/target/touch.txt" );
275 }
276
277
278
279
280
281
282 public void testitResumeFrom()
283 throws Exception
284 {
285 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2576" );
286
287 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
288 verifier.setAutoclean( false );
289 clean( verifier );
290 verifier.addCliOption( "-rf" );
291 verifier.addCliOption( "sub-b" );
292 verifier.setLogFileName( "log-resume.txt" );
293 verifier.executeGoal( "validate" );
294 verifier.verifyErrorFreeLog();
295 verifier.resetStreams();
296
297 verifier.assertFileNotPresent( "target/touch.txt" );
298 verifier.assertFileNotPresent( "sub-a/target/touch.txt" );
299 verifier.assertFilePresent( "sub-b/target/touch.txt" );
300 verifier.assertFilePresent( "sub-c/target/touch.txt" );
301 }
302
303 }