[MNG-2848] Environment variables in profile activation not working

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@929469 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-03-31 10:44:30 +00:00
parent 3caf7710de
commit 1c8ff10e2a
3 changed files with 134 additions and 0 deletions

View File

@ -388,6 +388,7 @@ public static Test suite()
suite.addTestSuite( MavenITmng2871PrePackageSubartifactResolutionTest.class );
suite.addTestSuite( MavenITmng2865MirrorWildcardTest.class );
suite.addTestSuite( MavenITmng2861RelocationsAndRangesTest.class );
suite.addTestSuite( MavenITmng2848ProfileActivationByEnvironmentVariableTest.class );
suite.addTestSuite( MavenITmng2843PluginConfigPropertiesInjectionTest.class );
suite.addTestSuite( MavenITmng2831CustomArtifactHandlerAndCustomLifecycleTest.class );
suite.addTestSuite( MavenITmng2820PomCommentsTest.class );

View File

@ -0,0 +1,62 @@
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 java.io.File;
import java.util.Properties;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-2848">MNG-2848</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng2848ProfileActivationByEnvironmentVariableTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng2848ProfileActivationByEnvironmentVariableTest()
{
super( "[2.0.9,)" );
}
/**
* Test activation of a profile via environment variables.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2848" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.setEnvironmentVariable( "MNG2848", "GO" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "target/profile.properties" );
assertEquals( "PASSED", props.getProperty( "project.properties.testProp" ) );
}
}

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng02848</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Maven Integration Test :: MNG-2848</name>
<description>
Test activation of a profile via environment variables.
</description>
<profiles>
<profile>
<id>test</id>
<activation>
<property>
<name>env.MNG2848</name>
<value>GO</value>
</property>
</activation>
<properties>
<testProp>PASSED</testProp>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-expression</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>eval</goal>
</goals>
<configuration>
<outputFile>target/profile.properties</outputFile>
<expressions>
<expression>project/properties</expression>
</expressions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>