@@ -52,6 +52,17 @@ protected SubscriberWhiteboxVerification(TestEnvironment env) {
52
52
*/
53
53
public abstract Publisher <T > createHelperPublisher (long elements );
54
54
55
+ /**
56
+ * Used to break possibly infinite wait-loops.
57
+ * Some Rules use the "eventually stop signalling" wording, which requires the test to spin accepting {@code onNext}
58
+ * signals until no more are signalled. In these tests, this value will be used as upper bound on the number of spin iterations.
59
+ *
60
+ * Override this method in case your implementation synchronously signals very large batches before reacting to cancellation (for example).
61
+ */
62
+ public long maxOnNextSignalsInTest () {
63
+ return 100 ;
64
+ }
65
+
55
66
////////////////////// TEST ENV CLEANUP /////////////////////////////////////
56
67
57
68
@ BeforeMethod
@@ -431,20 +442,6 @@ public void spec311_requestMaySynchronouslyCallOnCompleteOrOnError() throws Exce
431
442
notVerified (); // cannot be meaningfully tested, or can it?
432
443
}
433
444
434
- // Verifies rule: https://github.com/reactive-streams/reactive-streams#3.12
435
- @ Required @ Test
436
- public void spec312_cancelMustRequestThePublisherToEventuallyStopSignaling () throws Throwable {
437
- subscriberTest (new TestStageTestRun () {
438
- @ Override
439
- public void run (WhiteboxTestStage stage ) throws InterruptedException {
440
- stage .puppet ().signalCancel ();
441
- stage .expectCancelling ();
442
-
443
- stage .verifyNoAsyncErrors ();
444
- }
445
- });
446
- }
447
-
448
445
// Verifies rule: https://github.com/reactive-streams/reactive-streams#3.14
449
446
@ NotVerified @ Test
450
447
public void spec314_cancelMayCauseThePublisherToShutdownIfNoOtherSubscriptionExists () throws Exception {
@@ -518,7 +515,7 @@ public void subscriberTestWithoutSetup(TestStageTestRun body) throws Throwable {
518
515
519
516
public class WhiteboxTestStage extends ManualPublisher <T > {
520
517
public Publisher <T > pub ;
521
- public ManualSubscriber <T > tees ; // gives us access to an infinite stream of T values
518
+ public ManualSubscriber <T > tees ; // gives us access to a stream T values
522
519
public WhiteboxSubscriberProbe <T > probe ;
523
520
524
521
public T lastT = null ;
@@ -546,6 +543,10 @@ public SubscriberPuppet puppet() {
546
543
return probe .puppet ();
547
544
}
548
545
546
+ public WhiteboxSubscriberProbe <T > probe () {
547
+ return probe ;
548
+ }
549
+
549
550
public Publisher <T > createHelperPublisher (long elements ) {
550
551
return SubscriberWhiteboxVerification .this .createHelperPublisher (elements );
551
552
}
0 commit comments