You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2014/03/23 19:59:34 UTC

git commit: [MNG-5608] IT for warning on ${project.basedir} use for profile activation

Repository: maven-integration-testing
Updated Branches:
  refs/heads/master 644e48ede -> f15c20225


[MNG-5608] IT for warning on ${project.basedir} use for profile
activation

Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/f15c2022
Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/f15c2022
Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/f15c2022

Branch: refs/heads/master
Commit: f15c20225607f28c7719f2a87f3f2b3d0ae51412
Parents: 644e48e
Author: Hervé Boutemy <hb...@apache.org>
Authored: Sun Mar 23 19:59:31 2014 +0100
Committer: Hervé Boutemy <hb...@apache.org>
Committed: Sun Mar 23 19:59:31 2014 +0100

----------------------------------------------------------------------
 .../apache/maven/it/IntegrationTestSuite.java   |  2 +
 ...enITmng5608ProfileActivationWarningTest.java | 82 ++++++++++++++++
 .../src/test/resources/mng-5608/pom.xml         | 99 ++++++++++++++++++++
 3 files changed, 183 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f15c2022/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 1ea1362..72bc030 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -105,6 +105,8 @@ public class IntegrationTestSuite
         // Tests that don't run stable and need to be fixed
         // -------------------------------------------------------------------------------------------------------------
         // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
+
+        suite.addTestSuite( MavenITmng5608ProfileActivationWarningTest.class );
         suite.addTestSuite( MavenITmng5591WorkspaceReader.class );
         suite.addTestSuite( MavenITmng5581LifecycleMappingDelegate.class );
         suite.addTestSuite( MavenITmng5572ReactorPluginExtensionsTest.class  );

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f15c2022/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java
new file mode 100644
index 0000000..a98f659
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5608ProfileActivationWarningTest.java
@@ -0,0 +1,82 @@
+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 java.io.File;
+import java.util.List;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-5608">MNG-5608</a>:
+ * Profile activation warning test when file specification contains <code>${project.basedir}</code>
+ * instead of <code>${basedir}</code>
+ */
+public class MavenITmng5608ProfileActivationWarningTest
+    extends AbstractMavenIntegrationTestCase
+{
+
+    public MavenITmng5608ProfileActivationWarningTest()
+    {
+        super( "(3.2.1,)" );
+    }
+
+    public void testitMNG5608()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5608" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        // check expected profiles activated, just for sanity
+        Properties props = verifier.loadProperties( "target/project.properties" );
+        assertEquals( "expected 2 active profiles", 2, props.size() );
+        assertEquals( "expected profile exists-basedir", "expected active profile",
+                      props.getProperty( "exists-basedir" ) );
+        assertEquals( "expected profile mng-5608-missing-project.basedir", "expected active profile",
+                      props.getProperty( "mng-5608-missing-project.basedir" ) );
+
+        // check that the 2 profiles using ${project.basedir} caused warnings
+        List<String> logFile = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
+        assertNotNull( findWarning( logFile, "mng-5608-exists-project.basedir" ) );
+        assertNotNull( findWarning( logFile, "mng-5608-missing-project.basedir" ) );
+    }
+
+    private String findWarning( List<String> logLines, String profileId )
+    {
+        Pattern pattern = Pattern.compile( "(?i).*Failed to interpolate file location ..project.basedir./pom.xml for profile " + profileId + ": .*" );
+
+        for ( String logLine : logLines )
+        {
+            if ( pattern.matcher( logLine ).matches() )
+            {
+                return logLine;
+            }
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/f15c2022/core-it-suite/src/test/resources/mng-5608/pom.xml
----------------------------------------------------------------------
diff --git a/core-it-suite/src/test/resources/mng-5608/pom.xml b/core-it-suite/src/test/resources/mng-5608/pom.xml
new file mode 100644
index 0000000..dbd836f
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5608/pom.xml
@@ -0,0 +1,99 @@
+<?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 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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng5608</groupId>
+  <artifactId>profile-test</artifactId>
+  <version>1</version>
+  <packaging>pom</packaging>
+
+  <name>MNG-5608 - Profile activation warning test when file specification contains ${project.basedir}</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-uses-properties</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <phase>validate</phase>
+            <goals>
+              <goal>generate-properties</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <!-- ${project.basedir} not supported for profile activation -->
+    <profile>
+      <id>mng-5608-exists-project.basedir</id>
+      <activation>
+        <file>
+          <exists>${project.basedir}/pom.xml</exists>
+        </file>
+      </activation>
+      <properties>
+        <mng-5608-exists-project.basedir>unexpected active profile</mng-5608-exists-project.basedir>
+      </properties>
+    </profile>
+    <profile>
+      <id>mng-5608-missing-project.basedir</id>
+      <activation>
+        <file>
+          <missing>${project.basedir}/pom.xml</missing>
+        </file>
+      </activation>
+      <properties>
+        <mng-5608-missing-project.basedir>expected active profile</mng-5608-missing-project.basedir>
+      </properties>
+    </profile>
+
+    <!-- for reference: ${basedir} supported for profile activation, see MNG-2363 -->
+    <profile>
+      <id>exists-basedir</id>
+      <activation>
+        <file>
+          <exists>${basedir}/pom.xml</exists>
+        </file>
+      </activation>
+      <properties>
+        <exists-basedir>expected active profile</exists-basedir>
+      </properties>
+    </profile>
+    <profile>
+      <id>missing-basedir</id>
+      <activation>
+        <file>
+          <missing>${basedir}/pom.xml</missing>
+        </file>
+      </activation>
+      <properties>
+        <missing-basedir>unexpected active profile</missing-basedir>
+      </properties>
+    </profile>
+  </profiles>
+</project>