| 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.tck.SubscriberWhiteboxVerification; |
| 17 |
import org.reactivestreams.tck.TestEnvironment; |
| 18 |
import org.reactivestreams.tck.flow.support.SubscriberWhiteboxVerificationRules; |
| 19 |
|
| 20 |
import java.util.concurrent.Flow; |
| 21 |
|
| 22 |
/** |
| 23 |
* Provides whitebox style tests for verifying {@link java.util.concurrent.Flow.Subscriber} |
| 24 |
* and {@link java.util.concurrent.Flow.Subscription} specification rules. |
| 25 |
* |
| 26 |
* @see java.util.concurrent.Flow.Subscriber |
| 27 |
* @see java.util.concurrent.Flow.Subscription |
| 28 |
*/ |
| 29 |
public abstract class FlowSubscriberWhiteboxVerification<T> extends SubscriberWhiteboxVerification<T> |
| 30 |
implements SubscriberWhiteboxVerificationRules { |
| 31 |
|
| 32 |
protected FlowSubscriberWhiteboxVerification(TestEnvironment env) { |
| 33 |
super(env); |
| 34 |
} |
| 35 |
|
| 36 |
@Override |
| 37 |
final public Subscriber<T> createSubscriber(WhiteboxSubscriberProbe<T> probe) { |
| 38 |
return FlowAdapters.toSubscriber(createFlowSubscriber(probe)); |
| 39 |
} |
| 40 |
/** |
| 41 |
* This is the main method you must implement in your test incarnation. |
| 42 |
* It must create a new {@link org.reactivestreams.Subscriber} instance to be subjected to the testing logic. |
| 43 |
* |
| 44 |
* In order to be meaningfully testable your Subscriber must inform the given |
| 45 |
* `WhiteboxSubscriberProbe` of the respective events having been received. |
| 46 |
*/ |
| 47 |
protected abstract Flow.Subscriber<T> createFlowSubscriber(WhiteboxSubscriberProbe<T> probe); |
| 48 |
} |