diff options
author | Olivier Lamy <olamy@apache.org> | 2012-10-23 13:29:21 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-10-23 13:29:21 +0000 |
commit | ef66c2d19fdb5e17eb23a1bc2a669211c67f270e (patch) | |
tree | c5ce3e49aed7c265d0e6c26a89fd094b4a1d86c5 | |
parent | 38788585d73b698a6f1e932db711c37b5c45a48b (diff) | |
download | archiva-ef66c2d19fdb5e17eb23a1bc2a669211c67f270e.tar.gz archiva-ef66c2d19fdb5e17eb23a1bc2a669211c67f270e.zip |
use a new bean rather than a lot of params to ease futur enhancements
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1401289 13f79535-47bb-0310-9956-ffa450edef68
8 files changed, 265 insertions, 198 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java index 546593123..23dee2f46 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java @@ -34,6 +34,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException; @@ -54,11 +55,9 @@ import java.util.List; /** * Take an artifact off of disk and put it into the metadata repository. - * - * */ -@Service( "knownRepositoryContentConsumer#create-archiva-metadata" ) -@Scope( "prototype" ) +@Service ("knownRepositoryContentConsumer#create-archiva-metadata") +@Scope ("prototype") public class ArchivaMetadataCreationConsumer extends AbstractMonitoredConsumer implements KnownRepositoryContentConsumer, RegistryListener @@ -98,7 +97,7 @@ public class ArchivaMetadataCreationConsumer * factory. */ @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private RepositoryStorage repositoryStorage; private static final Logger log = LoggerFactory.getLogger( ArchivaMetadataCreationConsumer.class ); @@ -170,13 +169,16 @@ public class ArchivaMetadataCreationConsumer ProjectVersionMetadata versionMetadata = null; try { - versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId, artifact.getNamespace(), - artifact.getProject(), projectVersion ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( repoId ).namespace( artifact.getNamespace() ).projectId( + artifact.getProject() ).projectVersion( projectVersion ); + versionMetadata = repositoryStorage.readProjectVersionMetadata( readMetadataRequest ); createVersionMetadata = true; } catch ( RepositoryStorageMetadataNotFoundException e ) { - log.warn( "Missing or invalid POM for artifact:{} (repository:{}); creating empty metadata" , path, repoId ); + log.warn( "Missing or invalid POM for artifact:{} (repository:{}); creating empty metadata", path, + repoId ); versionMetadata = new ProjectVersionMetadata(); versionMetadata.setId( projectVersion ); @@ -185,7 +187,8 @@ public class ArchivaMetadataCreationConsumer } catch ( RepositoryStorageMetadataInvalidException e ) { - log.warn( "Error occurred resolving POM for artifact:{} (repository:{}); message: {}" , new Object[] { path, repoId, e.getMessage() } ); + log.warn( "Error occurred resolving POM for artifact:{} (repository:{}); message: {}", + new Object[]{ path, repoId, e.getMessage() } ); } // read the metadata and update it if it is newer or doesn't exist @@ -202,12 +205,16 @@ public class ArchivaMetadataCreationConsumer } catch ( MetadataRepositoryException e ) { - log.warn( "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), new Object[] { path, repoId, e.getMessage() }, e ); + log.warn( + "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), + new Object[]{ path, repoId, e.getMessage() }, e ); repositorySession.revert(); } catch ( RepositoryStorageRuntimeException e ) { - log.warn( "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), new Object[] { path, repoId, e.getMessage() }, e ); + log.warn( + "Error occurred persisting metadata for artifact:{} (repository:{}); message: {}" + e.getMessage(), + new Object[]{ path, repoId, e.getMessage() }, e ); repositorySession.revert(); } finally diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index 014f755e7..013cc4e7c 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -24,6 +24,7 @@ import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.archiva.metadata.repository.filter.ExcludesFilter; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException; @@ -56,7 +57,7 @@ import java.util.List; * unknowingly by the caller. * <p/> */ -@Service( "metadataResolver#default" ) +@Service ("metadataResolver#default") public class DefaultMetadataResolver implements MetadataResolver { @@ -72,7 +73,7 @@ public class DefaultMetadataResolver * appropriate methods to pass in the already determined repository configuration, for example, instead of the ID */ @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private RepositoryStorage repositoryStorage; /** @@ -98,7 +99,10 @@ public class DefaultMetadataResolver { try { - metadata = repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, projectVersion ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( repoId ).namespace( namespace ).projectId( + projectId ).projectVersion( projectVersion ); + metadata = repositoryStorage.readProjectVersionMetadata( readMetadataRequest ); log.debug( "Resolved project version metadata from storage: {}", metadata ); @@ -309,9 +313,11 @@ public class DefaultMetadataResolver { try { + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( repoId ).namespace( namespace ).projectId( + projectId ).projectVersion( projectVersion ); ProjectVersionMetadata versionMetadata = - repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, - projectVersion ); + repositoryStorage.readProjectVersionMetadata( readMetadataRequest ); for ( RepositoryListener listener : listeners ) { listener.addArtifact( session, repoId, namespace, projectId, versionMetadata ); @@ -365,8 +371,13 @@ public class DefaultMetadataResolver Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repoId, namespace, projectId, projectVersion ); ExcludesFilter<String> filter = new ExcludesFilter<String>( createArtifactIdList( artifacts ) ); + + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( repoId ).namespace( namespace ).projectId( projectId ).projectVersion( + projectVersion ).filter( filter ); + Collection<ArtifactMetadata> storageArtifacts = - repositoryStorage.readArtifactsMetadata( repoId, namespace, projectId, projectVersion, filter ); + repositoryStorage.readArtifactsMetadata( readMetadataRequest ); if ( storageArtifacts != null && !storageArtifacts.isEmpty() ) { diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java index e115812da..4921613a6 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java @@ -31,8 +31,7 @@ public interface RepositoryStorage { ProjectMetadata readProjectMetadata( String repoId, String namespace, String projectId ); - ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId, - String projectVersion ) + ProjectVersionMetadata readProjectVersionMetadata( ReadMetadataRequest readMetadataRequest ) throws RepositoryStorageMetadataInvalidException, RepositoryStorageMetadataNotFoundException, RepositoryStorageRuntimeException; @@ -48,8 +47,7 @@ public interface RepositoryStorage Collection<String> listProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter ) throws RepositoryStorageRuntimeException; - Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId, - String projectVersion, Filter<String> filter ) + Collection<ArtifactMetadata> readArtifactsMetadata( ReadMetadataRequest readMetadataRequest ) throws RepositoryStorageRuntimeException; // FIXME: reconsider this API, do we want to expose storage format in the form of a path? diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index 3eee39799..3476ca699 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -36,6 +36,7 @@ import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; @@ -91,7 +92,7 @@ import java.util.Map; * within the session in the context of a single managed repository's resolution needs. * <p/> */ -@Service( "repositoryStorage#maven2" ) +@Service ("repositoryStorage#maven2") public class Maven2RepositoryStorage implements RepositoryStorage { @@ -119,13 +120,13 @@ public class Maven2RepositoryStorage * */ @Inject - @Named( value = "repositoryPathTranslator#maven2" ) + @Named (value = "repositoryPathTranslator#maven2") private RepositoryPathTranslator pathTranslator; @Inject private WagonFactory wagonFactory; - private final static Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class ); + private static final Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class ); private static final String METADATA_FILENAME_START = "maven-metadata"; @@ -146,35 +147,39 @@ public class Maven2RepositoryStorage return null; } - public ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId, - String projectVersion ) + public ProjectVersionMetadata readProjectVersionMetadata( ReadMetadataRequest readMetadataRequest ) throws RepositoryStorageMetadataNotFoundException, RepositoryStorageMetadataInvalidException, RepositoryStorageRuntimeException { try { - ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId ); + ManagedRepository managedRepository = + managedRepositoryAdmin.getManagedRepository( readMetadataRequest.getRepoId() ); - String artifactVersion = projectVersion; - if ( VersionUtil.isSnapshot( projectVersion ) ) // skygo trying to improve speed by honoring managed configuration MRM-1658 + String artifactVersion = readMetadataRequest.getProjectVersion(); + if ( VersionUtil.isSnapshot( + readMetadataRequest.getProjectVersion() ) ) // skygo trying to improve speed by honoring managed configuration MRM-1658 { if ( managedRepository.isReleases() && !managedRepository.isSnapshots() ) { - throw new RepositoryStorageRuntimeException("lookforsnaponreleaseonly", "managed repo is configured for release only"); + throw new RepositoryStorageRuntimeException( "lookforsnaponreleaseonly", + "managed repo is configured for release only" ); } - } - else + } + else { if ( !managedRepository.isReleases() && managedRepository.isSnapshots() ) { - throw new RepositoryStorageRuntimeException("lookforsreleaseonsneponly", "managed repo is configured for snapshot only"); + throw new RepositoryStorageRuntimeException( "lookforsreleaseonsneponly", + "managed repo is configured for snapshot only" ); } } File basedir = new File( managedRepository.getLocation() ); - if ( VersionUtil.isSnapshot( projectVersion ) ) + if ( VersionUtil.isSnapshot( readMetadataRequest.getProjectVersion() ) ) { - File metadataFile = - pathTranslator.toFile( basedir, namespace, projectId, projectVersion, METADATA_FILENAME ); + File metadataFile = pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(), + readMetadataRequest.getProjectId(), + readMetadataRequest.getProjectVersion(), METADATA_FILENAME ); try { ArchivaRepositoryMetadata metadata = MavenMetadataReader.read( metadataFile ); @@ -197,8 +202,10 @@ public class Maven2RepositoryStorage } // TODO: won't work well with some other layouts, might need to convert artifact parts to ID by path translator - String id = projectId + "-" + artifactVersion + ".pom"; - File file = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, id ); + String id = readMetadataRequest.getProjectId() + "-" + artifactVersion + ".pom"; + File file = + pathTranslator.toFile( basedir, readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(), + readMetadataRequest.getProjectVersion(), id ); if ( !file.exists() ) { @@ -213,7 +220,7 @@ public class Maven2RepositoryStorage Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>(); Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap(); - List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repoId ); + List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( readMetadataRequest.getRepoId() ); if ( proxyConnectors != null ) { for ( ProxyConnector proxyConnector : proxyConnectors ) @@ -273,11 +280,11 @@ public class Maven2RepositoryStorage "Using defaults for project version metadata.." ); ProjectVersionMetadata metadata = new ProjectVersionMetadata(); - metadata.setId( projectVersion ); + metadata.setId( readMetadataRequest.getProjectVersion() ); MavenProjectFacet facet = new MavenProjectFacet(); - facet.setGroupId( namespace ); - facet.setArtifactId( projectId ); + facet.setGroupId( readMetadataRequest.getNamespace() ); + facet.setArtifactId( readMetadataRequest.getProjectId() ); facet.setPackaging( "jar" ); metadata.addFacet( facet ); @@ -286,13 +293,13 @@ public class Maven2RepositoryStorage ? problem.getMessage() : problem.getException().getMessage() ); RepositoryProblemFacet repoProblemFacet = new RepositoryProblemFacet(); - repoProblemFacet.setRepositoryId( repoId ); - repoProblemFacet.setId( repoId ); + repoProblemFacet.setRepositoryId( readMetadataRequest.getRepoId() ); + repoProblemFacet.setId( readMetadataRequest.getRepoId() ); repoProblemFacet.setMessage( errMsg ); repoProblemFacet.setProblem( errMsg ); - repoProblemFacet.setProject( projectId ); - repoProblemFacet.setVersion( projectVersion ); - repoProblemFacet.setNamespace( namespace ); + repoProblemFacet.setProject( readMetadataRequest.getProjectId() ); + repoProblemFacet.setVersion( readMetadataRequest.getProjectVersion() ); + repoProblemFacet.setNamespace( readMetadataRequest.getNamespace() ); metadata.addFacet( repoProblemFacet ); @@ -304,9 +311,9 @@ public class Maven2RepositoryStorage } // Check if the POM is in the correct location - boolean correctGroupId = namespace.equals( model.getGroupId() ); - boolean correctArtifactId = projectId.equals( model.getArtifactId() ); - boolean correctVersion = projectVersion.equals( model.getVersion() ); + boolean correctGroupId = readMetadataRequest.getNamespace().equals( model.getGroupId() ); + boolean correctArtifactId = readMetadataRequest.getProjectId().equals( model.getArtifactId() ); + boolean correctVersion = readMetadataRequest.getProjectVersion().equals( model.getVersion() ); if ( !correctGroupId || !correctArtifactId || !correctVersion ) { StringBuilder message = new StringBuilder( "Incorrect POM coordinates in '" + file + "':" ); @@ -329,7 +336,7 @@ public class Maven2RepositoryStorage ProjectVersionMetadata metadata = new ProjectVersionMetadata(); metadata.setCiManagement( convertCiManagement( model.getCiManagement() ) ); metadata.setDescription( model.getDescription() ); - metadata.setId( projectVersion ); + metadata.setId( readMetadataRequest.getProjectVersion() ); metadata.setIssueManagement( convertIssueManagement( model.getIssueManagement() ) ); metadata.setLicenses( convertLicenses( model.getLicenses() ) ); metadata.setMailingLists( convertMailingLists( model.getMailingLists() ) ); @@ -561,21 +568,25 @@ public class Maven2RepositoryStorage return getSortedFiles( dir, filter ); } - public Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId, - String projectVersion, Filter<String> filter ) + public Collection<ArtifactMetadata> readArtifactsMetadata( ReadMetadataRequest readMetadataRequest ) throws RepositoryStorageRuntimeException { - File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion ); + File dir = pathTranslator.toFile( getRepositoryBasedir( readMetadataRequest.getRepoId() ), + readMetadataRequest.getNamespace(), readMetadataRequest.getProjectId(), + readMetadataRequest.getProjectVersion() ); // all files that are not metadata and not a checksum / signature are considered artifacts - File[] files = dir.listFiles( new ArtifactDirectoryFilter( filter ) ); + File[] files = dir.listFiles( new ArtifactDirectoryFilter( readMetadataRequest.getFilter() ) ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(); if ( files != null ) { for ( File file : files ) { - ArtifactMetadata metadata = getArtifactFromFile( repoId, namespace, projectId, projectVersion, file ); + ArtifactMetadata metadata = + getArtifactFromFile( readMetadataRequest.getRepoId(), readMetadataRequest.getNamespace(), + readMetadataRequest.getProjectId(), readMetadataRequest.getProjectVersion(), + file ); artifacts.add( metadata ); } } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java index 0c8377c76..4c1fb4397 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverMRM1411RepoGroupTest.java @@ -19,15 +19,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import javax.inject.Inject; -import javax.inject.Named; import junit.framework.TestCase; -import org.apache.archiva.admin.model.beans.RepositoryGroup; import org.apache.archiva.common.utils.FileUtil; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; @@ -42,7 +34,7 @@ import org.apache.archiva.metadata.model.MailingList; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.Filter; -import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.proxy.common.WagonFactory; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.io.FileUtils; @@ -50,25 +42,34 @@ import org.apache.maven.wagon.Wagon; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; + +import javax.inject.Inject; +import javax.inject.Named; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.springframework.test.context.ContextConfiguration; -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) +@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest extends TestCase { private static final Filter<String> ALL = new AllFilter<String>(); @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named ( value = "repositoryStorage#maven2" ) private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; - + private static final String TEST_SNAP_REPO_ID = "tests"; - + private static final String TEST_REPO_GROUP_ID = "testrg"; private static final String TEST_REMOTE_REPO_ID = "central"; @@ -95,11 +96,11 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest private WagonFactory wagonFactory; ManagedRepositoryConfiguration testRepo; - + ManagedRepositoryConfiguration testRepoS; - + Configuration c; - + @Before @Override public void setUp() @@ -108,21 +109,21 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest super.setUp(); c = new Configuration(); - + testRepo = new ManagedRepositoryConfiguration(); testRepo.setId( TEST_REPO_ID ); testRepo.setLocation( new File( "target/test-repository" ).getAbsolutePath() ); testRepo.setReleases( true ); testRepo.setSnapshots( false ); c.addManagedRepository( testRepo ); - + testRepoS = new ManagedRepositoryConfiguration(); testRepoS.setId( TEST_SNAP_REPO_ID ); testRepoS.setLocation( new File( "target/test-repositorys" ).getAbsolutePath() ); testRepoS.setReleases( false ); testRepoS.setSnapshots( true ); c.addManagedRepository( testRepoS ); - + RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration(); testRemoteRepo.setId( TEST_REMOTE_REPO_ID ); testRemoteRepo.setLayout( "default" ); @@ -142,24 +143,24 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest proxyConnectors.setTargetRepoId( TEST_REMOTE_REPO_ID ); proxyConnectors.setDisabled( false ); c.addProxyConnector( proxyConnectors ); - + List<String> repos = new ArrayList<String>(); repos.add( TEST_REPO_ID ); repos.add( TEST_SNAP_REPO_ID ); - RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration( ); + RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration(); repoGroup.setId( TEST_REPO_GROUP_ID ); repoGroup.setRepositories( repos ); c.addRepositoryGroup( repoGroup ); - + configuration.save( c ); - assertFalse ( c.getManagedRepositories().get( 0 ).isSnapshots() ); - assertTrue ( c.getManagedRepositories().get( 0 ).isReleases() ); - - assertTrue ( c.getManagedRepositories().get( 1 ).isSnapshots() ); - assertFalse ( c.getManagedRepositories().get( 1 ).isReleases() ); - + assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() ); + assertTrue( c.getManagedRepositories().get( 0 ).isReleases() ); + + assertTrue( c.getManagedRepositories().get( 1 ).isSnapshots() ); + assertFalse( c.getManagedRepositories().get( 1 ).isReleases() ); + wagonFactory = mock( WagonFactory.class ); storage.setWagonFactory( wagonFactory ); @@ -176,8 +177,10 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a" ); - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "test-artifact-module-a" ).projectVersion( "1.0" ); + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); @@ -226,8 +229,10 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a" ); - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "test-artifact-module-a" ).projectVersion( "1.0" ); + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); assertEquals( "1.0", metadata.getId() ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); @@ -251,8 +256,11 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a" ); - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-parent", "1.1" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "missing-parent" ).projectVersion( "1.1" ); + + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); assertEquals( "1.1", metadata.getId() ); @@ -278,9 +286,12 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" ); copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-root", "target/test-repositorys/com/example/test/test-snapshot-artifact-root" ); - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_SNAP_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a", - "1.1-SNAPSHOT" ); + + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().namespace( TEST_SNAP_REPO_ID ).namespace( "com.example.test" ).projectId( + "test-snapshot-artifact-module-a" ).projectVersion( "1.1-SNAPSHOT" ); + + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); @@ -319,9 +330,10 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest copyTestArtifactWithParent( "target/test-classes/com/example/test/test-snapshot-artifact-module-a", "target/test-repositorys/com/example/test/test-snapshot-artifact-module-a" ); - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_SNAP_REPO_ID, "com.example.test", "test-snapshot-artifact-module-a", - "1.1-SNAPSHOT" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_SNAP_REPO_ID ).namespace( "com.example.test" ).projectId( + "test-snapshot-artifact-module-a" ).projectVersion( "1.1-SNAPSHOT" ); + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); @@ -353,7 +365,7 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest deleteTestArtifactWithParent( paths ); } - + @Test public void testGetProjectVersionMetadataWithParentSnapshotVersionAndSnapNotAllowed2() throws Exception @@ -361,9 +373,11 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest copyTestArtifactWithParent( "target/test-classes/com/example/test/test-artifact-module-b", "target/test-repository/com/example/test/test-artifact-module-b" ); - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "test-artifact-module-b", - "1.0" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "test-artifact-module-b" ).projectVersion( "1.0" ); + + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); @@ -413,7 +427,7 @@ public class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest assertNull( dependency.getClassifier() ); assertNull( dependency.getSystemPath() ); } - + private void assertArtifact( ArtifactMetadata artifact, String id, int size, String sha1, String md5 ) { assertEquals( id, artifact.getId() ); diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java index 5f211227a..a0965fcc4 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedReleaseTest.java @@ -19,12 +19,11 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import javax.inject.Inject; -import javax.inject.Named; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException; import org.apache.archiva.proxy.common.WagonFactory; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; @@ -33,16 +32,19 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; +import javax.inject.Inject; +import javax.inject.Named; + -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) +@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class Maven2RepositoryMetadataResolverManagedReleaseTest extends Maven2RepositoryMetadataResolverTest { private static final Filter<String> ALL = new AllFilter<String>(); @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named ( value = "repositoryStorage#maven2" ) private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -79,57 +81,65 @@ public class Maven2RepositoryMetadataResolverManagedReleaseTest testRepo.setReleases( true ); testRepo.setSnapshots( false ); - + configuration.save( c ); - assertFalse ( c.getManagedRepositories().get( 0 ).isSnapshots() ); - assertTrue ( c.getManagedRepositories().get( 0 ).isReleases() ); - + assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() ); + assertTrue( c.getManagedRepositories().get( 0 ).isReleases() ); + } @Test @Override - public void testModelWithJdkProfileActivation() + public void testModelWithJdkProfileActivation() throws Exception { // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot - - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.maven", "maven-archiver", "2.4.1" ); - } - - @Test( expected = RepositoryStorageRuntimeException.class) + + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId( + "maven-archiver" ).projectVersion( "2.4.1" ); + + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); + } + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata() throws Exception - { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT" ); + { + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "missing-metadata" ).projectVersion( "1.0-SNAPSHOT" ); + storage.readProjectVersionMetadata( readMetadataRequest ); } - - @Test( expected = RepositoryStorageRuntimeException.class) + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata() throws Exception { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "malformed-metadata", - "1.0-SNAPSHOT" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectVersion( + "malformed-metadata" ).projectVersion( "1.0-SNAPSHOT" ); + storage.readProjectVersionMetadata( readMetadataRequest ); } - - @Test( expected = RepositoryStorageRuntimeException.class) + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForTimestampedSnapshot() throws Exception { super.testGetProjectVersionMetadataForTimestampedSnapshot(); } - - - @Test( expected = RepositoryStorageRuntimeException.class) + + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata() throws Exception { super.testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata(); } - + } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java index ea51003ee..77d547353 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverManagedSnapshotTest.java @@ -19,14 +19,11 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import javax.inject.Inject; -import javax.inject.Named; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.Filter; -import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; -import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.junit.Before; @@ -34,16 +31,19 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; +import javax.inject.Inject; +import javax.inject.Named; + -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) +@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) public class Maven2RepositoryMetadataResolverManagedSnapshotTest extends Maven2RepositoryMetadataResolverTest { private static final Filter<String> ALL = new AllFilter<String>(); @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named ( value = "repositoryStorage#maven2" ) private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -79,54 +79,66 @@ public class Maven2RepositoryMetadataResolverManagedSnapshotTest testRepo.setReleases( false ); testRepo.setSnapshots( true ); - + configuration.save( c ); - assertTrue ( c.getManagedRepositories().get( 0 ).isSnapshots() ); - assertFalse ( c.getManagedRepositories().get( 0 ).isReleases() ); + assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() ); + assertFalse( c.getManagedRepositories().get( 0 ).isReleases() ); } - @Test( expected = RepositoryStorageRuntimeException.class) + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override - public void testModelWithJdkProfileActivation() + public void testModelWithJdkProfileActivation() throws Exception { // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot - - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.maven", "maven-archiver", "2.4.1" ); - } - - @Test( expected = RepositoryStorageRuntimeException.class ) + + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId( + "maven-archiver" ).projectVersion( "2.4.1" ); + + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); + } + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForMislocatedPom() - throws Exception + throws Exception { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ); - + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "mislocated-pom" ).projectVersion( "1.0" ); + storage.readProjectVersionMetadata( readMetadataRequest ); + } - + @Test @Override public void testGetProjectVersionMetadata() throws Exception { - // super test is on release - } - - @Test( expected = RepositoryStorageRuntimeException.class ) + // super test is on release + } + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForInvalidPom() throws Exception { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "invalid-pom" ).projectVersion( "1.0" ); + storage.readProjectVersionMetadata( readMetadataRequest ); } - - @Test( expected = RepositoryStorageRuntimeException.class ) + + @Test ( expected = RepositoryStorageRuntimeException.class ) @Override public void testGetProjectVersionMetadataForMissingPom() throws Exception { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId( + "missing-pom" ).projectVersion( "1.0" ); + storage.readProjectVersionMetadata( readMetadataRequest ); } } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index c9e047e50..65d15906d 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -19,6 +19,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ +import junit.framework.TestCase; import org.apache.archiva.common.utils.FileUtil; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; @@ -33,9 +34,11 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.ExcludesFilter; import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException; import org.apache.archiva.proxy.common.WagonFactory; +import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.io.FileUtils; import org.apache.maven.wagon.Wagon; import org.junit.Before; @@ -53,21 +56,19 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; -import junit.framework.TestCase; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } ) +@RunWith (ArchivaSpringJUnit4ClassRunner.class) +@ContextConfiguration (locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" }) public class Maven2RepositoryMetadataResolverTest extends TestCase { private static final Filter<String> ALL = new AllFilter<String>(); @Inject - @Named( value = "repositoryStorage#maven2" ) + @Named (value = "repositoryStorage#maven2") private Maven2RepositoryStorage storage; private static final String TEST_REPO_ID = "test"; @@ -96,9 +97,9 @@ public class Maven2RepositoryMetadataResolverTest private WagonFactory wagonFactory; ManagedRepositoryConfiguration testRepo; - + Configuration c; - + @Before @Override public void setUp() @@ -113,7 +114,6 @@ public class Maven2RepositoryMetadataResolverTest testRepo.setReleases( true ); testRepo.setSnapshots( true ); c.addManagedRepository( testRepo ); - RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration(); testRemoteRepo.setId( TEST_REMOTE_REPO_ID ); @@ -131,9 +131,9 @@ public class Maven2RepositoryMetadataResolverTest configuration.save( c ); - assertTrue ( c.getManagedRepositories().get( 0 ).isSnapshots() ); - assertTrue ( c.getManagedRepositories().get( 0 ).isReleases() ); - + assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() ); + assertTrue( c.getManagedRepositories().get( 0 ).isReleases() ); + wagonFactory = mock( WagonFactory.class ); storage.setWagonFactory( wagonFactory ); @@ -146,9 +146,10 @@ public class Maven2RepositoryMetadataResolverTest public void testModelWithJdkProfileActivation() throws Exception { - - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.maven", "maven-archiver", "2.4.1" ); + ReadMetadataRequest readMetadataRequest = + new ReadMetadataRequest().repoId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId( + "maven-archiver" ).projectVersion( "2.4.1" ); + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); } @@ -156,8 +157,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadata() throws Exception { - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1" ); + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1" ) ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() ); @@ -211,8 +212,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadata() throws Exception { - Collection<ArtifactMetadata> springArtifacts = - storage.readArtifactsMetadata( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ); + Collection<ArtifactMetadata> springArtifacts = storage.readArtifactsMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( springArtifacts ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -253,8 +254,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadataSnapshots() throws Exception { - Collection<ArtifactMetadata> testArtifacts = - storage.readArtifactsMetadata( TEST_REPO_ID, "com.example.test", "test-artifact", "1.0-SNAPSHOT", ALL ); + Collection<ArtifactMetadata> testArtifacts = storage.readArtifactsMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "test-artifact", "1.0-SNAPSHOT", ALL ) ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( testArtifacts ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -336,8 +337,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadataForTimestampedSnapshot() throws Exception { - ProjectVersionMetadata metadata = - storage.readProjectVersionMetadata( TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT" ); + ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT" ) ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "pom", facet.getPackaging() ); assertEquals( "http://www.apache.org/", metadata.getUrl() ); @@ -376,7 +377,8 @@ public class Maven2RepositoryMetadataResolverTest { try { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT" ); + storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT" ) ); fail( "Should not be found" ); } catch ( RepositoryStorageMetadataNotFoundException e ) @@ -391,8 +393,8 @@ public class Maven2RepositoryMetadataResolverTest { try { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "malformed-metadata", - "1.0-SNAPSHOT" ); + storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "malformed-metadata", "1.0-SNAPSHOT" ) ); fail( "Should not be found" ); } catch ( RepositoryStorageMetadataNotFoundException e ) @@ -407,8 +409,8 @@ public class Maven2RepositoryMetadataResolverTest { try { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "incomplete-metadata", - "1.0-SNAPSHOT" ); + storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "incomplete-metadata", "1.0-SNAPSHOT" ) ); fail( "Should not be found" ); } catch ( RepositoryStorageMetadataNotFoundException e ) @@ -423,7 +425,8 @@ public class Maven2RepositoryMetadataResolverTest { try { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ); + storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ) ); fail( "Should have received an exception due to invalid POM" ); } catch ( RepositoryStorageMetadataInvalidException e ) @@ -438,7 +441,8 @@ public class Maven2RepositoryMetadataResolverTest { try { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ); + storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ) ); fail( "Should have received an exception due to mislocated POM" ); } catch ( RepositoryStorageMetadataInvalidException e ) @@ -453,7 +457,8 @@ public class Maven2RepositoryMetadataResolverTest { try { - storage.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" ); + storage.readProjectVersionMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" ) ); fail( "Should not be found" ); } catch ( RepositoryStorageMetadataNotFoundException e ) @@ -551,8 +556,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifacts() throws Exception { - List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( - storage.readArtifactsMetadata( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) ); + List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( storage.readArtifactsMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) ) ); assertEquals( 3, artifacts.size() ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -574,8 +579,8 @@ public class Maven2RepositoryMetadataResolverTest { ExcludesFilter<String> filter = new ExcludesFilter<String>( Collections.singletonList( "plexus-spring-1.2.pom" ) ); - List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( - storage.readArtifactsMetadata( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) ); + List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( storage.readArtifactsMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) ) ); assertEquals( 2, artifacts.size() ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -593,9 +598,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactsTimestampedSnapshots() throws Exception { - List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( - storage.readArtifactsMetadata( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT", - ALL ) ); + List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( storage.readArtifactsMetadata( + new ReadMetadataRequest( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT", ALL ) ) ); assertEquals( 1, artifacts.size() ); ArtifactMetadata artifact = artifacts.get( 0 ); |