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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.