Class SubscriberBlackboxVerification<T>

    • Constructor Detail

      • SubscriberBlackboxVerification

        protected SubscriberBlackboxVerification​(TestEnvironment env)
    • Method Detail

      • createSubscriber

        public abstract Subscriber<T> createSubscriber()
        This is the main method you must implement in your test incarnation. It must create a new Subscriber instance to be subjected to the testing logic.
      • triggerRequest

        public void triggerRequest​(Subscriber<? super T> subscriber)
        Override this method if the Subscriber implementation you are verifying needs an external signal before it signals demand to its Publisher. By default this method does nothing.
      • startPublisherExecutorService

        @BeforeClass
        public void startPublisherExecutorService()
      • shutdownPublisherExecutorService

        @AfterClass
        public void shutdownPublisherExecutorService()
      • setUp

        @BeforeMethod
        public void setUp()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest

        public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest()
                                                                              throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber instance, expects it to call request() in a timely manner and signals as many onNext items as the very first request amount specified by the Subscriber.

        Verifies rule: 2.1

        Notes:

        • This test emits the number of items requested thus the Subscriber implementation should not request too much.
        • Only the very first request amount is considered.
        • This test doesn't signal onComplete after the first set of onNext signals has been emitted and may cause resource leak in Subscribers that expect a finite Publisher.
        • The test ignores cancellation from the Subscriber and emits the requested amount regardless.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber requires external stimulus to begin requesting; override the triggerRequest(org.reactivestreams.Subscriber) method in this case,
        • the TestEnvironment has large enough timeout specified in case the Subscriber has some time-delay behavior,
        • if the Subscriber requests zero or a negative value in some circumstances,
        • if the Subscriber throws an unchecked exception from its onSubscribe or onNext methods.
        Specified by:
        required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete

        public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete()
                                                                                               throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, signals an onSubscribe followed by an onComplete synchronously, and checks if neither request nor cancel was called from within the Subscriber's onComplete implementation.

        Verifies rule: 2.3

        Notes:

        • The test checks for the presensce of method named "onComplete" in the current stacktrace when handling the request or cancel calls in the test's own Subscription.

        If this test fails, the following could be checked within the Subscriber implementation:

        • no calls happen to request or cancel in response to an onComplete directly or indirectly,
        • if the Subscriber throws an unchecked exception from its onSubscribe or onComplete methods.
        Specified by:
        required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnComplete in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError

        public void required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError()
                                                                                            throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, signals an onSubscribe followed by an onError synchronously, and checks if neither request nor cancel was called from within the Subscriber's onComplete implementation.

        Verifies rule: 2.3

        Notes:

        • The test checks for the presensce of method named "onError" in the current stacktrace when handling the request or cancel calls in the test's own Subscription.

        If this test fails, the following could be checked within the Subscriber implementation:

        • no calls happen to request or cancel in response to an onError directly or indirectly,
        • if the Subscriber throws an unchecked exception from its onSubscribe or onError methods.
        Specified by:
        required_spec203_blackbox_mustNotCallMethodsOnSubscriptionOrPublisherInOnError in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • untested_spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError

        public void untested_spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError()
                                                                                                                 throws java.lang.Exception
        Description copied from interface: SubscriberBlackboxVerificationRules
        Currently, this test is skipped because there is no way to check what the Subscriber "considers" since rule §2.3 forbids interaction from within the onError and onComplete methods.

        Verifies rule: 2.4

        Notes:

        • It would be possible to check if there was an async interaction with the test's Subscription within a grace period but such check is still not generally decisive.
        Specified by:
        untested_spec204_blackbox_mustConsiderTheSubscriptionAsCancelledInAfterRecievingOnCompleteOrOnError in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Exception
      • required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal

        public void required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal()
                                                                                                                                 throws java.lang.Exception
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, signals onSubscribe twice synchronously and expects the second Subscription gets cancelled in a timely manner and without any calls to its request method.

        Verifies rule: 2.5

        Notes:

        • The test doesn't signal any other events than onSubscribe and may cause resource leak in Subscribers that expect a finite Publisher.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscribe.onSubscribe implementation actually tries to detect multiple calls to it,
        • if the second Subscription is cancelled asynchronously and that takes longer time than the TestEnvironment's timeout permits.
        Specified by:
        required_spec205_blackbox_mustCallSubscriptionCancelIfItAlreadyHasAnSubscriptionAndReceivesAnotherOnSubscribeSignal in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Exception
      • required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall

        public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall()
                                                                                                         throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, expects it to request some amount and in turn be able to receive an onComplete synchronously from the request call without any onNext signals before that.

        Verifies rule: 2.9

        Notes:

        • The test ignores cancellation from the Subscriber.
        • Invalid request amounts are ignored by this test.
        • Concurrent calls to the test's Subscription.request() must be externally synchronized, otherwise such case results probabilistically in multiple onComplete calls by the test.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber throws an unchecked exception from its onSubscribe or onComplete methods.
        • if the Subscriber requires external stimulus to begin requesting; override the triggerRequest(org.reactivestreams.Subscriber) method in this case,
        Specified by:
        required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall

        public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall()
                                                                                                            throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber and expects it to handle onComplete independent of whether the Subscriber requests items or not.

        Verifies rule: 2.9

        Notes:

        • Currently, the test doesn't call onSubscribe on the Subscriber which violates §1.9.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber throws an unchecked exception from its onSubscribe or onComplete methods.
        Specified by:
        required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall

        public void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall()
                                                                                                      throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, signals onSubscribe followed by an onError synchronously.

        Verifies rule: 2.10

        Notes:

        • Despite the method name, the test doesn't expect a request signal from Subscriber and emits the onError signal anyway.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber throws an unchecked exception from its onSubscribe or onError methods.
        Specified by:
        required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • untested_spec213_blackbox_failingOnSignalInvocation

        public void untested_spec213_blackbox_failingOnSignalInvocation()
                                                                 throws java.lang.Exception
        Description copied from interface: SubscriberBlackboxVerificationRules
        Currently, this test is skipped because it would require more control over the Subscriber to fail internally in response to a set of legal event emissions, not throw any exception from the Subscriber methods and have it cancel the Subscription.

        Verifies rule: 2.13

        Specified by:
        untested_spec213_blackbox_failingOnSignalInvocation in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Exception
      • required_spec213_blackbox_onSubscribe_mustThrowNullPointerExceptionWhenParametersAreNull

        public void required_spec213_blackbox_onSubscribe_mustThrowNullPointerExceptionWhenParametersAreNull()
                                                                                                      throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber and signals an onSubscribe event with null as a parameter and expects an immediate NullPointerException to be thrown by the Subscriber.onSubscribe method.

        Verifies rule: 2.13

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber throws a NullPointerException from its onSubscribe method in response to a null parameter and not some other unchecked exception or no exception at all.
        Specified by:
        required_spec213_blackbox_onSubscribe_mustThrowNullPointerExceptionWhenParametersAreNull in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull

        public void required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull()
                                                                                                 throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, signals an onSubscribe event followed by a onNext with null as a parameter and expects an immediate NullPointerException to be thrown by the Subscriber.onNext method.

        Verifies rule: 2.13

        Notes:

        • The test ignores cancellation and requests from the Subscriber and emits the onNext signal with a null parameter anyway.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber throws a NullPointerException from its onNext method in response to a null parameter and not some other unchecked exception or no exception at all.
        Specified by:
        required_spec213_blackbox_onNext_mustThrowNullPointerExceptionWhenParametersAreNull in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • required_spec213_blackbox_onError_mustThrowNullPointerExceptionWhenParametersAreNull

        public void required_spec213_blackbox_onError_mustThrowNullPointerExceptionWhenParametersAreNull()
                                                                                                  throws java.lang.Throwable
        Description copied from interface: SubscriberBlackboxVerificationRules
        Asks for a Subscriber, signals an onSubscribe event followed by a onError with null as a parameter and expects an immediate NullPointerException to be thrown by the Subscriber.onError method.

        Verifies rule: 2.13

        Notes:

        • The test ignores cancellation from the Subscriber and emits the onError signal with a null parameter anyway.

        If this test fails, the following could be checked within the Subscriber implementation:

        • if the Subscriber throws a NullPointerException from its onNext method in response to a null parameter and not some other unchecked exception or no exception at all.
        Specified by:
        required_spec213_blackbox_onError_mustThrowNullPointerExceptionWhenParametersAreNull in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Throwable
      • untested_spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber

        public void untested_spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber()
                                                                                     throws java.lang.Exception
        Description copied from interface: SubscriberBlackboxVerificationRules
        Currently, this test is skipped because element production is the responsibility of the Publisher and a Subscription is not expected to be the active element in an established subscription.

        Verifies rule: 3.10

        Notes:

        • This could be tested with a synchronous source currently not available within the TCK.
        Specified by:
        untested_spec310_blackbox_requestMaySynchronouslyCallOnNextOnSubscriber in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Exception
      • untested_spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists

        public void untested_spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists()
                                                                                                       throws java.lang.Exception
        Description copied from interface: SubscriberBlackboxVerificationRules
        Currently, this test is skipped because it is the responsibility of the Publisher deal with the case that all subscribers have cancelled their subscription.

        Verifies rule: 3.14

        Notes:

        • The specification lists this as an optional behavior because only some Publisher implementations (most likely Processors) would coordinate with multiple Subscribers.
        Specified by:
        untested_spec314_blackbox_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists in interface SubscriberBlackboxVerificationRules
        Throws:
        java.lang.Exception
      • notVerified

        public void notVerified()