From 4ddb5cbda95ee836747a1cb718aa1a6b55c27778 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 14 Feb 2009 10:48:26 +0000 Subject: [PATCH] [MNG-3732] [regression] project.getActiveProfiles() has not the same behaviour o Added IT git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@744477 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/it/IntegrationTestSuite.java | 1 + .../it/MavenITmng3732ActiveProfilesTest.java | 79 +++++++++++++++++++ .../src/test/resources/mng-3732/pom.xml | 72 +++++++++++++++++ .../src/test/resources/mng-3732/profiles.xml | 34 ++++++++ .../src/test/resources/mng-3732/settings.xml | 34 ++++++++ 5 files changed, 220 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-3732/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-3732/profiles.xml create mode 100644 its/core-it-suite/src/test/resources/mng-3732/settings.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 1fe086639f..608426e9c4 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -157,6 +157,7 @@ public static Test suite() suite.addTestSuite( MavenITmng3746POMPropertyOverrideTest.class ); suite.addTestSuite( MavenITmng3743ForkWithPluginManagementTest.class ); suite.addTestSuite( MavenITmng3740SelfReferentialReactorProjectsTest.class ); + suite.addTestSuite( MavenITmng3732ActiveProfilesTest.class ); suite.addTestSuite( MavenITmng3729MultiForkAggregatorsTest.class ); suite.addTestSuite( MavenITmng3724ExecutionProjectSyncTest.class ); suite.addTestSuite( MavenITmng3723ConcreteParentProjectTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java new file mode 100644 index 0000000000..9615caefb6 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java @@ -0,0 +1,79 @@ +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.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +/** + * This is a test set for MNG-3732. + * + * @author Benjamin Bentmann + * @version $Id$ + */ +public class MavenITmng3732ActiveProfilesTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng3732ActiveProfilesTest() + { + super( "[2.0,)" ); + } + + /** + * Verify that MavenProject.getActiveProfiles() includes profiles from all sources. + */ + public void testitMNG3732() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3732" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.getCliOptions().add( "--settings" ); + verifier.getCliOptions().add( "settings.xml" ); + verifier.getCliOptions().add( "-Ppom,profiles,settings" ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + Properties props = verifier.loadProperties( "target/profile.properties" ); + List ids = new ArrayList(); + ids.add( props.getProperty( "project.activeProfiles.0.id", "" ) ); + ids.add( props.getProperty( "project.activeProfiles.1.id", "" ) ); + ids.add( props.getProperty( "project.activeProfiles.2.id", "" ) ); + Collections.sort( ids ); + assertEquals( Arrays.asList( new String[] { "pom", "profiles", "settings" } ), ids ); + assertEquals( "3", props.getProperty( "project.activeProfiles" ) ); + + assertEquals( "PASSED-1", props.getProperty( "project.properties.pomProperty" ) ); + assertEquals( "PASSED-2", props.getProperty( "project.properties.settingsProperty" ) ); + assertEquals( "PASSED-3", props.getProperty( "project.properties.profilesProperty" ) ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-3732/pom.xml b/its/core-it-suite/src/test/resources/mng-3732/pom.xml new file mode 100644 index 0000000000..72687d07ee --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3732/pom.xml @@ -0,0 +1,72 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng03732 + parent + 1.0-SNAPSHOT + pom + + Maven Integration Test :: MNG-3732 + + Verify that MavenProject.getActiveProfiles() includes profiles from all sources. + + + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + target/profile.properties + + project/activeProfiles + project/properties + + + + + test + validate + + eval + + + + + + + + + + pom + + true + + + PASSED-1 + + + + diff --git a/its/core-it-suite/src/test/resources/mng-3732/profiles.xml b/its/core-it-suite/src/test/resources/mng-3732/profiles.xml new file mode 100644 index 0000000000..224234a8ae --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3732/profiles.xml @@ -0,0 +1,34 @@ + + + + + + + + profiles + + PASSED-3 + + + + + profiles + + diff --git a/its/core-it-suite/src/test/resources/mng-3732/settings.xml b/its/core-it-suite/src/test/resources/mng-3732/settings.xml new file mode 100644 index 0000000000..8d2721b1d5 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-3732/settings.xml @@ -0,0 +1,34 @@ + + + + + + + + settings + + PASSED-2 + + + + + settings + +