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()
Deprecated.
Use
succeedingThenComplete() instead. |
boolean |
failed()
Check if the context has been marked has failed or not.
|
<T> Handler<AsyncResult<T>> |
failing()
Deprecated.
Use
failingThenComplete() or failing(Handler) , for example
failing(e -> checkpoint.flag()) , failing(e -> { more testing code }) , or
failing(e -> {}) . |
<T> Handler<AsyncResult<T>> |
failing(Handler<Throwable> nextHandler)
Create an asynchronous result handler that expects a failure, and passes the exception to another handler.
|
<T> Handler<AsyncResult<T>> |
failingThenComplete()
Create an asynchronous result handler that expects a failure to then complete the test context.
|
void |
failNow(String message)
Calls
failNow(Throwable) with the message . |
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()
Deprecated.
Use
succeedingThenComplete() or succeeding(Handler) , for example
succeeding(value -> checkpoint.flag()) , succeeding(value -> { more testing code }) , or
succeeding(value -> {}) . |
<T> Handler<AsyncResult<T>> |
succeeding(Handler<T> nextHandler)
Create an asynchronous result handler that expects a success, and passes the value to another handler.
|
<T> Handler<AsyncResult<T>> |
succeedingThenComplete()
Create an asynchronous result handler that expects a success to then complete the test context.
|
Set<StackTraceElement> |
unsatisfiedCheckpointCallSites()
Gives the call sites of all unsatisfied checkpoints.
|
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 Set<StackTraceElement> unsatisfiedCheckpointCallSites()
StackTraceElement
references pointing to the unsatisfied checkpoint call sites.public void completeNow()
public void failNow(Throwable t)
t
- the cause of failure.public void failNow(String message)
failNow(Throwable)
with the message
.message
- the cause of failurepublic 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.@Deprecated public <T> Handler<AsyncResult<T>> succeeding()
succeedingThenComplete()
or succeeding(Handler)
, for example
succeeding(value -> checkpoint.flag())
, succeeding(value -> { more testing code })
, or
succeeding(value -> {})
.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 that is expected not to throw a Throwable
.@Deprecated public <T> Handler<AsyncResult<T>> failing()
failingThenComplete()
or failing(Handler)
, for example
failing(e -> checkpoint.flag())
, failing(e -> { more testing code })
, or
failing(e -> {})
.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 that is expected not to throw a Throwable
.public <T> Handler<AsyncResult<T>> succeedingThenComplete()
T
- the asynchronous result type.@Deprecated public <T> Handler<AsyncResult<T>> completing()
succeedingThenComplete()
instead.T
- the asynchronous result type.failingThenComplete()
public <T> Handler<AsyncResult<T>> failingThenComplete()
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 © 2024 Eclipse. All rights reserved.