]> source.dussan.org Git - archiva.git/commitdiff
fixed sorting which is causing the test to fail in some platforms
authorMaria Odea B. Ching <oching@apache.org>
Tue, 23 Feb 2010 08:34:24 +0000 (08:34 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Tue, 23 Feb 2010 08:34:24 +0000 (08:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@915240 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java

index b3150cc8620c0f71cd8847bbdd6154ed365419dd..8f48d484c9ebf764e08a391c463db511dc76444d 100644 (file)
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -531,8 +532,14 @@ public class FileMetadataRepositoryTest
         artifact2.setProject( "project2" );
         repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, "project2", TEST_PROJECT_VERSION, artifact2 );
 
-        assertEquals( Arrays.asList( artifact1, artifact2 ), new ArrayList<ArtifactMetadata>(
-            repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ) );
+        List<ArtifactMetadata> expected = Arrays.asList( artifact1, artifact2 );
+        Collections.sort( expected, new ArtifactMetadataComparator() );
+        
+        List<ArtifactMetadata> actual = new ArrayList<ArtifactMetadata>(
+                        repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) );
+        Collections.sort( actual, new ArtifactMetadataComparator() );
+        
+        assertEquals( expected, actual );
 
         repository.deleteRepository( TEST_REPO_ID );
 
@@ -572,6 +579,14 @@ public class FileMetadataRepositoryTest
         return artifact;
     }
 
+    private class ArtifactMetadataComparator implements Comparator<ArtifactMetadata>
+    {
+        public final int compare ( ArtifactMetadata a, ArtifactMetadata b)
+        {            
+            return ( (String) a.getProject() ).compareTo( (String) b.getProject() );
+        } 
+    }
+    
     private static class TestMetadataFacet
         implements MetadataFacet
     {