git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@372767 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-0.9-alpha-1
@@ -89,6 +89,11 @@ public class DefaultRepositoryConverter | |||
public void convert( Artifact artifact, ArtifactRepository targetRepository, ArtifactReporter reporter ) | |||
throws RepositoryConversionException | |||
{ | |||
if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) ) | |||
{ | |||
throw new RepositoryConversionException( getI18NString( "exception.repositories.match" ) ); | |||
} | |||
if ( copyArtifact( artifact, targetRepository, reporter ) ) | |||
{ | |||
copyPom( artifact, targetRepository, reporter ); |
@@ -24,6 +24,11 @@ package org.apache.maven.repository.converter; | |||
public class RepositoryConversionException | |||
extends Exception | |||
{ | |||
public RepositoryConversionException( String message ) | |||
{ | |||
super( message ); | |||
} | |||
public RepositoryConversionException( String message, Throwable cause ) | |||
{ | |||
super( message, cause ); |
@@ -17,4 +17,5 @@ | |||
failure.incorrect.md5=The MD5 checksum value was incorrect. | |||
failure.incorrect.sha1=The SHA1 checksum value was incorrect. | |||
warning.missing.pom=The artifact had no POM in the source repository. | |||
failure.target.already.exists=The artifact could not be converted because it already exists. | |||
failure.target.already.exists=The artifact could not be converted because it already exists. | |||
exception.repositories.match=Source and target repositories are identical. |
@@ -737,10 +737,28 @@ public class RepositoryConverterTest | |||
} | |||
public void testSourceAndTargetRepositoriesMatch() | |||
throws Exception | |||
{ | |||
// test that it fails if the same (initially - later we might allow this with extra checks) | |||
// test that it fails if the same | |||
// TODO | |||
ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); | |||
sourceRepository = factory.createArtifactRepository( "source", targetRepository.getUrl(), | |||
targetRepository.getLayout(), null, null ); | |||
Artifact artifact = createArtifact( "test", "repository-artifact", "1.0" ); | |||
try | |||
{ | |||
repositoryConverter.convert( artifact, targetRepository, reporter ); | |||
fail( "Should have failed trying to convert within the same repository" ); | |||
} | |||
catch ( RepositoryConversionException e ) | |||
{ | |||
// expected | |||
assertEquals( "check message", getI18nString( "exception.repositories.match" ), e.getMessage() ); | |||
assertNull( "Check no additional cause", e.getCause() ); | |||
} | |||
} | |||
private Artifact createArtifact( String groupId, String artifactId, String version ) |