public void testClientHang() throws Exception { // // Manually create a client transport so that it does not send KeepAlive // packets. // this should simulate a client hang. clientTransport = new TcpTransport( new OpenWireFormat(), SocketFactory.getDefault(), new URI("tcp://localhost:" + serverPort), null); clientTransport.setTransportListener( new TransportListener() { public void onCommand(Object command) { clientReceiveCount.incrementAndGet(); if (clientRunOnCommand != null) { clientRunOnCommand.run(); } } public void onException(IOException error) { if (!ignoreClientError.get()) { LOG.info("Client transport error:"); error.printStackTrace(); clientErrorCount.incrementAndGet(); } } public void transportInterupted() {} public void transportResumed() {} }); clientTransport.start(); WireFormatInfo info = new WireFormatInfo(); info.setVersion(OpenWireFormat.DEFAULT_VERSION); info.setMaxInactivityDuration(1000); clientTransport.oneway(info); assertEquals(0, serverErrorCount.get()); assertEquals(0, clientErrorCount.get()); // Server should consider the client timed out right away since the // client is not hart beating fast enough. Thread.sleep(6000); assertEquals(0, clientErrorCount.get()); assertTrue(serverErrorCount.get() > 0); }
public void oneway(Object message) throws IOException { input.oneway(message); }