[MRM-155] check paths are translated correctly when there is a mismatch between the requested repository layout and the managed repository layout

Submitted by: Nicolas de Loof (applied with changes)

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@439143 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-09-01 02:40:33 +00:00
parent 96ba48bf47
commit 2102fd5298
2 changed files with 42 additions and 3 deletions

View File

@ -124,7 +124,7 @@ public class DefaultProxyRequestHandler
}
else
{
get( path, target, repository, managedRepository, wagonProxy, force );
target = get( path, target, repository, managedRepository, wagonProxy, force );
}
}
@ -136,7 +136,11 @@ public class DefaultProxyRequestHandler
return target;
}
private void get( String path, File target, ProxiedArtifactRepository repository,
/**
* @return the target File may not be same as the target argument, if a
* maven1 to maven2 path convertion occured.
*/
private File get( String path, File target, ProxiedArtifactRepository repository,
ArtifactRepository managedRepository, ProxyInfo wagonProxy, boolean force )
throws ProxyException
{
@ -192,6 +196,8 @@ public class DefaultProxyRequestHandler
if ( artifact != null )
{
target = new File( managedRepository.getBasedir(), managedRepository.pathOf( artifact ) );
ArtifactRepository artifactRepository = repository.getRepository();
// we use the release policy for tracking failures, but only check for updates on snapshots
@ -227,6 +233,7 @@ public class DefaultProxyRequestHandler
// in case it previously failed and we've since found it
repository.clearFailure( path );
}
return target;
}
private void mergeMetadataFiles( File target, File metadataFile )

View File

@ -110,7 +110,7 @@ public class ProxyRequestHandlerTest
ArtifactRepositoryLayout legacyLayout =
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
legacyManagedRepository = createRepository( "managed-repository", repoLocation );
legacyManagedRepository = createRepository( "managed-repository", repoLocation, legacyLayout );
File location = getTestFile( "src/test/repositories/proxied1" );
proxiedRepository1 = createRepository( "proxied1", location );
@ -1592,6 +1592,38 @@ public class ProxyRequestHandlerTest
file.lastModified() );
}
public void testLegacyRequestConvertedToDefaultPathInManagedRepo()
throws Exception
{
// Check that a Maven1 legacy request is translated to a maven2 path in
// the managed repository.
String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( defaultManagedRepository.getBasedir(), path );
assertTrue( expectedFile.exists() );
File file = requestHandler.get( legacyPath, legacyProxiedRepositories, defaultManagedRepository );
assertEquals( "Check file matches", expectedFile, file );
}
public void testDefaultRequestConvertedToLegacyPathInManagedRepo()
throws Exception
{
// Check that a Maven2 default request is translated to a legacy path in
// the managed repository.
String legacyPath = "org.apache.maven.test/jars/get-default-layout-present-1.0.jar";
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
File expectedFile = new File( legacyManagedRepository.getBasedir(), legacyPath );
assertTrue( expectedFile.exists() );
File file = requestHandler.get( path, proxiedRepositories, legacyManagedRepository );
assertEquals( "Check file matches", expectedFile, file );
}
private static Versioning getVersioning( List versions )
{
Versioning versioning = new Versioning();