public class Waiter extends Object
Constructor and Description |
---|
Waiter()
Creates a new Waiter.
|
Modifier and Type | Method and Description |
---|---|
void |
assertEquals(Object expected,
Object actual)
Asserts that the
expected values equals the actual value |
void |
assertFalse(boolean condition)
Asserts that the
condition is false. |
void |
assertNotNull(Object object)
Asserts that the
object is not null. |
void |
assertNull(Object object)
Asserts that the
object is null. |
<T> void |
assertThat(T actual,
org.hamcrest.Matcher<? super T> matcher)
Asserts that
actual satisfies the condition specified by matcher . |
void |
assertTrue(boolean condition)
Asserts that the
condition is true. |
void |
await()
Waits until
resume() is called, or the test is failed. |
void |
await(long delay)
Waits until the
delay has elapsed, resume() is called, or the test is failed. |
void |
await(long delay,
int expectedResumes)
|
void |
await(long delay,
TimeUnit timeUnit)
Waits until the
delay has elapsed, resume() is called, or the test is failed. |
void |
await(long delay,
TimeUnit timeUnit,
int expectedResumes)
|
void |
fail()
Fails the current test.
|
void |
fail(String reason)
Fails the current test for the given
reason . |
void |
fail(Throwable reason)
Fails the current test with the given
reason , sets the number of expected resumes to 0, and throws the
reason as an AssertionError in the main test thread and in the current thread. |
void |
resume()
Resumes the waiter when the expected number of
resume() calls have occurred. |
void |
rethrow(Throwable failure)
Rethrows the
failure in the main test thread and in the current thread. |
public void assertEquals(Object expected, Object actual)
expected
values equals the actual
valueAssertionError
- when the assertion failspublic void assertFalse(boolean condition)
condition
is false.AssertionError
- when the assertion failspublic void assertNotNull(Object object)
object
is not null.AssertionError
- when the assertion failspublic void assertNull(Object object)
object
is null.AssertionError
- when the assertion failspublic void assertTrue(boolean condition)
condition
is true.AssertionError
- when the assertion failspublic <T> void assertThat(T actual, org.hamcrest.Matcher<? super T> matcher)
actual
satisfies the condition specified by matcher
.AssertionError
- when the assertion failspublic void await() throws TimeoutException
resume()
is called, or the test is failed.TimeoutException
- if the operation times out or is interrupted while waitingAssertionError
- if any assertion fails while waitingpublic void await(long delay) throws TimeoutException
delay
has elapsed, resume()
is called, or the test is failed.delay
- Delay to wait in millisecondsTimeoutException
- if the operation times out or is interrupted while waitingAssertionError
- if any assertion fails while waitingpublic void await(long delay, TimeUnit timeUnit) throws TimeoutException
delay
has elapsed, resume()
is called, or the test is failed.delay
- Delay to wait fortimeUnit
- TimeUnit to delay forTimeoutException
- if the operation times out or is interrupted while waitingAssertionError
- if any assertion fails while waitingpublic void await(long delay, int expectedResumes) throws TimeoutException
delay
- Delay to wait for in millisecondsexpectedResumes
- Number of times resume()
is expected to be called before the awaiting thread is
resumedTimeoutException
- if the operation times out or is interrupted while waitingAssertionError
- if any assertion fails while waitingpublic void await(long delay, TimeUnit timeUnit, int expectedResumes) throws TimeoutException
delay
- Delay to wait fortimeUnit
- TimeUnit to delay forexpectedResumes
- Number of times resume()
is expected to be called before the awaiting thread is
resumedTimeoutException
- if the operation times out or is interrupted while waitingAssertionError
- if any assertion fails while waitingpublic void resume()
resume()
calls have occurred.public void fail()
AssertionError
public void fail(String reason)
reason
.AssertionError
public void fail(Throwable reason)
reason
, sets the number of expected resumes to 0, and throws the
reason
as an AssertionError
in the main test thread and in the current thread.AssertionError
- wrapping the reason
public void rethrow(Throwable failure)
failure
in the main test thread and in the current thread. Differs from
fail(Throwable)
which wraps a failure in an AssertionError before throwing.Throwable
- the failure
Copyright © 2010–2019. All rights reserved.