T
- the return type of the taskpublic static class AsyncTaskManager.BarrierTask<T> extends Object
Use this interface to check that the task waits on the barrier and completes as expected
Constructor and Description |
---|
BarrierTask(Future<? extends T> result,
Barrier barrier) |
Modifier and Type | Method and Description |
---|---|
void |
assertAwaits()
Assert that the task waits on its barrier within WAIT_TIME_MS
|
void |
assertCompletes()
Assert that the task completes within WAIT_TIME_MS
|
void |
assertNotAwaiting()
Assert that the task does not wait on its barrier
|
void |
assertNotCompleting()
Assert that the task does not complete within EXPECTED_FAIL_TIME_MS
|
void |
assertResult(org.hamcrest.Matcher<? super T> matcher)
Assert that the task completes without exception within WAIT_TIME_MS and that the value returned is matched
by the provided matcher
|
void |
assertSuccess()
Assert that the task completes without exception within WAIT_TIME_MS
|
void |
assertThrows(Class<? extends Throwable> exceptionClass)
Assert that the task completes, throwing an exception of the specified class within WAIT_TIME_MS
|
T |
getResult()
Get the result of the task
|
T |
getResult(long time,
TimeUnit unit)
Get the result of the task
|
boolean |
isAwaiting()
Whether this task is awaiting its barrier right now
|
void |
openBarrier()
Open the barrier used by the task
|
public void openBarrier()
public void assertAwaits()
public void assertNotAwaiting()
This method always takes EXPECTED_FAIL_TIME_MS ms.
If you need to check multiple tasks, use AsyncTaskManager.assertAllNotAwaiting(Collection)
instead.
public void assertCompletes()
public void assertNotCompleting()
public void assertSuccess()
public void assertThrows(Class<? extends Throwable> exceptionClass)
exceptionClass
- the class of the expected exceptionpublic void assertResult(org.hamcrest.Matcher<? super T> matcher)
matcher
- the Matcher
used to assert the returned valuepublic T getResult() throws ExecutionException
Asserts that the task completes within WAIT_TIME_MS.
ExecutionException
- if the task threw an exception instead of returningpublic T getResult(long time, TimeUnit unit) throws ExecutionException
Asserts that the task completes within the given time
time
- the time to wait for the task to completeunit
- the unit for time
ExecutionException
- if the task threw an exception instead of returningpublic boolean isAwaiting()
This method returns immediately.
true
if this task is currently waiting on its barrier, otherwise false
Copyright © 2016 – 2021 Eclipse Foundation. All rights reserved.
Use is subject to license terms.