ReferenceCountExchangeClient implements ExchangeClient { @Override public InetSocketAddress getLocalAddress() { return client.getLocalAddress(); } ReferenceCountExchangeClient(ExchangeClient client); @Override void reset(URL url); @Override CompletableFuture<Object> request(Object request); @Override URL getUrl(); @Override InetSocketAddress getRemoteAddress(); @Override ChannelHandler getChannelHandler(); @Override CompletableFuture<Object> request(Object request, int timeout); @Override CompletableFuture<Object> request(Object request, ExecutorService executor); @Override CompletableFuture<Object> request(Object request, int timeout, ExecutorService executor); @Override boolean isConnected(); @Override void reconnect(); @Override InetSocketAddress getLocalAddress(); @Override boolean hasAttribute(String key); @Override void reset(Parameters parameters); @Override void send(Object message); @Override ExchangeHandler getExchangeHandler(); @Override Object getAttribute(String key); @Override void send(Object message, boolean sent); @Override void setAttribute(String key, Object value); @Override void removeAttribute(String key); @Override void close(); @Override void close(int timeout); @Override void startClose(); @Override boolean isClosed(); void incrementAndGetCount();  }
@Test public void test_share_connect() { init(0, 1); Assertions.assertEquals(demoClient.getLocalAddress(), helloClient.getLocalAddress()); Assertions.assertEquals(demoClient, helloClient); destoy(); }
@Test public void test_not_share_connect() { init(1, 1); Assertions.assertNotSame(demoClient.getLocalAddress(), helloClient.getLocalAddress()); Assertions.assertNotSame(demoClient, helloClient); destoy(); }
@Test public void test_mult_share_connect() { final int shareConnectionNum = 3; init(0, shareConnectionNum); List<ReferenceCountExchangeClient> helloReferenceClientList = getReferenceClientList(helloServiceInvoker); Assertions.assertEquals(shareConnectionNum, helloReferenceClientList.size()); List<ReferenceCountExchangeClient> demoReferenceClientList = getReferenceClientList(demoServiceInvoker); Assertions.assertEquals(shareConnectionNum, demoReferenceClientList.size()); Assertions.assertEquals(helloReferenceClientList, demoReferenceClientList); Assertions.assertEquals(demoClient.getLocalAddress(), helloClient.getLocalAddress()); Assertions.assertEquals(demoClient, helloClient); destoy(); }