Search in sources :

Example 21 with ArtifactReference

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

the class ChecksumTransferTest method testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting.

@Test
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingFixSetting() throws Exception {
    String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
    setManagedOlderThanRemote(expectedFile, remoteFile);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    // 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, "96a08dc80a108cba8efd3b20aec91b32a0b2cbd4  get-bad-local-checksum-1.0.jar", "46fdd6ca55bf1d7a7eb0c858f41e0ccd  get-bad-local-checksum-1.0.jar");
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 22 with ArtifactReference

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

the class ChecksumTransferTest method testGetChecksumWhenConnectorIsDisabled.

@Test
public void testGetChecksumWhenConnectorIsDisabled() throws Exception {
    String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    org.apache.archiva.common.utils.FileUtils.deleteDirectory(expectedFile.getParent());
    assertFalse(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, true);
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    assertNull(downloadedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 23 with ArtifactReference

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

the class ChecksumTransferTest method testGetWithNoChecksumsUsingFailSetting.

@Test
public void testGetWithNoChecksumsUsingFailSetting() 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);
    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);
    assertNotDownloaded(downloadedFile);
    assertChecksums(expectedFile, null, null);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 24 with ArtifactReference

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

the class ChecksumTransferTest method testGetChecksumCorrectSha1BadMd5UsingFixSetting.

@Test
public void testGetChecksumCorrectSha1BadMd5UsingFixSetting() throws Exception {
    String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-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, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar", "c35f3b76268b73a4ba617f6f275c49ab  get-checksum-sha1-bad-md5-1.0.jar");
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 25 with ArtifactReference

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

the class ChecksumTransferTest method testGetChecksumBadSha1BadMd5FailSetting.

@Test
public void testGetChecksumBadSha1BadMd5FailSetting() throws Exception {
    String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-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);
    assertNotDownloaded(downloadedFile);
    assertChecksums(expectedFile, null, null);
}
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