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
26 public class MavenITmng7051OptionalProfileActivationTest
27 extends AbstractMavenIntegrationTestCase
28 {
29 private static final String PROJECT_PATH = "/mng-7051-optional-profile-activation";
30
31 public MavenITmng7051OptionalProfileActivationTest()
32 {
33 super( "[4.0.0-alpha-1,)" );
34 }
35
36
37
38
39
40
41 public void testActivatingNonExistingProfileBreaks() throws Exception
42 {
43 final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
44 final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
45
46 verifier.addCliOption( "-P" );
47 verifier.addCliOption( "non-existing-profile" );
48 verifier.setLogFileName( "test-breaking.txt" );
49
50 try
51 {
52 verifier.executeGoal( "validate" );
53 fail( "Activated a non-existing profile without ? prefix should break the build, but it didn't." );
54 }
55 catch ( VerificationException ve )
56 {
57
58 verifier.verifyTextInLog( "[ERROR] The requested profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
59 }
60 }
61
62
63
64
65
66
67 public void testActivatingNonExistingProfileWithQuestionMarkDoesNotBreak() throws Exception
68 {
69 final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
70 final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
71
72 verifier.addCliOption( "-P" );
73 verifier.addCliOption( "?non-existing-profile" );
74 verifier.setLogFileName( "test-non-breaking.txt" );
75
76 verifier.executeGoal( "validate" );
77 verifier.verifyErrorFreeLog();
78 verifier.verifyTextInLog( "[INFO] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
79 }
80
81
82
83
84
85
86 public void testActivatingExistingAndNonExistingProfiles() throws Exception
87 {
88 final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
89 final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
90
91 verifier.addCliOption( "-P" );
92 verifier.addCliOption( "?non-existing-profile,existing" );
93 verifier.setLogFileName( "test-non-breaking-mixed.txt" );
94
95 verifier.executeGoal( "validate" );
96 verifier.verifyErrorFreeLog();
97 verifier.verifyTextInLog( "[INFO] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
98 }
99
100
101
102
103
104
105 public void testDeactivatingNonExistingProfileWithQuestionMarkDoesNotBreak() throws Exception
106 {
107 final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
108 final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
109
110 verifier.addCliOption( "-P" );
111 verifier.addCliOption( "!?non-existing-profile" );
112 verifier.setLogFileName( "test-deactivating-non-breaking.txt" );
113
114 verifier.executeGoal( "validate" );
115 verifier.verifyErrorFreeLog();
116 verifier.verifyTextInLog( "[INFO] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
117 }
118
119
120
121
122
123
124 public void testDeactivatingExistingAndNonExistingProfiles() throws Exception
125 {
126 final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
127 final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
128
129 verifier.addCliOption( "-P" );
130 verifier.addCliOption( "!?non-existing-profile,!existing" );
131 verifier.setLogFileName( "test-deactivating-non-breaking-mixed.txt" );
132
133 verifier.executeGoal( "validate" );
134 verifier.verifyErrorFreeLog();
135 verifier.verifyTextInLog( "[INFO] The requested optional profiles [non-existing-profile] could not be activated or deactivated because they do not exist." );
136 }
137 }