public final class VertxTestContext extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
VertxTestContext.ExecutionBlock
Interface for an executable block of assertion code.
|
Constructor and Description |
---|
VertxTestContext() |
Modifier and Type | Method and Description |
---|---|
<T> Future<T> |
assertComplete(Future<T> fut)
This method allows you to check if a future is completed.
|
<T> Future<T> |
assertFailure(Future<T> fut)
This method allows you to check if a future is failed.
|
boolean |
awaitCompletion(long timeout,
TimeUnit unit)
Wait for the completion of the test context.
|
Throwable |
causeOfFailure()
Give the cause of failure.
|
Checkpoint |
checkpoint()
Create a strict checkpoint.
|
Checkpoint |
checkpoint(int requiredNumberOfPasses)
Create a strict checkpoint.
|
boolean |
completed()
Check if the context has completed.
|
void |
completeNow()
Complete the test context immediately, making the corresponding test pass.
|
<T> Handler<AsyncResult<T>> |
completing()
Create an asynchronous result handler that expects a success to then complete the test context.
|
boolean |
failed()
Check if the context has been marked has failed or not.
|
<T> Handler<AsyncResult<T>> |
failing()
Create an asynchronous result handler that expects a failure.
|
<T> Handler<AsyncResult<T>> |
failing(Handler<Throwable> nextHandler)
Create an asynchronous result handler that expects a failure, and passes the exception to another handler.
|
void |
failNow(Throwable t)
Make the test context fail immediately, making the corresponding test fail.
|
Checkpoint |
laxCheckpoint()
Create a lax checkpoint.
|
Checkpoint |
laxCheckpoint(int requiredNumberOfPasses)
Create a lax checkpoint.
|
<T> Handler<AsyncResult<T>> |
succeeding()
Create an asynchronous result handler that expects a success.
|
<T> Handler<AsyncResult<T>> |
succeeding(Handler<T> nextHandler)
Create an asynchronous result handler that expects a success, and passes the value to another handler.
|
VertxTestContext |
verify(VertxTestContext.ExecutionBlock block)
Allow verifications and assertions to be made.
|
public boolean failed()
true
if the context has failed, false
otherwise.public Throwable causeOfFailure()
null
if the test context hasn't failed.public boolean completed()
true
if the context has completed, false
otherwise.public void completeNow()
public void failNow(Throwable t)
t
- the cause of failure.public Checkpoint laxCheckpoint()
public Checkpoint laxCheckpoint(int requiredNumberOfPasses)
requiredNumberOfPasses
- the required number of passes to validate the checkpoint.public Checkpoint checkpoint()
public Checkpoint checkpoint(int requiredNumberOfPasses)
requiredNumberOfPasses
- the required number of passes to validate the checkpoint.public <T> Handler<AsyncResult<T>> succeeding()
T
- the asynchronous result type.public <T> Handler<AsyncResult<T>> succeeding(Handler<T> nextHandler)
T
- the asynchronous result type.nextHandler
- the value handler to call on success.public <T> Handler<AsyncResult<T>> failing()
T
- the asynchronous result type.public <T> Handler<AsyncResult<T>> failing(Handler<Throwable> nextHandler)
T
- the asynchronous result type.nextHandler
- the exception handler to call on failure.public <T> Handler<AsyncResult<T>> completing()
T
- the asynchronous result type.public <T> Future<T> assertComplete(Future<T> fut)
fut
- The future to assert successpublic <T> Future<T> assertFailure(Future<T> fut)
fut
- The future to assert failurepublic VertxTestContext verify(VertxTestContext.ExecutionBlock block)
This method allows any assertion API to be used.
The semantic is that the verification is successful when no exception is being thrown upon calling block
,
otherwise the context fails with that exception.
block
- a block of code to execute.public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException
This method is automatically called by the VertxExtension
when using parameter injection of VertxTestContext
.
You should only call it when you instantiate this class manually.
timeout
- the timeout.unit
- the timeout unit.true
if the completion or failure happens before the timeout has been reached, false
otherwise.InterruptedException
- when the thread has been interrupted.Copyright © 2023 Eclipse. All rights reserved.