Socks5Server { public void sendReply(ResponseCode response) throws IOException { byte[] responseBytes = new byte[]{ (byte) 0x05, response.getCode(), (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, }; out.write(responseBytes); } Socks5Server(InputStream in, OutputStream out); boolean acceptAuthentication(); boolean readRequest(); void sendReply(ResponseCode response); Command getCommand(); InetAddress getAddress(); String getHostName(); int getPort();  }
@Test public void testSendReply_Success() throws IOException { InputStream in = new ByteArrayInputStream(new byte[0]); ByteArrayOutputStream out = new ByteArrayOutputStream(); Socks5Server server = new Socks5Server(in, out); server.sendReply(Socks5Server.ResponseCode.SUCCESS); assertArrayEquals(new byte[] { (byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}, out.toByteArray()); }