ProxyPongEntity { public ByteBuf output() { String pong; if(real != null) { pong = String.format("%s %s %s %d", PONG_PREFIX, direct.toString(), real.toString(), rtt); } else { pong = String.format("%s %s", PONG_PREFIX, direct.toString()); } return new SimpleStringParser(pong).format(); } ProxyPongEntity(HostPort direct);  ProxyPongEntity(HostPort direct, HostPort real, long rtt); HostPort getDirect(); HostPort getReal(); long getRtt(); @Override boolean equals(Object o); @Override int hashCode(); ByteBuf output(); @Override String toString();  }
@Test public void testOutput() { HostPort direct = localHostport(randomPort()), real = localHostport(randomPort()); long rtt = 200; ProxyPongEntity pong = new ProxyPongEntity(direct); Assert.assertEquals(Unpooled.copiedBuffer(("+PROXY PONG " + direct.toString() + "\r\n").getBytes()), pong.output()); logger.info("[output] {}", ByteBufUtils.readToString(pong.output())); pong = new ProxyPongEntity(direct, real, rtt); String expected = String.format("+PROXY PONG %s %s %d\r\n", direct.toString(), real.toString(), rtt); Assert.assertEquals(Unpooled.copiedBuffer(expected.getBytes()), pong.output()); logger.info("[output] {}", ByteBufUtils.readToString(pong.output())); }