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.Collections;
24 import java.util.Properties;
25
26 import org.apache.maven.it.util.ResourceExtractor;
27 import org.apache.maven.shared.utils.Os;
28
29
30
31
32
33
34
35 public class MavenITmng3933ProfilesXmlActivationTest
36 extends AbstractMavenIntegrationTestCase
37 {
38
39 public MavenITmng3933ProfilesXmlActivationTest()
40 {
41
42 super( "[2.0,3.0-alpha-1)" );
43 }
44
45
46
47
48
49
50
51 public void testitMNG3933()
52 throws Exception
53 {
54 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3933" );
55
56 Verifier verifier = newVerifier( testDir.getAbsolutePath() );
57 verifier.setAutoclean( false );
58 verifier.deleteDirectory( "target" );
59 verifier.getSystemProperties().setProperty( "maven.profile.activator", "test" );
60 verifier.executeGoal( "validate", Collections.singletonMap( "MAVEN_PROFILE", "test" ) );
61 verifier.verifyErrorFreeLog();
62 verifier.resetStreams();
63
64 Properties props = verifier.loadProperties( "target/profile.properties" );
65
66 assertEquals( "DEFAULT-ACTIVATION", props.getProperty( "project.properties.defaultProperty" ) );
67
68 assertEquals( "SYS-PROP-ACTIVATION", props.getProperty( "project.properties.sysProperty" ) );
69
70 if ( matchesVersionRange( "(2.0.8,)" ) )
71 {
72
73 assertEquals( "ENV-PROP-ACTIVATION", props.getProperty( "project.properties.envProperty" ) );
74 }
75
76 assertEquals( "MISSING-FILE-ACTIVATION", props.getProperty( "project.properties.fileProperty" ) );
77
78 assertEquals( "JDK-ACTIVATION", props.getProperty( "project.properties.jdkProperty" ) );
79
80 if ( matchesVersionRange( "(2.0.10,2.1.0-M1),(2.1.0-M1,)" ) )
81 {
82
83 if ( Os.isFamily( Os.FAMILY_WINDOWS ) || Os.isFamily( Os.FAMILY_MAC ) || Os.isFamily( Os.FAMILY_UNIX ) )
84 {
85 assertEquals( "OS-FAMILY-ACTIVATION", props.getProperty( "project.properties.osFamilyProperty" ) );
86 }
87 else
88 {
89 System.out.println();
90 System.out.println( "[WARNING] Skipping OS activation test on unrecognized OS: " + Os.OS_NAME );
91 System.out.println();
92 }
93 }
94
95 assertNull( props.getProperty( "project.properties.sysPropertyMissing" ) );
96 assertNull( props.getProperty( "project.properties.envPropertyMissing" ) );
97 assertNull( props.getProperty( "project.properties.filePropertyMissing" ) );
98 }
99
100 }