Search in sources :

Example 21 with Artifact

use of org.apache.archiva.repository.content.Artifact 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);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(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.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNull("File should not have been downloaded", downloadedFile);
}
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 22 with Artifact

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

the class ManagedDefaultTransferTest method testNotFoundInAnyProxies.

@Test
public void testNotFoundInAnyProxies() throws Exception {
    String path = "org/apache/maven/test/does-not-exist/1.0/does-not-exist-1.0.jar";
    setupTestableManagedRepository(path);
    Path expectedFile = managedDefaultDir.resolve(path);
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    assertNotExistsInManagedDefaultRepo(expectedFile);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED2, false);
    // Attempt the proxy fetch.
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNull("File returned was: " + downloadedFile + "; should have got a not found exception", 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 23 with Artifact

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

the class SnapshotTransferTest method testMetadataDrivenSnapshotNotPresentAlready.

@Test
public void testMetadataDrivenSnapshotNotPresentAlready() throws Exception {
    String path = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-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);
    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);
    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 24 with Artifact

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

the class SnapshotTransferTest method testTimestampDrivenSnapshotNotUpdated.

@Test
public void testTimestampDrivenSnapshotNotUpdated() 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, 12000000);
    long expectedTimestamp = Files.getLastModifiedTime(expectedFile).toMillis();
    BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
    Artifact artifact = layout.getArtifact(path);
    // Configure Connector (usually done within archiva.xml configuration)
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
    StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
    assertNotDownloaded(downloadedFile);
    assertNotModified(expectedFile, expectedTimestamp);
    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 25 with Artifact

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

the class SnapshotTransferTest method testNewerTimestampDrivenSnapshotOnFirstRepo.

@Test
public void testNewerTimestampDrivenSnapshotOnFirstRepo() 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);
    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);
    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

Artifact (org.apache.archiva.repository.content.Artifact)78 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)63 Test (org.junit.Test)60 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)59 Path (java.nio.file.Path)54 ArchivaItemSelector (org.apache.archiva.repository.content.base.ArchivaItemSelector)26 ItemSelector (org.apache.archiva.repository.content.ItemSelector)21 LayoutException (org.apache.archiva.repository.content.LayoutException)21 ContentItem (org.apache.archiva.repository.content.ContentItem)19 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)15 IOException (java.io.IOException)13 ManagedRepository (org.apache.archiva.repository.ManagedRepository)13 Project (org.apache.archiva.repository.content.Project)13 MavenMetadataReader (org.apache.archiva.maven.metadata.MavenMetadataReader)12 Version (org.apache.archiva.repository.content.Version)12 ArchivaContentItem (org.apache.archiva.repository.content.base.ArchivaContentItem)12 Reader (java.io.Reader)11 List (java.util.List)11 Collectors (java.util.stream.Collectors)11 Inject (javax.inject.Inject)11