Validating time operations

Validating time-based operations is a complex task. Traditionally, we used Thread.sleep  or wait-notify blocks to simulate the delay in the test case. Reactor also provides rich support to validate such operations. This allows us to build a virtual clock by using the Stepverifier.withVirtualTime method for Reactive Streams. The virtual clock can then be manipulated using any of the following operations to simulate time drift for the required operation:

Operations Description
thenAwait This only pauses the execution for the configured time.
expectNoEvent This pauses the execution and validates that no event has happened during the configured delay.

 

It is important to note that operators must be invoked ...

Get Hands-On Reactive Programming with Reactor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.