Search in sources :

Example 31 with ArtifactReference

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

the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresent.

@Test
public void testGetDefaultLayoutNotPresent() 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, false);
    // Attempt the proxy fetch.
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    Path sourceFile = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile, sourceFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 32 with ArtifactReference

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

the class ManagedDefaultTransferTest method testGetDefaultLayoutAlreadyPresentNewerThanRemotePolicyIgnored.

/**
 * <p>
 * Request a file, that exists locally, and remotely.
 * </p>
 * <p>
 * All policies are set to IGNORE.
 * </p>
 * <p>
 * Managed file is newer than remote file.
 * </p>
 * <p>
 * Transfer should not have occured, as managed file is newer.
 * </p>
 *
 * @throws Exception
 */
@Test
public void testGetDefaultLayoutAlreadyPresentNewerThanRemotePolicyIgnored() 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);
    Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
    // Set the managed File to be newer than local.
    setManagedNewerThanRemote(expectedFile, remoteFile);
    long originalModificationTime = Files.getLastModifiedTime(expectedFile).toMillis();
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    assertTrue(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
    // Attempt the proxy fetch.
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    assertNotDownloaded(downloadedFile);
    assertNotModified(expectedFile, originalModificationTime);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 33 with ArtifactReference

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

the class SnapshotTransferTest method testOlderTimestampDrivenSnapshotOnFirstRepo.

@Test
public void testOlderTimestampDrivenSnapshotOnFirstRepo() throws Exception {
    String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
    setManagedNewerThanRemote(expectedFile, remoteFile);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    // Attempt to download.
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    // Should not have downloaded as managed is newer than remote.
    assertNotDownloaded(downloadedFile);
    assertNoTempFiles(expectedFile);
}
Also used : Path(java.nio.file.Path) ArtifactReference(org.apache.archiva.model.ArtifactReference) Test(org.junit.Test)

Example 34 with ArtifactReference

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

the class SnapshotTransferTest method testTimestampDrivenSnapshotNotPresentAlready.

@Test
public void testTimestampDrivenSnapshotNotPresentAlready() throws Exception {
    String path = "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    Files.deleteIfExists(expectedFile);
    assertFalse(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    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)

Example 35 with ArtifactReference

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

the class SnapshotTransferTest method testSnapshotNonExistant.

@Test
public void testSnapshotNonExistant() throws Exception {
    String path = "org/apache/maven/test/does-not-exist/1.0-SNAPSHOT/does-not-exist-1.0-SNAPSHOT.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
    Files.deleteIfExists(expectedFile);
    assertFalse(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
    assertNotDownloaded(downloadedFile);
    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