Class AbstractSubscriber<T>

  • Type Parameters:
    T - the type of the items
    All Implemented Interfaces:
    org.reactivestreams.Subscriber<T>, org.reactivestreams.Subscription

    public class AbstractSubscriber<T>
    extends java.lang.Object
    implements org.reactivestreams.Subscriber<T>, org.reactivestreams.Subscription
    A convenient base class for a subscriber and subscription to extend in tests and that manages the subscription and requests.

    Implementations shall override onNext(Object), onError(Throwable) and/or onComplete() to add test-specific custom logic.

    • Constructor Detail

      • AbstractSubscriber

        public AbstractSubscriber()
        Creates a new AbstractSubscriber with 0 upfront requests.
      • AbstractSubscriber

        public AbstractSubscriber​(long req)
        Creates a new AbstractSubscriber with req upfront requests.
        Parameters:
        req - the number of upfront requests
    • Method Detail

      • onSubscribe

        public void onSubscribe​(org.reactivestreams.Subscription s)
        Specified by:
        onSubscribe in interface org.reactivestreams.Subscriber<T>
      • onNext

        public void onNext​(T t)
        Specified by:
        onNext in interface org.reactivestreams.Subscriber<T>
      • onError

        public void onError​(java.lang.Throwable t)
        Specified by:
        onError in interface org.reactivestreams.Subscriber<T>
      • onComplete

        public void onComplete()
        Specified by:
        onComplete in interface org.reactivestreams.Subscriber<T>
      • request

        public void request​(long n)
        Specified by:
        request in interface org.reactivestreams.Subscription
      • cancel

        public void cancel()
        Specified by:
        cancel in interface org.reactivestreams.Subscription