Search in sources :

Example 1 with UrlFailureCache

use of org.apache.archiva.policies.urlcache.UrlFailureCache in project archiva by apache.

the class CacheFailuresTransferTest method testGetWhenInBothProxiedButFirstCacheFailure.

@Test
public void testGetWhenInBothProxiedButFirstCacheFailure() throws Exception {
    String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    Files.deleteIfExists(expectedFile);
    assertFalse(Files.exists(expectedFile));
    String url = PathUtil.toUrl(REPOPATH_PROXIED1 + "/" + path);
    // Intentionally set failure on url in proxied1 (for test)
    UrlFailureCache failurlCache = lookupUrlFailureCache();
    failurlCache.cacheFailure(url);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false);
    saveConnector(ID_DEFAULT_MANAGED, "proxied2", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false);
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    // Validate that file actually came from proxied2 (as intended).
    Path proxied2File = Paths.get(REPOPATH_PROXIED2, path);
    assertFileEquals(expectedFile, downloadedFile, proxied2File);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) UrlFailureCache(org.apache.archiva.policies.urlcache.UrlFailureCache) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)1 ArtifactReference (org.apache.archiva.model.ArtifactReference)1 UrlFailureCache (org.apache.archiva.policies.urlcache.UrlFailureCache)1 Test (org.junit.Test)1