[MNG-3043] Allow 'mvn test' to work with test-jar dependencies in a reactor

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@751481 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-03-08 17:48:39 +00:00
parent fb3d76e491
commit 7f7419132d
9 changed files with 535 additions and 0 deletions

View File

@ -80,6 +80,7 @@ public class IntegrationTestSuite
// suite.addTestSuite( MavenITmng3714ToolchainsCliOptionTest.class ); // suite.addTestSuite( MavenITmng3714ToolchainsCliOptionTest.class );
// suite.addTestSuite( MavenITmng3645POMSyntaxErrorTest.class ); // suite.addTestSuite( MavenITmng3645POMSyntaxErrorTest.class );
// suite.addTestSuite( MavenITmng3391ImportScopeErrorScenariosTest.class ); // suite.addTestSuite( MavenITmng3391ImportScopeErrorScenariosTest.class );
// suite.addTestSuite( MavenITmng3043BestEffortReactorResolutionTest.class );
// suite.addTestSuite( MavenITmng3038TransitiveDepManVersionTest.class ); // suite.addTestSuite( MavenITmng3038TransitiveDepManVersionTest.class );
// suite.addTestSuite( MavenITmng2994SnapshotRangeRepositoryTest.class ); // suite.addTestSuite( MavenITmng2994SnapshotRangeRepositoryTest.class );
// suite.addTestSuite( MavenITmng2771PomExtensionComponentOverrideTest.class ); // suite.addTestSuite( MavenITmng2771PomExtensionComponentOverrideTest.class );

View File

