DefaultPingStats extends AbstractStats implements PingStats { @Override protected void doTask() { long start = System.currentTimeMillis(); new ProxyPingCommand(objectPool, getScheduled()).execute().addListener(commandFuture -> { if(!commandFuture.isSuccess()) { result = new PingStatsResult(start, Integer.MAX_VALUE, target, target); } ProxyPongEntity pong = commandFuture.getNow(); if(pong == null) { return; } result = new PingStatsResult(start, System.currentTimeMillis(), target, pong.getDirect()); }); } DefaultPingStats(ScheduledExecutorService scheduled, Endpoint endpoint,
                            SimpleKeyedObjectPool<Endpoint, NettyClient> keyedObjectPool); @Override Endpoint getEndpoint(); @Override PingStatsResult getPingStatsResult();  }
@Test public void doTask() throws Exception { Server server = startServer(port, "+PROXY PONG 127.0.0.1:" + port + "\r\n"); pingStats.doTask(); waitConditionUntilTimeOut(()->pingStats.getPingStatsResult() != null, 500); Assert.assertEquals(new HostPort(pingStats.getEndpoint().getHost(), pingStats.getEndpoint().getPort()), pingStats.getPingStatsResult().getDirect()); server.stop(); }