From 8638fb2cc3ed80c7410249a31ad253d67479a458 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Wed, 29 Jan 2020 19:13:03 +1100 Subject: [PATCH] Fix broken test cases Signed-off-by: Lachlan Roberts --- .../jetty/websocket/javax/tests/JavaxOnCloseTest.java | 3 ++- .../org/eclipse/jetty/websocket/tests/WebSocketStopTest.java | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/JavaxOnCloseTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/JavaxOnCloseTest.java index 6ab8fcfd55a..7a0ee518d70 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/JavaxOnCloseTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/JavaxOnCloseTest.java @@ -180,8 +180,9 @@ public class JavaxOnCloseTest assertTrue(serverEndpoint.openLatch.await(5, TimeUnit.SECONDS)); serverEndpoint.setOnClose((session) -> { - assertThrows(ClosedChannelException.class, + IOException error = assertThrows(IOException.class, () -> session.close(new CloseReason(CloseCodes.UNEXPECTED_CONDITION, "abnormal close 2"))); + assertThat(error.getCause(), instanceOf(ClosedChannelException.class)); clientEndpoint.unBlockClose(); }); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketStopTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketStopTest.java index cefe7e6854f..43ffc5e687f 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketStopTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketStopTest.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.websocket.tests; +import java.io.IOException; import java.net.URI; import java.nio.channels.ClosedChannelException; import java.util.concurrent.TimeUnit; @@ -38,6 +39,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -126,7 +128,8 @@ public class WebSocketStopTest assertThat(clientSocket.statusCode, is(StatusCode.NORMAL)); assertThat(serverSocket.statusCode, is(StatusCode.NORMAL)); - assertThrows(ClosedChannelException.class, + IOException error = assertThrows(IOException.class, () -> session.getRemote().sendString("this should fail before ExtensionStack")); + assertThat(error.getCause(), instanceOf(ClosedChannelException.class)); } }