@ -0,0 +1,176 @@
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.List;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3043">MNG-3043</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng3043BestEffortReactorResolutionTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng3043BestEffortReactorResolutionTest()
{
super( "[2.1.0,)" );
}
/**
* Test that dependencies on attached artifacts like a test JAR or an EJB client JAR which have not been built
* yet, i.e. in build phases prior to "package" like "test", are satisfied from the output directories of the
* projects in the reactor. This is meant as a best effort to provide a class path for compilation or testing.
*/
public void testitTestPhase()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3043" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "consumer-a/target" );
verifier.deleteDirectory( "consumer-b/target" );
verifier.deleteDirectory( "consumer-c/target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng3043" );
verifier.setLogFileName( "log-test.txt" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
List classpath;
classpath = verifier.loadLines( "consumer-a/target/compile.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-test" } );
assertNotContains( classpath, new String[] { "classes-main" } );
classpath = verifier.loadLines( "consumer-a/target/runtime.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-test" } );
assertNotContains( classpath, new String[] { "classes-main" } );
classpath = verifier.loadLines( "consumer-a/target/test.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-test" } );
assertNotContains( classpath, new String[] { "classes-main" } );
classpath = verifier.loadLines( "consumer-b/target/compile.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-main" } );
assertNotContains( classpath, new String[] { "classes-test" } );
classpath = verifier.loadLines( "consumer-b/target/runtime.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-main" } );
assertNotContains( classpath, new String[] { "classes-test" } );
classpath = verifier.loadLines( "consumer-b/target/test.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-main" } );
assertNotContains( classpath, new String[] { "classes-test" } );
classpath = verifier.loadLines( "consumer-c/target/compile.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-main" } );
assertContains( classpath, new String[] { "classes-test" } );
classpath = verifier.loadLines( "consumer-c/target/runtime.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-main" } );
assertContains( classpath, new String[] { "classes-test" } );
classpath = verifier.loadLines( "consumer-c/target/test.txt", "UTF-8" );
assertContains( classpath, new String[] { "classes-main" } );
assertContains( classpath, new String[] { "classes-test" } );
}
/**
* Test that dependency resolution still uses to the actual artifact files once these have been
* assembled/attached in the "package" phase. This ensures the class path is accurate and not locked to
* the output directories of the best effort model from above.
*/
public void testitPackagePhase()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3043" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "consumer-a/target" );
verifier.deleteDirectory( "consumer-b/target" );
verifier.deleteDirectory( "consumer-c/target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng3043" );
verifier.setLogFileName( "log-package.txt" );
verifier.executeGoal( "initialize" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
List classpath;
classpath = verifier.loadLines( "consumer-a/target/compile.txt", "UTF-8" );
assertContains( classpath, new String[] { "tests.jar" } );
assertNotContains( classpath, new String[] { "client.jar" } );
classpath = verifier.loadLines( "consumer-a/target/runtime.txt", "UTF-8" );
assertContains( classpath, new String[] { "tests.jar" } );
assertNotContains( classpath, new String[] { "client.jar" } );
classpath = verifier.loadLines( "consumer-a/target/test.txt", "UTF-8" );
assertContains( classpath, new String[] { "tests.jar" } );
assertNotContains( classpath, new String[] { "client.jar" } );
classpath = verifier.loadLines( "consumer-b/target/compile.txt", "UTF-8" );
assertContains( classpath, new String[] { "client.jar" } );
assertNotContains( classpath, new String[] { "tests.jar" } );
classpath = verifier.loadLines( "consumer-b/target/runtime.txt", "UTF-8" );
assertContains( classpath, new String[] { "client.jar" } );
assertNotContains( classpath, new String[] { "tests.jar" } );
classpath = verifier.loadLines( "consumer-b/target/test.txt", "UTF-8" );
assertContains( classpath, new String[] { "client.jar" } );
assertNotContains( classpath, new String[] { "tests.jar" } );
classpath = verifier.loadLines( "consumer-c/target/compile.txt", "UTF-8" );
assertContains( classpath, new String[] { "client.jar" } );
assertContains( classpath, new String[] { "tests.jar" } );
classpath = verifier.loadLines( "consumer-c/target/runtime.txt", "UTF-8" );
assertContains( classpath, new String[] { "client.jar" } );
assertContains( classpath, new String[] { "tests.jar" } );
classpath = verifier.loadLines( "consumer-c/target/test.txt", "UTF-8" );
assertContains( classpath, new String[] { "client.jar" } );
assertContains( classpath, new String[] { "tests.jar" } );
}
private void assertContains( List collection, Object[] items )
{
for ( int i = 0; i < items.length; i++ )
{
assertContains( collection, items[i] );
}
}
private void assertContains( List collection, Object item )
{
assertTrue( item + " missing in " + collection, collection.contains( item ) );
}
private void assertNotContains( List collection, Object[] items )
{
for ( int i = 0; i < items.length; i++ )
{
assertNotContains( collection, items[i] );
}
}
private void assertNotContains( List collection, Object item )
{
assertFalse( item + " present in " + collection, collection.contains( item ) );
}
}

View File

