mirror of https://github.com/apache/maven.git
add artifact scope tests
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ebe7275bf
commit
158ab5e513
|
@ -109,6 +109,57 @@ public class DefaultArtifactCollectorTest
|
|||
res.getArtifacts() );
|
||||
}
|
||||
|
||||
public void testResolveCompileScopeOverTestScope()
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
ArtifactSpec b = a.addDependency( "b", "1.0" );
|
||||
ArtifactSpec c = a.addDependency( "c", "3.0", Artifact.SCOPE_TEST );
|
||||
|
||||
b.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE );
|
||||
|
||||
Artifact modifiedC = createArtifact( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
|
||||
|
||||
ArtifactResolutionResult res = collect( a );
|
||||
assertEquals( "Check artifact list",
|
||||
new HashSet( Arrays.asList( new Object[]{a.artifact, b.artifact, modifiedC} ) ),
|
||||
res.getArtifacts() );
|
||||
}
|
||||
|
||||
public void testResolveRuntimeScopeOverTestScope()
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
ArtifactSpec b = a.addDependency( "b", "1.0" );
|
||||
ArtifactSpec c = a.addDependency( "c", "3.0", Artifact.SCOPE_TEST );
|
||||
|
||||
b.addDependency( "c", "2.0", Artifact.SCOPE_RUNTIME );
|
||||
|
||||
Artifact modifiedC = createArtifact( "c", "3.0", Artifact.SCOPE_RUNTIME ).artifact;
|
||||
|
||||
ArtifactResolutionResult res = collect( a );
|
||||
assertEquals( "Check artifact list",
|
||||
new HashSet( Arrays.asList( new Object[]{a.artifact, b.artifact, modifiedC} ) ),
|
||||
res.getArtifacts() );
|
||||
}
|
||||
|
||||
public void testResolveCompileScopeOverRuntimeScope()
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
ArtifactSpec b = a.addDependency( "b", "1.0" );
|
||||
ArtifactSpec c = a.addDependency( "c", "3.0", Artifact.SCOPE_RUNTIME );
|
||||
|
||||
b.addDependency( "c", "2.0", Artifact.SCOPE_COMPILE );
|
||||
|
||||
Artifact modifiedC = createArtifact( "c", "3.0", Artifact.SCOPE_COMPILE ).artifact;
|
||||
|
||||
ArtifactResolutionResult res = collect( a );
|
||||
assertEquals( "Check artifact list",
|
||||
new HashSet( Arrays.asList( new Object[]{a.artifact, b.artifact, modifiedC} ) ),
|
||||
res.getArtifacts() );
|
||||
}
|
||||
|
||||
private ArtifactResolutionResult collect( ArtifactSpec a )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
|
@ -117,9 +168,14 @@ public class DefaultArtifactCollectorTest
|
|||
}
|
||||
|
||||
private ArtifactSpec createArtifact( String id, String version )
|
||||
{
|
||||
return createArtifact( id, version, null );
|
||||
}
|
||||
|
||||
private ArtifactSpec createArtifact( String id, String version, String scope )
|
||||
{
|
||||
ArtifactSpec spec = new ArtifactSpec();
|
||||
spec.artifact = artifactFactory.createArtifact( "test", id, version, null, "jar" );
|
||||
spec.artifact = artifactFactory.createArtifact( "test", id, version, scope, "jar" );
|
||||
source.artifacts.put( spec.artifact.getId(), spec );
|
||||
return spec;
|
||||
}
|
||||
|
@ -132,7 +188,12 @@ public class DefaultArtifactCollectorTest
|
|||
|
||||
public ArtifactSpec addDependency( String id, String version )
|
||||
{
|
||||
ArtifactSpec dep = createArtifact( id, version );
|
||||
return addDependency( id, version, null );
|
||||
}
|
||||
|
||||
public ArtifactSpec addDependency( String id, String version, String scope )
|
||||
{
|
||||
ArtifactSpec dep = createArtifact( id, version, scope );
|
||||
dependencies.add( dep.artifact );
|
||||
return dep;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue