From c949bddf493545732eb451c93356932952e86908 Mon Sep 17 00:00:00 2001 From: marci4 Date: Tue, 31 Dec 2024 15:28:16 +0100 Subject: [PATCH] Adjust logging --- .../misc/OpeningHandshakeRejectionTest.java | 20 +++++++++++++++++-- .../ProtocolHandshakeRejectionTest.java | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/java_websocket/misc/OpeningHandshakeRejectionTest.java b/src/test/java/org/java_websocket/misc/OpeningHandshakeRejectionTest.java index cc79a635..5775ce64 100644 --- a/src/test/java/org/java_websocket/misc/OpeningHandshakeRejectionTest.java +++ b/src/test/java/org/java_websocket/misc/OpeningHandshakeRejectionTest.java @@ -266,12 +266,28 @@ public void onClose(int code, String reason, boolean remote) { @Override public void onError(Exception ex) { - fail("There should not be an exception"); + fail("There should not be an exception: " + ex.getMessage()); } }; - Thread finalThread = new Thread(webSocketClient); + final AssertionError[] exc = new AssertionError[1]; + exc[0] = null; + Thread finalThread = new Thread(new Runnable() { + @Override + public void run() { + try { + webSocketClient.run(); + }catch(AssertionError e){ + exc[0] = e; + countDownLatch.countDown(); + } + } + + }); finalThread.start(); finalThread.join(); + if (exc[0] != null) { + throw exc[0]; + } countDownLatch.await(); } } diff --git a/src/test/java/org/java_websocket/protocols/ProtocolHandshakeRejectionTest.java b/src/test/java/org/java_websocket/protocols/ProtocolHandshakeRejectionTest.java index 6f2ad6af..9525ffcd 100644 --- a/src/test/java/org/java_websocket/protocols/ProtocolHandshakeRejectionTest.java +++ b/src/test/java/org/java_websocket/protocols/ProtocolHandshakeRejectionTest.java @@ -615,7 +615,7 @@ public void onClose(int code, String reason, boolean remote) { @Override public void onError(Exception ex) { - fail("There should not be an exception"); + fail("There should not be an exception: " + ex.getMessage()); } }; final AssertionError[] exc = new AssertionError[1]; @@ -627,6 +627,7 @@ public void run() { webSocketClient.run(); }catch(AssertionError e){ exc[0] = e; + countDownLatch.countDown(); } }