You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/10/18 20:01:47 UTC

svn commit: r705900 - in /maven/core-integration-testing/trunk/core-it-suite/src/test: java/org/apache/maven/it/ resources/mng-2972-overridingPluginDependency/ resources/mng-2972/ resources/mng-2972/repo/ resources/mng-2972/repo/org/ resources/mng-2972...

Author: bentmann
Date: Sat Oct 18 11:01:46 2008
New Revision: 705900

URL: http://svn.apache.org/viewvc?rev=705900&view=rev
Log:
o Strengthened IT to check more aspects of dependency override

Added:
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.jar   (with props)
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.pom
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml   (with props)
Removed:
    maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972-overridingPluginDependency/
Modified:
    maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2972OverridePluginDependency.java

Modified: maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2972OverridePluginDependency.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2972OverridePluginDependency.java?rev=705900&r1=705899&r2=705900&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2972OverridePluginDependency.java (original)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2972OverridePluginDependency.java Sat Oct 18 11:01:46 2008
@@ -19,104 +19,71 @@
  * under the License.
  */
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.Assert;
-
 import org.apache.maven.it.Verifier;
 import org.apache.maven.it.util.FileUtils;
 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-2972">MNG-2972</a>.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
 public class MavenITmng2972OverridePluginDependency
     extends AbstractMavenIntegrationTestCase
 {
+
     public MavenITmng2972OverridePluginDependency()
     {
         super( "(2.0.8,)" );
     }
 
-    public void testitMNG2972()
+    /**
+     * Verify that a project-level plugin dependency replaces the original dependency from the plugin POM.
+     */
+    public void testitLifecycleInvocation()
         throws Exception
     {
+        run( false );
+    }
 
-        // The testdir is computed from the location of this
-        // file.
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2972-overridingPluginDependency" );
-
-        Verifier verifier;
-
-        /*
-         * We must first make sure that any artifact created by this test has been removed from the local repository.
-         * Failing to do this could cause unstable test results. Fortunately, the verifier makes it easy to do this.
-         */
-        verifier = new Verifier( testDir.getAbsolutePath() );
-        verifier.deleteArtifact( "org.apache.maven.its.mng2972", "user", "1.0", "jar" );
-        verifier.deleteArtifact( "org.apache.maven.its.mng2972", "mojo", "0.0.1-SNAPSHOT", "jar" );
-        verifier.deleteArtifact( "org.apache.maven.its.mng2972", "dep", "1.0", "jar" );
-        verifier.deleteArtifact( "org.apache.maven.its.mng2972", "dep", "2.0", "jar" );
-
-        verifier = new Verifier( new File( testDir.getAbsolutePath(), "dep1" ).getAbsolutePath() );
-        verifier.executeGoal( "install" );
-        verifier.verifyErrorFreeLog();
-
-        verifier = new Verifier( new File( testDir.getAbsolutePath(), "dep2" ).getAbsolutePath() );
-        verifier.executeGoal( "install" );
-        verifier.verifyErrorFreeLog();
-
-        verifier = new Verifier( new File( testDir.getAbsolutePath(), "mojo" ).getAbsolutePath() );
-        verifier.executeGoal( "install" );
-        verifier.verifyErrorFreeLog();
-
-        verifier = new Verifier( new File( testDir.getAbsolutePath(), "user" ).getAbsolutePath() );
-        verifier.executeGoal( "validate" );
-        verifier.verifyErrorFreeLog();
-
-        List lines =
-            verifier.loadFile( new File( testDir.getAbsolutePath(), "user" ).getAbsolutePath(), "log.txt", false );
-        int foundVersionOne = 0;
-        int foundVersionTwo = 0;
-        for ( Iterator i = lines.iterator(); i.hasNext(); )
-        {
-
-            String line = (String) i.next();
-            if ( line.indexOf( "MNG-2972-VERSION-1" ) != -1 )
-                foundVersionOne++;
-            if ( line.indexOf( "MNG-2972-VERSION-2" ) != -1 )
-                foundVersionTwo++;
-        }
-
-        verifier.resetStreams();
-
-        Assert.assertEquals( "Should not be using plugin dependency version 1", 0, foundVersionOne );
-        Assert.assertEquals( "Should be using plugin version 2 once.", 1, foundVersionTwo );
+    /**
+     * Verify that a project-level plugin dependency replaces the original dependency from the plugin POM.
+     */
+    public void testitCommandLineInvocation()
+        throws Exception
+    {
+        run( true );
+    }
 
-        /**
-         * Now try to execute the plugin directly
-         */
+    private void run( boolean cli )
+        throws Exception
+    {
+        String propFile = cli ? "target/cli.properties" : "target/lifecycle.properties";
 
-        verifier = new Verifier( new File( testDir.getAbsolutePath(), "user" ).getAbsolutePath() );
-        verifier.executeGoal( "org.apache.maven.its.mng2972:mojo:0.0.1-SNAPSHOT:test" );
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2972" );
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        verifier.setAutoclean( false );
+        verifier.deleteArtifact( "org.apache.maven.its.plugins.class-loader", "dep-b", "0.2-mng-2972", "jar" );
+        new File( testDir, propFile ).delete();
+        Properties sysProps = new Properties();
+        sysProps.setProperty( "clsldr.pluginClassLoaderOutput", propFile );
+        verifier.setSystemProperties( sysProps );
+        verifier.executeGoal( cli ? "org.apache.maven.its.plugins:maven-it-plugin-class-loader:2.1-SNAPSHOT:load" : "validate" );
         verifier.verifyErrorFreeLog();
-
-        lines = verifier.loadFile( new File( testDir.getAbsolutePath(), "user" ).getAbsolutePath(), "log.txt", false );
-        foundVersionOne = 0;
-        foundVersionTwo = 0;
-        for ( Iterator i = lines.iterator(); i.hasNext(); )
-        {
-
-            String line = (String) i.next();
-            if ( line.indexOf( "MNG-2972-VERSION-1" ) != -1 )
-                foundVersionOne++;
-            if ( line.indexOf( "MNG-2972-VERSION-2" ) != -1 )
-                foundVersionTwo++;
-        }
-
         verifier.resetStreams();
+        FileUtils.rename( new File( testDir, "log.txt"), new File( testDir, cli ? "log2.txt" : "log1.txt" ) );
 
-        Assert.assertEquals( "Should not be using plugin dependency version 1", 0, foundVersionOne );
-        Assert.assertEquals( "Should be using plugin version 2 once.", 1, foundVersionTwo );
+        Properties pclProps = verifier.loadProperties( propFile );
+        assertNotNull( pclProps.getProperty( "org.apache.maven.its.mng2972.MNG2972" ) );
+        assertNull( pclProps.getProperty( "org.apache.maven.plugin.coreit.ClassA" ) );
+        assertNull( pclProps.getProperty( "org.apache.maven.plugin.coreit.ClassB" ) );
+        assertEquals( "1", pclProps.getProperty( "org/apache/maven/its/mng2972/mng-2972.properties.count" ) );
+        assertEquals( "0", pclProps.getProperty( "org/apache/maven/plugin/coreit/a.properties.count" ) );
+        assertEquals( "0", pclProps.getProperty( "org/apache/maven/plugin/coreit/b.properties.count" ) );
     }
+
 }

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml?rev=705900&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml Sat Oct 18 11:01:46 2008
@@ -0,0 +1,97 @@
+<?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.mng2972</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+
+  <name>Maven Integration Test :: MNG-2972</name> 
+  <description>
+    Verify that a project-level plugin dependency replaces the original dependency from the plugin POM.
+  </description>
+
+  <repositories>
+    <repository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+      <releases>
+        <checksumPolicy>ignore</checksumPolicy>
+      </releases>
+      <snapshots>
+        <checksumPolicy>ignore</checksumPolicy>
+      </snapshots>
+    </repository>
+  </repositories>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+      <releases>
+        <checksumPolicy>ignore</checksumPolicy>
+      </releases>
+      <snapshots>
+        <checksumPolicy>ignore</checksumPolicy>
+      </snapshots>
+    </pluginRepository>
+  </pluginRepositories>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-class-loader</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <dependencies>
+          <!--
+          This dependency should replace the plugins's original dependency on
+            org.apache.maven.its.plugins.class-loader:dep-b
+          In detail, this replacement should have the following effects on both lifecycle invocations and command line
+          invocations of the plugin:
+            a) classes/resources from the custom dependency are available
+            b) classes/resources from the original dependency are not available at all
+            c) the transitive dependency on dep-a via the original dep-b is dropped
+          -->
+          <dependency>
+            <groupId>org.apache.maven.its.plugins.class-loader</groupId>
+            <artifactId>dep-b</artifactId>
+            <version>0.2-mng-2972</version>
+          </dependency>
+        </dependencies>
+        <configuration>
+          <classNames>org.apache.maven.its.mng2972.MNG2972,org.apache.maven.plugin.coreit.ClassA,org.apache.maven.plugin.coreit.ClassB</classNames>
+          <resourcePaths>org/apache/maven/its/mng2972/mng-2972.properties,org/apache/maven/plugin/coreit/a.properties,org/apache/maven/plugin/coreit/b.properties</resourcePaths>
+        </configuration>
+        <executions>
+          <execution>
+            <id>load</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>load</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.jar
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.jar?rev=705900&view=auto
==============================================================================
Binary file - no diff available.

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.pom
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.pom?rev=705900&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.pom (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/0.2-mng-2972/dep-b-0.2-mng-2972.pom Sat Oct 18 11:01:46 2008
@@ -0,0 +1,55 @@
+<?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.plugins.class-loader</groupId>
+  <artifactId>dep-b</artifactId>
+  <version>0.2-mng-2972</version>
+  <packaging>jar</packaging>
+
+  <distributionManagement>
+    <repository>
+      <id>maven-core-it</id>
+      <url>file:///${basedir}/repo</url>
+    </repository>
+  </distributionManagement>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>.</directory>
+        <includes>
+          <include>pom.xml</include>
+          <include>src/**</include>
+        </includes>
+      </resource>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+    </resources>
+  </build>
+</project>

Added: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml?rev=705900&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml (added)
+++ maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml Sat Oct 18 11:01:46 2008
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?><metadata>
+  <groupId>org.apache.maven.its.plugins.class-loader</groupId>
+  <artifactId>dep-b</artifactId>
+  <version>0.2-mng-2972</version>
+  <versioning>
+    <versions>
+      <version>0.2-mng-2972</version>
+    </versions>
+    <lastUpdated>20081018154402</lastUpdated>
+  </versioning>
+</metadata>
\ No newline at end of file

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-2972/repo/org/apache/maven/its/plugins/class-loader/dep-b/maven-metadata.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision