diff --git a/examples/src/test/java/org/reactivestreams/example/unicast/AsyncSubscriberTest.java b/examples/src/test/java/org/reactivestreams/example/unicast/AsyncSubscriberTest.java index 8a1f9cf1..cbd301d0 100644 --- a/examples/src/test/java/org/reactivestreams/example/unicast/AsyncSubscriberTest.java +++ b/examples/src/test/java/org/reactivestreams/example/unicast/AsyncSubscriberTest.java @@ -60,7 +60,7 @@ public AsyncSubscriberTest() { } }; - new NumberIterablePublisher(0, 10, e).subscribe(sub); + new NumberIterablePublisher(0, 10, e).subscribe(sub); latch.await(DefaultTimeoutMillis * 10, TimeUnit.MILLISECONDS); assertEquals(i.get(), 45); } diff --git a/tck/README.md b/tck/README.md index 1d1ac378..db9663d2 100644 --- a/tck/README.md +++ b/tck/README.md @@ -45,38 +45,40 @@ Specification rule abides the following naming convention: `spec###_DESC` where: ```java // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.1 - @Required @Test - public void spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable { + @Test public void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable // ... } ``` -The annotations on the test methods are used in order to signify the character of the test. For example, these are the kinds of annotations you may find: +The prefixes of the names of the test methods are used in order to signify the character of the test. For example, these are the kinds of prefixes you may find: +"required_", "optional_", "stochastic_", "untested_". + +Explanations: ```java -@Required @Test +@Test public void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable ``` ... means that this test case is a hard requirement, it covers a *MUST* or *MUST NOT* Rule of the Specification. ```java -@Additional @Test +@Test public void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable ``` -... means that this test case is optional, it covers a *MAY* or *SHOULD* Rule of the Specification. This annotation is also used if more configuration is needed in order to run it, e.g. `@Additional(implement = "createErrorStatePublisher") @Test` signals the implementer that in order to include this test case in his test runs, (s)he must implement the `Publisher createErrorStatePublisher()` method. +... means that this test case is optional, it covers a *MAY* or *SHOULD* Rule of the Specification. This prefix is also used if more configuration is needed in order to run it, e.g. `@Additional(implement = "createErrorStatePublisher") @Test` signals the implementer that in order to include this test case in his test runs, (s)he must implement the `Publisher createErrorStatePublisher()` method. ```java -@Stochastic @Test +@Test public void stochastic_spec103_mustSignalOnMethodsSequentially() throws Throwable ``` ... means that the Rule is either racy, and/or inherently hard to verify without heavy modification of the tested implementation. 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. ```java -@NotVerified @Test +@Test public void untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws Throwable ``` -... means that the test case is not implemented, either because it is inherently hard to verify (e.g. Rules which use the wording "*SHOULD consider X as Y*") or have not been implemented yet (though we hope we have implemented all we could!). Such tests will show up in your test runs as `SKIPPED`, with a message pointing out that the TCK is unable to validate this Rule. We would be delighted if you can figure out a way to deterministically test Rules, which have been marked with this annotation – pull requests are very welcome! +... means that the test case is not implemented, either because it is inherently hard to verify (e.g. Rules which use the wording "*SHOULD consider X as Y*") or have not been implemented yet (though we hope we have implemented all we could!). Such tests will show up in your test runs as `SKIPPED`, with a message pointing out that the TCK is unable to validate this Rule. We would be delighted if you can figure out a way to deterministically test Rules, which have been marked with this prefix – pull requests are very welcome! ### Test isolation diff --git a/tck/src/main/java/org/reactivestreams/tck/Annotations.java b/tck/src/main/java/org/reactivestreams/tck/Annotations.java deleted file mode 100644 index 0cf1f6bf..00000000 --- a/tck/src/main/java/org/reactivestreams/tck/Annotations.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.reactivestreams.tck; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -public class Annotations { - private Annotations() {} - - /** - * Used to mark tests for specification rules which were currently impossible to be implemented. - * For example tests like "Publisher SHOULD consider Subscription as ..." - is inherently hard to specifically test. - */ - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.SOURCE) - static @interface NotVerified { - } - - /** - * Used to mark stochastic tests which MAY yield false positives (pass) can violate the tested rule in some specific scenario. - */ - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.SOURCE) - static @interface Stochastic { - } - - /** - * Used to mark tests that MUST pass in all (even very restricted types of) Publishers / Subscribers. - */ - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.SOURCE) - static @interface Required { - } - - /** - * Used to mark how many subscribers will be used on the publisher under test. - * If an implementation declares it does not support enough subscribers as needed by such test, it will be SKIPPed instead of FAILed. - */ - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.SOURCE) - static @interface Subscribers { - long value() default 1; - } - - /** - * Used to mark tests which may be skipped / not implemented by certain implementations. - * These tests can be skipped by returning null from the given factory method. - */ - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.SOURCE) - static @interface Additional { - /** Description of situation when it's OK to not pass this test */ - String value() default ""; - - /** Name of the method to be implemented (returning not {@code null}) if this test should be run. */ - String implement() default ""; - } - -} diff --git a/tck/src/main/java/org/reactivestreams/tck/IdentityProcessorVerification.java b/tck/src/main/java/org/reactivestreams/tck/IdentityProcessorVerification.java index 39d2be98..8f85d4de 100644 --- a/tck/src/main/java/org/reactivestreams/tck/IdentityProcessorVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/IdentityProcessorVerification.java @@ -4,19 +4,20 @@ import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; -import org.reactivestreams.tck.Annotations.Subscribers; import org.reactivestreams.tck.TestEnvironment.ManualPublisher; import org.reactivestreams.tck.TestEnvironment.ManualSubscriber; import org.reactivestreams.tck.TestEnvironment.ManualSubscriberWithSubscriptionSupport; import org.reactivestreams.tck.TestEnvironment.Promise; import org.reactivestreams.tck.support.Function; +import org.reactivestreams.tck.support.SubscriberWhiteboxVerificationRules; +import org.reactivestreams.tck.support.PublisherVerificationRules; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.HashSet; import java.util.Set; -public abstract class IdentityProcessorVerification { +public abstract class IdentityProcessorVerification implements SubscriberWhiteboxVerificationRules, PublisherVerificationRules { private final TestEnvironment env; @@ -145,7 +146,7 @@ public long maxElementsFromPublisher() { * recursive calls to exceed the number returned by this method. * * @see reactive streams spec, rule 3.3 - * @see PublisherVerification#spec303_mustNotAllowUnboundedRecursion() + * @see PublisherVerification#required_spec303_mustNotAllowUnboundedRecursion() */ public long boundedDepthOfOnNextAndRequestRecursion() { return 1; @@ -189,178 +190,178 @@ public Publisher createPublisher(long elements) { return processor; // we run the PublisherVerification against this } - @Test - public void validate_maxElementsFromPublisher() throws Exception { - publisherVerification.validate_maxElementsFromPublisher(); + @Override @Test + public void required_validate_maxElementsFromPublisher() throws Exception { + publisherVerification.required_validate_maxElementsFromPublisher(); } - @Test - public void validate_boundedDepthOfOnNextAndRequestRecursion() throws Exception { - publisherVerification.validate_boundedDepthOfOnNextAndRequestRecursion(); + @Override @Test + public void required_validate_boundedDepthOfOnNextAndRequestRecursion() throws Exception { + publisherVerification.required_validate_boundedDepthOfOnNextAndRequestRecursion(); } /////////////////////// DELEGATED TESTS, A PROCESSOR "IS A" PUBLISHER ////////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#4.1 @Test - public void createPublisher1MustProduceAStreamOfExactly1Element() throws Throwable { - publisherVerification.createPublisher1MustProduceAStreamOfExactly1Element(); + public void required_createPublisher1MustProduceAStreamOfExactly1Element() throws Throwable { + publisherVerification.required_createPublisher1MustProduceAStreamOfExactly1Element(); } @Test - public void createPublisher3MustProduceAStreamOfExactly3Elements() throws Throwable { - publisherVerification.createPublisher3MustProduceAStreamOfExactly3Elements(); + public void required_createPublisher3MustProduceAStreamOfExactly3Elements() throws Throwable { + publisherVerification.required_createPublisher3MustProduceAStreamOfExactly3Elements(); } - @Test - public void spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable { - publisherVerification.spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements(); + @Override @Test + public void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable { + publisherVerification.required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements(); } - @Test - public void spec102_maySignalLessThanRequestedAndTerminateSubscription() throws Throwable { - publisherVerification.spec102_maySignalLessThanRequestedAndTerminateSubscription(); + @Override @Test + public void required_spec102_maySignalLessThanRequestedAndTerminateSubscription() throws Throwable { + publisherVerification.required_spec102_maySignalLessThanRequestedAndTerminateSubscription(); } - @Test - public void spec103_mustSignalOnMethodsSequentially() throws Throwable { - publisherVerification.spec103_mustSignalOnMethodsSequentially(); + @Override @Test + public void stochastic_spec103_mustSignalOnMethodsSequentially() throws Throwable { + publisherVerification.stochastic_spec103_mustSignalOnMethodsSequentially(); } - @Test - public void spec104_mustSignalOnErrorWhenFails() throws Throwable { - publisherVerification.spec104_mustSignalOnErrorWhenFails(); + @Override @Test + public void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable { + publisherVerification.optional_spec104_mustSignalOnErrorWhenFails(); } - @Test - public void spec105_mustSignalOnCompleteWhenFiniteStreamTerminates() throws Throwable { - publisherVerification.spec105_mustSignalOnCompleteWhenFiniteStreamTerminates(); + @Override @Test + public void required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates() throws Throwable { + publisherVerification.required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates(); } - @Test - public void spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws Throwable { - publisherVerification.spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled(); + @Override @Test + public void untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws Throwable { + publisherVerification.untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled(); } - @Test - public void spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws Throwable { - publisherVerification.spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled(); + @Override @Test + public void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws Throwable { + publisherVerification.required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled(); } - @Test - public void spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws Throwable { - publisherVerification.spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled(); + @Override @Test + public void untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws Throwable { + publisherVerification.untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled(); } - @Test - public void spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws Throwable { - publisherVerification.spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals(); + @Override @Test + public void untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws Throwable { + publisherVerification.untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals(); } - @Test - public void spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable { - publisherVerification.spec109_subscribeShouldNotThrowNonFatalThrowable(); + @Override @Test + public void untested_spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable { + publisherVerification.untested_spec109_subscribeShouldNotThrowNonFatalThrowable(); } - @Test - public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable { - publisherVerification.spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); + @Override @Test + public void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable { + publisherVerification.untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); } - @Test - public void spec111_maySupportMultiSubscribe() throws Throwable { - publisherVerification.spec111_maySupportMultiSubscribe(); + @Override @Test + public void optional_spec111_maySupportMultiSubscribe() throws Throwable { + publisherVerification.optional_spec111_maySupportMultiSubscribe(); } - @Test - public void spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe() throws Throwable { - publisherVerification.spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); + @Override @Test + public void required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe() throws Throwable { + publisherVerification.required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); } - @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable { - publisherVerification.spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne(); + @Override @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable { + publisherVerification.required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne(); } - @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable { - publisherVerification.spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront(); + @Override @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable { + publisherVerification.required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront(); } - @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable { - publisherVerification.spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected(); + @Override @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable { + publisherVerification.required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected(); } - @Test - public void spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws Throwable { - publisherVerification.spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe(); + @Override @Test + public void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws Throwable { + publisherVerification.required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe(); } - @Test - public void spec303_mustNotAllowUnboundedRecursion() throws Throwable { - publisherVerification.spec303_mustNotAllowUnboundedRecursion(); + @Override @Test + public void required_spec303_mustNotAllowUnboundedRecursion() throws Throwable { + publisherVerification.required_spec303_mustNotAllowUnboundedRecursion(); } - @Test - public void spec304_requestShouldNotPerformHeavyComputations() throws Exception { - publisherVerification.spec304_requestShouldNotPerformHeavyComputations(); + @Override @Test + public void untested_spec304_requestShouldNotPerformHeavyComputations() throws Exception { + publisherVerification.untested_spec304_requestShouldNotPerformHeavyComputations(); } - @Test - public void spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation() throws Exception { - publisherVerification.spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation(); + @Override @Test + public void untested_spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation() throws Exception { + publisherVerification.untested_spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation(); } - @Test - public void spec306_afterSubscriptionIsCancelledRequestMustBeNops() throws Throwable { - publisherVerification.spec306_afterSubscriptionIsCancelledRequestMustBeNops(); + @Override @Test + public void required_spec306_afterSubscriptionIsCancelledRequestMustBeNops() throws Throwable { + publisherVerification.required_spec306_afterSubscriptionIsCancelledRequestMustBeNops(); } - @Test - public void spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws Throwable { - publisherVerification.spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops(); + @Override @Test + public void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws Throwable { + publisherVerification.required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops(); } - @Test - public void spec309_requestZeroMustSignalIllegalArgumentException() throws Throwable { - publisherVerification.spec309_requestZeroMustSignalIllegalArgumentException(); + @Override @Test + public void required_spec309_requestZeroMustSignalIllegalArgumentException() throws Throwable { + publisherVerification.required_spec309_requestZeroMustSignalIllegalArgumentException(); } - @Test - public void spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws Throwable { - publisherVerification.spec309_requestNegativeNumberMustSignalIllegalArgumentException(); + @Override @Test + public void required_spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws Throwable { + publisherVerification.required_spec309_requestNegativeNumberMustSignalIllegalArgumentException(); } - @Test - public void spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable { - publisherVerification.spec312_cancelMustMakeThePublisherToEventuallyStopSignaling(); + @Override @Test + public void required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable { + publisherVerification.required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling(); } - @Test - public void spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws Throwable { - publisherVerification.spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber(); + @Override @Test + public void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws Throwable { + publisherVerification.required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber(); } - @Test - public void spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws Throwable { - publisherVerification.spec317_mustSupportAPendingElementCountUpToLongMaxValue(); + @Override @Test + public void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws Throwable { + publisherVerification.required_spec317_mustSupportAPendingElementCountUpToLongMaxValue(); } - @Test - public void spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws Throwable { - publisherVerification.spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue(); + @Override @Test + public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws Throwable { + publisherVerification.required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue(); } - @Test - public void spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue() throws Throwable { - publisherVerification.spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue(); + @Override @Test + public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue() throws Throwable { + publisherVerification.required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue(); } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.4 // for multiple subscribers - @Test @Subscribers(2) - public void spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError() throws Throwable { + @Test + public void required_spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError() throws Throwable { optionalMultipleSubscribersTest(2, new Function() { @Override public TestSetup apply(Long aLong) throws Throwable { @@ -465,131 +466,131 @@ public void mustImmediatelyPassOnOnErrorEventsReceivedFromItsUpstreamToItsDownst // Verifies rule: https://github.com/reactive-streams/reactive-streams#4.1 @Test - public void exerciseWhiteboxHappyPath() throws Throwable { - subscriberVerification.exerciseWhiteboxHappyPath(); + public void required_exerciseWhiteboxHappyPath() throws Throwable { + subscriberVerification.required_exerciseWhiteboxHappyPath(); } - @Test - public void spec201_mustSignalDemandViaSubscriptionRequest() throws Throwable { - subscriberVerification.spec201_mustSignalDemandViaSubscriptionRequest(); + @Override @Test + public void required_spec201_mustSignalDemandViaSubscriptionRequest() throws Throwable { + subscriberVerification.required_spec201_mustSignalDemandViaSubscriptionRequest(); } - @Test - public void spec202_shouldAsynchronouslyDispatch() throws Exception { - subscriberVerification.spec202_shouldAsynchronouslyDispatch(); + @Override @Test + public void untested_spec202_shouldAsynchronouslyDispatch() throws Exception { + subscriberVerification.untested_spec202_shouldAsynchronouslyDispatch(); } - @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { - subscriberVerification.spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); + @Override @Test + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { + subscriberVerification.required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); } - @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { - subscriberVerification.spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); + @Override @Test + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { + subscriberVerification.required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); } - @Test - public void spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception { - subscriberVerification.spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError(); + @Override @Test + public void untested_spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception { + subscriberVerification.untested_spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError(); } - @Test - public void spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { - subscriberVerification.spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal(); + @Override @Test + public void required_spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { + subscriberVerification.required_spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal(); } - @Test - public void spec206_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception { - subscriberVerification.spec206_mustCallSubscriptionCancelIfItIsNoLongerValid(); + @Override @Test + public void untested_spec206_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception { + subscriberVerification.untested_spec206_mustCallSubscriptionCancelIfItIsNoLongerValid(); } - @Test - public void spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception { - subscriberVerification.spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization(); + @Override @Test + public void untested_spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception { + subscriberVerification.untested_spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization(); } - @Test - public void spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable { - subscriberVerification.spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel(); + @Override @Test + public void required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable { + subscriberVerification.required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel(); } - @Test - public void spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { - subscriberVerification.spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall(); + @Override @Test + public void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { + subscriberVerification.required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall(); } - @Test - public void spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { - subscriberVerification.spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall(); + @Override @Test + public void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { + subscriberVerification.required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall(); } - @Test - public void spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { - subscriberVerification.spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall(); + @Override @Test + public void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { + subscriberVerification.required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall(); } - @Test - public void spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall() throws Throwable { - subscriberVerification.spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall(); + @Override @Test + public void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall() throws Throwable { + subscriberVerification.required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall(); } - @Test - public void spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception { - subscriberVerification.spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents(); + @Override @Test + public void untested_spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception { + subscriberVerification.untested_spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents(); } - @Test - public void spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation() throws Throwable { - subscriberVerification.spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation(); + @Override @Test + public void untested_spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation() throws Throwable { + subscriberVerification.untested_spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation(); } - @Test - public void spec213_failingOnSignalInvocation() throws Exception { - subscriberVerification.spec213_failingOnSignalInvocation(); + @Override @Test + public void untested_spec213_failingOnSignalInvocation() throws Exception { + subscriberVerification.untested_spec213_failingOnSignalInvocation(); } - @Test - public void spec301_mustNotBeCalledOutsideSubscriberContext() throws Exception { - subscriberVerification.spec301_mustNotBeCalledOutsideSubscriberContext(); + @Override @Test + public void untested_spec301_mustNotBeCalledOutsideSubscriberContext() throws Exception { + subscriberVerification.untested_spec301_mustNotBeCalledOutsideSubscriberContext(); } - @Test - public void spec308_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable { - subscriberVerification.spec308_requestMustRegisterGivenNumberElementsToBeProduced(); + @Override @Test + public void required_spec308_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable { + subscriberVerification.required_spec308_requestMustRegisterGivenNumberElementsToBeProduced(); } - @Test - public void spec310_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception { - subscriberVerification.spec310_requestMaySynchronouslyCallOnNextOnSubscriber(); + @Override @Test + public void untested_spec310_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception { + subscriberVerification.untested_spec310_requestMaySynchronouslyCallOnNextOnSubscriber(); } - @Test - public void spec311_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception { - subscriberVerification.spec311_requestMaySynchronouslyCallOnCompleteOrOnError(); + @Override @Test + public void untested_spec311_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception { + subscriberVerification.untested_spec311_requestMaySynchronouslyCallOnCompleteOrOnError(); } - @Test - public void spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception { - subscriberVerification.spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists(); + @Override @Test + public void untested_spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception { + subscriberVerification.untested_spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists(); } - @Test - public void spec315_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception { - subscriberVerification.spec315_cancelMustNotThrowExceptionAndMustSignalOnError(); + @Override @Test + public void untested_spec315_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception { + subscriberVerification.untested_spec315_cancelMustNotThrowExceptionAndMustSignalOnError(); } - @Test - public void spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception { - subscriberVerification.spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber(); + @Override @Test + public void untested_spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception { + subscriberVerification.untested_spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber(); } /////////////////////// ADDITIONAL "COROLLARY" TESTS ////////////////////// // A Processor // must trigger `requestFromUpstream` for elements that have been requested 'long ago' - @Test @Subscribers(2) - public void mustRequestFromUpstreamForElementsThatHaveBeenRequestedLongAgo() throws Throwable { + @Test + public void required_mustRequestFromUpstreamForElementsThatHaveBeenRequestedLongAgo() throws Throwable { optionalMultipleSubscribersTest(2, new Function() { @Override public TestSetup apply(Long subscribers) throws Throwable { diff --git a/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java b/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java index f879edab..4033461e 100644 --- a/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java @@ -9,6 +9,7 @@ import org.reactivestreams.tck.TestEnvironment.ManualSubscriberWithSubscriptionSupport; import org.reactivestreams.tck.support.Function; import org.reactivestreams.tck.support.Optional; +import org.reactivestreams.tck.support.PublisherVerificationRules; import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -22,7 +23,6 @@ import java.util.Random; import java.util.concurrent.atomic.AtomicReference; -import static org.reactivestreams.tck.Annotations.*; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -31,7 +31,7 @@ * * @see org.reactivestreams.Publisher */ -public abstract class PublisherVerification { +public abstract class PublisherVerification implements PublisherVerificationRules { private final TestEnvironment env; private final long publisherReferenceGCTimeoutMillis; @@ -82,7 +82,7 @@ public boolean skipStochasticTests() { * recursive calls to exceed the number returned by this method. * * @see reactive streams spec, rule 3.3 - * @see PublisherVerification#spec303_mustNotAllowUnboundedRecursion() + * @see PublisherVerification#required_spec303_mustNotAllowUnboundedRecursion() */ public long boundedDepthOfOnNextAndRequestRecursion() { return 1; @@ -97,8 +97,8 @@ public void setUp() throws Exception { ////////////////////// TEST SETUP VERIFICATION ////////////////////////////// - @Required @Test - public void createPublisher1MustProduceAStreamOfExactly1Element() throws Throwable { + @Override @Test + public void required_createPublisher1MustProduceAStreamOfExactly1Element() throws Throwable { activePublisherTest(1, true, new PublisherTestRun() { @Override public void run(Publisher pub) throws InterruptedException { @@ -114,8 +114,8 @@ Optional requestNextElementOrEndOfStream(Publisher pub, ManualSubscriber() { @Override public void run(Publisher pub) throws InterruptedException { @@ -133,13 +133,13 @@ Optional requestNextElementOrEndOfStream(Publisher pub, ManualSubscriber 0, "maxElementsFromPublisher MUST return a number > 0"); } - @Required @Test - public void validate_boundedDepthOfOnNextAndRequestRecursion() throws Exception { + @Override @Test + public void required_validate_boundedDepthOfOnNextAndRequestRecursion() throws Exception { assertTrue(boundedDepthOfOnNextAndRequestRecursion() >= 1, "boundedDepthOfOnNextAndRequestRecursion must return a number >= 1"); } @@ -147,8 +147,8 @@ public void validate_boundedDepthOfOnNextAndRequestRecursion() throws Exception ////////////////////// SPEC RULE VERIFICATION /////////////////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.1 - @Required @Test - public void spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable { + @Override @Test + public void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable { activePublisherTest(5, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws InterruptedException { @@ -170,8 +170,8 @@ public void run(Publisher pub) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.2 - @Required @Test - public void spec102_maySignalLessThanRequestedAndTerminateSubscription() throws Throwable { + @Override @Test + public void required_spec102_maySignalLessThanRequestedAndTerminateSubscription() throws Throwable { final int elements = 3; final int requested = 10; @@ -187,8 +187,8 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.3 - @Stochastic @Test - public void spec103_mustSignalOnMethodsSequentially() throws Throwable { + @Override @Test + public void stochastic_spec103_mustSignalOnMethodsSequentially() throws Throwable { final int iterations = 100; final int elements = 10; @@ -294,25 +294,25 @@ public void onComplete() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.4 - @Additional(implement = "createErrorStatePublisher") @Test - public void spec104_mustSignalOnErrorWhenFails() throws Throwable { + @Override @Test + public void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable { try { - errorPublisherTest(new PublisherTestRun() { - @Override - public void run(final Publisher pub) throws InterruptedException { - final Latch latch = new Latch(env); - pub.subscribe(new TestEnvironment.TestSubscriber(env) { - @Override - public void onError(Throwable cause) { - latch.assertOpen(String.format("Error-state Publisher %s called `onError` twice on new Subscriber", pub)); - latch.close(); - } - }); + whenHasErrorPublisherTest(new PublisherTestRun() { + @Override + public void run(final Publisher pub) throws InterruptedException { + final Latch latch = new Latch(env); + pub.subscribe(new TestEnvironment.TestSubscriber(env) { + @Override + public void onError(Throwable cause) { + latch.assertOpen(String.format("Error-state Publisher %s called `onError` twice on new Subscriber", pub)); + latch.close(); + } + }); - latch.expectClose(String.format("Error-state Publisher %s did not call `onError` on new Subscriber", pub)); + latch.expectClose(String.format("Error-state Publisher %s did not call `onError` on new Subscriber", pub)); - env.verifyNoAsyncErrors(env.defaultTimeoutMillis()); - } + env.verifyNoAsyncErrors(env.defaultTimeoutMillis()); + } }); } catch (SkipException se) { throw se; @@ -324,8 +324,8 @@ public void onError(Throwable cause) { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.5 - @Required @Test - public void spec105_mustSignalOnCompleteWhenFiniteStreamTerminates() throws Throwable { + @Override @Test + public void required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates() throws Throwable { activePublisherTest(3, true, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -340,14 +340,14 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.6 - @NotVerified @Test - public void spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws Throwable { + @Override @Test + public void untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws Throwable { notVerified(); // not really testable without more control over the Publisher } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.7 - @Required @Test - public void spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws Throwable { + @Override @Test + public void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws Throwable { activePublisherTest(1, true, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -363,32 +363,32 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.7 - @NotVerified @Test - public void spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws Throwable { + @Override @Test + public void untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws Throwable { notVerified(); // can we meaningfully test this, without more control over the publisher? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.8 - @NotVerified @Test - public void spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws Throwable { + @Override @Test + public void untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws Throwable { notVerified(); // can we meaningfully test this? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.9 - @NotVerified @Test - public void spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable { + @Override @Test + public void untested_spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.10 - @NotVerified @Test - public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable { + @Override @Test + public void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable { notVerified(); // can we meaningfully test this? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.11 - @Additional @Test - public void spec111_maySupportMultiSubscribe() throws Throwable { + @Override @Test + public void optional_spec111_maySupportMultiSubscribe() throws Throwable { optionalActivePublisherTest(1, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -401,36 +401,36 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.12 - @Additional(implement = "createErrorStatePublisher") @Test - public void spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe() throws Throwable { - errorPublisherTest(new PublisherTestRun() { - @Override - public void run(Publisher pub) throws Throwable { - final Latch onErrorLatch = new Latch(env); - ManualSubscriberWithSubscriptionSupport sub = new ManualSubscriberWithSubscriptionSupport(env) { - @Override - public void onError(Throwable cause) { - onErrorLatch.assertOpen("Only one onError call expected"); - onErrorLatch.close(); - } + @Override @Test + public void required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe() throws Throwable { + whenHasErrorPublisherTest(new PublisherTestRun() { + @Override + public void run(Publisher pub) throws Throwable { + final Latch onErrorLatch = new Latch(env); + ManualSubscriberWithSubscriptionSupport sub = new ManualSubscriberWithSubscriptionSupport(env) { + @Override + public void onError(Throwable cause) { + onErrorLatch.assertOpen("Only one onError call expected"); + onErrorLatch.close(); + } - @Override - public void onSubscribe(Subscription subs) { - env.flop("onSubscribe should not be called if Publisher is unable to subscribe a Subscriber"); - } - }; - pub.subscribe(sub); - onErrorLatch.assertClosed("Should have received onError"); + @Override + public void onSubscribe(Subscription subs) { + env.flop("onSubscribe should not be called if Publisher is unable to subscribe a Subscriber"); + } + }; + pub.subscribe(sub); + onErrorLatch.assertClosed("Should have received onError"); - env.verifyNoAsyncErrors(); - } + env.verifyNoAsyncErrors(); + } }); } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.13 - @Required @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable { - optionalActivePublisherTest(5, true, new PublisherTestRun() { + @Override @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable { + optionalActivePublisherTest(5, true, new PublisherTestRun() { // This test is skipped if the publisher is unbounded (never sends onComplete) @Override public void run(Publisher pub) throws InterruptedException { ManualSubscriber sub1 = env.newManualSubscriber(pub); @@ -479,9 +479,9 @@ public void run(Publisher pub) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.13 - @Required @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable { - optionalActivePublisherTest(3, false, new PublisherTestRun() { + @Override @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable { + optionalActivePublisherTest(3, false, new PublisherTestRun() { // This test is skipped if the publisher cannot produce enough elements @Override public void run(Publisher pub) throws Throwable { ManualSubscriber sub1 = env.newManualSubscriber(pub); @@ -512,9 +512,9 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.13 - @Required @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable { - optionalActivePublisherTest(3, true, new PublisherTestRun() { + @Override @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable { + optionalActivePublisherTest(3, true, new PublisherTestRun() { // This test is skipped if the publisher is unbounded (never sends onComplete) @Override public void run(Publisher pub) throws Throwable { ManualSubscriber sub1 = env.newManualSubscriber(pub); @@ -548,8 +548,8 @@ public void run(Publisher pub) throws Throwable { ///////////////////// SUBSCRIPTION TESTS ////////////////////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.2 - @Required @Test - public void spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws Throwable { + @Override @Test + public void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws Throwable { activePublisherTest(6, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -579,9 +579,8 @@ public void onNext(T element) { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.3 - @Required @Test - @Additional(implement = "boundedDepthOfOnNextAndRequestRecursion") - public void spec303_mustNotAllowUnboundedRecursion() throws Throwable { + @Override @Test + public void required_spec303_mustNotAllowUnboundedRecursion() throws Throwable { final long oneMoreThanBoundedLimit = boundedDepthOfOnNextAndRequestRecursion() + 1; activePublisherTest(oneMoreThanBoundedLimit, false, new PublisherTestRun() { @@ -627,20 +626,20 @@ public void onNext(T element) { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.4 - @NotVerified @Test - public void spec304_requestShouldNotPerformHeavyComputations() throws Exception { + @Override @Test + public void untested_spec304_requestShouldNotPerformHeavyComputations() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.5 - @NotVerified @Test - public void spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation() throws Exception { + @Override @Test + public void untested_spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.6 - @Required @Test - public void spec306_afterSubscriptionIsCancelledRequestMustBeNops() throws Throwable { + @Override @Test + public void required_spec306_afterSubscriptionIsCancelledRequestMustBeNops() throws Throwable { activePublisherTest(3, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -673,8 +672,8 @@ public void cancel() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.7 - @Required @Test - public void spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws Throwable { + @Override @Test + public void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws Throwable { activePublisherTest(1, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -694,8 +693,8 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.9 - @Required @Test - public void spec309_requestZeroMustSignalIllegalArgumentException() throws Throwable { + @Override @Test + public void required_spec309_requestZeroMustSignalIllegalArgumentException() throws Throwable { activePublisherTest(10, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { final ManualSubscriber sub = env.newManualSubscriber(pub); @@ -706,8 +705,8 @@ public void spec309_requestZeroMustSignalIllegalArgumentException() throws Throw } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.9 - @Required @Test - public void spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws Throwable { + @Override @Test + public void required_spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws Throwable { activePublisherTest(10, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { @@ -720,8 +719,8 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.12 - @Required @Test - public void spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable { + @Override @Test + public void required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable { // the publisher is able to signal more elements than the subscriber will be requesting in total final int publisherElements = 20; @@ -783,8 +782,8 @@ > AsyncPublisher receives cancel() - handles it right away, by "stopping itself" } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.13 - @Required @Test - public void spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws Throwable { + @Override @Test + public void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws Throwable { final ReferenceQueue> queue = new ReferenceQueue>(); final Function, WeakReference>> run = new Function, WeakReference>>() { @@ -821,8 +820,8 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.17 - @Required @Test - public void spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws Throwable { + @Override @Test + public void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws Throwable { final int totalElements = 3; activePublisherTest(totalElements, true, new PublisherTestRun() { @@ -840,8 +839,8 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.17 - @Required @Test - public void spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws Throwable { + @Override @Test + public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws Throwable { final int totalElements = 3; activePublisherTest(totalElements, true, new PublisherTestRun() { @@ -861,8 +860,8 @@ public void run(Publisher pub) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.17 - @Required @Test - public void spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue() throws Throwable { + @Override @Test + public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue() throws Throwable { activePublisherTest(Integer.MAX_VALUE, false, new PublisherTestRun() { @Override public void run(Publisher pub) throws Throwable { ManualSubscriberWithSubscriptionSupport sub = new BlackholeSubscriberWithSubscriptionSupport(env) { @@ -964,7 +963,7 @@ public void optionalActivePublisherTest(long elements, boolean completionSignalR /** * Additional test for Publisher in error state */ - public void errorPublisherTest(PublisherTestRun body) throws Throwable { + public void whenHasErrorPublisherTest(PublisherTestRun body) throws Throwable { potentiallyPendingTest(createErrorStatePublisher(), body, SKIPPING_NO_ERROR_PUBLISHER_AVAILABLE); } diff --git a/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java b/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java index ac31c173..c4e34b88 100644 --- a/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java @@ -7,12 +7,11 @@ import org.reactivestreams.tck.TestEnvironment.ManualSubscriber; import org.reactivestreams.tck.support.Optional; import org.reactivestreams.tck.support.TestException; +import org.reactivestreams.tck.support.SubscriberBlackboxVerificationRules; import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.reactivestreams.tck.Annotations.NotVerified; -import static org.reactivestreams.tck.Annotations.Required; import static org.reactivestreams.tck.SubscriberWhiteboxVerification.BlackboxSubscriberProxy; /** @@ -26,7 +25,7 @@ * @see org.reactivestreams.Subscriber * @see org.reactivestreams.Subscription */ -public abstract class SubscriberBlackboxVerification { +public abstract class SubscriberBlackboxVerification implements SubscriberBlackboxVerificationRules { private final TestEnvironment env; @@ -67,8 +66,8 @@ public void setUp() throws Exception { ////////////////////// SPEC RULE VERIFICATION /////////////////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.1 - @Required @Test - public void spec201_blackbox_mustSignalDemandViaSubscriptionRequest() throws Throwable { + @Override @Test + public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() throws Throwable { blackboxSubscriberTest(new BlackboxTestStageTestRun() { @Override public void run(BlackboxTestStage stage) throws InterruptedException { @@ -82,14 +81,14 @@ public void run(BlackboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.2 - @NotVerified @Test - public void spec202_blackbox_shouldAsynchronouslyDispatch() throws Exception { + @Override @Test + public void untested_spec202_blackbox_shouldAsynchronouslyDispatch() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.3 - @Required @Test - public void spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { + @Override @Test + public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @Override public void run(BlackboxTestStage stage) throws Throwable { @@ -125,8 +124,8 @@ public void cancel() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.3 - @Required @Test - public void spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { + @Override @Test + public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @Override public void run(BlackboxTestStage stage) throws Throwable { @@ -164,14 +163,14 @@ public void cancel() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.4 - @NotVerified @Test - public void spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception { + @Override @Test + public void untested_spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.5 - @Required @Test - public void spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { + @Override @Test + public void required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { new BlackboxTestStage(env) {{ // try to subscribe another time, if the subscriber calls `probe.registerOnSubscribe` the test will fail final TestEnvironment.Latch secondSubscriptionCancelled = new TestEnvironment.Latch(env); @@ -199,27 +198,27 @@ public String toString() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.6 - @NotVerified @Test - public void spec206_blackbox_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception { + @Override @Test + public void untested_spec206_blackbox_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.7 - @NotVerified @Test - public void spec207_blackbox_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception { + @Override @Test + public void untested_spec207_blackbox_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? // the same thread part of the clause can be verified but that is not very useful, or is it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.8 - @NotVerified @Test - public void spec208_blackbox_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable { + @Override @Test + public void untested_spec208_blackbox_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable { notVerified(); // cannot be meaningfully tested as black box, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.9 - @Required @Test - public void spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @Override public void run(BlackboxTestStage stage) throws Throwable { @@ -238,8 +237,8 @@ public void run(BlackboxTestStage stage) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.9 - @Required @Test - public void spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @Override public void run(BlackboxTestStage stage) throws Throwable { @@ -262,8 +261,8 @@ public void subscribe(Subscriber s) { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.10 - @Required @Test - public void spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { blackboxSubscriberTest(new BlackboxTestStageTestRun() { @Override @SuppressWarnings("ThrowableResultOfMethodCallIgnored") @@ -275,64 +274,64 @@ public void run(BlackboxTestStage stage) throws Throwable { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.11 - @NotVerified @Test - public void spec211_blackbox_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception { + @Override @Test + public void untested_spec211_blackbox_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.12 - @Required @Test - public void spec212_blackbox_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality() throws Throwable { + @Override @Test + public void untested_spec212_blackbox_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality() throws Throwable { notVerified(); // cannot be meaningfully tested as black box, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.13 - @NotVerified @Test - public void spec213_blackbox_failingOnSignalInvocation() throws Exception { + @Override @Test + public void untested_spec213_blackbox_failingOnSignalInvocation() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } ////////////////////// SUBSCRIPTION SPEC RULE VERIFICATION ////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.1 - @NotVerified @Test - public void spec301_blackbox_mustNotBeCalledOutsideSubscriberContext() throws Exception { + @Override @Test + public void untested_spec301_blackbox_mustNotBeCalledOutsideSubscriberContext() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.8 - @Required @Test - public void spec308_blackbox_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable { + @Override @Test + public void required_spec308_blackbox_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable { notVerified(); // cannot be meaningfully tested as black box, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.10 - @NotVerified @Test - public void spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception { + @Override @Test + public void untested_spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.11 - @NotVerified @Test - public void spec311_blackbox_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception { + @Override @Test + public void untested_spec311_blackbox_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.14 - @NotVerified @Test - public void spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception { + @Override @Test + public void untested_spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.15 - @NotVerified @Test - public void spec315_blackbox_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception { + @Override @Test + public void untested_spec315_blackbox_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.16 - @NotVerified @Test - public void spec316_blackbox_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception { + @Override @Test + public void untested_spec316_blackbox_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } diff --git a/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java b/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java index 1397d68a..acde4217 100644 --- a/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java @@ -3,17 +3,15 @@ import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; -import org.reactivestreams.tck.Annotations.Additional; import org.reactivestreams.tck.TestEnvironment.*; import org.reactivestreams.tck.support.Function; import org.reactivestreams.tck.support.Optional; import org.reactivestreams.tck.support.TestException; +import org.reactivestreams.tck.support.SubscriberWhiteboxVerificationRules; import org.testng.SkipException; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.reactivestreams.tck.Annotations.NotVerified; -import static org.reactivestreams.tck.Annotations.Required; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -23,7 +21,7 @@ * @see org.reactivestreams.Subscriber * @see org.reactivestreams.Subscription */ -public abstract class SubscriberWhiteboxVerification { +public abstract class SubscriberWhiteboxVerification implements SubscriberWhiteboxVerificationRules { private final TestEnvironment env; @@ -77,8 +75,8 @@ public void setUp() throws Exception { ////////////////////// TEST SETUP VERIFICATION ////////////////////////////// - @Required @Test - public void exerciseWhiteboxHappyPath() throws Throwable { + @Test + public void required_exerciseWhiteboxHappyPath() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -109,8 +107,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { ////////////////////// SPEC RULE VERIFICATION /////////////////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.1 - @Required @Test - public void spec201_mustSignalDemandViaSubscriptionRequest() throws Throwable { + @Override @Test + public void required_spec201_mustSignalDemandViaSubscriptionRequest() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -123,14 +121,14 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.2 - @NotVerified @Test - public void spec202_shouldAsynchronouslyDispatch() throws Exception { + @Override @Test + public void untested_spec202_shouldAsynchronouslyDispatch() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.3 - @Required @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { + @Override @Test + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { subscriberTestWithoutSetup(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws Throwable { @@ -168,8 +166,8 @@ public void cancel() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.3 - @Required @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { + @Override @Test + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { subscriberTestWithoutSetup(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws Throwable { @@ -209,14 +207,14 @@ public void cancel() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.4 - @NotVerified @Test - public void spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception { + @Override @Test + public void untested_spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.5 - @Required @Test - public void spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { + @Override @Test + public void required_spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { new WhiteboxTestStage(env) {{ // try to subscribe another time, if the subscriber calls `probe.registerOnSubscribe` the test will fail final Latch secondSubscriptionCancelled = new Latch(env); @@ -244,21 +242,21 @@ public String toString() { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.6 - @NotVerified @Test - public void spec206_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception { + @Override @Test + public void untested_spec206_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.7 - @NotVerified @Test - public void spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception { + @Override @Test + public void untested_spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? // the same thread part of the clause can be verified but that is not very useful, or is it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.8 - @Required @Test - public void spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable { + @Override @Test + public void required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -275,8 +273,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.9 - @Required @Test - public void spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -290,8 +288,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.9 - @Required @Test - public void spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -304,8 +302,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.10 - @Required @Test - public void spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -322,8 +320,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.10 - @Required @Test - public void spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall() throws Throwable { + @Override @Test + public void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -337,56 +335,34 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.11 - @NotVerified @Test - public void spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception { + @Override @Test + public void untested_spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.12 - @Additional @Test - public void spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation() throws Throwable { - optionalSubscriberTestWithoutSetup(new TestStageTestRun() { - @Override @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - public void run(WhiteboxTestStage stage) throws Exception { - stage.pub = stage.createHelperPublisher(1); - - stage.tees = new ManualSubscriberWithSubscriptionSupport(env); - - env.subscribe(stage.pub, stage.tees); - stage.tees.expectNone(); - - // subscribe the same subscriber again, - // this can not use convinience subscribe(pub, sub), because that one checks for noAsyncErrors - // instead we expect the error afterwards - stage.pub.subscribe(stage.tees); // NOTE: This is a spec violation! - - // NOTE: It would be nice to signal an error in response to such spec violation, however - // reacting to spec violations is not strictly regulated by the Spec - for example, just logging and ignoring may - // also be a valid response to this spec violation - it's up to the implementation - // - // The TCK is able to check only for onErroring in such case, thus the check below and the optional nature of this test - stage.tees.expectError(Exception.class, "Should not allow subscribing the same instance multiple times, see Reactive Streams Specification Rule 2.12"); - } - }); + @Override @Test + public void untested_spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation() throws Throwable { + notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#2.13 - @NotVerified @Test - public void spec213_failingOnSignalInvocation() throws Exception { + @Override @Test + public void untested_spec213_failingOnSignalInvocation() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } ////////////////////// SUBSCRIPTION SPEC RULE VERIFICATION ////////////////// // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.1 - @NotVerified @Test - public void spec301_mustNotBeCalledOutsideSubscriberContext() throws Exception { + @Override @Test + public void untested_spec301_mustNotBeCalledOutsideSubscriberContext() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.8 - @Required @Test - public void spec308_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable { + @Override @Test + public void required_spec308_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable { subscriberTest(new TestStageTestRun() { @Override public void run(WhiteboxTestStage stage) throws InterruptedException { @@ -403,32 +379,32 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.10 - @NotVerified @Test - public void spec310_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception { + @Override @Test + public void untested_spec310_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.11 - @NotVerified @Test - public void spec311_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception { + @Override @Test + public void untested_spec311_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.14 - @NotVerified @Test - public void spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception { + @Override @Test + public void untested_spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.15 - @NotVerified @Test - public void spec315_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception { + @Override @Test + public void untested_spec315_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.16 - @NotVerified @Test - public void spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception { + @Override @Test + public void untested_spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } diff --git a/tck/src/main/java/org/reactivestreams/tck/support/PublisherVerificationRules.java b/tck/src/main/java/org/reactivestreams/tck/support/PublisherVerificationRules.java new file mode 100644 index 00000000..0ad38bd1 --- /dev/null +++ b/tck/src/main/java/org/reactivestreams/tck/support/PublisherVerificationRules.java @@ -0,0 +1,43 @@ +package org.reactivestreams.tck.support; + + + +/** + * Internal TCK use only. + * Add / Remove tests for PublisherVerification here to make sure that they arre added/removed in the other places. + */ +public interface PublisherVerificationRules { + void required_validate_maxElementsFromPublisher() throws Exception; + void required_validate_boundedDepthOfOnNextAndRequestRecursion() throws Exception; + void required_createPublisher1MustProduceAStreamOfExactly1Element() throws Throwable; + void required_createPublisher3MustProduceAStreamOfExactly3Elements() throws Throwable; + void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements() throws Throwable; + void required_spec102_maySignalLessThanRequestedAndTerminateSubscription() throws Throwable; + void stochastic_spec103_mustSignalOnMethodsSequentially() throws Throwable; + void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable; + void required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates() throws Throwable; + void untested_spec106_mustConsiderSubscriptionCancelledAfterOnErrorOrOnCompleteHasBeenCalled() throws Throwable; + void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled() throws Throwable; + void untested_spec107_mustNotEmitFurtherSignalsOnceOnErrorHasBeenSignalled() throws Throwable; + void untested_spec108_possiblyCanceledSubscriptionShouldNotReceiveOnErrorOrOnCompleteSignals() throws Throwable; + void untested_spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable; + void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable; + void optional_spec111_maySupportMultiSubscribe() throws Throwable; + void required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe() throws Throwable; + void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable; + void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable; + void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable; + void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws Throwable; + void required_spec303_mustNotAllowUnboundedRecursion() throws Throwable; + void untested_spec304_requestShouldNotPerformHeavyComputations() throws Exception; + void untested_spec305_cancelMustNotSynchronouslyPerformHeavyCompuatation() throws Exception; + void required_spec306_afterSubscriptionIsCancelledRequestMustBeNops() throws Throwable; + void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops() throws Throwable; + void required_spec309_requestZeroMustSignalIllegalArgumentException() throws Throwable; + void required_spec309_requestNegativeNumberMustSignalIllegalArgumentException() throws Throwable; + void required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling() throws Throwable; + void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber() throws Throwable; + void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws Throwable; + void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws Throwable; + void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue() throws Throwable; +} \ No newline at end of file diff --git a/tck/src/main/java/org/reactivestreams/tck/support/SubscriberBlackboxVerificationRules.java b/tck/src/main/java/org/reactivestreams/tck/support/SubscriberBlackboxVerificationRules.java new file mode 100644 index 00000000..b260957a --- /dev/null +++ b/tck/src/main/java/org/reactivestreams/tck/support/SubscriberBlackboxVerificationRules.java @@ -0,0 +1,30 @@ +package org.reactivestreams.tck.support; + +/** + * Internal TCK use only. + * Add / Remove tests for SubscriberBlackboxVerification here to make sure that they arre added/removed in the other places. + */ +public interface SubscriberBlackboxVerificationRules { + void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() throws Throwable; + void untested_spec202_blackbox_shouldAsynchronouslyDispatch() throws Exception; + void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable; + void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable; + void untested_spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception; + void required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception; + void untested_spec206_blackbox_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception; + void untested_spec207_blackbox_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception; + void untested_spec208_blackbox_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable; + void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable; + void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable; + void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable; + void untested_spec211_blackbox_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception; + void untested_spec212_blackbox_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality() throws Throwable; + void untested_spec213_blackbox_failingOnSignalInvocation() throws Exception; + void untested_spec301_blackbox_mustNotBeCalledOutsideSubscriberContext() throws Exception; + void required_spec308_blackbox_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable; + void untested_spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception; + void untested_spec311_blackbox_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception; + void untested_spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception; + void untested_spec315_blackbox_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception; + void untested_spec316_blackbox_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception; +} \ No newline at end of file diff --git a/tck/src/main/java/org/reactivestreams/tck/support/SubscriberWhiteboxVerificationRules.java b/tck/src/main/java/org/reactivestreams/tck/support/SubscriberWhiteboxVerificationRules.java new file mode 100644 index 00000000..9368ca36 --- /dev/null +++ b/tck/src/main/java/org/reactivestreams/tck/support/SubscriberWhiteboxVerificationRules.java @@ -0,0 +1,32 @@ +package org.reactivestreams.tck.support; + +/** + * Internal TCK use only. + * Add / Remove tests for PublisherVerificaSubscriberWhiteboxVerification here to make sure that they arre added/removed in the other places. + */ +public interface SubscriberWhiteboxVerificationRules { + void required_exerciseWhiteboxHappyPath() throws Throwable; + void required_spec201_mustSignalDemandViaSubscriptionRequest() throws Throwable; + void untested_spec202_shouldAsynchronouslyDispatch() throws Exception; + void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable; + void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable; + void untested_spec204_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception; + void required_spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception; + void untested_spec206_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception; + void untested_spec207_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception; + void required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable; + void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable; + void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable; + void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable; + void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall() throws Throwable; + void untested_spec211_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception; + void untested_spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation() throws Throwable; + void untested_spec213_failingOnSignalInvocation() throws Exception; + void untested_spec301_mustNotBeCalledOutsideSubscriberContext() throws Exception; + void required_spec308_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable; + void untested_spec310_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception; + void untested_spec311_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception; + void untested_spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception; + void untested_spec315_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception; + void untested_spec316_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception; +} \ No newline at end of file diff --git a/tck/src/test/java/org/reactivestreams/tck/IdentityProcessorVerificationTest.java b/tck/src/test/java/org/reactivestreams/tck/IdentityProcessorVerificationTest.java index 9c62ef92..0ff89e92 100644 --- a/tck/src/test/java/org/reactivestreams/tck/IdentityProcessorVerificationTest.java +++ b/tck/src/test/java/org/reactivestreams/tck/IdentityProcessorVerificationTest.java @@ -16,7 +16,7 @@ public class IdentityProcessorVerificationTest extends TCKVerificationSupport { static final int DEFAULT_TIMEOUT_MILLIS = 100; @Test - public void spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError_shouldBeIgnored() throws Throwable { + public void required_spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError_shouldBeIgnored() throws Throwable { requireTestSkip(new ThrowingRunnable() { @Override public void run() throws Throwable { new IdentityProcessorVerification(newTestEnvironment(), DEFAULT_TIMEOUT_MILLIS){ @@ -35,13 +35,13 @@ public void spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecovera @Override public long maxSupportedSubscribers() { return 1; // can only support 1 subscribe => unable to run this test } - }.spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError(); + }.required_spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError(); } }, "The Publisher under test only supports 1 subscribers, while this test requires at least 2 to run"); } @Test - public void spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError_shouldFailWhileWaitingForOnError() throws Throwable { + public void required_spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError_shouldFailWhileWaitingForOnError() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { new IdentityProcessorVerification(newTestEnvironment(), DEFAULT_TIMEOUT_MILLIS) { @@ -93,7 +93,7 @@ public void spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecovera @Override public Publisher createErrorStatePublisher() { return SKIP; } - }.spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError(); + }.required_spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError(); } }, "Did not receive expected error on downstream within " + DEFAULT_TIMEOUT_MILLIS); } diff --git a/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java b/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java index ba61e69c..15274404 100644 --- a/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java +++ b/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java @@ -3,7 +3,6 @@ import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; -import org.reactivestreams.tck.Annotations.Additional; import org.reactivestreams.tck.support.TCKVerificationSupport; import org.reactivestreams.tck.support.TestException; import org.testng.annotations.Test; @@ -26,34 +25,34 @@ public class PublisherVerificationTest extends TCKVerificationSupport { static final int GC_TIMEOUT_MILLIS = 300; @Test - public void spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements_shouldFailBy_ExpectingOnError() throws Throwable { + public void required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements_shouldFailBy_ExpectingOnError() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements(); + noopPublisherVerification().required_spec101_subscriptionRequestMustResultInTheCorrectNumberOfProducedElements(); } }, "produced no element after first"); } @Test - public void spec102_maySignalLessThanRequestedAndTerminateSubscription_shouldFailBy_notReceivingAnyElement() throws Throwable { + public void required_spec102_maySignalLessThanRequestedAndTerminateSubscription_shouldFailBy_notReceivingAnyElement() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec102_maySignalLessThanRequestedAndTerminateSubscription(); + noopPublisherVerification().required_spec102_maySignalLessThanRequestedAndTerminateSubscription(); } }, "Did not receive expected element"); } @Test - public void spec102_maySignalLessThanRequestedAndTerminateSubscription_shouldFailBy_receivingTooManyElements() throws Throwable { + public void required_spec102_maySignalLessThanRequestedAndTerminateSubscription_shouldFailBy_receivingTooManyElements() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringSynchronousPublisherVerification().spec102_maySignalLessThanRequestedAndTerminateSubscription(); + demandIgnoringSynchronousPublisherVerification().required_spec102_maySignalLessThanRequestedAndTerminateSubscription(); } }, "Expected end-of-stream but got element [3]"); } @Test - public void spec103_mustSignalOnMethodsSequentially_shouldFailBy_concurrentlyAccessingOnNext() throws Throwable { + public void stochastic_spec103_mustSignalOnMethodsSequentially_shouldFailBy_concurrentlyAccessingOnNext() throws Throwable { final AtomicInteger startedSignallingThreads = new AtomicInteger(0); // this is an arbitrary number, we just need "many threads" to try to force an concurrent access scenario final int maxSignallingThreads = 10; @@ -114,7 +113,7 @@ public void spec103_mustSignalOnMethodsSequentially_shouldFailBy_concurrentlyAcc try { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - customPublisherVerification(concurrentAccessPublisher).spec103_mustSignalOnMethodsSequentially(); + customPublisherVerification(concurrentAccessPublisher).stochastic_spec103_mustSignalOnMethodsSequentially(); } }, "Illegal concurrent access detected"); } finally { @@ -124,7 +123,7 @@ public void spec103_mustSignalOnMethodsSequentially_shouldFailBy_concurrentlyAcc } @Test - public void spec103_mustSignalOnMethodsSequentially_shouldPass_forSynchronousPublisher() throws Throwable { + public void stochastic_spec103_mustSignalOnMethodsSequentially_shouldPass_forSynchronousPublisher() throws Throwable { customPublisherVerification(new Publisher() { @Override public void subscribe(final Subscriber s) { s.onSubscribe(new NoopSubscription() { @@ -137,11 +136,11 @@ public void spec103_mustSignalOnMethodsSequentially_shouldPass_forSynchronousPub } }); } - }).spec103_mustSignalOnMethodsSequentially(); + }).stochastic_spec103_mustSignalOnMethodsSequentially(); } @Test - public void spec104_mustSignalOnErrorWhenFails_shouldFail() throws Throwable { + public void optional_spec104_mustSignalOnErrorWhenFails_shouldFail() throws Throwable { final Publisher invalidErrorPublisher = new Publisher() { @Override public void subscribe(Subscriber s) { throw new RuntimeException("It is not valid to throw here!"); @@ -149,22 +148,22 @@ public void spec104_mustSignalOnErrorWhenFails_shouldFail() throws Throwable { }; requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - customPublisherVerification(SKIP, invalidErrorPublisher).spec104_mustSignalOnErrorWhenFails(); + customPublisherVerification(SKIP, invalidErrorPublisher).optional_spec104_mustSignalOnErrorWhenFails(); } }, "Publisher threw exception (It is not valid to throw here!) instead of signalling error via onError!"); } @Test - public void spec104_mustSignalOnErrorWhenFails_shouldBeSkippedWhenNoErrorPublisherGiven() throws Throwable { + public void optional_spec104_mustSignalOnErrorWhenFails_shouldBeSkippedWhenNoErrorPublisherGiven() throws Throwable { requireTestSkip(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec104_mustSignalOnErrorWhenFails(); + noopPublisherVerification().optional_spec104_mustSignalOnErrorWhenFails(); } }, PublisherVerification.SKIPPING_NO_ERROR_PUBLISHER_AVAILABLE); } @Test - public void spec105_mustSignalOnCompleteWhenFiniteStreamTerminates_shouldFail() throws Throwable { + public void required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates_shouldFail() throws Throwable { final Publisher forgotToSignalCompletionPublisher = new Publisher() { @Override public void subscribe(final Subscriber s) { s.onSubscribe(new NoopSubscription() { @@ -183,22 +182,22 @@ public void spec105_mustSignalOnCompleteWhenFiniteStreamTerminates_shouldFail() requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - customPublisherVerification(forgotToSignalCompletionPublisher).spec105_mustSignalOnCompleteWhenFiniteStreamTerminates(); + customPublisherVerification(forgotToSignalCompletionPublisher).required_spec105_mustSignalOnCompleteWhenFiniteStreamTerminates(); } }, "Expected end-of-stream but got element [3]"); } @Test - public void spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled_shouldFailForNotCompletingPublisher() throws Throwable { + public void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled_shouldFailForNotCompletingPublisher() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringSynchronousPublisherVerification().spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled(); + demandIgnoringSynchronousPublisherVerification().required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled(); } }, "Expected end-of-stream but got element [" /* element which should not have been signalled */); } @Test - public void spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled_shouldFailForPublisherWhichCompletesButKeepsServingData() throws Throwable { + public void required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled_shouldFailForPublisherWhichCompletesButKeepsServingData() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -220,57 +219,57 @@ public void spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled_shou } }); } - }).spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled(); + }).required_spec107_mustNotEmitFurtherSignalsOnceOnCompleteHasBeenSignalled(); } }, "Unexpected element 0 received after stream completed"); } - @Additional @Test - public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice_shouldFailBy_skippingSinceOptional() throws Throwable { + @Test + public void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice_shouldFailBy_skippingSinceOptional() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); + noopPublisherVerification().untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); } }, "Not verified by this TCK."); } @Test - public void spec111_maySupportMultiSubscribe_shouldFailBy_actuallyPass() throws Throwable { - noopPublisherVerification().spec111_maySupportMultiSubscribe(); + public void optional_spec111_maySupportMultiSubscribe_shouldFailBy_actuallyPass() throws Throwable { + noopPublisherVerification().optional_spec111_maySupportMultiSubscribe(); } - @Additional @Test - public void spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe_shouldFail() throws Throwable { + @Test + public void optional_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(SKIP, new Publisher() { @Override public void subscribe(Subscriber s) { } - }).spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); + }).required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); } }, "Should have received onError"); } - @Additional @Test - public void spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe_actuallyPass() throws Throwable { + @Test + public void optional_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe_actuallyPass() throws Throwable { customPublisherVerification(SKIP, new Publisher() { @Override public void subscribe(Subscriber s) { s.onError(new RuntimeException("Sorry, I'm busy now. Call me later.")); } - }).spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); + }).required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); } - @Additional @Test - public void spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe_beSkippedForNoGivenErrorPublisher() throws Throwable { + @Test + public void required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe_beSkippedForNoGivenErrorPublisher() throws Throwable { requireTestSkip(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); + noopPublisherVerification().required_spec112_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorInsteadOfOnSubscribe(); } }, PublisherVerification.SKIPPING_NO_ERROR_PUBLISHER_AVAILABLE); } - @Additional @Test - public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront_shouldFailBy_expectingOnError() throws Throwable { + @Test + public void required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront_shouldFailBy_expectingOnError() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -288,23 +287,23 @@ public void spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscri } }); } - }).spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront(); + }).required_spec113_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront(); } }, "Expected elements to be signaled in the same sequence to 1st and 2nd subscribers: Lists differ at element "); } @Test - public void spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe_shouldFailBy_reportingAsyncError() throws Throwable { + public void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe_shouldFailBy_reportingAsyncError() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - onErroringPublisherVerification().spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe(); + onErroringPublisherVerification().required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe(); } }, "Async error during test execution: Test Exception: Boom!"); } @Test - public void spec303_mustNotAllowUnboundedRecursion_shouldFailBy_informingAboutTooDeepStack() throws Throwable { + public void required_spec303_mustNotAllowUnboundedRecursion_shouldFailBy_informingAboutTooDeepStack() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -319,27 +318,27 @@ public void spec303_mustNotAllowUnboundedRecursion_shouldFailBy_informingAboutTo } }); } - }).spec303_mustNotAllowUnboundedRecursion(); + }).required_spec303_mustNotAllowUnboundedRecursion(); } }, /* Got 2 onNext calls within thread: ... */ "yet expected recursive bound was 1"); } @Test - public void spec306_afterSubscriptionIsCancelledRequestMustBeNops_shouldFailBy_unexpectedElement() throws Throwable { + public void required_spec306_afterSubscriptionIsCancelledRequestMustBeNops_shouldFailBy_unexpectedElement() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringSynchronousPublisherVerification().spec306_afterSubscriptionIsCancelledRequestMustBeNops(); + demandIgnoringSynchronousPublisherVerification().required_spec306_afterSubscriptionIsCancelledRequestMustBeNops(); } }, "Did not expect an element but got element [0]"); } @Test - public void spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops_shouldPass() throws Throwable { - demandIgnoringSynchronousPublisherVerification().spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops(); + public void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops_shouldPass() throws Throwable { + demandIgnoringSynchronousPublisherVerification().required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops(); } @Test - public void spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops_shouldFailBy_unexpectedErrorInCancelling() throws Throwable { + public void required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops_shouldFailBy_unexpectedErrorInCancelling() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -354,37 +353,37 @@ public void spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops } }); } - }).spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops(); + }).required_spec307_afterSubscriptionIsCancelledAdditionalCancelationsMustBeNops(); } }, "Async error during test execution: Test Exception: Boom!"); } @Test - public void spec309_requestZeroMustSignalIllegalArgumentException_shouldFailBy_expectingOnError() throws Throwable { + public void required_spec309_requestZeroMustSignalIllegalArgumentException_shouldFailBy_expectingOnError() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec309_requestZeroMustSignalIllegalArgumentException(); + noopPublisherVerification().required_spec309_requestZeroMustSignalIllegalArgumentException(); } }, "Expected onError"); } @Test - public void spec309_requestNegativeNumberMustSignalIllegalArgumentException_shouldFailBy_expectingOnError() throws Throwable { + public void required_spec309_requestNegativeNumberMustSignalIllegalArgumentException_shouldFailBy_expectingOnError() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopPublisherVerification().spec309_requestNegativeNumberMustSignalIllegalArgumentException(); + noopPublisherVerification().required_spec309_requestNegativeNumberMustSignalIllegalArgumentException(); } }, "Expected onError"); } @Test - public void spec312_cancelMustMakeThePublisherToEventuallyStopSignaling_shouldFailBy_havingEmitedMoreThanRequested() throws Throwable { + public void required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling_shouldFailBy_havingEmitedMoreThanRequested() throws Throwable { final ExecutorService pool = Executors.newFixedThreadPool(2); try { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringAsynchronousPublisherVerification(pool).spec312_cancelMustMakeThePublisherToEventuallyStopSignaling(); + demandIgnoringAsynchronousPublisherVerification(pool).required_spec312_cancelMustMakeThePublisherToEventuallyStopSignaling(); } }, /*Publisher signalled [...] */ ", which is more than the signalled demand: "); } finally { @@ -394,7 +393,7 @@ public void spec312_cancelMustMakeThePublisherToEventuallyStopSignaling_shouldFa } @Test - public void spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber_shouldFailBy_keepingTheReferenceLongerThanNeeded() throws Throwable { + public void required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber_shouldFailBy_keepingTheReferenceLongerThanNeeded() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -415,13 +414,13 @@ public void spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSu } }); } - }).spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber(); + }).required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber(); } }, "did not drop reference to test subscriber after subscription cancellation"); } @Test - public void spec317_mustSupportAPendingElementCountUpToLongMaxValue_shouldFail_onAsynchDemandIgnoringPublisher() throws Throwable { + public void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue_shouldFail_onAsynchDemandIgnoringPublisher() throws Throwable { // 10 is arbitrary here, we just need a "larger number" to get into concurrent access scenarios, anything more than 2 // should work, but getting up to 10 should be safer and doesn't hurt to play safe here final ExecutorService pool = Executors.newFixedThreadPool(10); @@ -429,7 +428,7 @@ public void spec317_mustSupportAPendingElementCountUpToLongMaxValue_shouldFail_o try { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringAsynchronousPublisherVerification(pool).spec317_mustSupportAPendingElementCountUpToLongMaxValue(); + demandIgnoringAsynchronousPublisherVerification(pool).required_spec317_mustSupportAPendingElementCountUpToLongMaxValue(); } }, "Expected end-of-stream but got"); } finally { @@ -439,26 +438,26 @@ public void spec317_mustSupportAPendingElementCountUpToLongMaxValue_shouldFail_o } @Test - public void spec317_mustSupportAPendingElementCountUpToLongMaxValue_shouldFail_onSynchDemandIgnoringPublisher() throws Throwable { + public void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue_shouldFail_onSynchDemandIgnoringPublisher() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringSynchronousPublisherVerification().spec317_mustSupportAPendingElementCountUpToLongMaxValue(); + demandIgnoringSynchronousPublisherVerification().required_spec317_mustSupportAPendingElementCountUpToLongMaxValue(); } }, "Received more than bufferSize (32) onNext signals. The Publisher probably emited more signals than expected!"); } @Test - public void spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onAsynchDemandIgnoringPublisher() throws Throwable { + public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onAsynchDemandIgnoringPublisher() throws Throwable { final ExecutorService signallersPool = Executors.newFixedThreadPool(2); requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - demandIgnoringAsynchronousPublisherVerification(signallersPool).spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue(); + demandIgnoringAsynchronousPublisherVerification(signallersPool).required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue(); } }, "Expected onError(java.lang.IllegalStateException)"); } @Test - public void spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onSynchDemandIgnoringPublisher() throws Throwable { + public void required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onSynchDemandIgnoringPublisher() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -476,13 +475,13 @@ public void spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue_shouldFail_onS } }); } - }).spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue(); + }).required_spec317_mustSignalOnErrorWhenPendingAboveLongMaxValue(); } }, "Expected onError(java.lang.IllegalStateException)"); } @Test - public void spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue_shouldFail_overflowingDemand() throws Throwable { + public void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue_shouldFail_overflowingDemand() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customPublisherVerification(new Publisher() { @@ -501,7 +500,7 @@ public void spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue_sh } }); } - }).spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue(); + }).required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue(); } }, "Async error during test execution: I'm signalling onError too soon!"); } diff --git a/tck/src/test/java/org/reactivestreams/tck/SubscriberBlackboxVerificationTest.java b/tck/src/test/java/org/reactivestreams/tck/SubscriberBlackboxVerificationTest.java index 8cd350be..aefa3efd 100644 --- a/tck/src/test/java/org/reactivestreams/tck/SubscriberBlackboxVerificationTest.java +++ b/tck/src/test/java/org/reactivestreams/tck/SubscriberBlackboxVerificationTest.java @@ -18,72 +18,72 @@ public class SubscriberBlackboxVerificationTest extends TCKVerificationSupport { static final int DEFAULT_TIMEOUT_MILLIS = 100; @Test - public void spec201_blackbox_mustSignalDemandViaSubscriptionRequest_shouldFailBy_notGettingRequestCall() throws Throwable { + public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest_shouldFailBy_notGettingRequestCall() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { - noopSubscriberVerification().spec201_blackbox_mustSignalDemandViaSubscriptionRequest(); + noopSubscriberVerification().required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest(); } }, "Did not receive expected `request` call within"); } @Test - public void spec201_blackbox_mustSignalDemandViaSubscriptionRequest_shouldPass() throws Throwable { - simpleSubscriberVerification().spec201_blackbox_mustSignalDemandViaSubscriptionRequest(); + public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest_shouldPass() throws Throwable { + simpleSubscriberVerification().required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest(); } @Test - public void spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingRequest() throws Throwable { + public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingRequest() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new KeepSubscriptionSubscriber() { @Override public void onComplete() { subscription.request(1); } - }).spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); + }).required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); } }, "Subscription::request MUST NOT be called from Subscriber::onComplete (Rule 2.3)!"); } @Test - public void spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingCancel() throws Throwable { + public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingCancel() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new KeepSubscriptionSubscriber() { @Override public void onComplete() { subscription.cancel(); } - }).spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); + }).required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); } }, "Subscription::cancel MUST NOT be called from Subscriber::onComplete (Rule 2.3)!"); } @Test - public void spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingRequest() throws Throwable { + public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingRequest() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new KeepSubscriptionSubscriber() { @Override public void onError(Throwable t) { subscription.request(1); } - }).spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); + }).required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); } }, "Subscription::request MUST NOT be called from Subscriber::onError (Rule 2.3)!"); } @Test - public void spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingCancel() throws Throwable { + public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingCancel() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new KeepSubscriptionSubscriber() { @Override public void onError(Throwable t) { subscription.cancel(); } - }).spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); + }).required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); } }, "Subscription::cancel MUST NOT be called from Subscriber::onError (Rule 2.3)!"); } @Test - public void spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal_shouldFail() throws Throwable { + public void required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new KeepSubscriptionSubscriber() { @@ -92,31 +92,31 @@ public void spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscript s.request(1); // this is wrong, as one should always check if should accept or reject the subscription } - }).spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal(); + }).required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal(); } }, "illegally called `subscription.request(1)"); } @Test - public void spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall_shouldFail() throws Throwable { + public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new NoopSubscriber() { // don't even request() - }).spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall(); + }).required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall(); } }, "did not call `registerOnComplete()`"); } @Test - public void spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall_shouldPass_withNoopSubscriber() throws Throwable { + public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall_shouldPass_withNoopSubscriber() throws Throwable { customSubscriberVerification(new NoopSubscriber() { // don't even request() - }).spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall(); + }).required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall(); } @Test - public void spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall_shouldFail() throws Throwable { + public void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { @@ -125,7 +125,7 @@ public void spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPreceding // this is wrong in many ways (incl. spec violation), but aims to simulate user code which "blows up" when handling the onError signal throw new RuntimeException("Wrong, don't do this!", t); // don't do this } - }).spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall(); + }).required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall(); } }, "Test Exception: Boom!"); // checks that the expected exception was delivered to onError, we don't expect anyone to implement onError so weirdly } diff --git a/tck/src/test/java/org/reactivestreams/tck/SubscriberWhiteboxVerificationTest.java b/tck/src/test/java/org/reactivestreams/tck/SubscriberWhiteboxVerificationTest.java index 6aa2ee94..cf62f8b8 100644 --- a/tck/src/test/java/org/reactivestreams/tck/SubscriberWhiteboxVerificationTest.java +++ b/tck/src/test/java/org/reactivestreams/tck/SubscriberWhiteboxVerificationTest.java @@ -22,7 +22,7 @@ public class SubscriberWhiteboxVerificationTest extends TCKVerificationSupport { static final int DEFAULT_TIMEOUT_MILLIS = 100; @Test - public void spec201_mustSignalDemandViaSubscriptionRequest_shouldFailBy_notGettingRequestCall() throws Throwable { + public void required_spec201_mustSignalDemandViaSubscriptionRequest_shouldFailBy_notGettingRequestCall() throws Throwable { // this mostly verifies the probe is injected correctly requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { @@ -42,18 +42,18 @@ public void spec201_mustSignalDemandViaSubscriptionRequest_shouldFailBy_notGetti } }; } - }).spec201_mustSignalDemandViaSubscriptionRequest(); + }).required_spec201_mustSignalDemandViaSubscriptionRequest(); } }, "Did not receive expected `request` call within"); } @Test - public void spec201_mustSignalDemandViaSubscriptionRequest_shouldPass() throws Throwable { - simpleSubscriberVerification().spec201_mustSignalDemandViaSubscriptionRequest(); + public void required_spec201_mustSignalDemandViaSubscriptionRequest_shouldPass() throws Throwable { + simpleSubscriberVerification().required_spec201_mustSignalDemandViaSubscriptionRequest(); } @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingRequest() throws Throwable { + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingRequest() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -70,13 +70,13 @@ public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shou } }; } - }).spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); + }).required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); } }, "Subscription::request MUST NOT be called from Subscriber::onComplete (Rule 2.3)!"); } @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingCancel() throws Throwable { + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shouldFail_dueToCallingCancel() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -93,13 +93,13 @@ public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete_shou } }; } - }).spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); + }).required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete(); } }, "Subscription::cancel MUST NOT be called from Subscriber::onComplete (Rule 2.3)!"); } @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingRequest() throws Throwable { + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingRequest() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -115,13 +115,13 @@ public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldF } }; } - }).spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); + }).required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); } }, "Subscription::request MUST NOT be called from Subscriber::onError (Rule 2.3)!"); } @Test - public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingCancel() throws Throwable { + public void required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldFail_dueToCallingCancel() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -137,13 +137,13 @@ public void spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError_shouldF } }; } - }).spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); + }).required_spec203_mustNotCallMethodsOnSubscriptionOrPublisherInOnError(); } }, "Subscription::cancel MUST NOT be called from Subscriber::onError (Rule 2.3)!"); } @Test - public void spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal_shouldFail() throws Throwable { + public void required_spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -157,13 +157,13 @@ public Subscriber apply(WhiteboxSubscriberProbe probe) throws } }; } - }).spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal(); + }).required_spec205_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal(); } }, "illegally accepted a second Subscription"); } @Test - public void spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel_shouldFail() throws Throwable { + public void required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -198,13 +198,13 @@ public Subscriber apply(WhiteboxSubscriberProbe probe) throws } }; } - }).spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel(); + }).required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel(); } }, "But I thought it's cancelled!"); } @Test - public void spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall_shouldFail() throws Throwable { + public void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -216,13 +216,13 @@ public Subscriber apply(WhiteboxSubscriberProbe probe) throws } }; } - }).spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall(); + }).required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall(); } }, "did not call `registerOnComplete()`"); } @Test - public void spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall_shouldPass_withNoopSubscriber() throws Throwable { + public void required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall_shouldPass_withNoopSubscriber() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { customSubscriberVerification(new Function, Subscriber>() { @@ -234,14 +234,14 @@ public Subscriber apply(WhiteboxSubscriberProbe probe) throws } }; } - }).spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall(); + }).required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall(); } }, "did not `registerOnSubscribe`"); } @Test - public void spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall_shouldFail() throws Throwable { + public void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { @@ -255,13 +255,13 @@ public Subscriber apply(WhiteboxSubscriberProbe probe) throws } }; } - }).spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall(); + }).required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall(); } }, "Test Exception: Boom!"); // checks that the expected exception was delivered to onError, we don't expect anyone to implement onError so weirdly } @Test - public void spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall_shouldFail() throws Throwable { + public void required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall_shouldFail() throws Throwable { requireTestFailure(new ThrowingRunnable() { @Override public void run() throws Throwable { @@ -279,36 +279,20 @@ public Subscriber apply(WhiteboxSubscriberProbe probe) throws } }; } - }).spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall(); + }).required_spec210_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall(); } }, "Test Exception: Boom!"); // checks that the expected exception was delivered to onError, we don't expect anyone to implement onError so weirdly } - - @Test - public void spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_shouldFail_ifItAcceptsTheSameSubscriberMoreTimes() throws Throwable { - requireTestFailure(new ThrowingRunnable() { - @Override public void run() throws Throwable { - - customSubscriberVerification(new Function, Subscriber>() { - @Override - public Subscriber apply(WhiteboxSubscriberProbe probe) throws Throwable { - return new SimpleSubscriberWithProbe(probe) { - }; - } - }).spec212_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality_specViolation(); - } - }, ""); - } - + @Test - public void spec308_requestMustRegisterGivenNumberElementsToBeProduced_shouldFail() throws Throwable { + public void required_spec308_requestMustRegisterGivenNumberElementsToBeProduced_shouldFail() throws Throwable { // sanity checks the "happy path", that triggerRequest() propagates the right demand customSubscriberVerification(new Function, Subscriber>() { @Override public Subscriber apply(WhiteboxSubscriberProbe probe) throws Throwable { return new SimpleSubscriberWithProbe(probe) {}; } - }).spec308_requestMustRegisterGivenNumberElementsToBeProduced(); + }).required_spec308_requestMustRegisterGivenNumberElementsToBeProduced(); } // FAILING IMPLEMENTATIONS //