@@ -249,79 +249,49 @@ public void untested_spec208_blackbox_mustBePreparedToReceiveOnNextSignalsAfterH
249
249
250
250
@ Override @ Test
251
251
public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPrecedingRequestCall () throws Throwable {
252
- blackboxSubscriberWithoutSetupTest (new BlackboxTestStageTestRun () {
253
- @ Override
252
+ blackboxSubscriberTest (new BlackboxTestStageTestRun () {
253
+ @ Override @ SuppressWarnings ( "ThrowableResultOfMethodCallIgnored" )
254
254
public void run (BlackboxTestStage stage ) throws Throwable {
255
- final Publisher <T > pub = new Publisher <T >() {
256
- @ Override public void subscribe (final Subscriber <? super T > s ) {
257
- s .onSubscribe (new Subscription () {
258
- private boolean completed = false ;
259
-
260
- @ Override public void request (long n ) {
261
- if (!completed ) {
262
- completed = true ;
263
- s .onComplete (); // Publisher now realises that it is in fact already completed
264
- }
265
- }
266
-
267
- @ Override public void cancel () {
268
- // noop, ignore
269
- }
270
- });
271
- }
272
- };
273
-
274
- final Subscriber <T > sub = createSubscriber ();
275
- final BlackboxSubscriberProxy <T > probe = stage .createBlackboxSubscriberProxy (env , sub );
276
-
277
- pub .subscribe (probe );
278
- triggerRequest (sub );
279
- probe .expectCompletion ();
280
- probe .expectNone ();
281
-
282
- env .verifyNoAsyncErrorsNoDelay ();
255
+ triggerRequest (stage .subProxy ().sub ());
256
+ final long notUsed = stage .expectRequest (); // received request signal
257
+ stage .sub ().onComplete ();
258
+ stage .subProxy ().expectCompletion ();
283
259
}
284
260
});
285
261
}
286
262
287
263
@ Override @ Test
288
264
public void required_spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall () throws Throwable {
289
- blackboxSubscriberWithoutSetupTest (new BlackboxTestStageTestRun () {
290
- @ Override
265
+ blackboxSubscriberTest (new BlackboxTestStageTestRun () {
266
+ @ Override @ SuppressWarnings ( "ThrowableResultOfMethodCallIgnored" )
291
267
public void run (BlackboxTestStage stage ) throws Throwable {
292
- final Publisher <T > pub = new Publisher <T >() {
293
- @ Override
294
- public void subscribe (final Subscriber <? super T > s ) {
295
- s .onSubscribe (new Subscription () {
296
- @ Override public void request (long n ) {
297
- // do nothing...
298
- }
299
- @ Override public void cancel () {
300
- // do nothing...
301
- }
302
- });
303
- // immediately complete
304
- s .onComplete ();
305
- }
306
- };
307
-
308
- final Subscriber <T > sub = createSubscriber ();
309
- final BlackboxSubscriberProxy <T > probe = stage .createBlackboxSubscriberProxy (env , sub );
310
-
311
- pub .subscribe (probe );
312
- probe .expectCompletion ();
313
-
314
- env .verifyNoAsyncErrorsNoDelay ();
268
+ final Subscriber <? super T > sub = stage .sub ();
269
+ sub .onComplete ();
270
+ stage .subProxy ().expectCompletion ();
315
271
}
316
272
});
317
273
}
318
274
319
275
@ Override @ Test
320
276
public void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithPrecedingRequestCall () throws Throwable {
321
277
blackboxSubscriberTest (new BlackboxTestStageTestRun () {
322
- @ Override
323
- @ SuppressWarnings ("ThrowableResultOfMethodCallIgnored" )
278
+ @ Override @ SuppressWarnings ("ThrowableResultOfMethodCallIgnored" )
324
279
public void run (BlackboxTestStage stage ) throws Throwable {
280
+ triggerRequest (stage .subProxy ().sub ());
281
+ final long notUsed = stage .expectRequest (); // received request signal
282
+ stage .sub ().onError (new TestException ()); // in response to that, we fail
283
+ stage .subProxy ().expectError (Throwable .class );
284
+ }
285
+ });
286
+ }
287
+
288
+ // Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#2.10
289
+ @ Override @ Test
290
+ public void required_spec210_blackbox_mustBePreparedToReceiveAnOnErrorSignalWithoutPrecedingRequestCall () throws Throwable {
291
+ blackboxSubscriberTest (new BlackboxTestStageTestRun () {
292
+ @ Override @ SuppressWarnings ("ThrowableResultOfMethodCallIgnored" )
293
+ public void run (BlackboxTestStage stage ) throws Throwable {
294
+
325
295
stage .sub ().onError (new TestException ());
326
296
stage .subProxy ().expectError (Throwable .class );
327
297
}
0 commit comments