mirror of https://github.com/apache/maven.git
added resolveArtifact() API tests
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1403192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b8279cc7e
commit
e32cf81b6c
|
@ -23,6 +23,8 @@ import org.sonatype.aether.artifact.Artifact;
|
|||
import org.sonatype.aether.collection.CollectRequest;
|
||||
import org.sonatype.aether.collection.CollectResult;
|
||||
import org.sonatype.aether.graph.Dependency;
|
||||
import org.sonatype.aether.resolution.ArtifactRequest;
|
||||
import org.sonatype.aether.resolution.ArtifactResult;
|
||||
import org.sonatype.aether.util.artifact.DefaultArtifact;
|
||||
|
||||
public class RepositorySystemTest
|
||||
|
@ -31,8 +33,8 @@ public class RepositorySystemTest
|
|||
public void testCollectDependencies()
|
||||
throws Exception
|
||||
{
|
||||
String artifactCoords = "ut.simple:artifact:1.0"; // TODO test extension:classifier
|
||||
Artifact artifact = new DefaultArtifact( artifactCoords );
|
||||
Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
|
||||
// notice: extension and classifier not really used in this test...
|
||||
|
||||
CollectRequest collectRequest = new CollectRequest();
|
||||
collectRequest.setRoot( new Dependency( artifact, null ) );
|
||||
|
@ -79,4 +81,39 @@ public class RepositorySystemTest
|
|||
assertEquals( "false", depArtifact.getProperty( "includesDependencies", null ) );
|
||||
assertEquals( 4, depArtifact.getProperties().size() );
|
||||
}
|
||||
|
||||
public void testResolveArtifact()
|
||||
throws Exception
|
||||
{
|
||||
Artifact artifact = new DefaultArtifact( "ut.simple:artifact:1.0" );
|
||||
|
||||
ArtifactRequest artifactRequest = new ArtifactRequest();
|
||||
artifactRequest.setArtifact( artifact );
|
||||
artifactRequest.addRepository( newTestRepository() );
|
||||
|
||||
ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
|
||||
assertFalse( artifactResult.isMissing() );
|
||||
assertTrue( artifactResult.isResolved() );
|
||||
artifact = artifactResult.getArtifact();
|
||||
assertNotNull( artifact.getFile() );
|
||||
assertEquals( "artifact-1.0.jar", artifact.getFile().getName() );
|
||||
|
||||
artifact = new DefaultArtifact( "ut.simple:artifact:zip:1.0" );
|
||||
artifactRequest.setArtifact( artifact );
|
||||
artifactResult = system.resolveArtifact( session, artifactRequest );
|
||||
assertFalse( artifactResult.isMissing() );
|
||||
assertTrue( artifactResult.isResolved() );
|
||||
artifact = artifactResult.getArtifact();
|
||||
assertNotNull( artifact.getFile() );
|
||||
assertEquals( "artifact-1.0.zip", artifact.getFile().getName() );
|
||||
|
||||
artifact = new DefaultArtifact( "ut.simple:artifact:zip:classifier:1.0" );
|
||||
artifactRequest.setArtifact( artifact );
|
||||
artifactResult = system.resolveArtifact( session, artifactRequest );
|
||||
assertFalse( artifactResult.isMissing() );
|
||||
assertTrue( artifactResult.isResolved() );
|
||||
artifact = artifactResult.getArtifact();
|
||||
assertNotNull( artifact.getFile() );
|
||||
assertEquals( "artifact-1.0-classifier.zip", artifact.getFile().getName() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue