From 6aac3f92a1f79ab7e69fa68cde9882dbd0278afb Mon Sep 17 00:00:00 2001 From: Konrad 'ktoso' Malawski Date: Tue, 7 Oct 2014 12:12:07 +0200 Subject: [PATCH] Fail test in case of double onError/onComplete signals --- .../tck/SubscriberWhiteboxVerification.java | 16 ++++++++++++++-- .../org/reactivestreams/tck/TestEnvironment.java | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java b/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java index a01ef4d5..7046e156 100644 --- a/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java @@ -493,6 +493,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException { // cumulative pending > Long.MAX_VALUE stage.probe.expectErrorWithMessage(IllegalStateException.class, "3.17"); + + env.verifyNoAsyncErrors(env.defaultTimeoutMillis()); } }); } @@ -626,12 +628,22 @@ public void registerOnNext(T element) { @Override public void registerOnComplete() { - elements.complete(); + try { + elements.complete(); + } catch (IllegalStateException ex) { + // "Queue full", onComplete was already called + env.flop("subscriber::onComplete was called a second time, which is illegal according to Rule 1.7"); + } } @Override public void registerOnError(Throwable cause) { - error.complete(cause); + try { + error.complete(cause); + } catch (IllegalStateException ex) { + // "Queue full", onError was already called + env.flop("subscriber::onError was called a second time, which is illegal according to Rule 1.7"); + } } public T expectNext() throws InterruptedException { diff --git a/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java b/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java index 4a554d48..54292cf9 100644 --- a/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java +++ b/tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java @@ -150,7 +150,7 @@ public void verifyNoAsyncErrors() { /** If {@code TestEnvironment#printlnDebug} is true, print debug message to std out. */ public void debug(String msg) { if (printlnDebug) - System.out.println(msg); + System.out.println("[TCK-DEBUG] " + msg); } // ---- classes ----