Author: pgier
Date: Wed May 14 13:19:26 2008
New Revision: 656403
URL: http://svn.apache.org/viewvc?rev=656403&view=rev
Log:
[MNG-3545] Adding test for profile activation and deactivation.
Added:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java
(with props)
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml
(with props)
Modified:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
Modified:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java?rev=656403&r1=656402&r2=656403&view=diff
==============================================================================
---
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
(original)
+++
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java
Wed May 14 13:19:26 2008
@@ -65,6 +65,7 @@
* a fail fast technique as well.
*/
+ suite.addTestSuite( MavenITmng3545ProfileDeactivation.class );
suite.addTestSuite( MavenITmng3498ForkToOtherMojoTest.class );
suite.addTestSuite( MavenITmng3485OverrideWagonExtensionTest.class );
suite.addTestSuite( MavenITmng3482DependencyPomInterpolationTest.class
);
Added:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java?rev=656403&view=auto
==============================================================================
---
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java
(added)
+++
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java
Wed May 14 13:19:26 2008
@@ -0,0 +1,196 @@
+package org.apache.maven.integrationtests;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * Test activation and deactivation of profiles.
+ *
+ */
+public class MavenITmng3545ProfileDeactivation
+ extends AbstractMavenIntegrationTestCase
+{
+ public MavenITmng3545ProfileDeactivation()
+ throws InvalidVersionSpecificationException
+ {
+ super( "(2.0.9,)" );
+ }
+
+ /**
+ * Test build with two active by default profiles
+ *
+ */
+ public void testBasicBuildWithDefaultProfiles()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3545-ProfileDeactivation" );
+
+ Verifier verifier;
+
+ verifier = new Verifier( testDir.getAbsolutePath() );
+
+ List cliOptions = new ArrayList();
+
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "package" );
+
+ verifier.verifyErrorFreeLog();
+ // profile 1 and 2 are active by default
+ verifier.assertFilePresent( "target/profile1/touch.txt" );
+ verifier.assertFilePresent( "target/profile2/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile3/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile4/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile5/touch.txt" );
+ verifier.resetStreams();
+
+ }
+
+ /**
+ * Test command line deactivation of active by default profiles.
+ *
+ */
+ public void testDeactivateDefaultProfiles()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3545-ProfileDeactivation" );
+
+ Verifier verifier;
+
+ verifier = new Verifier( testDir.getAbsolutePath() );
+
+ List cliOptions = new ArrayList();
+
+ // Deactivate active by default profiles
+ cliOptions.add( "-P-profile1" );
+ cliOptions.add( "-P -profile2" );
+
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "package" );
+
+ verifier.verifyErrorFreeLog();
+ verifier.assertFileNotPresent( "target/profile1/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile2/touch.txt" );
+ verifier.resetStreams();
+
+ }
+
+ /**
+ * Test command line deactivation of a profile that was activated
+ * by a property
+ *
+ */
+ public void testDeactivateActivatedByProp()
+ throws Exception
+ {
+
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3545-ProfileDeactivation" );
+
+ Verifier verifier;
+
+ verifier = new Verifier( testDir.getAbsolutePath() );
+
+ List cliOptions = new ArrayList();
+
+ // Activate with a prop, then deactivate
+ cliOptions.add( "-Dprofile3-active-by-property=true" );
+ cliOptions.add( "-P-profile3" );
+
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "package" );
+
+ verifier.verifyErrorFreeLog();
+ verifier.assertFilePresent( "target/profile1/touch.txt" );
+ verifier.assertFilePresent( "target/profile2/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile3/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile4/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile5/touch.txt" );
+ verifier.resetStreams();
+ }
+
+ /**
+ * Test that deactivating from the command line takes priority over
+ * activating from the command line.
+ *
+ */
+ public void testActivateThenDeactivate()
+ throws Exception
+ {
+
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3545-ProfileDeactivation" );
+
+ Verifier verifier;
+
+ verifier = new Verifier( testDir.getAbsolutePath() );
+
+ List cliOptions = new ArrayList();
+
+ // Activate then deactivate
+ cliOptions.add( "-Pprofile4" );
+ cliOptions.add( "-P-profile4" );
+
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "package" );
+
+ verifier.verifyErrorFreeLog();
+ verifier.assertFilePresent( "target/profile1/touch.txt" );
+ verifier.assertFilePresent( "target/profile2/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile3/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile4/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile5/touch.txt" );
+ verifier.resetStreams();
+ }
+
+ /**
+ * Test that default profiles are deactivated when another profile is
+ * activated.
+ *
+ */
+ public void testDefaultProfileAutoDeactivation()
+ throws Exception
+ {
+
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3545-ProfileDeactivation" );
+
+ Verifier verifier;
+
+ verifier = new Verifier( testDir.getAbsolutePath() );
+
+ List cliOptions = new ArrayList();
+
+ // Activate
+ cliOptions.add( "-Pprofile4" );
+
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "package" );
+
+ verifier.verifyErrorFreeLog();
+ verifier.assertFileNotPresent( "target/profile1/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile2/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile3/touch.txt" );
+ verifier.assertFilePresent( "target/profile4/touch.txt" );
+ verifier.assertFileNotPresent( "target/profile5/touch.txt" );
+ verifier.resetStreams();
+ }
+
+ /**
+ * remove the target dir after each test run
+ */
+ public void tearDown()
+ throws IOException
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3545-ProfileDeactivation" );
+
+ File targetDir = new File( testDir, "target" );
+ if ( targetDir.exists() )
+ {
+ targetDir.delete();
+ }
+ }
+
+}
Propchange:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3545ProfileDeactivation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml?rev=656403&view=auto
==============================================================================
---
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml
(added)
+++
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml
Wed May 14 13:19:26 2008
@@ -0,0 +1,154 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.its.mng3545</groupId>
+ <artifactId>test-artifact</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-touch</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <profiles>
+ <profile>
+ <id>profile1</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-touch</artifactId>
+ <executions>
+ <execution>
+ <id>profile1-touch</id>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${project.build.directory}/profile1</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>profile2</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-touch</artifactId>
+ <executions>
+ <execution>
+ <id>profile2-touch</id>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${project.build.directory}/profile2</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>profile3</id>
+ <activation>
+ <property>
+ <name>profile3-activation-property</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-touch</artifactId>
+ <executions>
+ <execution>
+ <id>profile3-touch</id>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${project.build.directory}/profile3</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>profile4</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-touch</artifactId>
+ <executions>
+ <execution>
+ <id>profile4-touch</id>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${project.build.directory}/profile4</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>profile5</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-touch</artifactId>
+ <executions>
+ <execution>
+ <id>profile5-touch</id>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${project.build.directory}/profile5</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <!--remove when the IT plugins are actually release-->
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache.snapshots</id>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
Propchange:
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3545-ProfileDeactivation/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision