Package org.reactivestreams.tck
Class TestEnvironment
- java.lang.Object
- 
- org.reactivestreams.tck.TestEnvironment
 
- 
 public class TestEnvironment extends java.lang.Object 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classTestEnvironment.BlackholeSubscriberWithSubscriptionSupport<T>Similar toTestEnvironment.ManualSubscriberWithSubscriptionSupportbut does not accumulate values signalled viaonNext, thus it can not be used to assert values signalled to this subscriber.static classTestEnvironment.LatchLike a CountDownLatch, but resettable and with some convenience methodsstatic classTestEnvironment.ManualPublisher<T>static classTestEnvironment.ManualSubscriber<T>Subscriberimplementation which can be steered by test code and asserted on.static classTestEnvironment.ManualSubscriberWithSubscriptionSupport<T>static classTestEnvironment.Promise<T>static classTestEnvironment.Receptacle<T>static classTestEnvironment.TestSubscriber<T>
 - 
Field SummaryFields Modifier and Type Field Description static intTEST_BUFFER_SIZE
 - 
Constructor SummaryConstructors 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.TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis, long defaultPollTimeoutMillis)Tests must specify the timeout for expected outcome of asynchronous interactions.TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis, long defaultPollTimeoutMillis, boolean printlnDebug)Tests must specify the timeout for expected outcome of asynchronous interactions.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAsyncErrors()voiddebug(java.lang.String msg)IfTestEnvironment#printlnDebugis true, print debug message to std out.booleandebugEnabled()longdefaultNoSignalsTimeoutMillis()This timeout is used when asserting that no further signals are emitted.longdefaultPollTimeoutMillis()The default amount of time to poll for events ifdefaultTimeoutMillisisn't preempted by an asynchronous event.longdefaultTimeoutMillis()This timeout is used when waiting for a signal to arrive.java.lang.ThrowabledropAsyncError()static longenvDefaultNoSignalsTimeoutMillis()Tries to parse the env variableDEFAULT_NO_SIGNALS_TIMEOUT_MILLISas long and returns the value if present OR its default value.static longenvDefaultPollTimeoutMillis()Tries to parse the env variableDEFAULT_POLL_TIMEOUT_MILLIS_ENVas long and returns the value if present OR its default value.static longenvDefaultTimeoutMillis()Tries to parse the env variableDEFAULT_TIMEOUT_MILLISas long and returns the value if present OR its default value.Optional<java.lang.StackTraceElement>findCallerMethodInStackTrace(java.lang.String method)Looks for givenmethodmethod in stack trace.voidflop(java.lang.String msg)To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously.voidflop(java.lang.Throwable thr)To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously.voidflop(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> TflopAndFail(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> voidsubscribe(org.reactivestreams.Publisher<T> pub, TestEnvironment.TestSubscriber<T> sub)<T> voidsubscribe(org.reactivestreams.Publisher<T> pub, TestEnvironment.TestSubscriber<T> sub, long timeoutMillis)voidverifyNoAsyncErrors()Waits fordefaultNoSignalsTimeoutMillis()and then verifies that no asynchronous errors were signalled pior to, or during that time (by callingflop()).voidverifyNoAsyncErrors(long delay)This version ofverifyNoAsyncErrorsshould be used when errors still could be signalled asynchronously duringdefaultTimeoutMillis()time.voidverifyNoAsyncErrorsNoDelay()Verifies that no asynchronous errors were signalled pior to calling this method (by callingflop()).
 
- 
- 
- 
Field Detail- 
TEST_BUFFER_SIZEpublic static final int TEST_BUFFER_SIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
TestEnvironmentpublic TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis, long defaultPollTimeoutMillis, boolean printlnDebug) Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests.- Parameters:
- defaultTimeoutMillis- default timeout to be used in all expect* methods
- defaultNoSignalsTimeoutMillis- default timeout to be used when no further signals are expected anymore
- defaultPollTimeoutMillis- default amount of time to poll for events if- defaultTimeoutMillisisn't preempted by an asynchronous event.
- printlnDebug- if true, signals such as OnNext / Request / OnComplete etc will be printed to standard output,
 
 - 
