@Test(expected=OptionAssignmentException.class) public void testCreateEndpointWithError() throws IOException { @SuppressWarnings("unchecked") final XEndpointListener<UndertowEndpoint> listener = mock(XEndpointListener.class); final UndertowEndpointManager mgr = new UndertowEndpointManager(null, 0, new DerivedEndpointConfig(), listener); final WebSocketChannel channel = Mockito.mock(WebSocketChannel.class); when(channel.setOption(any(), any())).thenThrow(new IOException("Boom")); mgr.createEndpoint(channel); }
UndertowEndpoint createEndpoint(WebSocketChannel channel) { final UndertowEndpoint endpoint = new UndertowEndpoint(this, channel); try { channel.setOption(Options.TCP_NODELAY, NODELAY); } catch (IOException e) { throw new OptionAssignmentException("Error setting option", e); } channel.getReceiveSetter().set(endpoint); channel.resumeReceives(); scanner.addEndpoint(endpoint); listener.onConnect(endpoint); if (idleTimeoutMillis != 0) { channel.setIdleTimeout(idleTimeoutMillis); } return endpoint; }
UndertowEndpointManager implements WebSocketConnectionCallback, XEndpointManager<UndertowEndpoint> { UndertowEndpoint createEndpoint(WebSocketChannel channel) { final UndertowEndpoint endpoint = new UndertowEndpoint(this, channel); try { channel.setOption(Options.TCP_NODELAY, NODELAY); } catch (IOException e) { throw new OptionAssignmentException("Error setting option", e); } channel.getReceiveSetter().set(endpoint); channel.resumeReceives(); scanner.addEndpoint(endpoint); listener.onConnect(endpoint); if (idleTimeoutMillis != 0) { channel.setIdleTimeout(idleTimeoutMillis); } return endpoint; } }
UndertowEndpointManager implements WebSocketConnectionCallback, XEndpointManager<UndertowEndpoint> { UndertowEndpoint createEndpoint(WebSocketChannel channel) { final UndertowEndpoint endpoint = new UndertowEndpoint(this, channel); try { channel.setOption(Options.TCP_NODELAY, NODELAY); } catch (IOException e) { throw new OptionAssignmentException("Error setting option", e); } channel.getReceiveSetter().set(endpoint); channel.resumeReceives(); scanner.addEndpoint(endpoint); listener.onConnect(endpoint); if (idleTimeoutMillis != 0) { channel.setIdleTimeout(idleTimeoutMillis); } return endpoint; } UndertowEndpointManager(XEndpointScanner<UndertowEndpoint> scanner, int idleTimeoutMillis, XEndpointConfig<?> config, 
                          XEndpointListener<? super UndertowEndpoint> listener); }
UndertowEndpointManager implements WebSocketConnectionCallback, XEndpointManager<UndertowEndpoint> { UndertowEndpoint createEndpoint(WebSocketChannel channel) { final UndertowEndpoint endpoint = new UndertowEndpoint(this, channel); try { channel.setOption(Options.TCP_NODELAY, NODELAY); } catch (IOException e) { throw new OptionAssignmentException("Error setting option", e); } channel.getReceiveSetter().set(endpoint); channel.resumeReceives(); scanner.addEndpoint(endpoint); listener.onConnect(endpoint); if (idleTimeoutMillis != 0) { channel.setIdleTimeout(idleTimeoutMillis); } return endpoint; } UndertowEndpointManager(XEndpointScanner<UndertowEndpoint> scanner, int idleTimeoutMillis, XEndpointConfig<?> config, 
                          XEndpointListener<? super UndertowEndpoint> listener); @Override void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel); @Override Collection<UndertowEndpoint> getEndpoints(); }
UndertowEndpointManager implements WebSocketConnectionCallback, XEndpointManager<UndertowEndpoint> { UndertowEndpoint createEndpoint(WebSocketChannel channel) { final UndertowEndpoint endpoint = new UndertowEndpoint(this, channel); try { channel.setOption(Options.TCP_NODELAY, NODELAY); } catch (IOException e) { throw new OptionAssignmentException("Error setting option", e); } channel.getReceiveSetter().set(endpoint); channel.resumeReceives(); scanner.addEndpoint(endpoint); listener.onConnect(endpoint); if (idleTimeoutMillis != 0) { channel.setIdleTimeout(idleTimeoutMillis); } return endpoint; } UndertowEndpointManager(XEndpointScanner<UndertowEndpoint> scanner, int idleTimeoutMillis, XEndpointConfig<?> config, 
                          XEndpointListener<? super UndertowEndpoint> listener); @Override void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel); @Override Collection<UndertowEndpoint> getEndpoints();  }