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