mirror of https://github.com/apache/maven.git
o we can use the test metadata source that will be injected.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@776500 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3ec487cdbf
commit
03aef5b15b
|
@ -63,10 +63,12 @@ public class ArtifactResolverTest
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
artifactFactory = null;
|
||||
projectArtifact = null;
|
||||
super.tearDown();
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
artifactFactory = null;
|
||||
projectArtifact = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,59 +111,7 @@ public class ArtifactResolverTest
|
|||
|
||||
Artifact h = createLocalArtifact( "h", "1.0" );
|
||||
|
||||
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
||||
{
|
||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
Set dependencies = new HashSet();
|
||||
|
||||
if ( "g".equals( artifact.getArtifactId() ) )
|
||||
{
|
||||
Artifact a = null;
|
||||
try
|
||||
{
|
||||
a = createArtifact( "org.apache.maven", "h", "1.0", "jar" );
|
||||
dependencies.add( a );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a );
|
||||
}
|
||||
}
|
||||
|
||||
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
|
||||
Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
|
||||
}
|
||||
|
||||
public Artifact retrieveRelocatedArtifact( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifact;
|
||||
}
|
||||
};
|
||||
|
||||
ArtifactResolutionResult result =
|
||||
artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), mds );
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null );
|
||||
|
||||
assertEquals( 3, result.getArtifacts().size() );
|
||||
|
||||
|
@ -183,60 +133,7 @@ public class ArtifactResolverTest
|
|||
Artifact j = createRemoteArtifact( "j", "1.0-SNAPSHOT" );
|
||||
deleteLocalArtifact( j );
|
||||
|
||||
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
||||
{
|
||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
Set dependencies = new HashSet();
|
||||
|
||||
if ( "i".equals( artifact.getArtifactId() ) )
|
||||
{
|
||||
Artifact a = null;
|
||||
try
|
||||
{
|
||||
a = createArtifact( "org.apache.maven", "j", "1.0-SNAPSHOT", "jar" );
|
||||
dependencies.add( a );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Error retrieving metadata", e, a );
|
||||
}
|
||||
}
|
||||
|
||||
return new ResolutionGroup( artifact, dependencies, remoteRepositories );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
|
||||
}
|
||||
|
||||
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
|
||||
Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactRepository remoteRepository )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
throw new UnsupportedOperationException( "Cannot get available versions in this test case" );
|
||||
}
|
||||
|
||||
public Artifact retrieveRelocatedArtifact( Artifact artifact,
|
||||
ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
return artifact;
|
||||
}
|
||||
};
|
||||
|
||||
ArtifactResolutionResult result =
|
||||
artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(),
|
||||
localRepository(), mds );
|
||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), null );
|
||||
|
||||
assertEquals( 3, result.getArtifacts().size() );
|
||||
|
||||
|
|
Loading…
Reference in New Issue