[MNG-3220][MNG-3391] Adding integration tests for these issues, although those for MNG-3391 are commented out for now, until we can figure something out.

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@638215 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-03-18 04:51:59 +00:00
parent 679eb12543
commit 05291f80a9
24 changed files with 662 additions and 2 deletions

View File

@ -64,14 +64,19 @@ public static Test suite()
* the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well.
*/
suite.addTestSuite( MavenITmng3428PluginDescriptorArtifactsIncompleteTest.class );
suite.addTestSuite( MavenITmng3426PluginsClasspathOverrideTest.class );
suite.addTestSuite( MavenITmng3396DependencyManagementForOverConstrainedRanges.class );
suite.addTestSuite( MavenITmng3394POMPluginVersionDominanceTest.class );
// Pending resolution of MNG-3391
// suite.addTestSuite( MavenITmng3391ImportScopeErrorScenariosTest.class );
suite.addTestSuite( MavenITmng3372DirectInvocationOfPlugins.class );
suite.addTestSuite( MavenITmng3341MetadataUpdatedFromDeploymentRepositoryTest.class );
suite.addTestSuite( MavenITmng3331ModulePathNormalization.class );
suite.addTestSuite( MavenITmng3220ImportScopeTest.class );
suite.addTestSuite( MavenITmng3099SettingsProfilesWithNoPOM.class );
suite.addTestSuite( MavenITmng2972OverridePluginDependency.class );
suite.addTestSuite( MavenITmng2861RelocationsAndRanges.class );
@ -201,7 +206,7 @@ public static Test suite()
/*
* Add tests in reverse alpha order above.
*/
// not fixed in the code yet. Test is correct.
// suite.addTestSuite( MavenITmng3284UsingCachedPluginsTest.class );

View File

@ -0,0 +1,78 @@
package org.apache.maven.integrationtests;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import java.io.File;
import java.util.Iterator;
import java.util.List;
public class MavenITmng3220ImportScopeTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng3220ImportScopeTest()
throws InvalidVersionSpecificationException
{
super( "(2.0.8,)" ); // only test in 2.0.9+
}
public void testitMNG3220a()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3220-importedDepMgmt/imported-pom-depMgmt" );
File dmDir = new File( testDir, "dm-pom" );
Verifier verifier = new Verifier( dmDir.getAbsolutePath() );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
File projectDir = new File( testDir, "project" );
verifier = new Verifier( projectDir.getAbsolutePath() );
verifier.executeGoal( "package" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
public void testitMNG3220b()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3220-importedDepMgmt/depMgmt-pom-module-notImported" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
try
{
verifier.executeGoal( "install" );
fail( "Should fail to build with missing junit version." );
}
catch ( VerificationException e )
{
}
verifier.resetStreams();
List lines = verifier.loadFile( new File( testDir, "log.txt" ), false );
boolean found = false;
for ( Iterator it = lines.iterator(); it.hasNext(); )
{
String line = (String) it.next();
if ( line.indexOf( "\'dependencies.dependency.version\' is missing for junit:junit") > -1 )
{
found = true;
break;
}
}
assertTrue( "Should have found validation error line in output.", found );
}
}

View File

@ -0,0 +1,84 @@
package org.apache.maven.integrationtests;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import java.io.File;
public class MavenITmng3391ImportScopeErrorScenariosTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng3391ImportScopeErrorScenariosTest()
throws InvalidVersionSpecificationException
{
super( "(2.0.8,)" ); // only test in 2.0.9+
}
public void testitMNG3391a()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3391-importScopeErrorScenarios/depMgmt-importPom-noParentCycle" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.deleteArtifact( "org.apache.maven.its.mng3391.2", "dm-pom", "1", "pom" );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
public void testitMNG3391b()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3391-importScopeErrorScenarios/depMgmt-importPom-noParentCycle" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.deleteArtifact( "org.apache.maven.its.mng3391.2", "dm-pom", "1", "pom" );
Verifier v2 = new Verifier( new File( testDir, "dm-pom" ).getAbsolutePath() );
v2.executeGoal( "install" );
v2.verifyErrorFreeLog();
v2.resetStreams();
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
public void testitMNG3391c()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3391-importScopeErrorScenarios/depMgmt-importPom-parentCycle" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.deleteArtifact( "org.apache.maven.its.mng3391.1", "dm-pom", "1", "pom" );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
public void testitMNG3391d()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3391-importScopeErrorScenarios/depMgmt-importPom-parentCycle" );
Verifier verifier = new Verifier( new File( testDir, "dm-pom" ).getAbsolutePath() );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
}

View File

