Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2010-09-09 18:16:37 -0400
committerMatthias Sohn2010-09-09 18:16:37 -0400
commit06d14b39fa580600b4faf4b21b7cf4322f24d7de (patch)
treedb1d33e06861d009f549ccebbf752f19b0cd4bc0 /org.eclipse.egit.core.test
parent5f136001cacd2b336627cf16893fed2ef85e66d2 (diff)
downloadegit-06d14b39fa580600b4faf4b21b7cf4322f24d7de.tar.gz
egit-06d14b39fa580600b4faf4b21b7cf4322f24d7de.tar.xz
egit-06d14b39fa580600b4faf4b21b7cf4322f24d7de.zip
Sort roots by full path to ensure stable assertion results
GitResourceVariantTree uses a HashSet to store resource variants which doesn't guarantee stable sort order which may break the assertions in GitResourceVariantTreeTest.shouldReturnTwoRoots() [1]. To fix this we sort the roots before doing assertions. [1] http://dev.eclipse.org/mhonarc/lists/egit-dev/msg01497.html Change-Id: If92b0bb43bfb0a022df6fefb98b06b00ace03c35 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
index 3ca306c1b..a2b99f62a 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.Comparator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -119,10 +120,19 @@ public class GitResourceVariantTreeTest extends GitTestCase {
store);
// then
- assertEquals(2, grvt.roots().length);
- IResource actualProject = grvt.roots()[1];
+ IResource[] roots = grvt.roots();
+ // sort in order to be able to assert the project instances
+ Arrays.sort(roots, new Comparator<IResource>() {
+ public int compare(IResource r1, IResource r2) {
+ String path1 = r1.getFullPath().toString();
+ String path2 = r2.getFullPath().toString();
+ return path1.compareTo(path2);
+ }
+ });
+ assertEquals(2, roots.length);
+ IResource actualProject = roots[0];
assertEquals(this.project.project, actualProject);
- IResource actualProject1 = grvt.roots()[0];
+ IResource actualProject1 = roots[1];
assertEquals(secondIProject, actualProject1);
}

Back to the top