public class TestEnvironment extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
TestEnvironment.BlackholeSubscriberWithSubscriptionSupport<T> |
Similar to
TestEnvironment.ManualSubscriberWithSubscriptionSupport
but does not accumulate values signalled via onNext , thus it can not be used to assert
values signalled to this subscriber. |
static class |
TestEnvironment.Latch |
Like a CountDownLatch, but resettable and with some convenience methods
|
static class |
TestEnvironment.ManualPublisher<T> |
|
static class |
TestEnvironment.ManualSubscriber<T> |
Subscriber implementation which can be steered by test code and asserted on. |
static class |
TestEnvironment.ManualSubscriberWithSubscriptionSupport<T> |
|
static class |
TestEnvironment.Promise<T> |
|
static class |
TestEnvironment.Receptacle<T> |
|
static class |
TestEnvironment.TestSubscriber<T> |
Modifier and Type | Field | Description |
---|---|---|
static int |
TEST_BUFFER_SIZE |
Constructor | Description |
---|---|
TestEnvironment() |
Tests must specify the timeout for expected outcome of asynchronous
interactions.
|
TestEnvironment(boolean printlnDebug) |
Tests must specify the timeout for expected outcome of asynchronous
interactions.
|
TestEnvironment(long defaultTimeoutMillis) |
Tests must specify the timeout for expected outcome of asynchronous
interactions.
|
TestEnvironment(long defaultTimeoutMillis,
long defaultNoSignalsTimeoutMillis) |
Tests must specify the timeout for expected outcome of asynchronous
interactions.
|
TestEnvironment(long defaultTimeoutMillis,
long defaultNoSignalsTimeoutMillis,
boolean printlnDebug) |
Tests must specify the timeout for expected outcome of asynchronous
interactions.
|
Modifier and Type | Method | Description |
---|---|---|
void |
clearAsyncErrors() |
|
void |
debug(java.lang.String msg) |
If
TestEnvironment#printlnDebug is true, print debug message to std out. |
long |
defaultNoSignalsTimeoutMillis() |
This timeout is used when asserting that no further signals are emitted.
|
long |
defaultTimeoutMillis() |
This timeout is used when waiting for a signal to arrive.
|
java.lang.Throwable |
dropAsyncError() |
|
static long |
envDefaultNoSignalsTimeoutMillis() |
Tries to parse the env variable
DEFAULT_NO_SIGNALS_TIMEOUT_MILLIS as long and returns the value if present OR its default value. |
static long |
envDefaultTimeoutMillis() |
Tries to parse the env variable
DEFAULT_TIMEOUT_MILLIS as long and returns the value if present OR its default value. |
Optional<java.lang.StackTraceElement> |
findCallerMethodInStackTrace(java.lang.String method) |
Looks for given
method method in stack trace. |
void |
flop(java.lang.String msg) |
To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously.
|
void |
flop(java.lang.Throwable thr) |
To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously.
|
void |
flop(java.lang.Throwable thr,
java.lang.String msg) |
To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously.
|
<T> T |
flopAndFail(java.lang.String msg) |
To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously.
|
<T> TestEnvironment.ManualSubscriber<T> |
newBlackholeSubscriber(org.reactivestreams.Publisher<T> pub) |
|
<T> TestEnvironment.ManualSubscriber<T> |
newManualSubscriber(org.reactivestreams.Publisher<T> pub) |
|
<T> TestEnvironment.ManualSubscriber<T> |
newManualSubscriber(org.reactivestreams.Publisher<T> pub,
long timeoutMillis) |
|
<T> void |
subscribe(org.reactivestreams.Publisher<T> pub,
TestEnvironment.TestSubscriber<T> sub) |
|
<T> void |
subscribe(org.reactivestreams.Publisher<T> pub,
TestEnvironment.TestSubscriber<T> sub,
long timeoutMillis) |
|
void |
verifyNoAsyncErrors() |
Waits for
defaultTimeoutMillis() and then verifies that no asynchronous errors
were signalled pior to, or during that time (by calling flop() ). |
void |
verifyNoAsyncErrors(long delay) |
This version of
verifyNoAsyncErrors should be used when errors still could be signalled
asynchronously during defaultTimeoutMillis() time. |
void |
verifyNoAsyncErrorsNoDelay() |
Verifies that no asynchronous errors were signalled pior to calling this method (by calling
flop() ). |
public static final int TEST_BUFFER_SIZE
public TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis, boolean printlnDebug)
defaultTimeoutMillis
- default timeout to be used in all expect* methodsdefaultNoSignalsTimeoutMillis
- default timeout to be used when no further signals are expected anymoreprintlnDebug
- if true, signals such as OnNext / Request / OnComplete etc will be printed to standard output,public TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis)
defaultTimeoutMillis
- default timeout to be used in all expect* methodsdefaultNoSignalsTimeoutMillis
- default timeout to be used when no further signals are expected anymorepublic TestEnvironment(long defaultTimeoutMillis)
defaultTimeoutMillis
- default timeout to be used in all expect* methodspublic TestEnvironment(boolean printlnDebug)
DEFAULT_TIMEOUT_MILLIS
or the default value (DEFAULT_TIMEOUT_MILLIS
) will be used.printlnDebug
- if true, signals such as OnNext / Request / OnComplete etc will be printed to standard output,
often helpful to pinpoint simple race conditions etc.public TestEnvironment()
DEFAULT_TIMEOUT_MILLIS
or the default value (DEFAULT_TIMEOUT_MILLIS
) will be used.public long defaultTimeoutMillis()
public long defaultNoSignalsTimeoutMillis()
public static long envDefaultTimeoutMillis()
DEFAULT_TIMEOUT_MILLIS
as long and returns the value if present OR its default value.java.lang.IllegalArgumentException
- when unable to parse the env variablepublic static long envDefaultNoSignalsTimeoutMillis()
DEFAULT_NO_SIGNALS_TIMEOUT_MILLIS
as long and returns the value if present OR its default value.java.lang.IllegalArgumentException
- when unable to parse the env variablepublic void flop(java.lang.String msg)
env.verifyNoAsyncErrorsNoDelay()
at the end of your TCK tests to verify there no flops called during it's execution.
To check investigate asyncErrors more closely you can use expectError
methods or collect the error directly
from the environment using env.dropAsyncError()
.
To clear asyncErrors you can call clearAsyncErrors()
public void flop(java.lang.Throwable thr, java.lang.String msg)
env.verifyNoAsyncErrorsNoDelay()
at the end of your TCK tests to verify there no flops called during it's execution.
To check investigate asyncErrors more closely you can use expectError
methods or collect the error directly
from the environment using env.dropAsyncError()
.
To clear asyncErrors you can call clearAsyncErrors()
public void flop(java.lang.Throwable thr)
env.verifyNoAsyncErrorsNoDelay()
at the end of your TCK tests to verify there no flops called during it's execution.
To check investigate asyncErrors more closely you can use expectError
methods or collect the error directly
from the environment using env.dropAsyncError()
.
To clear asyncErrors you can call clearAsyncErrors()
public <T> T flopAndFail(java.lang.String msg)
flop(java.lang.String)
which only records the error.
Use env.verifyNoAsyncErrorsNoDelay()
at the end of your TCK tests to verify there no flops called during it's execution.
To check investigate asyncErrors more closely you can use expectError
methods or collect the error directly
from the environment using env.dropAsyncError()
.
To clear asyncErrors you can call clearAsyncErrors()
public <T> void subscribe(org.reactivestreams.Publisher<T> pub, TestEnvironment.TestSubscriber<T> sub) throws java.lang.InterruptedException
java.lang.InterruptedException
public <T> void subscribe(org.reactivestreams.Publisher<T> pub, TestEnvironment.TestSubscriber<T> sub, long timeoutMillis) throws java.lang.InterruptedException
java.lang.InterruptedException
public <T> TestEnvironment.ManualSubscriber<T> newBlackholeSubscriber(org.reactivestreams.Publisher<T> pub) throws java.lang.InterruptedException
java.lang.InterruptedException
public <T> TestEnvironment.ManualSubscriber<T> newManualSubscriber(org.reactivestreams.Publisher<T> pub) throws java.lang.InterruptedException
java.lang.InterruptedException
public <T> TestEnvironment.ManualSubscriber<T> newManualSubscriber(org.reactivestreams.Publisher<T> pub, long timeoutMillis) throws java.lang.InterruptedException
java.lang.InterruptedException
public void clearAsyncErrors()
public java.lang.Throwable dropAsyncError()
public void verifyNoAsyncErrors()
defaultTimeoutMillis()
and then verifies that no asynchronous errors
were signalled pior to, or during that time (by calling flop()
).public void verifyNoAsyncErrors(long delay)
verifyNoAsyncErrors
should be used when errors still could be signalled
asynchronously during defaultTimeoutMillis()
time.
It will immediatly check if any async errors were signaled (using flop(String)
,
and if no errors encountered wait for another default timeout as the errors may yet be signalled.
The initial check is performed in order to fail-fast in case of an already failed test.public void verifyNoAsyncErrorsNoDelay()
flop()
).
This version of verifyNoAsyncError does not wait before checking for asynchronous errors, and is to be used
for example in tight loops etc.public void debug(java.lang.String msg)
TestEnvironment#printlnDebug
is true, print debug message to std out.public Optional<java.lang.StackTraceElement> findCallerMethodInStackTrace(java.lang.String method)
method
method in stack trace.
Can be used to answer questions like "was this method called from onComplete?".