o Extended IT to test other profile activators, too

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@729856 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2008-12-29 10:41:46 +00:00
parent 310d6d4172
commit 56fdeed07c
4 changed files with 219 additions and 79 deletions

View File

@ -95,7 +95,7 @@ public class IntegrationTestSuite
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 );

View File

@ -1,72 +0,0 @@
package org.apache.maven.it;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.it.util.Os;
import java.io.File;
import java.util.Properties;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3933">MNG-3933</a>.
*
* @author Benjamin Bentmann
* @version $Id$
*/
public class MavenITmng3933OsTriggeredExternalProfileTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng3933OsTriggeredExternalProfileTest()
{
super( "(2.0.10,2.1.0-M1),(2.1.0-M1,)" );
}
/**
* Test that OS-triggered profiles from an external profiles.xml are activated.
*/
public void testitMNG3933()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3933" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
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( "PASSED", props.getProperty( "project.properties.profileProperty" ) );
}
else
{
System.out.println();
System.out.println( "[WARNING] Skipping test on unrecognized OS: " + Os.OS_NAME );
System.out.println();
}
}
}

View File

@ -0,0 +1,97 @@
package org.apache.maven.it;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.it.util.Os;
import java.io.File;
import java.util.Collections;
import java.util.Properties;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3933">MNG-3933</a>.
*
* @author Benjamin Bentmann
* @version $Id$
*/
public class MavenITmng3933ProfilesXmlActivationTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng3933ProfilesXmlActivationTest()
{
}
/**
* 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
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3933" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
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" );
assertEquals( "DEFAULT-ACTIVATION", props.getProperty( "project.properties.defaultProperty" ) );
assertEquals( "SYS-PROP-ACTIVATION", props.getProperty( "project.properties.sysProperty" ) );
if ( matchesVersionRange( "(2.0.8,)" ) )
{
// MNG-2848
assertEquals( "ENV-PROP-ACTIVATION", props.getProperty( "project.properties.envProperty" ) );
}
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,)" ) )
{
// 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" ) );
}
}

View File

@ -20,38 +20,153 @@ under the License.
-->
<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>