T - The type of values that will be emitted by the Observablepublic class TestSubscriber<T>
extends rx.Subscriber<T>
Subscriber that records all events so that assertions can be made against them for testing purposes
TestSubscriber is entirely thread safe and makes no assumptions about the Observable contract| Modifier and Type | Class and Description |
|---|---|
class |
TestSubscriber.AssertionChain
A fluent class used to walk the chain of events received by a
TestSubscriber and make assertions against each event in the order received |
| Constructor and Description |
|---|
TestSubscriber() |
| Modifier and Type | Method and Description |
|---|---|
void |
assertDoesNotHaveEvent(org.hamcrest.Matcher<rx.Notification> matcher)
Asserts that this Subscriber has not received an event matching the given matcher
|
void |
assertHasEvent(org.hamcrest.Matcher<rx.Notification> matcher)
Asserts that this Subscriber has received an event matching the given matcher
|
void |
assertWellBehaved() |
void |
awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher)
Holds the current thread until the subscriber has received an events that match the given matcher
|
void |
awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher,
int times)
Holds the current thread until the subscriber has received a certain number of events that match the given matcher
|
void |
awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher,
int times,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
Holds the current thread until the subscriber has received a certain number of events that match the given matcher
|
void |
awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
Holds the current thread until the subscriber has received an events that match the given matcher
|
TestSubscriber.AssertionChain |
beginAssertionChain()
Begins a
TestSubscriber.AssertionChain that will make assertions against all of the events that have been recorded |
void |
onCompleted() |
void |
onError(java.lang.Throwable e) |
void |
onNext(T t) |
public void onCompleted()
public void onError(java.lang.Throwable e)
public void onNext(T t)
public void awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher,
int times,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
throws java.lang.InterruptedException
Holds the current thread until the subscriber has received a certain number of events that match the given matcher
This is useful for waiting until a Observable is in a certain state before making assumptions against it's events
Fails: When the proper number of matching events aren't recorded before a timeout occurs
matcher - The matcher used for checking the eventstimes - How many events need to be seen that match before the thread is releasedtimeout - How long to wait before timing outtimeUnit - The unit to be used for the timeoutjava.lang.InterruptedException - When the thread is interruptedpublic void awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher,
int times)
throws java.lang.InterruptedException
Holds the current thread until the subscriber has received a certain number of events that match the given matcher
This is useful for waiting until a Observable is in a certain state before making assumptions against it's events
The wait will timeout after ms
Fails: When the proper number of matching events aren't recorded before a timeout occurs
matcher - The matcher used for checking the eventstimes - How many events need to be seen that match before the thread is releasedjava.lang.InterruptedException - When the thread is interruptedpublic void awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
throws java.lang.InterruptedException
Holds the current thread until the subscriber has received an events that match the given matcher
This is useful for waiting until a Observable is in a certain state before making assumptions against it's events
Fails: When a matching event isn't recorded before a timeout occurs
matcher - The matcher used for checking the eventstimeout - How long to wait before timing outtimeUnit - The unit to be used for the timeoutjava.lang.InterruptedException - When the thread is interruptedpublic void awaitEvent(org.hamcrest.Matcher<rx.Notification> matcher)
throws java.lang.InterruptedException
Holds the current thread until the subscriber has received an events that match the given matcher
This is useful for waiting until a Observable is in a certain state before making assumptions against it's events
The wait will timeout after ms
Fails: When a matching event isn't recorded before a timeout occurs
matcher - The matcher used for checking the eventsjava.lang.InterruptedException - When the thread is interruptedpublic TestSubscriber.AssertionChain beginAssertionChain()
TestSubscriber.AssertionChain that will make assertions against all of the events that have been recordedpublic void assertHasEvent(org.hamcrest.Matcher<rx.Notification> matcher)
matcher - The matcher to check withpublic void assertDoesNotHaveEvent(org.hamcrest.Matcher<rx.Notification> matcher)
matcher - The matcher to check withpublic void assertWellBehaved()