[MNG-4005] Throw Validation Error if pom contains a dependency with two different versions.

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@784244 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-06-12 19:28:00 +00:00
parent 2256d15ae3
commit 56f8e5c276
13 changed files with 463 additions and 10 deletions

View File

@ -119,6 +119,7 @@ public static Test suite()
suite.addTestSuite( MavenITmng4009InheritProfileEffectsTest.class );
suite.addTestSuite( MavenITmng4008MergedFilterOrderTest.class );
suite.addTestSuite( MavenITmng4007PlatformFileSeparatorTest.class );
suite.addTestSuite( MavenITmng4005UniqueDependencyKeyTest.class );
suite.addTestSuite( MavenITmng4000MultiPluginExecutionsTest.class );
suite.addTestSuite( MavenITmng3998PluginExecutionConfigTest.class );
suite.addTestSuite( MavenITmng3983PluginResolutionFromProfileReposTest.class );

View File

@ -0,0 +1,100 @@
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.Collections;
import java.util.List;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4005">MNG-4005</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4005UniqueDependencyKeyTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng4005UniqueDependencyKeyTest()
{
super( "[3.0-alpha-3,)" );
}
/**
* Test that duplicate dependencies cause a validation error during building.
*/
public void testitProjectBuild()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4005/build" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
try
{
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
fail( "Duplicate dependency did not cause validation error" );
}
catch ( VerificationException e )
{
// expected
}
finally
{
verifier.resetStreams();
}
}
/**
* Test that duplicate dependencies don't cause a validation error during metadata retrieval.
*/
public void testitMetadataRetrieval()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4005/metadata" );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng4005" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
verifier.getCliOptions().add( "-s" );
verifier.getCliOptions().add( "settings.xml" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
List artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
Collections.sort( artifacts );
List expected = new ArrayList();
expected.add( "org.apache.maven.its.mng4005:a:jar:0.2" );
expected.add( "org.apache.maven.its.mng4005:b:jar:0.1" );
assertEquals( expected, artifacts );
}
}

View File

@ -57,7 +57,7 @@ public void testit()
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng4190" );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() );
verifier.getCliOptions().add( "-X -s" );
verifier.getCliOptions().add( "-s" );
verifier.getCliOptions().add( "settings.xml" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();

View File

@ -0,0 +1,47 @@
<?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.mng4005</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4005</name>
<description>
Test that duplicate dependency declarations cause a validation error during building.
</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,64 @@
<?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.mng4005</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<name>Maven Integration Test :: MNG-4005</name>
<description>
Test that duplicate dependencies do not cause a validation error during metadata retrieval.
</description>
<dependencies>
<dependency>
<!-- The POM of this dependency is invalid, yet its transitive dependencies should be resolved, too -->
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>b</artifactId>
<version>0.1</version>
</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>test</id>
<phase>validate</phase>
<configuration>
<projectArtifacts>target/artifacts.txt</projectArtifacts>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,36 @@
<?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.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.2</version>
<packaging>jar</packaging>
<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xsi:schemaLocation="http://maven.apache.org/METADATA/1.0.0 http://maven.apache.org/xsd/metadata-1.0.0.xsd" xmlns="http://maven.apache.org/METADATA/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.2</version>
<versioning>
<release>0.2</release>
<versions>
<version>0.2</version>
</versions>
<lastUpdated>20090612175831</lastUpdated>
</versioning>
</metadata>

View File

@ -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.mng4005</groupId>
<artifactId>b</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
<!-- The duplicate dependencies in here should not cause a validation error during metadata retrieval -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.2</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.2</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>test</id>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.2</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>a</artifactId>
<version>0.2</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xsi:schemaLocation="http://maven.apache.org/METADATA/1.0.0 http://maven.apache.org/xsd/metadata-1.0.0.xsd" xmlns="http://maven.apache.org/METADATA/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<groupId>org.apache.maven.its.mng4005</groupId>
<artifactId>b</artifactId>
<version>0.1</version>
<versioning>
<release>0.1</release>
<versions>
<version>0.1</version>
</versions>
<lastUpdated>20090612180153</lastUpdated>
</versioning>
</metadata>

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.
-->
<settings>
<profiles>
<profile>
<id>maven-core-it-repo</id>
<repositories>
<repository>
<id>maven-core-it</id>
<url>@baseurl@/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>maven-core-it-repo</activeProfile>
</activeProfiles>
</settings>

View File

@ -34,8 +34,18 @@ under the License.
</repository>
</distributionManagement>
<dependencies>
<dependency>
<!-- if the model builder rejected this POM, the test will miss this dependency -->
<groupId>org.apache.maven.its.mng4193</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
<!-- The duplicate repository id's in here should not cause a validation error during metadata retrieval -->
<repositories>
<!-- The duplicate repository id should not cause a validation error during metadata retrieval -->
<repository>
<id>non-unique-id</id>
<url>http://repo1.maven.org</url>
@ -45,13 +55,40 @@ under the License.
<url>http://repo2.maven.org</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>non-unique-id</id>
<url>http://repo1.maven.org</url>
</pluginRepository>
<pluginRepository>
<id>non-unique-id</id>
<url>http://repo2.maven.org</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<!-- if the model builder rejected this POM, the test will miss this dependency -->
<groupId>org.apache.maven.its.mng4193</groupId>
<artifactId>a</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>test</id>
<repositories>
<repository>
<id>non-unique-id</id>
<url>http://repo1.maven.org</url>
</repository>
<repository>
<id>non-unique-id</id>
<url>http://repo2.maven.org</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>non-unique-id</id>
<url>http://repo1.maven.org</url>
</pluginRepository>
<pluginRepository>
<id>non-unique-id</id>
<url>http://repo2.maven.org</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>