[java-support] branch master updated: Rework tests to hande the fact that on windows times can be equal
Rod Widdowson
rdw at steadingsoftware.com
Wed May 29 12:11:43 EDT 2019
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=9bd0c6a17bc11c58d8eb3eb3d4577f90acf2a280
The following commit(s) were added to refs/heads/master by this push:
new 9bd0c6a Rework tests to hande the fact that on windows times can be equal
9bd0c6a is described below
commit 9bd0c6a17bc11c58d8eb3eb3d4577f90acf2a280
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed May 29 17:11:32 2019 +0100
Rework tests to hande the fact that on windows times can be equal
---
.../httpclient/IdleConectionSweeperTest.java | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/test/java/net/shibboleth/utilities/java/support/httpclient/IdleConectionSweeperTest.java b/src/test/java/net/shibboleth/utilities/java/support/httpclient/IdleConectionSweeperTest.java
index 14a0c73..f7a0175 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/httpclient/IdleConectionSweeperTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/httpclient/IdleConectionSweeperTest.java
@@ -36,8 +36,14 @@ public class IdleConectionSweeperTest {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
IdleConnectionSweeper sweeper = new IdleConnectionSweeper(connectionManager, Duration.ofMillis(30), SWEEP_INTERVAL);
- Thread.sleep(200);
- Assert.assertTrue(sweeper.scheduledExecutionTime().plus(SWEEP_INTERVAL).isAfter(Instant.now()));
+ Thread.sleep(75);
+ long scheduledPlus =sweeper.scheduledExecutionTime().plus(SWEEP_INTERVAL).toEpochMilli();
+ long now = Instant.now().toEpochMilli();
+ if (now > scheduledPlus) {
+ Assert.assertTrue(scheduledPlus >= now);
+
+ }
+ Assert.assertTrue(scheduledPlus >= now);
sweeper.destroy();
Assert.assertTrue(sweeper.isDestroyed());
@@ -51,8 +57,14 @@ public class IdleConectionSweeperTest {
Timer timer = new Timer(true);
sweeper = new IdleConnectionSweeper(connectionManager, Duration.ofMillis(30), SWEEP_INTERVAL, timer);
- Thread.sleep(150);
- Assert.assertTrue(sweeper.scheduledExecutionTime().plus(SWEEP_INTERVAL).isAfter(Instant.now()));
+ Thread.sleep(10);
+ scheduledPlus =sweeper.scheduledExecutionTime().plus(SWEEP_INTERVAL).toEpochMilli();
+ now = Instant.now().toEpochMilli();
+ if (now > scheduledPlus) {
+ Assert.assertTrue(scheduledPlus >= now);
+
+ }
+ Assert.assertTrue(scheduledPlus >= now);
sweeper.destroy();
Assert.assertTrue(sweeper.isDestroyed());
@@ -63,5 +75,7 @@ public class IdleConectionSweeperTest {
} catch (DestroyedComponentException e) {
// expected this
}
+ timer.cancel();
}
+
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list