diff --git a/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java b/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java index d3af02b9..cb02e310 100644 --- a/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java @@ -89,7 +89,6 @@ public void setUp() throws Exception { ////////////////////// SPEC RULE VERIFICATION /////////////////////////////// - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.1 @Override @Test public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() throws Throwable { blackboxSubscriberTest(new BlackboxTestStageTestRun() { @@ -105,13 +104,11 @@ public void run(BlackboxTestStage stage) throws InterruptedException { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.2 @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-jvm#2.3 @Override @Test public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -148,7 +145,6 @@ public void cancel() { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.3 @Override @Test public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -187,13 +183,11 @@ public void cancel() { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.4 @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-jvm#2.5 @Override @Test public void required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception { new BlackboxTestStage(env) {{ @@ -222,26 +216,22 @@ public String toString() { }}; } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.6 @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-jvm#2.7 @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-jvm#2.8 @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-jvm#2.9 @Override @Test public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -279,7 +269,6 @@ public void run(BlackboxTestStage stage) throws Throwable { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.9 @Override @Test public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -303,7 +292,6 @@ public void subscribe(Subscriber s) { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.10 @Override @Test public void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable { blackboxSubscriberTest(new BlackboxTestStageTestRun() { @@ -316,25 +304,21 @@ public void run(BlackboxTestStage stage) throws Throwable { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.11 @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-jvm#2.12 @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-jvm#2.13 @Override @Test public void untested_spec213_blackbox_failingOnSignalInvocation() throws Exception { notVerified(); // cannot be meaningfully tested, or can it? } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.13 @Override @Test public void required_spec213_blackbox_onSubscribe_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -357,7 +341,6 @@ public void run(BlackboxTestStage stage) throws Throwable { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.13 @Override @Test public void required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -385,7 +368,6 @@ public void run(BlackboxTestStage stage) throws Throwable { }); } - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.13 @Override @Test public void required_spec213_blackbox_onError_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable { blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() { @@ -415,43 +397,36 @@ public void run(BlackboxTestStage stage) throws Throwable { ////////////////////// SUBSCRIPTION SPEC RULE VERIFICATION ////////////////// - // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#3.1 @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-jvm#3.8 @Override @Test public void untested_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-jvm#3.10 @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-jvm#3.11 @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-jvm#3.14 @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-jvm#3.15 @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-jvm#3.16 @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/support/SubscriberBlackboxVerificationRules.java b/tck/src/main/java/org/reactivestreams/tck/support/SubscriberBlackboxVerificationRules.java index 69e9628c..6c822f16 100644 --- a/tck/src/main/java/org/reactivestreams/tck/support/SubscriberBlackboxVerificationRules.java +++ b/tck/src/main/java/org/reactivestreams/tck/support/SubscriberBlackboxVerificationRules.java @@ -11,34 +11,359 @@ package org.reactivestreams.tck.support; +import org.reactivestreams.tck.SubscriberBlackboxVerification; + /** * 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 { + /** + * Asks for a {@code Subscriber} instance, expects it to call {@code request()} in + * a timely manner and signals as many {@code onNext} items as the very first request + * amount specified by the {@code Subscriber}. + *

+ * Verifies rule: 2.1 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() throws Throwable; + /** + * Currently, this test is skipped because there is no agreed upon approach how + * to detect if the {@code Subscriber} really goes async or just responds in + * a timely manner. + *

+ * Verifies rule: 2.2 + */ void untested_spec202_blackbox_shouldAsynchronouslyDispatch() throws Exception; + /** + * Asks for a {@code Subscriber}, signals an {@code onSubscribe} followed by an {@code onComplete} synchronously, + * and checks if neither {@code request} nor {@code cancel} was called from within the {@code Subscriber}'s + * {@code onComplete} implementation. + *

+ * Verifies rule: 2.3 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete() throws Throwable; + /** + * Asks for a {@code Subscriber}, signals an {@code onSubscribe} followed by an {@code onError} synchronously, + * and checks if neither {@code request} nor {@code cancel} was called from within the {@code Subscriber}'s + * {@code onComplete} implementation. + *

+ * Verifies rule: 2.3 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError() throws Throwable; + /** + * Currently, this test is skipped because there is no way to check what the {@code Subscriber} "considers" + * since rule §2.3 forbids interaction from within the {@code onError} and {@code onComplete} methods. + *

+ * Verifies rule: 2.4 + *

+ * Notes: + *

+ */ void untested_spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError() throws Exception; + /** + * Asks for a {@code Subscriber}, signals {@code onSubscribe} twice synchronously and expects the second {@code Subscription} gets + * cancelled in a timely manner and without any calls to its {@code request} method. + *

+ * Verifies rule: 2.5 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal() throws Exception; + + /** + * Currently, this test is skipped because it requires more control over the {@code Subscriber} implementation + * to make it cancel the {@code Subscription} for some external condition. + *

+ * Verifies rule: 2.6 + */ void untested_spec206_blackbox_mustCallSubscriptionCancelIfItIsNoLongerValid() throws Exception; + /** + * Currently, this test is skipped because it requires more control over the {@code Subscriber} implementation + * to issue requests based on external stimulus. + *

+ * Verifies rule: 2.7 + */ void untested_spec207_blackbox_mustEnsureAllCallsOnItsSubscriptionTakePlaceFromTheSameThreadOrTakeCareOfSynchronization() throws Exception; + /** + * Currently, this test is skipped because there is no way to make the {@code Subscriber} implementation + * cancel the test's {@code Subscription} and check the outcome of sending {@code onNext}s after such + * cancel. + *

+ * Verifies rule: 2.8 + */ void untested_spec208_blackbox_mustBePreparedToReceiveOnNextSignalsAfterHavingCalledSubscriptionCancel() throws Throwable; + /** + * Asks for a {@code Subscriber}, expects it to request some amount and in turn be able to receive an {@code onComplete} + * synchronously from the {@code request} call without any {@code onNext} signals before that. + *

+ * Verifies rule: 2.9 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall() throws Throwable; + /** + * Asks for a {@code Subscriber} and expects it to handle {@code onComplete} independent of whether the {@code Subscriber} + * requests items or not. + *

+ * Verifies rule: 2.9 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall() throws Throwable; + /** + * Asks for a {@code Subscriber}, signals {@code onSubscribe} followed by an {@code onError} synchronously. + *

+ * Verifies rule: 2.10 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall() throws Throwable; + /** + * Currently, this test is skipped because it would require analyzing what the {@code Subscriber} implementation + * does. + *

+ * Verifies rule: 2.11 + */ void untested_spec211_blackbox_mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents() throws Exception; + /** + * Currently, this test is skipped because the test for + * {@link #required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal §2.5} + * is in a better position to test for handling the reuse of the same {@code Subscriber}. + *

+ * Verifies rule: 2.12 + *

+ * Notes: + *

+ */ void untested_spec212_blackbox_mustNotCallOnSubscribeMoreThanOnceBasedOnObjectEquality() throws Throwable; + /** + * Currently, this test is skipped because it would require more control over the {@code Subscriber} to + * fail internally in response to a set of legal event emissions, not throw any exception from the {@code Subscriber} + * methods and have it cancel the {@code Subscription}. + *

+ * Verifies rule: 2.13 + */ void untested_spec213_blackbox_failingOnSignalInvocation() throws Exception; + /** + * Asks for a {@code Subscriber} and signals an {@code onSubscribe} event with {@code null} as a parameter and + * expects an immediate {@code NullPointerException} to be thrown by the {@code Subscriber.onSubscribe} method. + *

+ * Verifies rule: 2.13 + *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec213_blackbox_onSubscribe_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable; + /** + * Asks for a {@code Subscriber}, signals an {@code onSubscribe} event followed by a + * {@code onNext} with {@code null} as a parameter and + * expects an immediate {@code NullPointerException} to be thrown by the {@code Subscriber.onNext} method. + *

+ * Verifies rule: 2.13 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable; + /** + * Asks for a {@code Subscriber}, signals an {@code onSubscribe} event followed by a + * {@code onError} with {@code null} as a parameter and + * expects an immediate {@code NullPointerException} to be thrown by the {@code Subscriber.onError} method. + *

+ * Verifies rule: 2.13 + *

+ * Notes: + *

+ *

+ * If this test fails, the following could be checked within the {@code Subscriber} implementation: + *

+ */ void required_spec213_blackbox_onError_mustThrowNullPointerExceptionWhenParametersAreNull() throws Throwable; + /** + * Currently, this test is skipped because there is no agreed upon way for specifying, enforcing and testing + * a {@code Subscriber} with an arbitrary context. + *

+ * Verifies rule: 3.1 + */ void untested_spec301_blackbox_mustNotBeCalledOutsideSubscriberContext() throws Exception; + /** + * Currently, this test is skipped because element production is the responsibility of the {@code Publisher} and + * a {@code Subscription} is not expected to be the active element in an established subscription. + *

+ * Verifies rule: 3.8 + */ void untested_spec308_blackbox_requestMustRegisterGivenNumberElementsToBeProduced() throws Throwable; + /** + * Currently, this test is skipped because element production is the responsibility of the {@code Publisher} and + * a {@code Subscription} is not expected to be the active element in an established subscription. + *

+ * Verifies rule: 3.10 + *

+ * Notes: + *

+ */ void untested_spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber() throws Exception; + /** + * Currently, this test is skipped because signal production is the responsibility of the {@code Publisher} and + * a {@code Subscription} is not expected to be the active element in an established subscription. + *

+ * Verifies rule: 3.11 + *

+ * Notes: + *

+ */ void untested_spec311_blackbox_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exception; + /** + * Currently, this test is skipped because it is the responsibility of the {@code Publisher} deal with the case + * that all subscribers have cancelled their subscription. + *

+ * Verifies rule: 3.14 + *

+ * Notes: + *

+ */ void untested_spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists() throws Exception; + /** + * Currently, this test is skipped because it requires more control over the {@code Subscriber} implementation + * thus there is no way to detect that the {@code Subscriber} called its own {@code onError} method in response + * to an exception thrown from {@code Subscription.cancel}. + *

+ * Verifies rule: 3.15 + */ void untested_spec315_blackbox_cancelMustNotThrowExceptionAndMustSignalOnError() throws Exception; + /** + * Currently, this test is skipped because it requires more control over the {@code Subscriber} implementation + * thus there is no way to detect that the {@code Subscriber} called its own {@code onError} method in response + * to an exception thrown from {@code Subscription.request}. + *

+ * Verifies rule: 3.16 + */ void untested_spec316_blackbox_requestMustNotThrowExceptionAndMustOnErrorTheSubscriber() throws Exception; }