TestEnvironmentpublic TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis, boolean printlnDebug) Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests.- Parameters:
- defaultTimeoutMillis- default timeout to be used in all expect* methods
- defaultNoSignalsTimeoutMillis- default timeout to be used when no further signals are expected anymore
- printlnDebug- if true, signals such as OnNext / Request / OnComplete etc will be printed to standard output,
 
 - 
TestEnvironmentpublic TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis, long defaultPollTimeoutMillis) Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests.- Parameters:
- defaultTimeoutMillis- default timeout to be used in all expect* methods
- defaultNoSignalsTimeoutMillis- default timeout to be used when no further signals are expected anymore
- defaultPollTimeoutMillis- default amount of time to poll for events if- defaultTimeoutMillisisn't preempted by an asynchronous event.
 
 - 
TestEnvironmentpublic TestEnvironment(long defaultTimeoutMillis, long defaultNoSignalsTimeoutMillis) Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests.- Parameters:
- defaultTimeoutMillis- default timeout to be used in all expect* methods
- defaultNoSignalsTimeoutMillis- default timeout to be used when no further signals are expected anymore
 
 - 
TestEnvironmentpublic TestEnvironment(long defaultTimeoutMillis) Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests.- Parameters:
- defaultTimeoutMillis- default timeout to be used in all expect* methods
 
 - 
TestEnvironmentpublic TestEnvironment(boolean printlnDebug) Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests. The default timeout for all expect* methods will be obtained by either the env variableDEFAULT_TIMEOUT_MILLISor the default value (DEFAULT_TIMEOUT_MILLIS) will be used.- Parameters:
- printlnDebug- if true, signals such as OnNext / Request / OnComplete etc will be printed to standard output, often helpful to pinpoint simple race conditions etc.
 
 - 
TestEnvironmentpublic TestEnvironment() Tests must specify the timeout for expected outcome of asynchronous interactions. Longer timeout does not invalidate the correctness of the implementation, but can in some cases result in longer time to run the tests. The default timeout for all expect* methods will be obtained by either the env variableDEFAULT_TIMEOUT_MILLISor the default value (DEFAULT_TIMEOUT_MILLIS) will be used.
 
- 
 - 
Method Detail- 
defaultTimeoutMillispublic long defaultTimeoutMillis() This timeout is used when waiting for a signal to arrive.
 - 
defaultNoSignalsTimeoutMillispublic long defaultNoSignalsTimeoutMillis() This timeout is used when asserting that no further signals are emitted. Note that this timeout default
 - 
defaultPollTimeoutMillispublic long defaultPollTimeoutMillis() The default amount of time to poll for events ifdefaultTimeoutMillisisn't preempted by an asynchronous event.
 - 
envDefaultTimeoutMillispublic static long envDefaultTimeoutMillis() Tries to parse the env variableDEFAULT_TIMEOUT_MILLISas long and returns the value if present OR its default value.- Throws:
- java.lang.IllegalArgumentException- when unable to parse the env variable
 
 - 
envDefaultNoSignalsTimeoutMillispublic static long envDefaultNoSignalsTimeoutMillis() Tries to parse the env variableDEFAULT_NO_SIGNALS_TIMEOUT_MILLISas long and returns the value if present OR its default value.- Throws:
- java.lang.IllegalArgumentException- when unable to parse the env variable
 
 - 
envDefaultPollTimeoutMillispublic static long envDefaultPollTimeoutMillis() Tries to parse the env variableDEFAULT_POLL_TIMEOUT_MILLIS_ENVas long and returns the value if present OR its default value.- Throws:
- java.lang.IllegalArgumentException- when unable to parse the env variable
 
 - 
floppublic void flop(java.lang.String msg) To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously. This method does *NOT* fail the test - it's up to inspections of the error to fail the test if required. Useenv.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 useexpectErrormethods or collect the error directly from the environment usingenv.dropAsyncError(). To clear asyncErrors you can callclearAsyncErrors()
 - 
