Changing tests for proxy API

This commit is contained in:
Martin Stockhammer 2020-06-07 14:42:43 +02:00
parent dda90e3302
commit bca678b5c0
6 changed files with 48 additions and 44 deletions

View File

@ -157,7 +157,7 @@ public class CacheFailuresTransferTest
setupTestableManagedRepository( path );
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
Files.deleteIfExists( expectedFile );
assertFalse( Files.exists( expectedFile ) );

View File

@ -26,6 +26,7 @@ import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.easymock.EasyMock;
@ -56,7 +57,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -79,7 +80,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -106,7 +107,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -133,7 +134,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -159,7 +160,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -185,7 +186,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -211,7 +212,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -235,7 +236,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -262,7 +263,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -286,7 +287,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -313,7 +314,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -337,7 +338,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -364,7 +365,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -392,7 +393,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -419,7 +420,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile ) );
@ -446,7 +447,7 @@ public class ChecksumTransferTest
Path expectedFile = managedDefaultDir.resolve( path );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
FileUtils.deleteDirectory( expectedFile.getParent( ) );
assertFalse( Files.exists( expectedFile.getParent( ) ) );
@ -501,7 +502,7 @@ public class ChecksumTransferTest
setManagedOlderThanRemote( expectedFile, remoteFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS,
@ -529,7 +530,7 @@ public class ChecksumTransferTest
setManagedOlderThanRemote( expectedFile, remoteFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS,
@ -558,7 +559,7 @@ public class ChecksumTransferTest
setManagedOlderThanRemote( expectedFile, remoteFile );
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,

View File

@ -22,6 +22,7 @@ package org.apache.archiva.proxy;
import org.apache.archiva.policies.*;
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
@ -599,7 +600,7 @@ public class ErrorHandlingTest
{
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
managedDefaultRepository.toArtifactReference( path ) );
layout.getArtifact( path ) );
fail( "Proxy should not have succeeded" );
}
catch ( ProxyDownloadException e )
@ -642,7 +643,7 @@ public class ErrorHandlingTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(),
managedDefaultRepository.toArtifactReference( path ) );
layout.getArtifact( path ) );
wagonMockControl.verify();
return downloadedFile;

View File

@ -33,6 +33,7 @@ import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.proxy.model.RepositoryProxyHandler;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.base.BasicManagedRepository;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
@ -222,7 +223,7 @@ public class HttpProxyTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
Path expectedFile = managedDefaultRepository.getRepository().getRoot().resolve( path ).getFilePath();
Files.deleteIfExists( expectedFile );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Attempt the proxy fetch.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact );

View File

@ -25,6 +25,7 @@ import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.storage.StorageAsset;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
@ -59,7 +60,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -84,7 +85,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -147,7 +148,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );
@ -230,7 +231,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );
@ -277,7 +278,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );
@ -311,7 +312,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );
Files.setLastModifiedTime( expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS ));
@ -339,7 +340,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -373,7 +374,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -400,7 +401,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -427,7 +428,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertNotExistsInManagedDefaultRepo( expectedFile );
@ -464,7 +465,7 @@ public class ManagedDefaultTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertNotExistsInManagedDefaultRepo( expectedFile );

View File

@ -25,6 +25,7 @@ import org.apache.archiva.policies.ChecksumPolicy;
import org.apache.archiva.policies.ReleasesPolicy;
import org.apache.archiva.policies.SnapshotsPolicy;
import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.content.Artifact;
import org.apache.archiva.repository.storage.StorageAsset;
import org.junit.Test;
@ -53,7 +54,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -76,7 +77,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -101,7 +102,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );
Files.setLastModifiedTime( expectedFile, FileTime.from( getPastDate().getTime(), TimeUnit.MILLISECONDS ));
@ -130,7 +131,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false );
@ -219,7 +220,7 @@ public class SnapshotTransferTest
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );
@ -250,7 +251,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
// Configure Connector (usually done within archiva.xml configuration)
saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false);
@ -273,7 +274,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -302,7 +303,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
Artifact artifact = layout.getArtifact( path );
Files.deleteIfExists(expectedFile);
assertFalse( Files.exists(expectedFile) );
@ -332,8 +333,7 @@ public class SnapshotTransferTest
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class );
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
artifact.setProjectVersion( "1.0-SNAPSHOT" );
Artifact artifact = layout.getArtifact( path );
assertTrue( Files.exists(expectedFile) );