Skip to content

Commit

Permalink
Merge pull request #443 from stuartwdouglas/437
Browse files Browse the repository at this point in the history
Fixes #437, make sure web socket connection is closed by the test
  • Loading branch information
gsmet committed Jan 8, 2019
2 parents 6c07abd + 68214aa commit 8cf6751
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void websocketTest() throws Exception {
final URI uri = new URI("http://localhost:8080/echo");

LinkedBlockingDeque<String> message = new LinkedBlockingDeque<>();
ContainerProvider.getWebSocketContainer().connectToServer(new Endpoint() {
Session session = ContainerProvider.getWebSocketContainer().connectToServer(new Endpoint() {
@Override
public void onOpen(Session session, EndpointConfig endpointConfig) {
session.addMessageHandler(new MessageHandler.Whole<String>() {
Expand All @@ -54,7 +54,10 @@ public void onMessage(String s) {
}
}, ClientEndpointConfig.Builder.create().build(), uri);


Assert.assertEquals("hello", message.poll(20, TimeUnit.SECONDS));
try {
Assert.assertEquals("hello", message.poll(20, TimeUnit.SECONDS));
} finally {
session.close();
}
}
}

0 comments on commit 8cf6751

Please sign in to comment.