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.io.IOException;
26
27
28
29
30
31
32
33
34 public class MavenITmng6511OptionalProjectSelectionTest extends AbstractMavenIntegrationTestCase
35 {
36 private static final String RESOURCE_PATH = "/mng-6511-optional-project-selection";
37 private final File testDir;
38
39 public MavenITmng6511OptionalProjectSelectionTest() throws IOException
40 {
41 super( "[4.0.0-alpha-1,)" );
42 testDir = ResourceExtractor.simpleExtractResources( getClass(), RESOURCE_PATH );
43 }
44
45 public void testSelectExistingOptionalProfile() throws VerificationException
46 {
47 newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
48
49 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
50 verifier.setLogFileName( "log-select-existing.txt" );
51 verifier.addCliOption( "-pl ?existing-module" );
52 verifier.executeGoal( "validate" );
53 verifier.verifyErrorFreeLog();
54 verifier.assertFilePresent( "existing-module/target/touch.txt" );
55 }
56
57 public void testSelectExistingOptionalProfileByArtifactId() throws VerificationException
58 {
59 newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
60
61 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
62 verifier.setLogFileName( "log-select-existing-artifact-id.txt" );
63 verifier.addCliOption( "-pl ?:existing-module" );
64 verifier.executeGoal( "validate" );
65 verifier.verifyErrorFreeLog();
66 verifier.assertFilePresent( "existing-module/target/touch.txt" );
67 }
68
69 public void testSelectNonExistingOptionalProfile() throws VerificationException
70 {
71 newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
72
73 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
74 verifier.setLogFileName( "log-select-non-existing.txt" );
75 verifier.addCliOption( "-pl ?non-existing-module" );
76 verifier.executeGoal( "validate" );
77 verifier.verifyErrorFreeLog();
78 verifier.assertFilePresent( "existing-module/target/touch.txt" );
79 }
80
81 public void testDeselectExistingOptionalProfile() throws VerificationException
82 {
83 newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
84
85 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
86 verifier.setLogFileName( "log-deselect-existing.txt" );
87 verifier.addCliOption( "-pl !?existing-module" );
88 verifier.executeGoal( "validate" );
89 verifier.verifyErrorFreeLog();
90 verifier.assertFileNotPresent( "existing-module/target/touch.txt" );
91 }
92
93 public void testDeselectNonExistingOptionalProfile() throws VerificationException
94 {
95 newVerifier( testDir.getAbsolutePath() ).executeGoal( "clean" );
96
97 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
98 verifier.setLogFileName( "log-deselect-non-existing.txt" );
99 verifier.addCliOption( "-pl !?non-existing-module" );
100 verifier.executeGoal( "validate" );
101 verifier.verifyErrorFreeLog();
102 verifier.assertFilePresent( "existing-module/target/touch.txt" );
103 }
104 }