Improve DelayerUsageTests

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
This commit is contained in:
abilan
2022-12-01 14:46:09 -05:00
parent 66ca0743ed
commit 91c6e16945

View File

@@ -80,7 +80,7 @@ public class DelayerUsageTests {
});
assertThat(outputA.receive(10000)).isNotNull();
assertThat(System.currentTimeMillis() - start).isGreaterThanOrEqualTo(1000);
assertThat(System.currentTimeMillis() - start).isCloseTo(1000, withinPercentage(10));
}
@Test
@@ -124,17 +124,17 @@ public class DelayerUsageTests {
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");
}