ProxyEnabledNettyKeyedPoolClientFactory extends NettyKeyedPoolClientFactory { @Override public PooledObject<NettyClient> makeObject(Endpoint key) throws Exception { if(!isProxyEnabled(key)) { return super.makeObject(key); } ProxyConnectProtocol protocol = ((ProxyEnabled) key).getProxyProtocol(); ChannelFuture f = proxyedConnectionFactory.getProxyedConnectionChannelFuture(protocol, b); f.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { future.channel().writeAndFlush(protocol.output()); } }); NettyClient nettyClient = new AsyncNettyClient(f, key); f.channel().attr(NettyClientHandler.KEY_CLIENT).set(nettyClient); return new DefaultPooledObject<>(nettyClient); } ProxyEnabledNettyKeyedPoolClientFactory(int eventLoopThreads, ProxyResourceManager resourceManager);  ProxyEnabledNettyKeyedPoolClientFactory(ProxyResourceManager resourceManager); @Override PooledObject<NettyClient> makeObject(Endpoint key);  }
@Test public void testMakeNormalObject() throws Exception { Server server = startEchoServer(); NettyClient client = factory.makeObject(localHostEndpoint(server.getPort())).getObject(); Assert.assertEquals(1, server.getConnected()); Assert.assertTrue(client.channel().isActive()); Assert.assertTrue(client instanceof DefaultNettyClient); client.sendRequest(Unpooled.copiedBuffer("hello".getBytes())); }