Search in sources :

Example 71 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset 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 72 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset 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 73 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset 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)

Example 74 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class SnapshotTransferTest method testTimestampDrivenSnapshotNotPresentAlreadyExpiredCacheFailure.

@Test
public void testTimestampDrivenSnapshotNotPresentAlreadyExpiredCacheFailure() 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);
    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, ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, false);
    saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.YES, 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)

Example 75 with StorageAsset

use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.

the class SnapshotTransferTest method testTimestampDrivenSnapshotNotExpired.

/**
 * TODO: Has problems with wagon implementation not preserving timestamp.
 */
/*
    public void testNewerTimestampDrivenSnapshotOnSecondRepoThanFirstNotPresentAlready()
        throws Exception
    {
        String path = "org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-SNAPSHOT.jar";
        setupTestableManagedRepository( path );
        
        Path expectedFile = managedDefaultDir.resolve(path);
        ArtifactReference artifact = createArtifactReference( "default", path );

        Files.delete(expectedFile);
        assertFalse( Files.exists(expectedFile) );

        // Create customized proxy / target repository
        File targetProxyDir = saveTargetedRepositoryConfig( ID_PROXIED1_TARGET, REPOPATH_PROXIED1,
                                                            REPOPATH_PROXIED1_TARGET, "default" );

        new File( targetProxyDir, path ).setLastModified( getPastDate().getTime() );

        // Configure Connector (usually done within archiva.xml configuration)
        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1_TARGET, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );

        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );

        // Should have downloaded the content from proxy2, as proxy1 has an old (by file.lastModified check) version.
        Path proxiedFile = Paths.get(REPOPATH_PROXIED2, path);
        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
        assertNoTempFiles( expectedFile );
    } 

    public void testOlderTimestampDrivenSnapshotOnSecondRepoThanFirstNotPresentAlready()
        throws Exception
    {
        String path = "org/apache/maven/test/get-timestamped-snapshot-in-both/1.0-SNAPSHOT/get-timestamped-snapshot-in-both-1.0-SNAPSHOT.jar";
        setupTestableManagedRepository( path );
        
        Path expectedFile = managedDefaultDir.resolve(path);
        ArtifactReference artifact = createArtifactReference( "default", path );

        Files.delete(expectedFile);
        assertFalse( Files.exists(expectedFile) );

        // Create customized proxy / target repository
        File targetProxyDir = saveTargetedRepositoryConfig( ID_PROXIED2_TARGET, REPOPATH_PROXIED2,
                                                            REPOPATH_PROXIED2_TARGET, "default" );

        new File( targetProxyDir, path ).setLastModified( getPastDate().getTime() );

        // Configure Connector (usually done within archiva.xml configuration)
        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );
        saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2_TARGET, ChecksumPolicy.IGNORED, ReleasesPolicy.IGNORED,
                       SnapshotsPolicy.IGNORED, CachedFailuresPolicy.IGNORED );

        File downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository, artifact );

        File proxiedFile = new File( REPOPATH_PROXIED1_TARGET, path );
        assertFileEquals( expectedFile, downloadedFile, proxiedFile );
        assertNoTempFiles( expectedFile );
    } */
@Test
public void testTimestampDrivenSnapshotNotExpired() 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));
    Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
    Files.setLastModifiedTime(proxiedFile, FileTime.from(getFutureDate().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);
    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

StorageAsset (org.apache.archiva.repository.storage.StorageAsset)191 Path (java.nio.file.Path)91 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)61 IOException (java.io.IOException)59 Test (org.junit.Test)59 Artifact (org.apache.archiva.repository.content.Artifact)54 ManagedRepository (org.apache.archiva.repository.ManagedRepository)27 ArchivaIndexingContext (org.apache.archiva.indexer.ArchivaIndexingContext)22 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)22 List (java.util.List)20 Inject (javax.inject.Inject)20 RepositoryMetadataException (org.apache.archiva.repository.metadata.RepositoryMetadataException)20 Collectors (java.util.stream.Collectors)19 RemoteRepository (org.apache.archiva.repository.RemoteRepository)19 IndexingContext (org.apache.maven.index.context.IndexingContext)19 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)18 StringUtils (org.apache.commons.lang3.StringUtils)18 Logger (org.slf4j.Logger)18 LoggerFactory (org.slf4j.LoggerFactory)18 Map (java.util.Map)17