@org.junit.Test public void testStringOnMessage() throws Exception { ProgramaticClientEndpoint endpoint = new ProgramaticClientEndpoint(); ContainerProvider.getWebSocketContainer() .connectToServer( endpoint, ClientEndpointConfig.Builder.create().build(), new URI( "ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/foo")); Assert.assertEquals("Hello Stuart", endpoint.getResponses().poll(15, TimeUnit.SECONDS)); }
@org.junit.Test public void testBytesOnMessage() throws Exception { SSLContext context = DefaultServer.getClientSSLContext(); ProgramaticClientEndpoint endpoint = new ProgramaticClientEndpoint(); ClientEndpointConfig clientEndpointConfig = ClientEndpointConfig.Builder.create().build(); clientEndpointConfig .getUserProperties() .put(DefaultWebSocketClientSslProvider.SSL_CONTEXT, context); ContainerProvider.getWebSocketContainer() .connectToServer( endpoint, clientEndpointConfig, new URI( "wss://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostSSLPort("default") + "/partial")); Assert.assertArrayEquals(bytes, endpoint.getResponses().poll(15, TimeUnit.SECONDS)); }