WebSocketEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { WebSocketClientEndpointConfiguration endpointConfiguration = new WebSocketClientEndpointConfiguration(); endpointConfiguration.setEndpointUri(String.format("ws: WebSocketEndpoint endpoint = new WebSocketEndpoint(endpointConfiguration); enrichEndpointConfiguration(endpoint.getEndpointConfiguration(), getEndpointConfigurationParameters(parameters, WebSocketClientEndpointConfiguration.class), context); return endpoint; } WebSocketEndpointComponent();   }
@Test public void testCreateClientEndpoint() throws Exception { WebSocketEndpointComponent component = new WebSocketEndpointComponent(); Endpoint endpoint = component.createEndpoint("ws: Assert.assertEquals(endpoint.getClass(), WebSocketEndpoint.class); Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "ws: Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L); endpoint = component.createEndpoint("websocket: Assert.assertEquals(endpoint.getClass(), WebSocketEndpoint.class); Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "ws: Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateClientEndpointWithParameters() throws Exception { WebSocketEndpointComponent component = new WebSocketEndpointComponent(); Endpoint endpoint = component.createEndpoint("ws:localhost:8088?timeout=10000", context); Assert.assertEquals(endpoint.getClass(), WebSocketEndpoint.class); Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "ws: Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 10000L); }
@Test public void testCreateClientEndpointWithCustomParameters() throws Exception { WebSocketEndpointComponent component = new WebSocketEndpointComponent(); Endpoint endpoint = component.createEndpoint("ws: Assert.assertEquals(endpoint.getClass(), WebSocketEndpoint.class); Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getEndpointUri(), "ws: Assert.assertEquals(((WebSocketEndpoint) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }