Debian Codegraph @

tck-flow/src/main/java/org/reactivestreams/tck/flow/FlowSubscriberBlackboxVerification.java

raw
1 /************************************************************************
2 * Licensed under Public Domain (CC0) *
3 * *
4 * To the extent possible under law, the person who associated CC0 with *
5 * this code has waived all copyright and related or neighboring *
6 * rights to this code. *
7 * *
8 * You should have received a copy of the CC0 legalcode along with this *
9 * work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.*
10 ************************************************************************/
11
12 package org.reactivestreams.tck.flow;
13
14 import org.reactivestreams.FlowAdapters;
15 import org.reactivestreams.Subscriber;
16 import org.reactivestreams.Subscription;
17 import org.reactivestreams.tck.SubscriberBlackboxVerification;
18 import org.reactivestreams.tck.TestEnvironment;
19 import org.reactivestreams.tck.flow.support.SubscriberBlackboxVerificationRules;
20
21 import java.util.concurrent.Flow;
22
23 /**
24 * Provides tests for verifying {@link java.util.concurrent.Flow.Subscriber} and {@link java.util.concurrent.Flow.Subscription}
25 * specification rules, without any modifications to the tested implementation (also known as "Black Box" testing).
26 *
27 * This verification is NOT able to check many of the rules of the spec, and if you want more
28 * verification of your implementation you'll have to implement {@code org.reactivestreams.tck.SubscriberWhiteboxVerification}
29 * instead.
30 *
31 * @see java.util.concurrent.Flow.Subscriber
32 * @see java.util.concurrent.Flow.Subscription
33 */
34 public abstract class FlowSubscriberBlackboxVerification<T> extends SubscriberBlackboxVerification<T>
35 implements SubscriberBlackboxVerificationRules {
36
37 protected FlowSubscriberBlackboxVerification(TestEnvironment env) {
38 super(env);
39 }
40
41 @Override
42 public final void triggerRequest(Subscriber<? super T> subscriber) {
43 triggerFlowRequest(FlowAdapters.toFlowSubscriber(subscriber));
44 }
45 /**
46 * Override this method if the {@link java.util.concurrent.Flow.Subscriber} implementation you are verifying
47 * needs an external signal before it signals demand to its Publisher.
48 *
49 * By default this method does nothing.
50 */
51 public void triggerFlowRequest(Flow.Subscriber<? super T> subscriber) {
52 // this method is intentionally left blank
53 }
54
55 @Override
56 public final Subscriber<T> createSubscriber() {
57 return FlowAdapters.<T>toSubscriber(createFlowSubscriber());
58 }
59 /**
60 * This is the main method you must implement in your test incarnation.
61 * It must create a new {@link Flow.Subscriber} instance to be subjected to the testing logic.
62 */
63 abstract public Flow.Subscriber<T> createFlowSubscriber();
64
65 }