[MNG-4891] Improve robustness of snapshot dependency resolution in case a remote repo accidently uses the id "local"

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@1032960 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-11-09 12:23:40 +00:00
parent ac354cdfcd
commit 9920a9d0a7
5 changed files with 213 additions and 6 deletions

View File

@ -83,6 +83,7 @@ public class IntegrationTestSuite
// -------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng4891RobustSnapshotResolutionTest.class );
suite.addTestSuite( MavenITmng4877DeployUsingPrivateKeyTest.class );
suite.addTestSuite( MavenITmng4874UpdateLatestPluginVersionTest.class );
suite.addTestSuite( MavenITmng4872ReactorResolutionAttachedWithExclusionsTest.class );

View File

@ -0,0 +1,71 @@
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-4891">MNG-4891</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4891RobustSnapshotResolutionTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng4891RobustSnapshotResolutionTest()
{
super( "[2.0.3,3.0-alpha-1),[3.0.1,)" );
}
/**
* Verify that resolution of a local snapshot still succeeds even if the maven-metadata-local.xml has been
* corrupted by a remote repository that misuses the same repo id, i.e. "local".
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4891" );
Verifier verifier = newVerifier( new File( testDir, "producer" ).getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng4891" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier = newVerifier( new File( testDir, "consumer" ).getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
List artifacts = verifier.loadLines( "target/artifacts.txt", "UTF-8" );
assertTrue( artifacts.toString(), artifacts.contains( "org.apache.maven.its.mng4891:producer:jar:0.1-SNAPSHOT" ) );
}
}

View File

@ -19,12 +19,6 @@ specific language governing permissions and limitations
under the License.
-->
<!--
These settings are meant for ITs that don't download artifacts from remote servers, i.e. ITs that either use their
own test repos or can employ the local repository (after bootstrapping). This configuration uses a file: URL to
"central" to avoid needless network access for files knowingly not present externally.
-->
<settings>
<servers>
<server>

View File

@ -0,0 +1,66 @@
<?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.mng4891</groupId>
<artifactId>consumer</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4891 :: Dependency Consumer</name>
<description>
Verify that resolution of a local snapshot still succeeds even if the maven-metadata-local.xml has been
corrupted by a remote repository that misuses the same repo id, i.e. "local".
</description>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng4891</groupId>
<artifactId>producer</artifactId>
<version>0.1-SNAPSHOT</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>
<configuration>
<projectArtifacts>target/artifacts.txt</projectArtifacts>
<significantPathLevels>1</significantPathLevels>
</configuration>
<executions>
<execution>
<id>resolve</id>
<phase>validate</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,75 @@
<?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.mng4891</groupId>
<artifactId>producer</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4891 :: Dependency Producer</name>
<description>
Verify that resolution of a local snapshot still succeeds even if the maven-metadata-local.xml has been
corrupted by a remote repository that misuses the same repo id, i.e. "local".
</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-artifact</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>install</id>
<phase>validate</phase>
<goals>
<goal>set</goal>
<goal>attach-pom</goal>
<goal>install</goal>
</goals>
<configuration>
<mainFile>pom.xml</mainFile>
</configuration>
</execution>
<execution>
<id>deploy</id>
<phase>validate</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<!-- NOTE: Having the repo id clash with the id used internally for the local repo is the crucial piece here -->
<repositoryId>local</repositoryId>
<repositoryUrl>file:///${basedir}/target/repo</repositoryUrl>
<file>pom.xml</file>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>