Class PublisherVerification<T>
- All Implemented Interfaces:
PublisherVerificationRules
- Direct Known Subclasses:
FlowPublisherVerification
Publisher
specification rules.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private final TestEnvironment
private static final String
private final long
The amount of time after which a cancelled Subscriber reference should be dropped.static final String
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new verification class using the given env and configuration.PublisherVerification
(TestEnvironment env, long publisherReferenceGCTimeoutMillis) Constructs a new verification class using the given env and configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activePublisherTest
(long elements, boolean completionSignalRequired, PublisherVerification.PublisherTestRun<T> body) Test for feature that SHOULD/MUST be implemented, using a live publisher.long
In order to verify rule 3.3 of the reactive streams spec, this number will be used to check if aSubscription
actually solves the "unbounded recursion" problem by not allowing the number of recursive calls to exceed the number returned by this method.By implementing this method, additional TCK tests concerning a "failed" publishers will be run.createPublisher
(long elements) This is the main method you must implement in your test incarnation.static long
Tries to parse the env variablePUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS
as long and returns the value if present, OR its default value (DEFAULT_PUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS
).long
Override and return lower value if your Publisher is only able to produce a known number of elements.void
void
notVerified
(String message) void
Asks for an errorPublisher
that should callonSubscribe
exactly once followed by a single call toonError()
without receiving any requests and otherwise not throwing any exception.void
Asks for an emptyPublisher
(i.e., length 0) and verifies it completes in a timely manner.void
Asks for a single-elementPublisher
and subscribes to it twice, without consuming with eitherSubscriber
instance (i.e., no requests are issued).void
Asks for a shortPublisher
(length 3), subscribes 3Subscriber
s to it, requests more than the length items upfront with each and verifies they all received the same items in the same order (but does not verify they all complete).void
Asks for a shortPublisher
(length 3), subscribes 3Subscriber
s to it, requests more than the length items upfront with each and verifies they all received the same items in the same order followed by anonComplete
signal.void
Asks for a shortPublisher
(length 5), subscribes 3Subscriber
s to it, requests with different patterns and checks if all 3 received the same events in the same order.void
Asks for a single-elementPublisher
and subscribes to it twice.void
Asks for a shortPublisher
(length 10) and issues a random, negativerequest()
call which should trigger anonError
call with anIllegalArgumentException
.void
optionalActivePublisherTest
(long elements, boolean completionSignalRequired, PublisherVerification.PublisherTestRun<T> body) Test for feature that MAY be implemented.void
void
potentiallyPendingTest
(Publisher<T> pub, PublisherVerification.PublisherTestRun<T> body, String message) long
Return this value frommaxElementsFromPublisher()
to mark that the givenPublisher
, is not able to signal completion.void
Asks for aPublisher
that should emit exactly one item and complete (both within a timeout specified byTestEnvironment.defaultTimeoutMillis()
) in response to a request(1).void
Asks for aPublisher
that should emit exactly three items and complete (all within a timeout specified byTestEnvironment.defaultTimeoutMillis()
).void
Asks for aPublisher
that responds to a request pattern of 0 (not requesting upfront), 1, 1 and 2 in a timely manner.void
Asks for a shortPublisher
and verifies that requesting once and with more than the length (but bounded) results in the correct number of items to be emitted (i.e., length 3 and request 10) followed by anonComplete
signal.void
Asks for a shortPublisher
(i.e., length 3) and verifies, after requesting one by one, the sequence completes normally.void
Asks for a single-elementPublisher
and checks if requesting after the terminal event doesn't lead to more items or terminal signals to be emitted.void
Asks for an errorPublisher
that should callonSubscribe
exactly once followed by a single call toonError()
without receiving any requests.void
Asks for an emptyPublisher
and verifies ifonSubscribe
signal was emitted before any otheronNext
,onError
oronComplete
signal.void
Asks for an emptyPublisher
and callssubscribe
on it withnull
that should result in aNullPointerException
to be thrown.void
Asks for a shortPublisher
(length 6), requests several times from withinonSubscribe
and then requests one-by-one fromonNext
.void
Asks for aPublisher
with length equal to the value returned byPublisherVerificationRules.required_validate_boundedDepthOfOnNextAndRequestRecursion()
plus 1, callsrequest(1)
externally and then from withinonNext
and checks if the stack depth did not increase beyond the amount permitted byPublisherVerificationRules.required_validate_boundedDepthOfOnNextAndRequestRecursion()
.void
Asks for a shortPublisher
(length 3) and verifies that cancelling without requesting anything, then requesting items should result in no signals to be emitted.void
Asks for a single-elementPublisher
and verifies that without requesting anything, cancelling the sequence multiple times should result in no signals to be emitted and should result in an thrown exception.void
Asks for a shortPublisher
(length 10) and issues a random, negativerequest()
call which should trigger anonError
call with anIllegalArgumentException
.void
Asks for a shortPublisher
(length 10) and issues arequest(0)
which should trigger anonError
call with anIllegalArgumentException
.void
Asks for a shortPublisher
(length 20), requests some items (less than the length), consumes one item then cancels the sequence and verifies the publisher emitted at most the requested amount and stopped emitting (or terminated).void
Asks for a shortPublisher
(length 3) requests and consumes one element from it, cancels theSubscription
, callsSystem.gc()
and then checks if all references to the testSubscriber
has been dropped (by checking theWeakReference
has been emptied).void
Asks for a very longPublisher
(up toInteger.MAX_VALUE
), requestsLong.MAX_VALUE - 1
after each received item and expects no failure due to a potential overflow in the pending emission count while consuming 10 items and cancelling the sequence.void
Asks for a shortPublisher
(length 3) and requestsLong.MAX_VALUE
from it in total (split across twoLong.MAX_VALUE / 2
and onerequest(1)
), verifying that thePublisher
emits all of its items and completes normally.void
Asks for a shortPublisher
(length 3) and requestsLong.MAX_VALUE
from it, verifying that thePublisher
emits all of its items and completes normally and does not keep spinning attempting to fulfill theLong.MAX_VALUE
demand by some means.void
Validates that the override ofboundedDepthOfOnNextAndRequestRecursion()
returns a positive value.void
Validates that the override ofmaxElementsFromPublisher()
returns a non-negative value.void
setUp()
boolean
Override and returntrue
in order to skip executing tests marked asStochastic
.void
Asks for a shortPublisher
(i.e., length 10), repeatedly subscribes to thisPublisher
, requests items one by one and verifies thePublisher
calls theonXXX
methods non-overlappingly.void
stochasticTest
(int n, Function<Integer, Void> body) Executes a given test bodyn
times.void
Currently, this test is skipped because it is unclear this rule can be effectively checked on aPublisher
instance without looking into or hooking into the implementation of it.void
Currently, this test is skipped, although it is possible to validate an errorPublisher
along the same lines asPublisherVerificationRules.required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled()
.void
Currently, this test is skipped because there was no agreement on how to verify its "eventually" requirement.void
Currently, this test is skipped because there is no common agreement on what is to be considered a fatal exception and besides,Publisher.subscribe
is only allowed throw aNullPointerException
and any other exception would require looking into or hooking into the implementation of thePublisher
.void
Currently, this test is skipped because enforcing rule ยง1.10 requires unlimited retention and reference-equal checks on all incomingSubscriber
which is generally infeasible, plus reusing the sameSubscriber
instance is better detected (or ignored) insideSubscriber.onSubscribe
when the method is called multiple times.void
Currently, this test is skipped because arequest
could enter into a synchronous computation viaonNext
legally and otherwise there is no common agreement how to detect such heavy computation reliably.void
Currently, this test is skipped because there is no reliable agreed upon way to detect a heavy computation.void
Additional test for Publisher in error state
-
Field Details
-
PUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS_ENV
- See Also:
-
DEFAULT_PUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS
private static final long DEFAULT_PUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS- See Also:
-
env
-
publisherReferenceGCTimeoutMillis
private final long publisherReferenceGCTimeoutMillisThe amount of time after which a cancelled Subscriber reference should be dropped. See Rule 3.13 for details. -
SKIPPING_NO_ERROR_PUBLISHER_AVAILABLE
- See Also:
-
SKIPPING_OPTIONAL_TEST_FAILED
- See Also:
-
-
Constructor Details
-
PublisherVerification
Constructs a new verification class using the given env and configuration.- Parameters:
publisherReferenceGCTimeoutMillis
- used to determine after how much time a reference to a Subscriber should be already dropped by the Publisher.
-
PublisherVerification
Constructs a new verification class using the given env and configuration. The value forpublisherReferenceGCTimeoutMillis
will be obtained by usingenvPublisherReferenceGCTimeoutMillis()
.
-
-
Method Details
-
envPublisherReferenceGCTimeoutMillis
public static long envPublisherReferenceGCTimeoutMillis()Tries to parse the env variablePUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS
as long and returns the value if present, OR its default value (DEFAULT_PUBLISHER_REFERENCE_GC_TIMEOUT_MILLIS
). This value is used to determine after how much time a reference to a Subscriber should be already dropped by the Publisher.- Throws:
IllegalArgumentException
- when unable to parse the env variable
-
createPublisher
This is the main method you must implement in your test incarnation. It must create a Publisher for a stream with exactly the given number of elements. If `elements` is `Long.MAX_VALUE` the produced stream must be infinite. -
createFailedPublisher
By implementing this method, additional TCK tests concerning a "failed" publishers will be run. The expected behaviour of thePublisher
returned by this method is hand out a subscription, followed by signallingonError
on it, as specified by Rule 1.9. If you ignore these additional tests, returnnull
from this method. -
maxElementsFromPublisher
public long maxElementsFromPublisher()Override and return lower value if your Publisher is only able to produce a known number of elements. For example, if it is designed to return at-most-one element, return1
from this method. Defaults toLong.MAX_VALUE - 1
, meaning that the Publisher can be produce a huge but NOT an unbounded number of elements. To mark your Publisher will *never* signal anonComplete
override this method and returnLong.MAX_VALUE
, which will result in *skipping all tests which require an onComplete to be triggered* (!). -
skipStochasticTests
public boolean skipStochasticTests()Override and returntrue
in order to skip executing tests marked asStochastic
. Stochastic in this case means that the Rule is impossible or infeasible to deterministically verifyโ usually this means that this test case can yield false positives ("be green") even if for some case, the given implementation may violate the tested behaviour. -
boundedDepthOfOnNextAndRequestRecursion
public long boundedDepthOfOnNextAndRequestRecursion()In order to verify rule 3.3 of the reactive streams spec, this number will be used to check if aSubscription
actually solves the "unbounded recursion" problem by not allowing the number of recursive calls to exceed the number returned by this method.- See Also:
-
setUp
- Throws:
Exception
-
required_createPublisher1MustProduceAStreamOfExactly1Element
Description copied from interface:PublisherVerificationRules
Asks for aPublisher
that should emit exactly one item and complete (both within a timeout specified byTestEnvironment.defaultTimeoutMillis()
) in response to a request(1).The test is not executed if
maxElementsFromPublisher()
returns zero. If this test fails, the following could be checked within thePublisher
implementation:- the
Publisher.subscribe(Subscriber)
method has actual implementation, - in the
Publisher.subscribe(Subscriber)
method, if there is an upstreamPublisher
, thatPublisher
is actually subscribed to, - if the
Publisher
is part of a chain, all elements actually issue arequest()
call in response to the test subscriber or by default to their upstream, - in the
Publisher.subscribe(Subscriber)
method, theSubscriber.onSubscribe
is called as part of the preparation process (usually before subscribing to otherPublisher
s), - if the
Publisher
implementation works for a consumer that callsrequest(1)
, - if the
Publisher
implementation is able to emit anonComplete
without requests, - that the
Publisher
implementation does not emit more than the allowed elements (exactly one).
- Specified by:
required_createPublisher1MustProduceAStreamOfExactly1Element
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_createPublisher3MustProduceAStreamOfExactly3Elements
Description copied from interface:PublisherVerificationRules
Asks for aPublisher
that should emit exactly three items and complete (all within a timeout specified byTestEnvironment.defaultTimeoutMillis()
).The test is not executed if
maxElementsFromPublisher()
is less than 3.The tests requests one-by-one and verifies each single response item arrives in time.
If this test fails, the following could be checked within the
Publisher
implementation:- the
Publisher.subscribe(Subscriber)
method has actual implementation, - in the
Publisher.subscribe(Subscriber)
method, if there is an upstreamPublisher
, thatPublisher
is actually subscribed to, - if the
Publisher
is part of a chain, all elements actually issue arequest()
call in response to the test subscriber or by default to their upstream, - in the
Publisher.subscribe(Subscriber)
method, theSubscriber.onSubscribe
is called as part of the preparation process (usually before subscribing to otherPublisher
s), - if the
Publisher
implementation works for a subscriber that callsrequest(1)
after consuming an item, - if the
Publisher
implementation is able to emit anonComplete
without requests.
- Specified by:
required_createPublisher3MustProduceAStreamOfExactly3Elements
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_validate_maxElementsFromPublisher
Description copied from interface:PublisherVerificationRules
Validates that the override ofmaxElementsFromPublisher()
returns a non-negative value.- Specified by:
required_validate_maxElementsFromPublisher
in interfacePublisherVerificationRules
- Throws:
Exception
-
required_validate_boundedDepthOfOnNextAndRequestRecursion
Description copied from interface:PublisherVerificationRules
Validates that the override ofboundedDepthOfOnNextAndRequestRecursion()
returns a positive value.- Specified by:
required_validate_boundedDepthOfOnNextAndRequestRecursion
in interfacePublisherVerificationRules
- Throws:
Exception
-
required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements
public void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for aPublisher
that responds to a request pattern of 0 (not requesting upfront), 1, 1 and 2 in a timely manner.Verifies rule: 1.1
The test is not executed if
maxElementsFromPublisher()
is less than 5.This test ensures that the
Publisher
implementation correctly responds torequest()
calls that in total are less than the number of elements thisPublisher
could emit (thus the completion event won't be emitted).If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- Specified by:
required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec102_maySignalLessThanRequestedAndTerminateSubscription
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
and verifies that requesting once and with more than the length (but bounded) results in the correct number of items to be emitted (i.e., length 3 and request 10) followed by anonComplete
signal.Verifies rule: 1.2
The test is not executed if
maxElementsFromPublisher()
is less than 3.This test ensures that the
Publisher
implementation can deal with larger requests than the number of items it can produce.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass.
- Specified by:
required_spec102_maySignalLessThanRequestedAndTerminateSubscription
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
stochastic_spec103_mustSignalOnMethodsSequentially
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(i.e., length 10), repeatedly subscribes to thisPublisher
, requests items one by one and verifies thePublisher
calls theonXXX
methods non-overlappingly.Verifies rule: 1.3
The test is not executed if
maxElementsFromPublisher()
is less than 10.Note that this test is probabilistic, that is, may not capture any concurrent invocation in a {code Publisher} implementation. Note also that this test is sensitive to cases when a
request()
call inonSubscribe()
triggers an asynchronous call to the otheronXXX
methods. In contrast, the test allows synchronous call chain ofonSubscribe -> request -> onNext
.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if a
request()
call fromonSubscribe()
could trigger an asynchronous call toonNext()
and if so, make sure suchrequest()
calls are deferred until the call toonSubscribe()
returns normally.
- Specified by:
stochastic_spec103_mustSignalOnMethodsSequentially
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
optional_spec104_mustSignalOnErrorWhenFails
Description copied from interface:PublisherVerificationRules
Asks for an errorPublisher
that should callonSubscribe
exactly once followed by a single call toonError()
without receiving any requests and otherwise not throwing any exception.Verifies rule: 1.4
The test is not executed if
PublisherVerification.createErrorPublisher()
returns null.If this test fails, the following could be checked within the error
Publisher
implementation:- the
Publisher.subscribe(Subscriber)
method has actual implementation, - in the
Publisher.subscribe(Subscriber)
method, if there is an upstreamPublisher
, thatPublisher
is actually subscribed to, - if the
Publisher
implementation does signal anonSubscribe
before signallingonError
, - if the
Publisher
implementation is able to emit anonError
without requests, - if the
Publisher
is non-empty as this test requires aPublisher
to signal anonError
eagerly.
- Specified by:
optional_spec104_mustSignalOnErrorWhenFails
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(i.e., length 3) and verifies, after requesting one by one, the sequence completes normally.Verifies rule: 1.5
The test is not executed if
maxElementsFromPublisher()
is less than 3.Note that the tests requests 1 after the items have been received and before expecting an
onComplete
signal.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass,
- Specified by:
required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
optional_spec105_emptyStreamMustTerminateBySignallingOnComplete
Description copied from interface:PublisherVerificationRules
Asks for an emptyPublisher
(i.e., length 0) and verifies it completes in a timely manner.Verifies rule: 1.5
Note that the tests requests 1 before expecting an
onComplete
signal.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - if the
Publisher
is non-empty as this test requires aPublisher
without items.
- Specified by:
optional_spec105_emptyStreamMustTerminateBySignallingOnComplete
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled
public void untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws ThrowableDescription copied from interface:PublisherVerificationRules
Currently, this test is skipped because it is unclear this rule can be effectively checked on aPublisher
instance without looking into or hooking into the implementation of it.Verifies rule: 1.6
- Specified by:
untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled
in interfacePublisherVerificationRules
- Throws:
Throwable
-
required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled
public void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a single-elementPublisher
and checks if requesting after the terminal event doesn't lead to more items or terminal signals to be emitted.Verifies rule: 1.7
The test is not executed if
maxElementsFromPublisher()
is less than 1.The tests requests more items than the expected
Publisher
length upfront and some more items after its completion.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - the indication for the terminal state is properly persisted and a request call can't trigger emission of more items or another terminal signal.
- Specified by:
required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled
public void untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws ThrowableDescription copied from interface:PublisherVerificationRules
Currently, this test is skipped, although it is possible to validate an errorPublisher
along the same lines asPublisherVerificationRules.required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled()
.Verifies rule: 1.7
- Specified by:
untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled
in interfacePublisherVerificationRules
- Throws:
Throwable
-
untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals
public void untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws ThrowableDescription copied from interface:PublisherVerificationRules
Currently, this test is skipped because there was no agreement on how to verify its "eventually" requirement.Verifies rule: 1.8
- Specified by:
untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals
in interfacePublisherVerificationRules
- Throws:
Throwable
-
untested_spec109_subscribeShouldNotThrowNonFatalThrowable
Description copied from interface:PublisherVerificationRules
Currently, this test is skipped because there is no common agreement on what is to be considered a fatal exception and besides,Publisher.subscribe
is only allowed throw aNullPointerException
and any other exception would require looking into or hooking into the implementation of thePublisher
.Verifies rule: 1.9
- Specified by:
untested_spec109_subscribeShouldNotThrowNonFatalThrowable
in interfacePublisherVerificationRules
- Throws:
Throwable
-
required_spec109_subscribeThrowNPEOnNullSubscriber
Description copied from interface:PublisherVerificationRules
Asks for an emptyPublisher
and callssubscribe
on it withnull
that should result in aNullPointerException
to be thrown.Verifies rule: 1.9
If this test fails, check if the
subscribe()
implementation has an explicit null check (or a method dereference on theSubscriber
), especially if the incomingSubscriber
is wrapped or stored to be used later.- Specified by:
required_spec109_subscribeThrowNPEOnNullSubscriber
in interfacePublisherVerificationRules
- Throws:
Throwable
-
required_spec109_mustIssueOnSubscribeForNonNullSubscriber
Description copied from interface:PublisherVerificationRules
Asks for an emptyPublisher
and verifies ifonSubscribe
signal was emitted before any otheronNext
,onError
oronComplete
signal.Verifies rule: 1.9
Note that this test doesn't request anything, however, an
onNext
is not considered as a failure.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - the
Publisher.subscribe(Subscriber)
method has actual implementation, - in the
Publisher.subscribe(Subscriber)
method, if there is an upstreamPublisher
, thatPublisher
is actually subscribed to, - in the
Publisher.subscribe(Subscriber)
method, theSubscriber.onSubscribe
is called as part of the preparation process (usually before subscribing to otherPublisher
s).
- Specified by:
required_spec109_mustIssueOnSubscribeForNonNullSubscriber
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec109_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorAfterOnSubscribe
public void required_spec109_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorAfterOnSubscribe() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for an errorPublisher
that should callonSubscribe
exactly once followed by a single call toonError()
without receiving any requests.Verifies rule: 1.9
The test is not executed if
PublisherVerification.createErrorPublisher()
returns null.The difference between this test and
PublisherVerificationRules.optional_spec104_mustSignalOnErrorWhenFails()
is that there is no explicit verification if exceptions were thrown in addition to the regularonSubscribe+onError
signal pair.If this test fails, the following could be checked within the error
Publisher
implementation:- the
Publisher.subscribe(Subscriber)
method has actual implementation, - in the
Publisher.subscribe(Subscriber)
method, if there is an upstreamPublisher
, thatPublisher
is actually subscribed to, - if the
Publisher
implementation is able to emit anonError
without requests, - if the
Publisher
is non-empty as this test expects aPublisher
without items.
- the
-
untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice
public void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws ThrowableDescription copied from interface:PublisherVerificationRules
Currently, this test is skipped because enforcing rule ยง1.10 requires unlimited retention and reference-equal checks on all incomingSubscriber
which is generally infeasible, plus reusing the sameSubscriber
instance is better detected (or ignored) insideSubscriber.onSubscribe
when the method is called multiple times.Verifies rule: 1.10
- Specified by:
untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice
in interfacePublisherVerificationRules
- Throws:
Throwable
-
optional_spec111_maySupportMultiSubscribe
Description copied from interface:PublisherVerificationRules
Asks for a single-elementPublisher
and subscribes to it twice, without consuming with eitherSubscriber
instance (i.e., no requests are issued).Verifies rule: 1.11
The test is not executed if
maxElementsFromPublisher()
is less than 1.Note that this test ignores what signals the
Publisher
emits. Any exception thrown through non-regular means will indicate a skipped test.- Specified by:
optional_spec111_maySupportMultiSubscribe
in interfacePublisherVerificationRules
- Throws:
Throwable
-
optional_spec111_registeredSubscribersMustReceiveOnNextOrOnCompleteSignals
public void optional_spec111_registeredSubscribersMustReceiveOnNextOrOnCompleteSignals() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a single-elementPublisher
and subscribes to it twice. EachSubscriber
requests for 1 element and checks if onNext or onComplete signals was received.Verifies rule: 1.11, and depends on valid implementation of rule 1.5 in order to verify this.
The test is not executed if
maxElementsFromPublisher()
is less than 1.Any exception thrown through non-regular means will indicate a skipped test.
- Specified by:
optional_spec111_registeredSubscribersMustReceiveOnNextOrOnCompleteSignals
in interfacePublisherVerificationRules
- Throws:
Throwable
-
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 5), subscribes 3Subscriber
s to it, requests with different patterns and checks if all 3 received the same events in the same order.Verifies rule: 1.11
The test is not executed if
maxElementsFromPublisher()
is less than 5.The request pattern for the first
Subscriber
is (1, 1, 2, 1); for the second is (2, 3) and for the third is (3, 1, 1).Note that this test requires a
Publisher
that always emits the same signals to anySubscriber
, regardless of when they subscribe and how they request elements. I.e., a "live"Publisher
emitting the current time would not pass this test.Note that this test is optional and may appear skipped even if the behavior should be actually supported by the
Publisher
, see the skip message for an indication of this.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- Specified by:
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 3), subscribes 3Subscriber
s to it, requests more than the length items upfront with each and verifies they all received the same items in the same order (but does not verify they all complete).Verifies rule: 1.11
The test is not executed if
maxElementsFromPublisher()
is less than 3.Note that this test requires a
Publisher
that always emits the same signals to anySubscriber
, regardless of when they subscribe and how they request elements. I.e., a "live"Publisher
emitting the current time would not pass this test.Note that this test is optional and may appear skipped even if the behavior should be actually supported by the
Publisher
, see the skip message for an indication of this.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- the
-
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 3), subscribes 3Subscriber
s to it, requests more than the length items upfront with each and verifies they all received the same items in the same order followed by anonComplete
signal.Verifies rule: 1.11
The test is not executed if
maxElementsFromPublisher()
is less than 3.Note that this test requires a
Publisher
that always emits the same signals to anySubscriber
, regardless of when they subscribe and how they request elements. I.e., a "live"Publisher
emitting the current time would not pass this test.Note that this test is optional and may appear skipped even if the behavior should be actually supported by the
Publisher
, see the skip message for an indication of this.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- the
-
required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe
public void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 6), requests several times from withinonSubscribe
and then requests one-by-one fromonNext
.Verifies rule: 3.2
The test is not executed if
maxElementsFromPublisher()
is less than 6.The request pattern is 3 x 1 from within
onSubscribe
and one from within eachonNext
invocation.The test consumes the
Publisher
but otherwise doesn't verify thePublisher
completes (however, it checks for errors).If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- Specified by:
required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec303_mustNotAllowUnboundedRecursion
Description copied from interface:PublisherVerificationRules
Asks for aPublisher
with length equal to the value returned byPublisherVerificationRules.required_validate_boundedDepthOfOnNextAndRequestRecursion()
plus 1, callsrequest(1)
externally and then from withinonNext
and checks if the stack depth did not increase beyond the amount permitted byPublisherVerificationRules.required_validate_boundedDepthOfOnNextAndRequestRecursion()
.Verifies rule: 3.3
The test is not executed if
maxElementsFromPublisher()
is less thanPublisherVerificationRules.required_validate_boundedDepthOfOnNextAndRequestRecursion()
plus 1.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the implementation doesn't allow unbounded recursion when
request()
is called from withinonNext
, i.e., the lack of reentrant-safe state machine around the request amount (such as a for loop with a bound on the parametern
that callsonNext
).
- Specified by:
required_spec303_mustNotAllowUnboundedRecursion
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
untested_spec304_requestShouldNotPerformHeavyComputations
Description copied from interface:PublisherVerificationRules
Currently, this test is skipped because arequest
could enter into a synchronous computation viaonNext
legally and otherwise there is no common agreement how to detect such heavy computation reliably.Verifies rule: 3.4
- Specified by:
untested_spec304_requestShouldNotPerformHeavyComputations
in interfacePublisherVerificationRules
- Throws:
Exception
-
untested_spec305_cancelMustNotSynchronouslyPerformHeavyComputation
Description copied from interface:PublisherVerificationRules
Currently, this test is skipped because there is no reliable agreed upon way to detect a heavy computation.Verifies rule: 3.5
- Specified by:
untested_spec305_cancelMustNotSynchronouslyPerformHeavyComputation
in interfacePublisherVerificationRules
- Throws:
Exception
-
required_spec306_afterSubscriptionIsCancelledRequestMustBeNops
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 3) and verifies that cancelling without requesting anything, then requesting items should result in no signals to be emitted.Verifies rule: 3.6
The test is not executed if
maxElementsFromPublisher()
is less than 3.The post-cancellation request pattern is (1, 1, 1).
If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the cancellation indicator flag is properly persisted (may require volatile) and checked as part of the signal emission process.
- Specified by:
required_spec306_afterSubscriptionIsCancelledRequestMustBeNops
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops
public void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a single-elementPublisher
and verifies that without requesting anything, cancelling the sequence multiple times should result in no signals to be emitted and should result in an thrown exception.Verifies rule: 3.7
The test is not executed if
maxElementsFromPublisher()
is less than 1.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the cancellation indicator flag is properly persisted (may require volatile) and checked as part of the signal emission process.
- Specified by:
required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec309_requestZeroMustSignalIllegalArgumentException
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 10) and issues arequest(0)
which should trigger anonError
call with anIllegalArgumentException
.Verifies rule: 3.9
The test is not executed if
maxElementsFromPublisher()
is less than 10.Note that this test expects the
IllegalArgumentException
being signalled throughonError
, not by throwing fromrequest()
(which is also forbidden) or signalling the error by any other means (i.e., through theThread.currentThread().getUncaughtExceptionHandler()
for example).Note also that requesting and emission may happen concurrently and honoring this rule may require extra coordination within the
Publisher
.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the
Publisher
can emit anonError
in this particular case, even if there was no prior and legalrequest
call and even if thePublisher
would like to emit items first before emitting anonError
in general.
- Specified by:
required_spec309_requestZeroMustSignalIllegalArgumentException
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec309_requestNegativeNumberMustSignalIllegalArgumentException
public void required_spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 10) and issues a random, negativerequest()
call which should trigger anonError
call with anIllegalArgumentException
.Verifies rule: 3.9
The test is not executed if
maxElementsFromPublisher()
is less than 10.Note that this test expects the
IllegalArgumentException
being signalled throughonError
, not by throwing fromrequest()
(which is also forbidden) or signalling the error by any other means (i.e., through theThread.currentThread().getUncaughtExceptionHandler()
for example).Note also that requesting and emission may happen concurrently and honoring this rule may require extra coordination within the
Publisher
.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the
Publisher
can emit anonError
in this particular case, even if there was no prior and legalrequest
call and even if thePublisher
would like to emit items first before emitting anonError
in general.
- Specified by:
required_spec309_requestNegativeNumberMustSignalIllegalArgumentException
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
optional_spec309_requestNegativeNumberMaySignalIllegalArgumentExceptionWithSpecificMessage
public void optional_spec309_requestNegativeNumberMaySignalIllegalArgumentExceptionWithSpecificMessage() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 10) and issues a random, negativerequest()
call which should trigger anonError
call with anIllegalArgumentException
.Verifies rule: 3.9
The test is not executed if
maxElementsFromPublisher()
is less than 10.Note that this test expects the
IllegalArgumentException
being signalled throughonError
, not by throwing fromrequest()
(which is also forbidden) or signalling the error by any other means (i.e., through theThread.currentThread().getUncaughtExceptionHandler()
for example).Note also that requesting and emission may happen concurrently and honoring this rule may require extra coordination within the
Publisher
.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the
Publisher
can emit anonError
in this particular case, even if there was no prior and legalrequest
call and even if thePublisher
would like to emit items first before emitting anonError
in general.
- Specified by:
optional_spec309_requestNegativeNumberMaySignalIllegalArgumentExceptionWithSpecificMessage
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 20), requests some items (less than the length), consumes one item then cancels the sequence and verifies the publisher emitted at most the requested amount and stopped emitting (or terminated).Verifies rule: 3.12
The test is not executed if
maxElementsFromPublisher()
is less than 20.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the cancellation indicator flag is properly persisted (may require volatile) and checked as part of the signal emission process.
- Specified by:
required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber
public void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 3) requests and consumes one element from it, cancels theSubscription
, callsSystem.gc()
and then checks if all references to the testSubscriber
has been dropped (by checking theWeakReference
has been emptied).Verifies rule: 3.13
The test is not executed if
maxElementsFromPublisher()
is less than 3.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - the cancellation indicator flag is properly persisted (may require volatile) and checked as part of the signal emission process.
- the
Publisher
stores theSubscriber
reference somewhere which is then not cleaned up when theSubscriber
is cancelled. Note that this may happen on many code paths in aPublisher
, for example in an emission loop that terminates because of thecancel
signal or because reaching a terminal state. Note also that eagerly nullingSubscriber
references may not be necessary for this test to pass in case there is a self-contained chain of them (i.e.,Publisher.subscribe()
creates a chain of freshSubscriber
instances where each of them only references their downstreamSubscriber
thus the chain can get GC'd when the reference to the finalSubscriber
is dropped).
- Specified by:
required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec317_mustSupportAPendingElementCountUpToLongMaxValue
Description copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 3) and requestsLong.MAX_VALUE
from it, verifying that thePublisher
emits all of its items and completes normally and does not keep spinning attempting to fulfill theLong.MAX_VALUE
demand by some means.Verifies rule: 3.17
The test is not executed if
maxElementsFromPublisher()
is less than 3.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- Specified by:
required_spec317_mustSupportAPendingElementCountUpToLongMaxValue
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue
public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws ThrowableDescription copied from interface:PublisherVerificationRules
Asks for a shortPublisher
(length 3) and requestsLong.MAX_VALUE
from it in total (split across twoLong.MAX_VALUE / 2
and onerequest(1)
), verifying that thePublisher
emits all of its items and completes normally.Verifies rule: 3.17
The test is not executed if
maxElementsFromPublisher()
is less than 3.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
implements adding individual request amounts together properly (not overflowing into zero or negative pending request amounts) or not properly deducing the number of emitted items from the pending amount, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- Specified by:
required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue
Description copied from interface:PublisherVerificationRules
Asks for a very longPublisher
(up toInteger.MAX_VALUE
), requestsLong.MAX_VALUE - 1
after each received item and expects no failure due to a potential overflow in the pending emission count while consuming 10 items and cancelling the sequence.Verifies rule: 3.17
The test is not executed if
maxElementsFromPublisher()
is less thanInteger.MAX_VALUE
.The request pattern is one
request(1)
upfront and tenrequest(Long.MAX_VALUE - 1)
after.If this test fails, the following could be checked within the
Publisher
implementation:- the
TestEnvironment
has large enough timeout specified in case thePublisher
has some time-delay behavior, - make sure the
PublisherVerificationRules.required_createPublisher1MustProduceAStreamOfExactly1Element()
andPublisherVerificationRules.required_createPublisher3MustProduceAStreamOfExactly3Elements()
tests pass, - if the
Publisher
implementation considers the cumulative request amount it receives, - if the
Publisher
implements adding individual request amounts together properly (not overflowing into zero or negative pending request amounts) or not properly deducing the number of emitted items from the pending amount, - if the
Publisher
doesn't lose anyrequest()
signal and the state transition from idle -> emitting or emitting -> keep emitting works properly.
- Specified by:
required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue
in interfacePublisherVerificationRules
- Throws:
Throwable
- the
-
activePublisherTest
public void activePublisherTest(long elements, boolean completionSignalRequired, PublisherVerification.PublisherTestRun<T> body) throws Throwable Test for feature that SHOULD/MUST be implemented, using a live publisher.- Parameters:
elements
- the number of elements the Publisher under test must be able to emit to run this testcompletionSignalRequired
- true if anonComplete
signal is required by this test to run. If the tested Publisher is unable to signal completion, tests requireing onComplete signals will be skipped. To signal if your Publisher is able to signal completion seemaxElementsFromPublisher()
.- Throws:
Throwable
-
optionalActivePublisherTest
public void optionalActivePublisherTest(long elements, boolean completionSignalRequired, PublisherVerification.PublisherTestRun<T> body) throws Throwable Test for feature that MAY be implemented. This test will be marked as SKIPPED if it fails.- Parameters:
elements
- the number of elements the Publisher under test must be able to emit to run this testcompletionSignalRequired
- true if anonComplete
signal is required by this test to run. If the tested Publisher is unable to signal completion, tests requireing onComplete signals will be skipped. To signal if your Publisher is able to signal completion seemaxElementsFromPublisher()
.- Throws:
Throwable
-
whenHasErrorPublisherTest
public void whenHasErrorPublisherTest(PublisherVerification.PublisherTestRun<T> body) throws Throwable Additional test for Publisher in error state- Throws:
Throwable
-
potentiallyPendingTest
public void potentiallyPendingTest(Publisher<T> pub, PublisherVerification.PublisherTestRun<T> body) throws Throwable - Throws:
Throwable
-
potentiallyPendingTest
public void potentiallyPendingTest(Publisher<T> pub, PublisherVerification.PublisherTestRun<T> body, String message) throws Throwable - Throws:
Throwable
-
stochasticTest
Executes a given test bodyn
times. All the test runs must pass in order for the stochastic test to pass.- Throws:
Throwable
-
notVerified
public void notVerified() -
publisherUnableToSignalOnComplete
public long publisherUnableToSignalOnComplete()Return this value frommaxElementsFromPublisher()
to mark that the givenPublisher
, is not able to signal completion. For example it is strictly a time-bound or unbounded source of data. Returning this value frommaxElementsFromPublisher()
will result in skipping all TCK tests which require onComplete signals! -
notVerified
-