Search in sources :

Example 41 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    Files.deleteIfExists(expectedFile);
    assertFalse(Files.exists(expectedFile));
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNotDownloaded(downloadedFile);
    assertNoTempFiles(expectedFile);
}
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 42 with BaseRepositoryContentLayout

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

the class SnapshotTransferTest method testGetMetadataDrivenSnapshotRemoteUpdate.

@Test
public void testGetMetadataDrivenSnapshotRemoteUpdate() throws Exception {
    // Metadata driven snapshots (using a full timestamp) are treated like a release. It is the timing of the
    // updates to the metadata files that triggers which will be downloaded
    String path = "org/apache/maven/test/get-present-metadata-snapshot/1.0-SNAPSHOT/get-present-metadata-snapshot-1.0-20050831.101112-1.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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, false);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
    assertNotNull(downloadedFile);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxiedFile);
    assertNoTempFiles(expectedFile);
}
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 43 with BaseRepositoryContentLayout

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

the class ManagedDefaultTransferTest method testGetDefaultLayoutAlreadyPresentPolicyOnce.

/**
 * The attempt here should result in no file being transferred.
 * <p/>
 * The file exists locally, and the policy is ONCE.
 *
 * @throws Exception
 */
@Test
public void testGetDefaultLayoutAlreadyPresentPolicyOnce() 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    assertTrue(Files.exists(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.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), expectedFile);
    assertNoTempFiles(expectedFile);
}
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 44 with BaseRepositoryContentLayout

use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxiedFile);
    assertNoTempFiles(expectedFile);
}
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 45 with BaseRepositoryContentLayout

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

the class ManagedDefaultTransferTest method testGetDefaultLayoutAlreadyPresentOlderThanRemotePolicyIgnored.

/**
 * <p>
 * Request a file, that exists locally, and remotely.
 * </p>
 * <p>
 * All policies are set to IGNORE.
 * </p>
 * <p>
 * Managed file is older than Remote file.
 * </p>
 * <p>
 * Transfer should have occured, as managed file is older than remote.
 * </p>
 *
 * @throws Exception
 */
@Test
public void testGetDefaultLayoutAlreadyPresentOlderThanRemotePolicyIgnored() 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 remote file.
    setManagedOlderThanRemote(expectedFile, remoteFile);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
    assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxiedFile);
    assertNoTempFiles(expectedFile);
}
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