Fix broken test cases

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-01-29 19:13:03 +11:00
parent fdd27a9f28
commit 8638fb2cc3
2 changed files with 6 additions and 2 deletions

View File

@ -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();
});

View File

@ -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));
}
}