@@ -22,19 +22,19 @@ protected SubscriberVerification(TestEnvironment env) {
22
22
* In order to be meaningfully testable your Subscriber must inform the given
23
23
* `SubscriberProbe` of the respective events having been received.
24
24
*/
25
- abstract Subscriber <T > createSubscriber (SubscriberProbe <T > probe );
25
+ public abstract Subscriber <T > createSubscriber (SubscriberProbe <T > probe );
26
26
27
27
/**
28
28
* Helper method required for generating test elements.
29
29
* It must create a Publisher for a stream with exactly the given number of elements.
30
30
* If `elements` is zero the produced stream must be infinite.
31
31
*/
32
- abstract Publisher <T > createHelperPublisher (int elements );
32
+ public abstract Publisher <T > createHelperPublisher (int elements );
33
33
34
34
////////////////////// TEST SETUP VERIFICATION ///////////////////////////
35
35
36
36
@ Test
37
- void exerciseHappyPath () throws InterruptedException {
37
+ public void exerciseHappyPath () throws InterruptedException {
38
38
new TestSetup (env ) {{
39
39
puppet ().triggerRequestMore (1 );
40
40
@@ -63,7 +63,7 @@ void exerciseHappyPath() throws InterruptedException {
63
63
// must asynchronously schedule a respective event to the subscriber
64
64
// must not call any methods on the Subscription, the Publisher or any other Publishers or Subscribers
65
65
@ Test
66
- void onSubscribeAndOnNextMustAsynchronouslyScheduleAnEvent () {
66
+ public void onSubscribeAndOnNextMustAsynchronouslyScheduleAnEvent () {
67
67
// cannot be meaningfully tested, or can it?
68
68
}
69
69
@@ -72,14 +72,14 @@ void onSubscribeAndOnNextMustAsynchronouslyScheduleAnEvent() {
72
72
// must not call any methods on the Subscription, the Publisher or any other Publishers or Subscribers
73
73
// must consider the Subscription cancelled after having received the event
74
74
@ Test
75
- void onCompleteAndOnErrorMustAsynchronouslyScheduleAnEvent () {
75
+ public void onCompleteAndOnErrorMustAsynchronouslyScheduleAnEvent () {
76
76
// cannot be meaningfully tested, or can it?
77
77
}
78
78
79
79
// A Subscriber
80
80
// must not accept an `onSubscribe` event if it already has an active Subscription
81
81
@ Test
82
- void mustNotAcceptAnOnSubscribeEventIfItAlreadyHasAnActiveSubscription () throws InterruptedException {
82
+ public void mustNotAcceptAnOnSubscribeEventIfItAlreadyHasAnActiveSubscription () throws InterruptedException {
83
83
new TestSetup (env ) {{
84
84
// try to subscribe another time, if the subscriber calls `probe.registerOnSubscribe` the test will fail
85
85
sub ().onSubscribe (
@@ -100,7 +100,7 @@ public void cancel() {
100
100
// A Subscriber
101
101
// must call Subscription::cancel during shutdown if it still has an active Subscription
102
102
@ Test
103
- void mustCallSubscriptionCancelDuringShutdownIfItStillHasAnActiveSubscription () throws InterruptedException {
103
+ public void mustCallSubscriptionCancelDuringShutdownIfItStillHasAnActiveSubscription () throws InterruptedException {
104
104
new TestSetup (env ) {{
105
105
puppet ().triggerShutdown ();
106
106
expectCancelling ();
@@ -112,14 +112,14 @@ void mustCallSubscriptionCancelDuringShutdownIfItStillHasAnActiveSubscription()
112
112
// A Subscriber
113
113
// must ensure that all calls on a Subscription take place from the same thread or provide for respective external synchronization
114
114
@ Test
115
- void mustEnsureThatAllCallsOnASubscriptionTakePlaceFromTheSameThreadOrProvideExternalSync () {
115
+ public void mustEnsureThatAllCallsOnASubscriptionTakePlaceFromTheSameThreadOrProvideExternalSync () {
116
116
// cannot be meaningfully tested, or can it?
117
117
}
118
118
119
119
// A Subscriber
120
120
// must be prepared to receive one or more `onNext` events after having called Subscription::cancel
121
121
@ Test
122
- void mustBePreparedToReceiveOneOrMoreOnNextEventsAfterHavingCalledSubscriptionCancel () throws InterruptedException {
122
+ public void mustBePreparedToReceiveOneOrMoreOnNextEventsAfterHavingCalledSubscriptionCancel () throws InterruptedException {
123
123
new TestSetup (env ) {{
124
124
puppet ().triggerRequestMore (1 );
125
125
puppet ().triggerCancel ();
@@ -133,7 +133,7 @@ void mustBePreparedToReceiveOneOrMoreOnNextEventsAfterHavingCalledSubscriptionCa
133
133
// A Subscriber
134
134
// must be prepared to receive an `onComplete` event with a preceding Subscription::requestMore call
135
135
@ Test
136
- void mustBePreparedToReceiveAnOnCompleteEventWithAPrecedingSubscriptionRequestMore () throws InterruptedException {
136
+ public void mustBePreparedToReceiveAnOnCompleteEventWithAPrecedingSubscriptionRequestMore () throws InterruptedException {
137
137
new TestSetup (env ) {{
138
138
puppet ().triggerRequestMore (1 );
139
139
sendCompletion ();
@@ -146,7 +146,7 @@ void mustBePreparedToReceiveAnOnCompleteEventWithAPrecedingSubscriptionRequestMo
146
146
// A Subscriber
147
147
// must be prepared to receive an `onComplete` event without a preceding Subscription::requestMore call
148
148
@ Test
149
- void mustBePreparedToReceiveAnOnCompleteEventWithoutAPrecedingSubscriptionRequestMore () throws InterruptedException {
149
+ public void mustBePreparedToReceiveAnOnCompleteEventWithoutAPrecedingSubscriptionRequestMore () throws InterruptedException {
150
150
new TestSetup (env ) {{
151
151
sendCompletion ();
152
152
probe .expectCompletion ();
@@ -158,7 +158,7 @@ void mustBePreparedToReceiveAnOnCompleteEventWithoutAPrecedingSubscriptionReques
158
158
// A Subscriber
159
159
// must be prepared to receive an `onError` event with a preceding Subscription::requestMore call
160
160
@ Test
161
- void mustBePreparedToReceiveAnOnErrorEventWithAPrecedingSubscriptionRequestMore () throws InterruptedException {
161
+ public void mustBePreparedToReceiveAnOnErrorEventWithAPrecedingSubscriptionRequestMore () throws InterruptedException {
162
162
new TestSetup (env ) {{
163
163
puppet ().triggerRequestMore (1 );
164
164
Exception ex = new RuntimeException ("Test exception" );
@@ -172,7 +172,7 @@ void mustBePreparedToReceiveAnOnErrorEventWithAPrecedingSubscriptionRequestMore(
172
172
// A Subscriber
173
173
// must be prepared to receive an `onError` event without a preceding Subscription::requestMore call
174
174
@ Test
175
- void mustBePreparedToReceiveAnOnErrorEventWithoutAPrecedingSubscriptionRequestMore () throws InterruptedException {
175
+ public void mustBePreparedToReceiveAnOnErrorEventWithoutAPrecedingSubscriptionRequestMore () throws InterruptedException {
176
176
new TestSetup (env ) {{
177
177
Exception ex = new RuntimeException ("Test exception" );
178
178
sendError (ex );
@@ -184,15 +184,15 @@ void mustBePreparedToReceiveAnOnErrorEventWithoutAPrecedingSubscriptionRequestMo
184
184
// A Subscriber
185
185
// must make sure that all calls on its `onXXX` methods happen-before the processing of the respective events
186
186
@ Test
187
- void mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents () {
187
+ public void mustMakeSureThatAllCallsOnItsMethodsHappenBeforeTheProcessingOfTheRespectiveEvents () {
188
188
// cannot be meaningfully tested, or can it?
189
189
}
190
190
191
191
/////////////////////// ADDITIONAL "COROLLARY" TESTS //////////////////////
192
192
193
193
/////////////////////// TEST INFRASTRUCTURE //////////////////////
194
194
195
- class TestSetup extends ManualPublisher <T > {
195
+ public class TestSetup extends ManualPublisher <T > {
196
196
ManualSubscriber <T > tees ; // gives us access to an infinite stream of T values
197
197
Probe probe ;
198
198
T lastT = null ;
@@ -205,24 +205,24 @@ public TestSetup(TestEnvironment env) throws InterruptedException {
205
205
probe .puppet .expectCompletion (env .defaultTimeoutMillis (), String .format ("Subscriber %s did not `registerOnSubscribe`" , sub ()));
206
206
}
207
207
208
- Subscriber <T > sub () {
208
+ public Subscriber <T > sub () {
209
209
return subscriber .get ();
210
210
}
211
211
212
- SubscriberPuppet puppet () {
212
+ public SubscriberPuppet puppet () {
213
213
return probe .puppet .value ();
214
214
}
215
215
216
- void sendNextTFromUpstream () throws InterruptedException {
216
+ public void sendNextTFromUpstream () throws InterruptedException {
217
217
sendNext (nextT ());
218
218
}
219
219
220
- T nextT () throws InterruptedException {
220
+ public T nextT () throws InterruptedException {
221
221
lastT = tees .requestNextElement ();
222
222
return lastT ;
223
223
}
224
224
225
- class Probe implements SubscriberProbe <T > {
225
+ public class Probe implements SubscriberProbe <T > {
226
226
Promise <SubscriberPuppet > puppet = new Promise <SubscriberPuppet >(env );
227
227
Receptacle <T > elements = new Receptacle <T >(env );
228
228
Latch completed = new Latch (env );
@@ -248,30 +248,30 @@ public void registerOnError(Throwable cause) {
248
248
error .complete (cause );
249
249
}
250
250
251
- void expectNext (T expected ) throws InterruptedException {
251
+ public void expectNext (T expected ) throws InterruptedException {
252
252
expectNext (expected , env .defaultTimeoutMillis ());
253
253
}
254
254
255
- void expectNext (T expected , long timeoutMillis ) throws InterruptedException {
255
+ public void expectNext (T expected , long timeoutMillis ) throws InterruptedException {
256
256
T received = elements .next (timeoutMillis , String .format ("Subscriber %s did not call `registerOnNext(%s)`" , sub (), expected ));
257
257
if (!received .equals (expected )) {
258
258
env .flop (String .format ("Subscriber %s called `registerOnNext(%s)` rather than `registerOnNext(%s)`" , sub (), received , expected ));
259
259
}
260
260
}
261
261
262
- void expectCompletion () throws InterruptedException {
262
+ public void expectCompletion () throws InterruptedException {
263
263
expectCompletion (env .defaultTimeoutMillis ());
264
264
}
265
265
266
- void expectCompletion (long timeoutMillis ) throws InterruptedException {
266
+ public void expectCompletion (long timeoutMillis ) throws InterruptedException {
267
267
completed .expectClose (timeoutMillis , String .format ("Subscriber %s did not call `registerOnComplete()`" , sub ()));
268
268
}
269
269
270
- void expectError (Throwable expected ) throws InterruptedException {
270
+ public void expectError (Throwable expected ) throws InterruptedException {
271
271
expectError (expected , env .defaultTimeoutMillis ());
272
272
}
273
273
274
- void expectError (Throwable expected , long timeoutMillis ) throws InterruptedException {
274
+ public void expectError (Throwable expected , long timeoutMillis ) throws InterruptedException {
275
275
error .expectCompletion (timeoutMillis , String .format ("Subscriber %s did not call `registerOnError(%s)`" , sub (), expected ));
276
276
if (error .value () != expected ) {
277
277
env .flop (String .format ("Subscriber %s called `registerOnError(%s)` rather than `registerOnError(%s)`" , sub (), error .value (), expected ));
@@ -284,7 +284,7 @@ public void verifyNoAsyncErrors() {
284
284
}
285
285
}
286
286
287
- interface SubscriberProbe <T > {
287
+ public interface SubscriberProbe <T > {
288
288
/**
289
289
* Must be called by the test subscriber when it has received the `onSubscribe` event.
290
290
*/
@@ -306,7 +306,7 @@ interface SubscriberProbe<T> {
306
306
void registerOnError (Throwable cause );
307
307
}
308
308
309
- interface SubscriberPuppet {
309
+ public interface SubscriberPuppet {
310
310
void triggerShutdown ();
311
311
312
312
void triggerRequestMore (int elements );
0 commit comments