Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2017-01-27 20:38:26 +0000
committerStefan Xenos2017-02-08 20:09:25 +0000
commit5cde01389ab7e39b3cb4bbb68b3d8e2ecb2d3ebd (patch)
tree1da9a4b2600839b097f71aba87f4dcb799e8fd70
parent20e61d9a98736e0ada5d75598028f5ca69ba6de8 (diff)
downloadrt.equinox.p2-5cde01389ab7e39b3cb4bbb68b3d8e2ecb2d3ebd.tar.gz
rt.equinox.p2-5cde01389ab7e39b3cb4bbb68b3d8e2ecb2d3ebd.tar.xz
rt.equinox.p2-5cde01389ab7e39b3cb4bbb68b3d8e2ecb2d3ebd.zip
Assert that two object arrays are equal with JUnit's assertArrayEquals(Object[], Object[])
This provides a more clear error message for both cases when array lengths are different or they contain different elements: java.lang.AssertionError: array lengths differed, expected.length=0 actual.length=1 at org.junit.Assert.fail(Assert.java:88) at org.junit.internal.ComparisonCriteria.assertArraysAreSameLength(ComparisonCriteria.java:76) at org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:37) at org.junit.Assert.internalArrayEquals(Assert.java:532) at org.junit.Assert.assertArrayEquals(Assert.java:283) at org.junit.Assert.assertArrayEquals(Assert.java:298) arrays first differed at element [1]; expected:<[1]> but was:<[2]> at org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:55) at org.junit.Assert.internalArrayEquals(Assert.java:532) at org.junit.Assert.assertArrayEquals(Assert.java:283) at org.junit.Assert.assertArrayEquals(Assert.java:298) Change-Id: I468b376d696445c1aaae920b9b2b71c0813b09ca Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SiteIndexFileTest.java39
1 files changed, 16 insertions, 23 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SiteIndexFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SiteIndexFileTest.java
index 61c79eec8..3272a411a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SiteIndexFileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SiteIndexFileTest.java
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata.repository;
+import static org.junit.Assert.assertArrayEquals;
+
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
@@ -42,13 +44,6 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
}
}
- private void assertArrayOrder(String[] expected, String[] actual) {
- assertEquals(expected.length, actual.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals(expected[i], actual[i]);
- }
- }
-
/*
* Tests that the sort method works in a simple case
*/
@@ -56,7 +51,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first", "second", "third"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), null);
- assertArrayOrder(new String[] {"first", "second", "third"}, suffixes);
+ assertArrayEquals(new String[] {"first", "second", "third"}, suffixes);
}
/*
@@ -66,7 +61,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first", "second", "third"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"first", "second", "third"});
- assertArrayOrder(new String[] {"first", "second", "third"}, suffixes);
+ assertArrayEquals(new String[] {"first", "second", "third"}, suffixes);
}
/*
@@ -76,7 +71,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"first", "second", "third"});
- assertArrayOrder(new String[] {"first"}, suffixes);
+ assertArrayEquals(new String[] {"first"}, suffixes);
}
/*
@@ -86,7 +81,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first", "second", "third"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"first"});
- assertArrayOrder(new String[] {"first", "second", "third"}, suffixes);
+ assertArrayEquals(new String[] {"first", "second", "third"}, suffixes);
}
/*
@@ -96,7 +91,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first", "second", "third"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"foo", "bar"});
- assertArrayOrder(new String[] {"first", "second", "third"}, suffixes);
+ assertArrayEquals(new String[] {"first", "second", "third"}, suffixes);
}
/*
@@ -106,7 +101,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first", "second", "third"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"third", "second", "first"});
- assertArrayOrder(new String[] {"third", "second", "first"}, suffixes);
+ assertArrayEquals(new String[] {"third", "second", "first"}, suffixes);
}
/*
@@ -116,7 +111,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"first", "second", "third"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"third"});
- assertArrayOrder(new String[] {"third", "first", "second"}, suffixes);
+ assertArrayEquals(new String[] {"third", "first", "second"}, suffixes);
}
/*
@@ -126,7 +121,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"a", "b", "c", "d", "e", "f"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"b", "e", "f"});
- assertArrayOrder(new String[] {"b", "e", "f", "a", "c", "d"}, suffixes);
+ assertArrayEquals(new String[] {"b", "e", "f", "a", "c", "d"}, suffixes);
}
/*
@@ -136,7 +131,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"a", "b", "c", "d", "e", "f"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"first", "b", "second", "e", "third", "f"});
- assertArrayOrder(new String[] {"b", "e", "f", "a", "c", "d"}, suffixes);
+ assertArrayEquals(new String[] {"b", "e", "f", "a", "c", "d"}, suffixes);
}
/*
@@ -146,7 +141,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"a", "b", "c", "d", "e", "f"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"a", "b", "a"});
- assertArrayOrder(new String[] {"a", "b", "c", "d", "e", "f"}, suffixes);
+ assertArrayEquals(new String[] {"a", "b", "c", "d", "e", "f"}, suffixes);
}
/*
@@ -156,7 +151,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"a", "b", "c", "d", "e", "f"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"a", "!"});
- assertArrayOrder(new String[] {"a"}, suffixes);
+ assertArrayEquals(new String[] {"a"}, suffixes);
}
/*
@@ -166,7 +161,7 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
VisibleMetadataRepositoryManager repositoryManager = new VisibleMetadataRepositoryManager();
String[] suffixes = {"a", "b", "c", "d", "e", "f"};
suffixes = repositoryManager.sortSuffixes(suffixes, new URI("http://foo"), new String[] {"!"});
- assertArrayOrder(new String[] {}, suffixes);
+ assertArrayEquals(new String[] {}, suffixes);
}
/*
@@ -241,10 +236,8 @@ public class SiteIndexFileTest extends AbstractProvisioningTest {
LocationProperties locationProperties = LocationProperties.create(inputStream);
assertNotNull("1.0", locationProperties);
assertEquals("1.1", Version.createOSGi(1, 0, 0), locationProperties.getVersion());
- assertEquals("1.2", 3, locationProperties.getMetadataFactorySearchOrder().length);
- assertEquals("1.4", 3, locationProperties.getArtifactFactorySearchOrder().length);
- assertArrayOrder(new String[] {"bar", "foo", "!"}, locationProperties.getMetadataFactorySearchOrder());
- assertArrayOrder(new String[] {"foo", "bar", "!"}, locationProperties.getArtifactFactorySearchOrder());
+ assertArrayEquals(new String[] {"bar", "foo", "!"}, locationProperties.getMetadataFactorySearchOrder());
+ assertArrayEquals(new String[] {"foo", "bar", "!"}, locationProperties.getArtifactFactorySearchOrder());
}
/*

Back to the top