floppublic 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. This method does *NOT* fail the test - it's up to inspections of the error to fail the test if required. This overload keeps the passed in throwable as the asyncError, instead of creating an AssertionError for this. Useenv.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 useexpectErrormethods or collect the error directly from the environment usingenv.dropAsyncError(). To clear asyncErrors you can callclearAsyncErrors()
 - 
floppublic void flop(java.lang.Throwable thr) To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously. This method does *NOT* fail the test - it's up to inspections of the error to fail the test if required. This overload keeps the passed in throwable as the asyncError, instead of creating an AssertionError for this. Useenv.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 useexpectErrormethods or collect the error directly from the environment usingenv.dropAsyncError(). To clear asyncErrors you can callclearAsyncErrors()
 - 
flopAndFailpublic <T> T flopAndFail(java.lang.String msg) To flop means to "fail asynchronously", either by onErroring or by failing some TCK check triggered asynchronously. This method DOES fail the test right away (it tries to, by throwing an AssertionException), in such it is different fromflop(java.lang.String)which only records the error. Useenv.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 useexpectErrormethods or collect the error directly from the environment usingenv.dropAsyncError(). To clear asyncErrors you can callclearAsyncErrors()
 - 
subscribepublic <T> void subscribe(org.reactivestreams.Publisher<T> pub, TestEnvironment.TestSubscriber<T> sub) throws java.lang.InterruptedException - Throws:
- java.lang.InterruptedException
 
 - 
subscribepublic <T> void subscribe(org.reactivestreams.Publisher<T> pub, TestEnvironment.TestSubscriber<T> sub, long timeoutMillis) throws java.lang.InterruptedException - Throws:
- java.lang.InterruptedException
 
 - 
newBlackholeSubscriberpublic <T> TestEnvironment.ManualSubscriber<T> newBlackholeSubscriber(org.reactivestreams.Publisher<T> pub) throws java.lang.InterruptedException - Throws:
- java.lang.InterruptedException
 
 - 
newManualSubscriberpublic <T> TestEnvironment.ManualSubscriber<T> newManualSubscriber(org.reactivestreams.Publisher<T> pub) throws java.lang.InterruptedException - Throws:
- java.lang.InterruptedException
 
 - 
newManualSubscriberpublic <T> TestEnvironment.ManualSubscriber<T> newManualSubscriber(org.reactivestreams.Publisher<T> pub, long timeoutMillis) throws java.lang.InterruptedException - Throws:
- java.lang.InterruptedException
 
 - 
clearAsyncErrorspublic void clearAsyncErrors() 
 - 
dropAsyncErrorpublic java.lang.Throwable dropAsyncError() 
 - 
verifyNoAsyncErrorspublic void verifyNoAsyncErrors() Waits fordefaultNoSignalsTimeoutMillis()and then verifies that no asynchronous errors were signalled pior to, or during that time (by callingflop()).
 - 
verifyNoAsyncErrorspublic void verifyNoAsyncErrors(long delay) This version ofverifyNoAsyncErrorsshould be used when errors still could be signalled asynchronously duringdefaultTimeoutMillis()time. It will immediatly check if any async errors were signaled (usingflop(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.
 - 
verifyNoAsyncErrorsNoDelaypublic void verifyNoAsyncErrorsNoDelay() Verifies that no asynchronous errors were signalled pior to calling this method (by callingflop()). This version of verifyNoAsyncError does not wait before checking for asynchronous errors, and is to be used for example in tight loops etc.
 - 
debugpublic void debug(java.lang.String msg) IfTestEnvironment#printlnDebugis true, print debug message to std out.
 - 
debugEnabledpublic final boolean debugEnabled() 
 - 
findCallerMethodInStackTracepublic Optional<java.lang.StackTraceElement> findCallerMethodInStackTrace(java.lang.String method) Looks for givenmethodmethod in stack trace. Can be used to answer questions like "was this method called from onComplete?".- Returns:
- the caller's StackTraceElement at which he the looked for method was found in the call stack, EMPTY otherwise
 
 
- 
 
-