Class Async

java.lang.Object
org.kiwiproject.concurrent.Async

public final class Async extends Object
Static utilities that work with CompletableFuture and can make testing easier by permitting selective (e.g. in unit tests) forcing of synchronous behavior for things that would normally execute asynchronously. This applies only to some methods, so read the method's documentation before assuming.

Use the xxxAsync methods when you need to control concurrent behavior and make things deterministic during unit tests (e.g. blocking on futures). Note this does actually change the true behavior of the code under test, since methods will execute synchronously, so use with care, caution, and understanding.

Implementation Note:
the "asyncMode" flag is a STATIC variable and should only ever be changed during testing using the setUnitTestAsyncMode(Mode) method. Generally, you should set this before tests and reset after they have run. Note also this almost certainly will cause unexpected behavior if tests are run in parallel.