make test case portable

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@385958 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-03-15 03:15:15 +00:00
parent c2aa05ab96
commit ab1bc02dec
1 changed files with 39 additions and 24 deletions

View File

@ -26,6 +26,8 @@ import org.codehaus.plexus.PlexusTestCase;
import java.io.File; import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -359,34 +361,47 @@ public class DefaultArtifactDiscovererTest
public void testStandalonePoms() public void testStandalonePoms()
{ {
List artifacts = discoverer.discoverStandalonePoms( repository, null, false ); List models = discoverer.discoverStandalonePoms( repository, null, false );
assertEquals( 4, artifacts.size() ); assertEquals( 4, models.size() );
Iterator itr = artifacts.iterator();
//Artifact artifact = (Artifact) itr.next(); // Define order we expect
Collections.sort( models, new Comparator()
{
public int compare( Object o1, Object o2 )
{
Model m1 = (Model) o1;
Model m2 = (Model) o2;
int result = m1.getGroupId().compareTo( m2.getGroupId() );
if ( result == 0 )
{
result = m1.getArtifactId().compareTo( m2.getArtifactId() );
}
if ( result == 0 )
{
result = m1.getVersion().compareTo( m2.getVersion() );
}
return result;
}
} );
Iterator itr = models.iterator();
Model model = (Model) itr.next(); Model model = (Model) itr.next();
Artifact artifact = assertEquals( "org.apache.maven", model.getGroupId() );
createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() ); assertEquals( "B", model.getArtifactId() );
assertEquals( "org.apache.maven", artifact.getGroupId() ); assertEquals( "1.0", model.getVersion() );
assertEquals( "B", artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
model = (Model) itr.next(); model = (Model) itr.next();
artifact = assertEquals( "org.apache.maven", model.getGroupId() );
createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() ); assertEquals( "B", model.getArtifactId() );
assertEquals( "org.apache.maven", artifact.getGroupId() ); assertEquals( "2.0", model.getVersion() );
assertEquals( "B", artifact.getArtifactId() );
assertEquals( "2.0", artifact.getVersion() );
model = (Model) itr.next(); model = (Model) itr.next();
artifact = assertEquals( "org.apache.maven", model.getGroupId() );
createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() ); assertEquals( "discovery", model.getArtifactId() );
assertEquals( "org.apache.maven", artifact.getGroupId() ); assertEquals( "1.0", model.getVersion() );
assertEquals( "discovery", artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
model = (Model) itr.next(); model = (Model) itr.next();
artifact = assertEquals( "org.apache.testgroup", model.getGroupId() );
createArtifact( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging() ); assertEquals( "discovery", model.getArtifactId() );
assertEquals( "org.apache.testgroup", artifact.getGroupId() ); assertEquals( "1.0", model.getVersion() );
assertEquals( "discovery", artifact.getArtifactId() );
assertEquals( "1.0", artifact.getVersion() );
} }
private Artifact createArtifact( String groupId, String artifactId, String version ) private Artifact createArtifact( String groupId, String artifactId, String version )