public abstract class PublisherVerification<T> extends java.lang.Object implements PublisherVerificationRules
Publisher specification rules.Publisher| Modifier and Type | Class and Description |
|---|---|
static interface |
PublisherVerification.PublisherTestRun<T> |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
SKIPPING_NO_ERROR_PUBLISHER_AVAILABLE |
static java.lang.String |
SKIPPING_OPTIONAL_TEST_FAILED |
| Constructor and Description |
|---|
PublisherVerification(TestEnvironment env)
Constructs 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.
|
public static final java.lang.String SKIPPING_NO_ERROR_PUBLISHER_AVAILABLE
public static final java.lang.String SKIPPING_OPTIONAL_TEST_FAILED
public PublisherVerification(TestEnvironment env, long publisherReferenceGCTimeoutMillis)
publisherReferenceGCTimeoutMillis - used to determine after how much time a reference to a Subscriber should be already dropped by the Publisher.public PublisherVerification(TestEnvironment env)
publisherReferenceGCTimeoutMillis will be obtained by using envPublisherReferenceGCTimeoutMillis().public static long envPublisherReferenceGCTimeoutMillis()
PUBLISHER_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.java.lang.IllegalArgumentException - when unable to parse the env variablepublic abstract org.reactivestreams.Publisher<T> createPublisher(long elements)
public abstract org.reactivestreams.Publisher<T> createFailedPublisher()
Publisher returned by this method is hand out a subscription,
followed by signalling onError on it, as specified by Rule 1.9.
If you ignore these additional tests, return null from this method.public long maxElementsFromPublisher()
1 from this method.
Defaults to Long.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 an onComplete override this method and return Long.MAX_VALUE,
which will result in *skipping all tests which require an onComplete to be triggered* (!).public boolean skipStochasticTests()
true in order to skip executing tests marked as Stochastic.
Such tests MAY sometimes fail even though the implpublic long boundedDepthOfOnNextAndRequestRecursion()
Subscription actually solves the "unbounded recursion" problem by not allowing the number of
recursive calls to exceed the number returned by this method.public void setUp() throws java.lang.Exception
java.lang.Exceptionpublic void required_createPublisher1MustProduceAStreamOfExactly1Element() throws java.lang.Throwable
required_createPublisher1MustProduceAStreamOfExactly1Element in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_createPublisher3MustProduceAStreamOfExactly3Elements() throws java.lang.Throwable
required_createPublisher3MustProduceAStreamOfExactly3Elements in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_validate_maxElementsFromPublisher() throws java.lang.Exception
required_validate_maxElementsFromPublisher in interface PublisherVerificationRulesjava.lang.Exceptionpublic void required_validate_boundedDepthOfOnNextAndRequestRecursion() throws java.lang.Exception
required_validate_boundedDepthOfOnNextAndRequestRecursion in interface PublisherVerificationRulesjava.lang.Exceptionpublic void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws java.lang.Throwable
required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec102_maySignalLessThanRequestedAndTerminateSubscription() throws java.lang.Throwable
required_spec102_maySignalLessThanRequestedAndTerminateSubscription in interface PublisherVerificationRulesjava.lang.Throwablepublic void stochastic_spec103_mustSignalOnMethodsSequentially() throws java.lang.Throwable
stochastic_spec103_mustSignalOnMethodsSequentially in interface PublisherVerificationRulesjava.lang.Throwablepublic void optional_spec104_mustSignalOnErrorWhenFails() throws java.lang.Throwable
optional_spec104_mustSignalOnErrorWhenFails in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates() throws java.lang.Throwable
required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates in interface PublisherVerificationRulesjava.lang.Throwablepublic void optional_spec105_emptyStreamMustTerminateBySignallingOnComplete() throws java.lang.Throwable
optional_spec105_emptyStreamMustTerminateBySignallingOnComplete in interface PublisherVerificationRulesjava.lang.Throwablepublic void untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws java.lang.Throwable
untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws java.lang.Throwable
required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled in interface PublisherVerificationRulesjava.lang.Throwablepublic void untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws java.lang.Throwable
untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled in interface PublisherVerificationRulesjava.lang.Throwablepublic void untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws java.lang.Throwable
untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals in interface PublisherVerificationRulesjava.lang.Throwablepublic void untested_spec109_subscribeShouldNotThrowNonFatalThrowable() throws java.lang.Throwable
untested_spec109_subscribeShouldNotThrowNonFatalThrowable in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec109_subscribeThrowNPEOnNullSubscriber() throws java.lang.Throwable
required_spec109_subscribeThrowNPEOnNullSubscriber in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec109_mustIssueOnSubscribeForNonNullSubscriber() throws java.lang.Throwable
required_spec109_mustIssueOnSubscribeForNonNullSubscriber in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec109_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorAfterOnSubscribe() throws java.lang.Throwable
required_spec109_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorAfterOnSubscribe in interface PublisherVerificationRulesjava.lang.Throwablepublic void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws java.lang.Throwable
untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice in interface PublisherVerificationRulesjava.lang.Throwablepublic void optional_spec111_maySupportMultiSubscribe() throws java.lang.Throwable
optional_spec111_maySupportMultiSubscribe in interface PublisherVerificationRulesjava.lang.Throwablepublic void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws java.lang.Throwable
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne in interface PublisherVerificationRulesjava.lang.Throwablepublic void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws java.lang.Throwable
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront in interface PublisherVerificationRulesjava.lang.Throwablepublic void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws java.lang.Throwable
optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws java.lang.Throwable
required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec303_mustNotAllowUnboundedRecursion() throws java.lang.Throwable
required_spec303_mustNotAllowUnboundedRecursion in interface PublisherVerificationRulesjava.lang.Throwablepublic void untested_spec304_requestShouldNotPerformHeavyComputations() throws java.lang.Exception
untested_spec304_requestShouldNotPerformHeavyComputations in interface PublisherVerificationRulesjava.lang.Exceptionpublic void untested_spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation() throws java.lang.Exception
untested_spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation in interface PublisherVerificationRulesjava.lang.Exceptionpublic void required_spec306_afterSubscriptionIsCancelledRequestMustBeNops() throws java.lang.Throwable
required_spec306_afterSubscriptionIsCancelledRequestMustBeNops in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws java.lang.Throwable
required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec309_requestZeroMustSignalIllegalArgumentException() throws java.lang.Throwable
required_spec309_requestZeroMustSignalIllegalArgumentException in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws java.lang.Throwable
required_spec309_requestNegativeNumberMustSignalIllegalArgumentException in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws java.lang.Throwable
required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws java.lang.Throwable
required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws java.lang.Throwable
required_spec317_mustSupportAPendingElementCountUpToLongMaxValue in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws java.lang.Throwable
required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue in interface PublisherVerificationRulesjava.lang.Throwablepublic void required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue() throws java.lang.Throwable
required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue in interface PublisherVerificationRulesjava.lang.Throwablepublic void activePublisherTest(long elements, boolean completionSignalRequired, PublisherVerification.PublisherTestRun<T> body) throws java.lang.Throwable
elements - the number of elements the Publisher under test must be able to emit to run this testcompletionSignalRequired - true if an onComplete 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 see maxElementsFromPublisher().java.lang.Throwablepublic void optionalActivePublisherTest(long elements, boolean completionSignalRequired, PublisherVerification.PublisherTestRun<T> body) throws java.lang.Throwable
elements - the number of elements the Publisher under test must be able to emit to run this testcompletionSignalRequired - true if an onComplete 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 see maxElementsFromPublisher().java.lang.Throwablepublic void whenHasErrorPublisherTest(PublisherVerification.PublisherTestRun<T> body) throws java.lang.Throwable
java.lang.Throwablepublic void potentiallyPendingTest(org.reactivestreams.Publisher<T> pub, PublisherVerification.PublisherTestRun<T> body) throws java.lang.Throwable
java.lang.Throwablepublic void potentiallyPendingTest(org.reactivestreams.Publisher<T> pub, PublisherVerification.PublisherTestRun<T> body, java.lang.String message) throws java.lang.Throwable
java.lang.Throwablepublic void stochasticTest(int n, Function<java.lang.Integer,java.lang.Void> body) throws java.lang.Throwable
n times.
All the test runs must pass in order for the stochastic test to pass.java.lang.Throwablepublic void notVerified()
public long publisherUnableToSignalOnComplete()
maxElementsFromPublisher() to mark that the given Publisher,
is not able to signal completion. For example it is strictly a time-bound or unbounded source of data.
Returning this value from maxElementsFromPublisher() will result in skipping all TCK tests which require onComplete signals!public void notVerified(java.lang.String message)