@ -0,0 +1,22 @@
<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>
<parent>
<groupId>org.apache.maven.its.mng3220.2</groupId>
<version>1</version>
<artifactId>parent</artifactId>
</parent>
<artifactId>dm-pom</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,24 @@
<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.mng3220.2</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1</version>
<modules>
<module>dm-pom</module>
<module>project</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng3220.2</groupId>
<artifactId>dm-pom</artifactId>
<version>1</version>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,20 @@
<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>
<parent>
<groupId>org.apache.maven.its.mng3220.2</groupId>
<version>1</version>
<artifactId>parent</artifactId>
</parent>
<artifactId>project</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
package test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -0,0 +1,18 @@
<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.mng3220.1</groupId>
<artifactId>dm-pom</artifactId>
<packaging>pom</packaging>
<version>1</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,28 @@
<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.mng3220.1</groupId>
<artifactId>project</artifactId>
<packaging>jar</packaging>
<version>1</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng3220.1</groupId>
<artifactId>dm-pom</artifactId>
<version>1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
package test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -0,0 +1,16 @@
These tests are designed to test the import scope when used in the dependencyManagement section.
The first, imported-pom-depMgmt, tests whether a dependency in a project's dependencyManagement section of type == pom and scope == import will have its own dependencyManagement section merged with the main project's. If this works, the junit dependency in the project's main dependencies section will have a version provided for it, and the build will succeed. This requires the dm-pom project to be installed first, since there is no other link between the projects than the dependencyManagement specification from project -> dm-pom. To execute:
1. cd dm-pom
2. mvn install
3. cd project
4. mvn package
The second, depMgmt-pom-module-notImported, ensures that POM references in dependencyManagement sections that don't specify scope == import will not have their own dependencyManagement sections merged with those of the referencing POM. The dm-pom POM provides a version for junit in its dependencyManagement section, and the project POM specifies a junit dependency without a version. The top-level POM specifies a reference to the dm-pom POM in its dependencyManagement section, and module entries for both dm-pom and project POMs. When the build is started at the top level, it will fail with an invalid dependency specification in the project POM (the junit version is missing, since the dm-pom's junit specification is not merged).
NOTE: The dependencyManagement reference to dm-pom in the top-level POM does NOT use scope == import. The scope of dm-pom here is a critical feature of this test.
To execute:
1. mvn install

View File

@ -0,0 +1,26 @@
<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>
<!--
<parent>
<groupId>org.apache.maven.its.mng3391.2</groupId>
<version>1</version>
<artifactId>parent</artifactId>
</parent>
-->
<groupId>org.apache.maven.its.mng3391.2</groupId>
<version>1</version>
<artifactId>dm-pom</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,25 @@
<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.mng3391.2</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1</version>
<modules>
<module>dm-pom</module>
<module>project</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng3391.2</groupId>
<artifactId>dm-pom</artifactId>
<version>1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,20 @@
<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>
<parent>
<groupId>org.apache.maven.its.mng3391.2</groupId>
<version>1</version>
<artifactId>parent</artifactId>
</parent>
<artifactId>project</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
package test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -0,0 +1,24 @@
<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>
<parent>
<groupId>org.apache.maven.its.mng3391.1</groupId>
<version>1</version>
<artifactId>parent</artifactId>
</parent>
<groupId>org.apache.maven.its.mng3391.1</groupId>
<version>1</version>
<artifactId>dm-pom</artifactId>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,25 @@
<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.mng3391.1</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1</version>
<modules>
<module>dm-pom</module>
<module>project</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng3391.1</groupId>
<artifactId>dm-pom</artifactId>
<version>1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -0,0 +1,20 @@
<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>
<parent>
<groupId>org.apache.maven.its.mng3391.1</groupId>
<version>1</version>
<artifactId>parent</artifactId>
</parent>
<artifactId>project</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,13 @@
package test;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
package test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -0,0 +1,21 @@
In some scenarios, usage of the import scope can result in a StackOverflowException or OutOfMemoryException. The tests in this group are designed to define the edges of this problem.
The first build, depMgmt-importPom-noParentCycle, has a module POM that is also referenced from the top level as a dependencyManagement entry with type == pom and scope == import. The dm-pom project (the module in question) DOES NOT specify the top-level POM as its parent. This build should fail on the first execution, but succeed as soon as the dm-pom POM is installed into the local repository. To execute:
1. mvn install
2. Observe the ArtifactNotFoundException listing org.apache.maven.its.mng3391.2:dm-pom:pom:1 as missing. This is because the dm-pom module hasn't been loaded at the time that the dm-pom is required for merging dependencyManagement.
3. cd dm-pom
4. mvn install
5. mvn install (from the top level again)
6. Observe that the build succeeds this time.
The second build, depMgmt-importPom-parentCycle, is designed to show the two error conditions that result from the the dm-pom POM listing the top-level POM as its parent, while the top-level POM simultaneously lists the dm-pom as a module AND as a dependencyManagement entry with scope == import and type == pom. This build will fail with an ArtifactNotFoundException on the first run. On the second run, the dm-pom is first installed manually into the local repository, and will result in either a StackOverflowException or an OutOfMemoryException.
1. mvn install
2. Observe the ArtifactNotFoundException listing org.apache.maven.its.mng3391.2:dm-pom:pom:1 as missing. This is because the dm-pom module hasn't been loaded at the time that the dm-pom is required for merging dependencyManagement.
3. cd dm-pom
4. copy pom.xml to <local-repository>/org/apache/maven/its/mng3391/1/dm-pom/1/dm-pom-1.pom
5. mvn install (from the top level again)
6. Observe that this build brings Maven to its knees.
NOTE: We can't really run this last build (yet) because it will wreck the entire IT run.