Skip to content

Commit 5a998cc

Browse files
akarnokdviktorklang
authored andcommitted
Error message about doesCoordinatedEmission.
1 parent 521972b commit 5a998cc

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

tck/src/main/java/org/reactivestreams/tck/IdentityProcessorVerification.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ public TestSetup apply(Long aLong) throws Throwable {
450450
sub1.request(1);
451451
sub2.request(1);
452452

453+
expectRequest();
454+
453455
final T x = sendNextTFromUpstream();
454456

455457
expectNextElement(sub1, x);
@@ -459,9 +461,18 @@ public TestSetup apply(Long aLong) throws Throwable {
459461
sub2.request(1);
460462
} else {
461463
sub1.request(1);
462-
expectRequest();
464+
465+
expectRequest(env.defaultTimeoutMillis(),
466+
"If the Processor coordinates requests/emissions when having multiple Subscribers"
467+
+ " at once, please override doesCoordinatedEmission() in this "
468+
+ "IdentityProcessorVerification to allow this test to pass.");
469+
463470
final T x = sendNextTFromUpstream();
464-
expectNextElement(sub1, x);
471+
expectNextElement(sub1, x,
472+
"If the Processor coordinates requests/emissions when having multiple Subscribers"
473+
+ " at once, please override doesCoordinatedEmission() in this "
474+
+ "IdentityProcessorVerification to allow this test to pass.");
475+
465476
sub1.request(1);
466477

467478
// sub1 has received one element, and has one demand pending
@@ -744,7 +755,10 @@ public TestSetup apply(Long subscribers) throws Throwable {
744755
expectNextElement(sub2, z);
745756
} else {
746757
final T z = sendNextTFromUpstream();
747-
expectNextElement(sub1, z);
758+
expectNextElement(sub1, z,
759+
"If the Processor coordinates requests/emissions when having multiple Subscribers"
760+
+ " at once, please override doesCoordinatedEmission() in this "
761+
+ "IdentityProcessorVerification to allow this test to pass.");
748762
sub2.expectNone(); // since sub2 hasn't requested anything yet
749763

750764
sub2.request(1);
@@ -818,6 +832,13 @@ public void expectNextElement(ManualSubscriber<T> sub, T expected) throws Interr
818832
}
819833
}
820834

835+
public void expectNextElement(ManualSubscriber<T> sub, T expected, String errorMessageAddendum) throws InterruptedException {
836+
final T elem = sub.nextElement(String.format("timeout while awaiting %s. %s", expected, errorMessageAddendum));
837+
if (!elem.equals(expected)) {
838+
env.flop(String.format("Received `onNext(%s)` on downstream but expected `onNext(%s)`", elem, expected));
839+
}
840+
}
841+
821842
public T sendNextTFromUpstream() throws InterruptedException {
822843
final T x = nextT();
823844
sendNext(x);

tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,17 @@ public long expectRequest(long timeoutMillis) throws InterruptedException {
763763
}
764764
}
765765

766+
767+
public long expectRequest(long timeoutMillis, String errorMessageAddendum) throws InterruptedException {
768+
long requested = requests.next(timeoutMillis, String.format("Did not receive expected `request` call. %s", errorMessageAddendum));
769+
if (requested <= 0) {
770+
return env.<Long>flopAndFail(String.format("Requests cannot be zero or negative but received request(%s)", requested));
771+
} else {
772+
pendingDemand += requested;
773+
return requested;
774+
}
775+
}
776+
766777
public void expectExactRequest(long expected) throws InterruptedException {
767778
expectExactRequest(expected, env.defaultTimeoutMillis());
768779
}

0 commit comments

Comments
 (0)