@@ -437,8 +437,30 @@ public void spec312_cancelMustRequestThePublisherToEventuallyStopSignaling() thr
437
437
subscriberTest (new TestStageTestRun () {
438
438
@ Override
439
439
public void run (WhiteboxTestStage stage ) throws InterruptedException {
440
+ final int requestedElements = 5 ;
441
+
442
+ stage .puppet ().triggerRequest (requestedElements );
443
+ stage .expectRequest ();
444
+ stage .signalNext ();
445
+
446
+ // cancelling is NOT REQUIRED to stop the stream immediatly, example: there may be signals in flight
440
447
stage .puppet ().signalCancel ();
441
- stage .expectCancelling ();
448
+
449
+ stage .probe ().expectNext ();
450
+ boolean stillBeingSignalled ;
451
+ do {
452
+ // depends on Rule 3.6 https://github.com/reactive-streams/reactive-streams#3.12
453
+ // requesting from a cancelled subscription MUST be a NOPs
454
+ stage .puppet ().triggerRequest (1 );
455
+ stage .signalNext (); // signalling will stop, since Subscription cancelled
456
+
457
+ try {
458
+ stage .probe ().expectNone ();
459
+ stillBeingSignalled = false ;
460
+ } catch (Throwable th ) {
461
+ stillBeingSignalled = true ;
462
+ }
463
+ } while (stillBeingSignalled );
442
464
443
465
stage .verifyNoAsyncErrors ();
444
466
}
@@ -518,7 +540,7 @@ public void subscriberTestWithoutSetup(TestStageTestRun body) throws Throwable {
518
540
519
541
public class WhiteboxTestStage extends ManualPublisher <T > {
520
542
public Publisher <T > pub ;
521
- public ManualSubscriber <T > tees ; // gives us access to an infinite stream of T values
543
+ public ManualSubscriber <T > tees ; // gives us access to a stream T values
522
544
public WhiteboxSubscriberProbe <T > probe ;
523
545
524
546
public T lastT = null ;
@@ -546,6 +568,10 @@ public SubscriberPuppet puppet() {
546
568
return probe .puppet ();
547
569
}
548
570
571
+ public WhiteboxSubscriberProbe <T > probe () {
572
+ return probe ;
573
+ }
574
+
549
575
public Publisher <T > createHelperPublisher (long elements ) {
550
576
return SubscriberWhiteboxVerification .this .createHelperPublisher (elements );
551
577
}
0 commit comments