Skip to content

Commit

Permalink
Improve DelayerUsageTests
Browse files Browse the repository at this point in the history
The time-based tests are very sensitive to an activity on the target machine.
So, strict test sometimes fail.

* Fix `DelayerUsageTests` to deal with approximate values to compare by some percentage
  • Loading branch information
artembilan committed Dec 1, 2022
1 parent 66ca074 commit 91c6e16
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testDelayWithDefaultSchedulerAndTransactionSynchronization() {
});

assertThat(outputA.receive(10000)).isNotNull();
assertThat(System.currentTimeMillis() - start).isGreaterThanOrEqualTo(1000);
assertThat(System.currentTimeMillis() - start).isCloseTo(1000, withinPercentage(10));
}

@Test
Expand Down Expand Up @@ -124,17 +124,17 @@ public void testDelayerInsideChain() {
delayerInsideChain.send(new GenericMessage<>("Hello"));
Message<?> message = outputA.receive(10000);
assertThat(message).isNotNull();
assertThat(System.currentTimeMillis() - start).isGreaterThanOrEqualTo(1000);
assertThat(System.currentTimeMillis() - start).isCloseTo(1000, withinPercentage(10));
assertThat(message.getPayload()).isEqualTo("hello");
}

@Test
public void testInt2243DelayerExpression() {
public void delayEvaluatedFromExpression() {
long start = System.currentTimeMillis();
this.inputC.send(new GenericMessage<>("test"));
Message<?> message = this.outputC.receive(10000);
assertThat(message).isNotNull();
assertThat(System.currentTimeMillis() - start).isGreaterThanOrEqualTo(1000);
assertThat(System.currentTimeMillis() - start).isCloseTo(1000, withinPercentage(10));
assertThat(message.getPayload()).isEqualTo("test");
}

Expand Down

0 comments on commit 91c6e16

Please sign in to comment.