mirror of https://github.com/apache/archiva.git
MRM-678 : cache 404 errors in UrlFailureCache
testcase fixed to check for cache (not) to be used when cachefailure is (disabled /) enabled git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@617102 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3efbda7258
commit
bfd88ba767
|
@ -550,7 +550,7 @@ public class DefaultRepositoryProxyConnectors
|
||||||
}
|
}
|
||||||
catch ( NotFoundException e )
|
catch ( NotFoundException e )
|
||||||
{
|
{
|
||||||
// Do not cache url here.
|
urlFailureCache.cacheFailure( url );
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
catch ( NotModifiedException e )
|
catch ( NotModifiedException e )
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class CacheFailuresTransferTest
|
||||||
|
|
||||||
// Configure Repository (usually done within archiva.xml configuration)
|
// Configure Repository (usually done within archiva.xml configuration)
|
||||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||||
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/repo/", "default" );
|
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/anotherrepo/", "default" );
|
||||||
|
|
||||||
// Configure Connector (usually done within archiva.xml configuration)
|
// Configure Connector (usually done within archiva.xml configuration)
|
||||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||||
|
@ -71,8 +71,12 @@ public class CacheFailuresTransferTest
|
||||||
|
|
||||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
// TODO: test failure is cached!
|
wagonMockControl.verify();
|
||||||
|
|
||||||
|
// Second attempt to download same artifact use cache
|
||||||
|
wagonMockControl.reset();
|
||||||
|
wagonMockControl.replay();
|
||||||
|
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
wagonMockControl.verify();
|
wagonMockControl.verify();
|
||||||
|
|
||||||
assertNotDownloaded( downloadedFile );
|
assertNotDownloaded( downloadedFile );
|
||||||
|
@ -92,7 +96,7 @@ public class CacheFailuresTransferTest
|
||||||
|
|
||||||
// Configure Repository (usually done within archiva.xml configuration)
|
// Configure Repository (usually done within archiva.xml configuration)
|
||||||
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "test://bad.machine.com/repo/", "default" );
|
||||||
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/repo/", "default" );
|
saveRemoteRepositoryConfig( "badproxied2", "Bad Proxied 2", "test://bad.machine.com/anotherrepo/", "default" );
|
||||||
|
|
||||||
// Configure Connector (usually done within archiva.xml configuration)
|
// Configure Connector (usually done within archiva.xml configuration)
|
||||||
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
saveConnector( ID_DEFAULT_MANAGED, "badproxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
|
||||||
|
@ -107,10 +111,18 @@ public class CacheFailuresTransferTest
|
||||||
|
|
||||||
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
// TODO: test failure is not cached!
|
|
||||||
|
|
||||||
wagonMockControl.verify();
|
wagonMockControl.verify();
|
||||||
|
|
||||||
|
// Second attempt to download same artifact DOES NOT use cache
|
||||||
|
wagonMockControl.reset();
|
||||||
|
wagonMock.get( path, new File( expectedFile.getParentFile(), expectedFile.getName() + ".tmp" ) );
|
||||||
|
wagonMockControl.setThrowable( new ResourceDoesNotExistException( "resource does not exist." ), 2 );
|
||||||
|
wagonMockControl.replay();
|
||||||
|
|
||||||
|
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );
|
||||||
|
|
||||||
|
wagonMockControl.verify();
|
||||||
|
|
||||||
assertNotDownloaded( downloadedFile );
|
assertNotDownloaded( downloadedFile );
|
||||||
assertNoTempFiles( expectedFile );
|
assertNoTempFiles( expectedFile );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue