use of com.weibo.api.motan.transport.MessageHandler in project motan by weibocom.
the class NettyEndpointFactoryTest method testNotShareChannel.
private void testNotShareChannel(boolean isServer) {
NettyEndpointFactory factory = new NettyEndpointFactory();
MessageHandler handler = new ProviderMessageRouter();
URL url = new URL("motan", "localhost", 18080, "com.weibo.api.motan.procotol.example.IHello");
Endpoint endpoint = createEndpoint(url, handler, isServer, factory);
Assert.assertEquals(endpoint.getUrl().getUri(), url.getUri());
url = new URL("motan", "localhost", 18081, "com.weibo.api.motan.procotol.example.IHello");
endpoint = createEndpoint(url, handler, isServer, factory);
Assert.assertEquals(endpoint.getUrl().getUri(), url.getUri());
Assert.assertTrue(endpoint != createEndpoint(new URL("motan", "localhost", 18081, "com.weibo.api.motan.procotol.example.IHello"), handler, isServer, factory));
if (isServer) {
Assert.assertEquals(factory.getShallServerChannels().size(), 0);
}
if (isServer) {
factory.safeReleaseResource((Server) endpoint, url);
} else {
Assert.assertEquals(((HeartbeatClientEndpointManager) factory.getEndpointManager()).getClients().size(), 3);
factory.safeReleaseResource((Client) endpoint, url);
Assert.assertEquals(((HeartbeatClientEndpointManager) factory.getEndpointManager()).getClients().size(), 2);
}
}
Aggregations