@ -0,0 +1,76 @@
<?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>
<parent>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>parent</artifactId>
<version>1</version>
</parent>
<artifactId>consumer-a</artifactId>
<name>Maven Integration Test :: MNG-3043 :: Consumer A</name>
<description>
Test that dependencies on attached artifacts like a test JAR or an EJB client JAR which have not been built
yet, i.e. in build phases prior to "package" like "test", are satisfied from the output directories of the
projects in the reactor. This is meant as a best effort to provide a class path for compilation or testing.
</description>
<dependencies>
<!-- This module depends *only* on the test JAR -->
<dependency>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>dependency</artifactId>
<version>0.1-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>compile-classpath</id>
<phase>validate</phase>
<goals>
<goal>compile</goal>
<goal>runtime</goal>
<goal>test</goal>
</goals>
<configuration>
<compileClassPath>target/compile.txt</compileClassPath>
<runtimeClassPath>target/runtime.txt</runtimeClassPath>
<testClassPath>target/test.txt</testClassPath>
<significantPathLevels>1</significantPathLevels>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,76 @@
<?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>
<parent>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>parent</artifactId>
<version>1</version>
</parent>
<artifactId>consumer-b</artifactId>
<name>Maven Integration Test :: MNG-3043 :: Consumer B</name>
<description>
Test that dependencies on attached artifacts like a test JAR or an EJB client JAR which have not been built
yet, i.e. in build phases prior to "package" like "test", are satisfied from the output directories of the
projects in the reactor. This is meant as a best effort to provide a class path for compilation or testing.
</description>
<dependencies>
<!-- This module depends *only* on the EJB client JAR -->
<dependency>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>dependency</artifactId>
<version>0.1-SNAPSHOT</version>
<type>ejb-client</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>compile-classpath</id>
<phase>validate</phase>
<goals>
<goal>compile</goal>
<goal>runtime</goal>
<goal>test</goal>
</goals>
<configuration>
<compileClassPath>target/compile.txt</compileClassPath>
<runtimeClassPath>target/runtime.txt</runtimeClassPath>
<testClassPath>target/test.txt</testClassPath>
<significantPathLevels>1</significantPathLevels>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,82 @@
<?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>
<parent>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>parent</artifactId>
<version>1</version>
</parent>
<artifactId>consumer-c</artifactId>
<name>Maven Integration Test :: MNG-3043 :: Consumer C</name>
<description>
Test that dependencies on attached artifacts like a test JAR or an EJB client JAR which have not been built
yet, i.e. in build phases prior to "package" like "test", are satisfied from the output directories of the
projects in the reactor. This is meant as a best effort to provide a class path for compilation or testing.
</description>
<dependencies>
<!-- This module depends on *both* artifacts -->
<dependency>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>dependency</artifactId>
<version>0.1-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>dependency</artifactId>
<version>0.1-SNAPSHOT</version>
<type>ejb-client</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>compile-classpath</id>
<phase>validate</phase>
<goals>
<goal>compile</goal>
<goal>runtime</goal>
<goal>test</goal>
</goals>
<configuration>
<compileClassPath>target/compile.txt</compileClassPath>
<runtimeClassPath>target/runtime.txt</runtimeClassPath>
<testClassPath>target/test.txt</testClassPath>
<significantPathLevels>1</significantPathLevels>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,81 @@
<?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>
<parent>
<groupId>org.apache.maven.its.mng3043</groupId>
<artifactId>parent</artifactId>
<version>1</version>
</parent>
<artifactId>dependency</artifactId>
<version>0.1-SNAPSHOT</version>
<name>Maven Integration Test :: MNG-3043 :: Dependency</name>
<description>
Test that dependencies on attached artifacts like a test JAR or an EJB client JAR which have not been built
yet, i.e. in build phases prior to "package" like "test", are satisfied from the output directories of the
projects in the reactor. This is meant as a best effort to provide a class path for compilation or testing.
</description>
<build>
<outputDirectory>classes-main</outputDirectory>
<testOutputDirectory>classes-test</testOutputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-artifact</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<!-- For the purposes of this test, the "initialize" phase plays the role of the "package" phase -->
<execution>
<!-- mimic creation of test JAR -->
<id>package-test-jar</id>
<phase>initialize</phase>
<goals>
<goal>attach</goal>
</goals>
<configuration>
<attachedFile>test-classes/tests.jar</attachedFile>
<artifactType>test-jar</artifactType>
<artifactClassifier>tests</artifactClassifier>
</configuration>
</execution>
<execution>
<!-- mimic creation of EJB client JAR -->
<id>package-ejb-client-jar</id>
<phase>initialize</phase>
<goals>
<goal>attach</goal>
</goals>
<configuration>
<attachedFile>main-classes/client.jar</attachedFile>
<artifactType>ejb-client</artifactType>
<artifactClassifier>client</artifactClassifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,43 @@
<?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.mng3043</groupId>
<artifactId>parent</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>Maven Integration Test :: MNG-3043</name>
<description>
Test that dependencies on attached artifacts like a test JAR or an EJB client JAR which have not been built
yet, i.e. in build phases prior to "package" like "test", are satisfied from the output directories of the
projects in the reactor. This is meant as a best effort to provide a class path for compilation or testing.
</description>
<modules>
<module>dependency</module>
<module>consumer-a</module>
<module>consumer-b</module>
<module>consumer-c</module>
</modules>
</project>