SocketETLServer extends Thread { @Override public void run() { try { final InetAddress localHost = InetAddress.getLocalHost(); server = new ServerSocket(port, -1, localHost); server.setReuseAddress(true); uri = TcpUriFactory.createUri( (InetSocketAddress) server.getLocalSocketAddress()); LOGGER.info("listening on '" + uri + "' for MMI events"); while (!stopRequest) { final Socket socket = server.accept(); final InetSocketAddress address = (InetSocketAddress) socket.getRemoteSocketAddress(); final URI remoteUri = TcpUriFactory.createUri(address); LOGGER.info("connection from " + remoteUri); final SocketETLClient client = new SocketETLClient(adapter, socket); client.start(); } } catch (IOException e) { LOGGER.error(e.getMessage(), e); } catch (URISyntaxException e) { LOGGER.error(e.getMessage(), e); } } SocketETLServer(final SocketETLProtocolAdapter protocolAdapter,
            final int portNumber); URI getUri(); @Override void run();  }
@Test(timeout = 5000) public void testRun() throws Exception { final SocketETLProtocolAdapter adapter = new SocketETLProtocolAdapter(); adapter.addMMIEventListener(this); final SocketETLServer server = new SocketETLServer(adapter, 4242); server.start(); Thread.sleep(500); InetAddress address = InetAddress.getLocalHost(); final Socket client = new Socket(address, 4242); final Mmi mmi = new Mmi(); final StartRequest request = new StartRequest(); request.setContext("http: request.setRequestId("4242"); mmi.setStartRequest(request); final File file = new File("unittests/vxml/hello.vxml"); final URI uri = file.toURI(); request.setContentURL(uri.toURL()); final JAXBContext ctx = JAXBContext.newInstance(Mmi.class); final Marshaller marshaller = ctx.createMarshaller(); final OutputStream out = client.getOutputStream(); marshaller.marshal(mmi, out); out.flush(); out.close(); synchronized (lock) { lock.wait(); } Assert.assertTrue(event.getLifeCycleEvent() instanceof StartRequest); client.close(); }