Search in sources :

Example 6 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNotDownloaded(downloadedFile);
    assertChecksums(expectedFile, null, null);
}
Also used : Path(java.nio.file.Path) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 7 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), 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) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 8 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.

the class ChecksumTransferTest method testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting.

@Test
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting() 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxied1File);
    assertNoTempFiles(expectedFile);
    // There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
    assertChecksums(expectedFile, "invalid checksum file", "invalid checksum file");
}
Also used : Path(java.nio.file.Path) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 9 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    // This is a success situation. No SHA1 with a Good MD5.
    Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxied1File);
    assertNoTempFiles(expectedFile);
    assertChecksums(expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar");
}
Also used : Path(java.nio.file.Path) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 10 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNotDownloaded(downloadedFile);
    assertChecksums(expectedFile, null, null);
}
Also used : Path(java.nio.file.Path) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Aggregations

BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)62 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)55 Artifact (org.apache.archiva.repository.content.Artifact)50 Path (java.nio.file.Path)49 Test (org.junit.Test)45 LayoutException (org.apache.archiva.repository.content.LayoutException)10 ArchivaItemSelector (org.apache.archiva.repository.content.base.ArchivaItemSelector)9 ContentItem (org.apache.archiva.repository.content.ContentItem)7 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)5 Project (org.apache.archiva.repository.content.Project)5 Version (org.apache.archiva.repository.content.Version)5 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 ContentAccessException (org.apache.archiva.repository.content.ContentAccessException)4 ItemSelector (org.apache.archiva.repository.content.ItemSelector)4 ResourceDoesNotExistException (org.apache.maven.wagon.ResourceDoesNotExistException)4 IOException (java.io.IOException)3 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)3 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 RepositoryException (org.apache.archiva.repository.RepositoryException)3