Repository: james-project Updated Branches: refs/heads/master 510b4e9b3 -> 751e4fc5e
JAMES-2462 AbstractNotificationRegistryTest::registerShouldWorkWithExpiracyDate is unstable This is due to the way Cassandra TTL works. We should expect TTL to be in [delay - 1s, delay] when specifying `delay` as a TTL value, and not be exactly `delay` Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/751e4fc5 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/751e4fc5 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/751e4fc5 Branch: refs/heads/master Commit: 751e4fc5ec247883be1d7e02d619985304cfbf33 Parents: 510b4e9 Author: benwa <[email protected]> Authored: Wed Jul 11 11:58:06 2018 +0700 Committer: benwa <[email protected]> Committed: Wed Jul 11 17:39:41 2018 +0700 ---------------------------------------------------------------------- .../CassandraNotificationRegistryTest.java | 2 +- .../AbstractNotificationRegistryTest.java | 29 ++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/751e4fc5/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java ---------------------------------------------------------------------- diff --git a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java index aada43c..a736d32 100644 --- a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java +++ b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/vacation/CassandraNotificationRegistryTest.java @@ -37,7 +37,7 @@ public class CassandraNotificationRegistryTest extends AbstractNotificationRegis @Override @Before public void setUp() throws Exception { - cassandra = CassandraCluster.create(new CassandraNotificationRegistryModule(), cassandraServer.getIp(), cassandraServer.getBindingPort()); + cassandra = CassandraCluster.create(new CassandraNotificationRegistryModule(), cassandraServer.getHost()); super.setUp(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/751e4fc5/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java ---------------------------------------------------------------------- diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java index 35666a0..111ecab 100644 --- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java +++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/vacation/AbstractNotificationRegistryTest.java @@ -36,9 +36,10 @@ import org.junit.Test; public abstract class AbstractNotificationRegistryTest { public static final ZonedDateTime ZONED_DATE_TIME = ZonedDateTime.parse("2016-04-03T02:01:01+07:00[Asia/Vientiane]"); - public static final ZonedDateTime ZONED_DATE_TIME_PLUS_1_SECONDS = ZonedDateTime.parse("2016-04-03T02:01:02+07:00[Asia/Vientiane]"); - public static final ZonedDateTime ZONED_DATE_TIME_PLUS_10_SECONDS = ZonedDateTime.parse("2016-04-03T02:01:11+07:00[Asia/Vientiane]"); + public static final ZonedDateTime ZONED_DATE_TIME_PLUS_4_SECONDS = ZonedDateTime.parse("2016-04-03T02:01:05+07:00[Asia/Vientiane]"); + public static final ZonedDateTime ZONED_DATE_TIME_PLUS_8_SECONDS = ZonedDateTime.parse("2016-04-03T02:01:09+07:00[Asia/Vientiane]"); public static final AccountId ACCOUNT_ID = AccountId.fromString("id"); + private NotificationRegistry notificationRegistry; private ZonedDateTimeProvider zonedDateTimeProvider; private RecipientId recipientId; @@ -53,38 +54,38 @@ public abstract class AbstractNotificationRegistryTest { } @Test - public void isRegisterShouldReturnFalseByDefault() throws Exception { + public void isRegisterShouldReturnFalseByDefault() { assertThat(notificationRegistry.isRegistered(ACCOUNT_ID, recipientId).join()).isFalse(); } @Test - public void registerShouldWork() throws Exception { + public void registerShouldWork() { notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.empty()).join(); assertThat(notificationRegistry.isRegistered(ACCOUNT_ID, recipientId).join()).isTrue(); } @Test - public void registerShouldWorkWithExpiracyDate() throws Exception { + public void registerShouldWorkWithExpiracyDate() { when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME); - notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.of(ZONED_DATE_TIME_PLUS_1_SECONDS)).join(); + notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.of(ZONED_DATE_TIME_PLUS_4_SECONDS)).join(); assertThat(notificationRegistry.isRegistered(ACCOUNT_ID, recipientId).join()).isTrue(); } @Test - public void registerShouldExpireAfterExpiracyDate() throws Exception { + public void registerShouldExpireAfterExpiracyDate() { when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME); - notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.of(ZONED_DATE_TIME_PLUS_1_SECONDS)).join(); + notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.of(ZONED_DATE_TIME_PLUS_4_SECONDS)).join(); - when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME_PLUS_10_SECONDS); + when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME_PLUS_8_SECONDS); - await().atMost(2, TimeUnit.SECONDS).until(() -> !notificationRegistry.isRegistered(ACCOUNT_ID, recipientId).join()); + await().atMost(20, TimeUnit.SECONDS).until(() -> !notificationRegistry.isRegistered(ACCOUNT_ID, recipientId).join()); } @Test - public void flushShouldWork() throws Exception { + public void flushShouldWork() { when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME); notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.empty()).join(); @@ -94,8 +95,8 @@ public abstract class AbstractNotificationRegistryTest { } @Test - public void registerShouldNotPersistWhenExpiryDateIsPast() throws Exception { - when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME_PLUS_1_SECONDS); + public void registerShouldNotPersistWhenExpiryDateIsPast() { + when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME_PLUS_4_SECONDS); notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.of(ZONED_DATE_TIME)).join(); @@ -103,7 +104,7 @@ public abstract class AbstractNotificationRegistryTest { } @Test - public void registerShouldNotPersistWhenExpiryDateIsPresent() throws Exception { + public void registerShouldNotPersistWhenExpiryDateIsPresent() { when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME); notificationRegistry.register(ACCOUNT_ID, recipientId, Optional.of(ZONED_DATE_TIME)).join(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
