AJPClient { public boolean ping() throws IOException { if (!isConnected()) throw new IOException("Not connected to server"); if (!isIdle()) throw new IllegalStateException("Client is currently assigned"); out.write(PING); out.flush(); PONG.readMessage(in); return PONG.peekByte() == AJPConstants.JK_AJP13_CPONG_REPLY; } AJPClient(); void connect(InetSocketAddress target); void connect(InetSocketAddress target, Proxy proxy); void setTimeout(int timeout); void close(); boolean isConnected(); boolean isIdle(); boolean ping(); StreamingResponse fetchResponse(StreamingRequest request); AJPProperties getProperties(); void setProperties(AJPProperties properties); long getRequestTime(); long getResponseHeaderTime();  }
@Test @Disabled("Requires an AJP server on the other end") public void ping() throws Exception { InetSocketAddress ajp = new InetSocketAddress("localhost", 8009); AJPClient connection = new AJPClient(); connection.connect(ajp); for (int i = 0; i < 15; i++) if (!connection.ping()) System.out.println("Ping failed!"); connection.close(); }