@Test public void connectionTimeoutIsHandledByGivenListener() throws IOException { @SuppressWarnings("unchecked") final Consumer<Exception> onServerException = mock(Consumer.class); final RfLintIntegrationServer server = new RfLintIntegrationServer(100, TimeUnit.MILLISECONDS, onServerException); server.start(); verify(onServerException).accept(any(SocketTimeoutException.class)); }
public void start(final RfLintClientEventsListener... eventsListeners) throws IOException { try { serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host)); serverSocket.setReuseAddress(true); serverSocket.setSoTimeout(timeoutInMillis); serverSetupSemaphore.release(); try (Socket clientSocket = serverSocket.accept()) { this.clientSocket = clientSocket; final BufferedReader eventsReader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream(), Charsets.UTF_8)); runEventsLoop(eventsReader, eventsListeners); } catch (final Exception e) { if (!stopped) { onServerException.accept(e); } } } catch (final Exception e) { onServerException.accept(e); } finally { stop(); } }
RfLintIntegrationServer { public void start(final RfLintClientEventsListener... eventsListeners) throws IOException { try { serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host)); serverSocket.setReuseAddress(true); serverSocket.setSoTimeout(timeoutInMillis); serverSetupSemaphore.release(); try (Socket clientSocket = serverSocket.accept()) { this.clientSocket = clientSocket; final BufferedReader eventsReader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream(), Charsets.UTF_8)); runEventsLoop(eventsReader, eventsListeners); } catch (final Exception e) { if (!stopped) { onServerException.accept(e); } } } catch (final Exception e) { onServerException.accept(e); } finally { stop(); } } }
RfLintIntegrationServer { public void start(final RfLintClientEventsListener... eventsListeners) throws IOException { try { serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host)); serverSocket.setReuseAddress(true); serverSocket.setSoTimeout(timeoutInMillis); serverSetupSemaphore.release(); try (Socket clientSocket = serverSocket.accept()) { this.clientSocket = clientSocket; final BufferedReader eventsReader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream(), Charsets.UTF_8)); runEventsLoop(eventsReader, eventsListeners); } catch (final Exception e) { if (!stopped) { onServerException.accept(e); } } } catch (final Exception e) { onServerException.accept(e); } finally { stop(); } } RfLintIntegrationServer(final Consumer<Exception> onServerException);  RfLintIntegrationServer(final int timeout, final TimeUnit timeUnit,
            final Consumer<Exception> onServerException); }
RfLintIntegrationServer { public void start(final RfLintClientEventsListener... eventsListeners) throws IOException { try { serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host)); serverSocket.setReuseAddress(true); serverSocket.setSoTimeout(timeoutInMillis); serverSetupSemaphore.release(); try (Socket clientSocket = serverSocket.accept()) { this.clientSocket = clientSocket; final BufferedReader eventsReader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream(), Charsets.UTF_8)); runEventsLoop(eventsReader, eventsListeners); } catch (final Exception e) { if (!stopped) { onServerException.accept(e); } } } catch (final Exception e) { onServerException.accept(e); } finally { stop(); } } RfLintIntegrationServer(final Consumer<Exception> onServerException);  RfLintIntegrationServer(final int timeout, final TimeUnit timeUnit,
            final Consumer<Exception> onServerException); static final int findFreePort(); String getHost(); int getPort(); void start(final RfLintClientEventsListener... eventsListeners); void waitForServerToSetup(); void stop(); }
RfLintIntegrationServer { public void start(final RfLintClientEventsListener... eventsListeners) throws IOException { try { serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host)); serverSocket.setReuseAddress(true); serverSocket.setSoTimeout(timeoutInMillis); serverSetupSemaphore.release(); try (Socket clientSocket = serverSocket.accept()) { this.clientSocket = clientSocket; final BufferedReader eventsReader = new BufferedReader( new InputStreamReader(clientSocket.getInputStream(), Charsets.UTF_8)); runEventsLoop(eventsReader, eventsListeners); } catch (final Exception e) { if (!stopped) { onServerException.accept(e); } } } catch (final Exception e) { onServerException.accept(e); } finally { stop(); } } RfLintIntegrationServer(final Consumer<Exception> onServerException);  RfLintIntegrationServer(final int timeout, final TimeUnit timeUnit,
            final Consumer<Exception> onServerException); static final int findFreePort(); String getHost(); int getPort(); void start(final RfLintClientEventsListener... eventsListeners); void waitForServerToSetup(); void stop();  }