[utilities COMMIT] /java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/IndexingObjectS...
noreply at shibboleth.net
noreply at shibboleth.net
Sat Jun 7 07:13:46 EDT 2014
Author: iay
Date: Sat Jun 7 07:13:45 2014
New Revision: 594
URL: http://svn.shibboleth.net/view/utilities?rev=594&view=rev
Log:
JSPT-39: add a unit test for the collision case
Modified:
java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/IndexingObjectStoreTest.java
Modified: java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/IndexingObjectStoreTest.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/IndexingObjectStoreTest.java?rev=594&r1=593&r2=594&view=diff
==============================================================================
--- java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/IndexingObjectStoreTest.java (original)
+++ java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/collection/IndexingObjectStoreTest.java Sat Jun 7 07:13:45 2014
@@ -76,4 +76,27 @@
Assert.assertTrue(store.isEmpty());
Assert.assertEquals(store.size(), 0);
}
+
+ @Test
+ public void testCollision() {
+ /*
+ * These String values have the same hashCode() value, using the
+ * algorithm that is documented as part of the Java 7 API. As it
+ * is part of the API, we do not expect it to vary between
+ * implementations.
+ */
+ final String s1 = "FB";
+ final String s2 = "Ea";
+ Assert.assertEquals(s1.hashCode(), s2.hashCode());
+
+ final IndexingObjectStore<String> store = new IndexingObjectStore<>();
+
+ final String s1index = store.put(s1);
+ final String s2index = store.put(s2);
+ Assert.assertNotEquals(s1index, s2index);
+ Assert.assertTrue(store.contains(s1index));
+ Assert.assertTrue(store.contains(s2index));
+ Assert.assertEquals(store.get(s1index), s1);
+ Assert.assertEquals(store.get(s2index), s2);
+ }
}
More information about the commits
mailing list