Author: bentmann Date: Mon Dec 29 02:41:46 2008 New Revision: 729856 URL: http://svn.apache.org/viewvc?rev=729856&view=rev Log: o Extended IT to test other profile activators, too
Added: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933ProfilesXmlActivationTest.java - copied, changed from r729841, maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933OsTriggeredExternalProfileTest.java Removed: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933OsTriggeredExternalProfileTest.java Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3933/profiles.xml Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=729856&r1=729855&r2=729856&view=diff ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java (original) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java Mon Dec 29 02:41:46 2008 @@ -95,7 +95,7 @@ suite.addTestSuite( MavenITmng3940EnvVarInterpolationTest.class ); suite.addTestSuite( MavenITmng3938MergePluginExecutionsTest.class ); suite.addTestSuite( MavenITmng3937MergedPluginExecutionGoalsTest.class ); - suite.addTestSuite( MavenITmng3933OsTriggeredExternalProfileTest.class ); + suite.addTestSuite( MavenITmng3933ProfilesXmlActivationTest.class ); suite.addTestSuite( MavenITmng3927PluginDefaultExecutionConfigTest.class ); suite.addTestSuite( MavenITmng3925MergedPluginExecutionOrderTest.class ); suite.addTestSuite( MavenITmng3924XmlMarkupInterpolationTest.class ); Copied: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933ProfilesXmlActivationTest.java (from r729841, maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933OsTriggeredExternalProfileTest.java) URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933ProfilesXmlActivationTest.java?p2=maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933ProfilesXmlActivationTest.java&p1=maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933OsTriggeredExternalProfileTest.java&r1=729841&r2=729856&rev=729856&view=diff ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933OsTriggeredExternalProfileTest.java (original) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3933ProfilesXmlActivationTest.java Mon Dec 29 02:41:46 2008 @@ -24,6 +24,7 @@ import org.apache.maven.it.util.Os; import java.io.File; +import java.util.Collections; import java.util.Properties; /** @@ -32,17 +33,17 @@ * @author Benjamin Bentmann * @version $Id$ */ -public class MavenITmng3933OsTriggeredExternalProfileTest +public class MavenITmng3933ProfilesXmlActivationTest extends AbstractMavenIntegrationTestCase { - public MavenITmng3933OsTriggeredExternalProfileTest() + public MavenITmng3933ProfilesXmlActivationTest() { - super( "(2.0.10,2.1.0-M1),(2.1.0-M1,)" ); } /** - * Test that OS-triggered profiles from an external profiles.xml are activated. + * Test that profiles from an external profiles.xml are properly activated. This is really a different story + * than profiles in the settings.xml or the POM. */ public void testitMNG3933() throws Exception @@ -52,21 +53,45 @@ Verifier verifier = new Verifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); verifier.deleteDirectory( "target" ); - verifier.executeGoal( "validate" ); + verifier.getSystemProperties().setProperty( "maven.profile.activator", "test" ); + verifier.executeGoal( "validate", Collections.singletonMap( "MAVEN_PROFILE", "test" ) ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); Properties props = verifier.loadProperties( "target/profile.properties" ); - if ( Os.isFamily( Os.FAMILY_WINDOWS ) || Os.isFamily( Os.FAMILY_MAC ) || Os.isFamily( Os.FAMILY_UNIX ) ) + + assertEquals( "DEFAULT-ACTIVATION", props.getProperty( "project.properties.defaultProperty" ) ); + + assertEquals( "SYS-PROP-ACTIVATION", props.getProperty( "project.properties.sysProperty" ) ); + + if ( matchesVersionRange( "(2.0.8,)" ) ) { - assertEquals( "PASSED", props.getProperty( "project.properties.profileProperty" ) ); + // MNG-2848 + assertEquals( "ENV-PROP-ACTIVATION", props.getProperty( "project.properties.envProperty" ) ); } - else + + assertEquals( "MISSING-FILE-ACTIVATION", props.getProperty( "project.properties.fileProperty" ) ); + + assertEquals( "JDK-ACTIVATION", props.getProperty( "project.properties.jdkProperty" ) ); + + if ( matchesVersionRange( "(2.0.10,2.1.0-M1),(2.1.0-M1,)" ) ) { - System.out.println(); - System.out.println( "[WARNING] Skipping test on unrecognized OS: " + Os.OS_NAME ); - System.out.println(); + // MNG-3933 + if ( Os.isFamily( Os.FAMILY_WINDOWS ) || Os.isFamily( Os.FAMILY_MAC ) || Os.isFamily( Os.FAMILY_UNIX ) ) + { + assertEquals( "OS-FAMILY-ACTIVATION", props.getProperty( "project.properties.osFamilyProperty" ) ); + } + else + { + System.out.println(); + System.out.println( "[WARNING] Skipping OS activation test on unrecognized OS: " + Os.OS_NAME ); + System.out.println(); + } } + + assertEquals( null, props.getProperty( "project.properties.sysPropertyMissing" ) ); + assertEquals( null, props.getProperty( "project.properties.envPropertyMissing" ) ); + assertEquals( null, props.getProperty( "project.properties.filePropertyMissing" ) ); } } Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3933/profiles.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3933/profiles.xml?rev=729856&r1=729855&r2=729856&view=diff ============================================================================== --- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3933/profiles.xml (original) +++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-3933/profiles.xml Mon Dec 29 02:41:46 2008 @@ -20,38 +20,153 @@ --> <profilesXml> + <activeProfiles> + <activeProfile>profile-default</activeProfile> + </activeProfiles> <profiles> + <!-- check activation by default --> <profile> - <id>PROFILE-A</id> + <id>profile-default</id> + <properties> + <defaultProperty>DEFAULT-ACTIVATION</defaultProperty> + </properties> + </profile> + + <!-- check activation by OS family --> + <profile> + <id>profile-os-a</id> <activation> <os> <family>winDOWS</family> </os> </activation> <properties> - <profileProperty>PASSED</profileProperty> + <osFamilyProperty>OS-FAMILY-ACTIVATION</osFamilyProperty> </properties> </profile> <profile> - <id>PROFILE-B</id> + <id>profile-os-b</id> <activation> <os> <family>unIX</family> </os> </activation> <properties> - <profileProperty>PASSED</profileProperty> + <osFamilyProperty>OS-FAMILY-ACTIVATION</osFamilyProperty> </properties> </profile> <profile> - <id>PROFILE-C</id> + <id>profile-os-c</id> <activation> <os> <family>mAC</family> </os> </activation> <properties> - <profileProperty>PASSED</profileProperty> + <osFamilyProperty>OS-FAMILY-ACTIVATION</osFamilyProperty> + </properties> + </profile> + + <!-- check activation by JDK version --> + <profile> + <id>profile-jdk</id> + <activation> + <jdk>!1.0</jdk> + </activation> + <properties> + <jdkProperty>JDK-ACTIVATION</jdkProperty> + </properties> + </profile> + + <!-- check non-activation by JDK version --> + <profile> + <id>profile-jdk-inactive</id> + <activation> + <jdk>1.0.0.0</jdk> + </activation> + <properties> + <jdkPropertyMissing>JDK-ACTIVATION</jdkPropertyMissing> + </properties> + </profile> + + <!-- check activation by ordinary system property --> + <profile> + <id>profile-sys-prop</id> + <activation> + <property> + <name>maven.profile.activator</name> + <value>test</value> + </property> + </activation> + <properties> + <sysProperty>SYS-PROP-ACTIVATION</sysProperty> + </properties> + </profile> + + <!-- check non-activation by absent system property --> + <profile> + <id>profile-sys-prop-inactive</id> + <activation> + <property> + <name>maven.profile.inactive</name> + </property> + </activation> + <properties> + <sysPropertyMissing>SYS-PROP-ACTIVATION</sysPropertyMissing> + </properties> + </profile> + + <!-- check activation by environment variable --> + <profile> + <id>profile-env-prop</id> + <activation> + <property> + <name>env.MAVEN_PROFILE</name> + <value>test</value> + </property> + </activation> + <properties> + <envProperty>ENV-PROP-ACTIVATION</envProperty> + </properties> + </profile> + + <!-- check non-activation by environment variable --> + <profile> + <id>profile-env-prop-inactive</id> + <activation> + <property> + <name>env.MAVEN_CORE_IT</name> + <value>missing</value> + </property> + </activation> + <properties> + <envPropertyMissing>ENV-PROP-ACTIVATION</envPropertyMissing> + </properties> + </profile> + + <!-- check activation by missing file --> + <profile> + <id>profile-file-missing</id> + <activation> + <file> + <missing>a-funky-file-name-that-most-likely-does-not-exist-on-an-ordinary-box</missing> + </file> + </activation> + <properties> + <fileProperty>MISSING-FILE-ACTIVATION</fileProperty> + </properties> + </profile> + + <!-- check non-activation by missing file --> + <profile> + <id>profile-file-missing-inactive</id> + <activation> + <file> + <exists>a-funky-file-name-that-most-likely-does-not-exist-on-an-ordinary-box</exists> + </file> + </activation> + <properties> + <filePropertyMissing>MISSING-FILE-ACTIVATION</filePropertyMissing> </properties> </profile> </profiles>