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 MavenITmng3545ProfileDeactivationTest
32 extends AbstractMavenIntegrationTestCase
33 {
34
35 public MavenITmng3545ProfileDeactivationTest()
36 {
37 super( "(2.0.9,)" );
38 }
39
40
41
42
43
44
45 public void testBasicBuildWithDefaultProfiles()
46 throws Exception
47 {
48 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3545" );
49
50 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
51 verifier.setAutoclean( false );
52 verifier.deleteDirectory( "target" );
53 verifier.setLogFileName( "log1.txt" );
54
55 verifier.executeGoal( "validate" );
56
57 verifier.verifyErrorFreeLog();
58
59 verifier.assertFilePresent( "target/profile1/touch.txt" );
60 verifier.assertFilePresent( "target/profile2/touch.txt" );
61 verifier.assertFileNotPresent( "target/profile3/touch.txt" );
62 verifier.assertFileNotPresent( "target/profile4/touch.txt" );
63 verifier.assertFileNotPresent( "target/profile5/touch.txt" );
64 verifier.resetStreams();
65 }
66
67
68
69
70
71
72 public void testDeactivateDefaultProfilesHyphen()
73 throws Exception
74 {
75 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3545" );
76
77 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
78 verifier.setAutoclean( false );
79 verifier.deleteDirectory( "target" );
80 verifier.setLogFileName( "log2.txt" );
81
82
83 verifier.addCliOption( "-P-profile1" );
84 verifier.addCliOption( "-P -profile2" );
85
86 verifier.executeGoal( "validate" );
87
88 verifier.verifyErrorFreeLog();
89 verifier.assertFileNotPresent( "target/profile1/touch.txt" );
90 verifier.assertFileNotPresent( "target/profile2/touch.txt" );
91 verifier.resetStreams();
92 }
93
94 public void testDeactivateDefaultProfilesExclamation()
95 throws Exception
96 {
97 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3545" );
98
99 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
100 verifier.setAutoclean( false );
101 verifier.deleteDirectory( "target" );
102 verifier.setLogFileName( "log3.txt" );
103
104
105 verifier.addCliOption( "-P!profile1" );
106 verifier.addCliOption( "-P !profile2" );
107
108 verifier.executeGoal( "validate" );
109
110 verifier.verifyErrorFreeLog();
111 verifier.assertFileNotPresent( "target/profile1/touch.txt" );
112 verifier.assertFileNotPresent( "target/profile2/touch.txt" );
113 verifier.resetStreams();
114 }
115
116
117
118
119
120
121
122 public void testDeactivateActivatedByProp()
123 throws Exception
124 {
125 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3545" );
126
127 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
128 verifier.setAutoclean( false );
129 verifier.deleteDirectory( "target" );
130 verifier.setLogFileName( "log4.txt" );
131
132
133 verifier.addCliOption( "-Dprofile3-active-by-property=true" );
134 verifier.addCliOption( "-P-profile3" );
135
136 verifier.executeGoal( "validate" );
137
138 verifier.verifyErrorFreeLog();
139 verifier.assertFilePresent( "target/profile1/touch.txt" );
140 verifier.assertFilePresent( "target/profile2/touch.txt" );
141 verifier.assertFileNotPresent( "target/profile3/touch.txt" );
142 verifier.assertFileNotPresent( "target/profile4/touch.txt" );
143 verifier.assertFileNotPresent( "target/profile5/touch.txt" );
144 verifier.resetStreams();
145 }
146
147
148
149
150
151
152
153 public void testActivateThenDeactivate()
154 throws Exception
155 {
156 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3545" );
157
158 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
159 verifier.setAutoclean( false );
160 verifier.deleteDirectory( "target" );
161 verifier.setLogFileName( "log5.txt" );
162
163
164 verifier.addCliOption( "-Pprofile4" );
165 verifier.addCliOption( "-P-profile4" );
166
167 verifier.executeGoal( "validate" );
168
169 verifier.verifyErrorFreeLog();
170 verifier.assertFilePresent( "target/profile1/touch.txt" );
171 verifier.assertFilePresent( "target/profile2/touch.txt" );
172 verifier.assertFileNotPresent( "target/profile3/touch.txt" );
173 verifier.assertFileNotPresent( "target/profile4/touch.txt" );
174 verifier.assertFileNotPresent( "target/profile5/touch.txt" );
175 verifier.resetStreams();
176 }
177
178
179
180
181
182
183
184 public void testDefaultProfileAutoDeactivation()
185 throws Exception
186 {
187 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3545" );
188
189 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
190 verifier.setAutoclean( false );
191 verifier.deleteDirectory( "target" );
192 verifier.setLogFileName( "log6.txt" );
193
194
195 verifier.addCliOption( "-Pprofile4" );
196
197 verifier.executeGoal( "validate" );
198
199 verifier.verifyErrorFreeLog();
200 verifier.assertFileNotPresent( "target/profile1/touch.txt" );
201 verifier.assertFileNotPresent( "target/profile2/touch.txt" );
202 verifier.assertFileNotPresent( "target/profile3/touch.txt" );
203 verifier.assertFilePresent( "target/profile4/touch.txt" );
204 verifier.assertFileNotPresent( "target/profile5/touch.txt" );
205 verifier.resetStreams();
206 }
207
208 }