From 1694da24700f2422db5c74b78a4a36e93c3beffe Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 23 Feb 2010 08:34:24 +0000 Subject: [PATCH] fixed sorting which is causing the test to fail in some platforms git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@915240 13f79535-47bb-0310-9956-ffa450edef68 --- .../file/FileMetadataRepositoryTest.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java index b3150cc86..8f48d484c 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java +++ b/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java @@ -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( - repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ) ); + List expected = Arrays.asList( artifact1, artifact2 ); + Collections.sort( expected, new ArtifactMetadataComparator() ); + + List actual = new ArrayList( + 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 + { + public final int compare ( ArtifactMetadata a, ArtifactMetadata b) + { + return ( (String) a.getProject() ).compareTo( (String) b.getProject() ); + } + } + private static class TestMetadataFacet implements MetadataFacet { -- 2.39.5