[java-support] branch maint-7 updated: JSPT-91 - multimap test failures dependent on execution time zone
Ian Young
ian at iay.org.uk
Thu Jul 25 06:03:59 EDT 2019
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch maint-7
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=187fbb2c0aedef825788b027ba48786e5df3b19c
The following commit(s) were added to refs/heads/maint-7 by this push:
new 187fbb2 JSPT-91 - multimap test failures dependent on execution time zone
187fbb2 is described below
commit 187fbb2c0aedef825788b027ba48786e5df3b19c
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Jul 25 11:01:46 2019 +0100
JSPT-91 - multimap test failures dependent on execution time zone
https://issues.shibboleth.net/jira/browse/JSPT-91
Stabilise the comparison between the various objects involved by
forcing everything to be associated with an explicit ISOChronology.
---
.../support/collection/ClassToInstanceMultiMapTest.java | 14 +++++++++++++-
.../collection/LockableClassToInstanceMultiMapTest.java | 14 +++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/test/java/net/shibboleth/utilities/java/support/collection/ClassToInstanceMultiMapTest.java b/src/test/java/net/shibboleth/utilities/java/support/collection/ClassToInstanceMultiMapTest.java
index 28f2724..a722e18 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/collection/ClassToInstanceMultiMapTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/collection/ClassToInstanceMultiMapTest.java
@@ -23,12 +23,14 @@ import java.util.List;
import org.joda.time.Chronology;
import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
import org.joda.time.ReadableDateTime;
import org.joda.time.ReadableInstant;
import org.joda.time.base.AbstractDateTime;
import org.joda.time.base.AbstractInstant;
import org.joda.time.base.BaseDateTime;
+import org.joda.time.chrono.ISOChronology;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -83,15 +85,25 @@ public class ClassToInstanceMultiMapTest {
@Test public void testValuesAndContainsValues() {
ClassToInstanceMultiMap<AbstractInstant> map = new ClassToInstanceMultiMap<>();
- DateTime now = new DateTime();
+ // Create "now: as a DateTime with a specific chronology so that it
+ // can be guaranteed to compare non-equals with "instant" below.
+ final DateTimeZone notUTC = DateTimeZone.forID("America/Los_Angeles");
+ DateTime now = new DateTime(ISOChronology.getInstance(notUTC));
map.put(now);
DateTime now100 = now.plus(100);
map.put(now100);
+ // instants implicitly have the ISOChronology in the UTC time zone
Instant instant = new Instant();
map.put(instant);
+ // This test makes the assumption that "now" and "instant"
+ // do not compare as "equal". If they do, the second added will
+ // be omitted from the map.values() collection because the collection
+ // .contains() the first one.
+ Assert.assertFalse(now.equals(instant), "now is equals to instant; test assumption violated");
+
Assert.assertEquals(map.values().size(), 3);
Assert.assertFalse(map.containsValue(null));
Assert.assertFalse(map.containsValue(now.minus(100)));
diff --git a/src/test/java/net/shibboleth/utilities/java/support/collection/LockableClassToInstanceMultiMapTest.java b/src/test/java/net/shibboleth/utilities/java/support/collection/LockableClassToInstanceMultiMapTest.java
index 476d085..2faf0cb 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/collection/LockableClassToInstanceMultiMapTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/collection/LockableClassToInstanceMultiMapTest.java
@@ -23,12 +23,14 @@ import java.util.List;
import org.joda.time.Chronology;
import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
import org.joda.time.Instant;
import org.joda.time.ReadableDateTime;
import org.joda.time.ReadableInstant;
import org.joda.time.base.AbstractDateTime;
import org.joda.time.base.AbstractInstant;
import org.joda.time.base.BaseDateTime;
+import org.joda.time.chrono.ISOChronology;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -83,15 +85,25 @@ public class LockableClassToInstanceMultiMapTest {
@Test public void testValuesAndContainsValues() {
LockableClassToInstanceMultiMap<AbstractInstant> map = new LockableClassToInstanceMultiMap<>();
- DateTime now = new DateTime();
+ // Create now as a DateTime with a specific chronology so that it
+ // can be guaranteed to compare non-equals with "instant" below.
+ final DateTimeZone notUTC = DateTimeZone.forID("America/Los_Angeles");
+ DateTime now = new DateTime(ISOChronology.getInstance(notUTC));
map.putWithLock(now);
DateTime now100 = now.plus(100);
map.putWithLock(now100);
+ // instants implicitly have the ISOChronology in the UTC time zone
Instant instant = new Instant();
map.putWithLock(instant);
+ // This test makes the assumption that "now" and "instant"
+ // do not compare as "equal". If they do, the second added will
+ // be omitted from the map.values() collection because the collection
+ // .contains() the first one.
+ Assert.assertFalse(now.equals(instant), "now is equals to instant; test assumption violated");
+
Assert.assertEquals(map.valuesWithLock().size(), 3);
Assert.assertFalse(map.containsValueWithLock(null));
Assert.assertFalse(map.containsValueWithLock(now.minus(100)));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list