Search in sources :

Example 26 with ArtifactReference

use of org.apache.archiva.model.ArtifactReference in project archiva by apache.

the class ChecksumTransferTest method testGetChecksumNoSha1CorrectMd5UsingFailSetting.

@Test
public void testGetChecksumNoSha1CorrectMd5UsingFailSetting() throws Exception {
    String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    FileUtils.deleteDirectory(expectedFile.getParent());
    assertFalse(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    // This is a success situation. No SHA1 with a Good MD5.
    Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile, proxied1File);
    assertNoTempFiles(expectedFile);
    assertChecksums(expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar");
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 27 with ArtifactReference

use of org.apache.archiva.model.ArtifactReference in project archiva by apache.

the class ChecksumTransferTest method testGetChecksumNoSha1CorrectMd5UsingFixSetting.

@Test
public void testGetChecksumNoSha1CorrectMd5UsingFixSetting() throws Exception {
    String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    FileUtils.deleteDirectory(expectedFile.getParent());
    assertFalse(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile, proxied1File);
    assertNoTempFiles(expectedFile);
    assertChecksums(expectedFile, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb  get-checksum-md5-only-1.0.jar", "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar");
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 28 with ArtifactReference

use of org.apache.archiva.model.ArtifactReference in project archiva by apache.

the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresentConnectorOffline.

@Test
public void testGetDefaultLayoutNotPresentConnectorOffline() throws Exception {
    String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    // Ensure file isn't present first.
    assertNotExistsInManagedDefaultRepo(expectedFile);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ONCE, SnapshotsPolicy.ONCE, CachedFailuresPolicy.NO, true);
    // Attempt the proxy fetch.
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    assertNull("File should not have been downloaded", downloadedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 29 with ArtifactReference

use of org.apache.archiva.model.ArtifactReference in project archiva by apache.

the class ManagedDefaultTransferTest method testGetInSecondProxiedRepoFirstFails.

@Test
public void testGetInSecondProxiedRepoFirstFails() 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);
    assertNotExistsInManagedDefaultRepo(expectedFile);
    // Configure Repository (usually done within archiva.xml configuration)
    saveRemoteRepositoryConfig("badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default");
    wagonMock.get(EasyMock.eq(path), EasyMock.anyObject(File.class));
    EasyMock.expectLastCall().andThrow(new ResourceDoesNotExistException("transfer failed"));
    wagonMockControl.replay();
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "badproxied", false);
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED2, false);
    // Attempt the proxy fetch.
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    wagonMockControl.verify();
    Path proxied2File = Paths.get(REPOPATH_PROXIED2, path);
    assertFileEquals(expectedFile, downloadedFile, proxied2File);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) File(java.io.File) ResourceDoesNotExistException(org.apache.maven.wagon.ResourceDoesNotExistException) Test(org.junit.Test)

Example 30 with ArtifactReference

use of org.apache.archiva.model.ArtifactReference in project archiva by apache.

the class ManagedDefaultTransferTest method testGetDefaultLayoutRemoteUpdate.

/**
 * The attempt here should result in file being transferred.
 * <p/>
 * The file exists locally, is over 6 years old, and the policy is DAILY.
 *
 * @throws Exception
 */
@Test
public void testGetDefaultLayoutRemoteUpdate() throws Exception {
    String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    assertTrue(Files.exists(expectedFile));
    Files.setLastModifiedTime(expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.DAILY, SnapshotsPolicy.DAILY, CachedFailuresPolicy.NO, false);
    // Attempt the proxy fetch.
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile, proxiedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Aggregations

ArtifactReference (org.apache.archiva.model.ArtifactReference)77 Path (java.nio.file.Path)62 Test (org.junit.Test)50 LayoutException (org.apache.archiva.repository.LayoutException)13 IOException (java.io.IOException)10 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)9 ContentNotFoundException (org.apache.archiva.repository.ContentNotFoundException)8 RepositoryException (org.apache.archiva.repository.RepositoryException)8 VersionedReference (org.apache.archiva.model.VersionedReference)7 File (java.io.File)5 Date (java.util.Date)5 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)5 RepositoryTask (org.apache.archiva.scheduler.repository.model.RepositoryTask)5 ResourceDoesNotExistException (org.apache.maven.wagon.ResourceDoesNotExistException)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)4 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)4 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)4 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)4