use of org.apache.dubbo.remoting.transport.ChannelHandlerAdapter in project dubbo by alibaba.
the class ExchangersTest method testBind.
@Test
public void testBind() throws RemotingException {
String url = "dubbo://127.0.0.1:12345?exchanger=mockExchanger";
Exchangers.bind(url, Mockito.mock(Replier.class));
Exchangers.bind(url, new ChannelHandlerAdapter(), Mockito.mock(Replier.class));
Exchangers.bind(url, new ExchangeHandlerDispatcher());
Assertions.assertThrows(RuntimeException.class, () -> Exchangers.bind((URL) null, new ExchangeHandlerDispatcher()));
Assertions.assertThrows(RuntimeException.class, () -> Exchangers.bind(url, (ExchangeHandlerDispatcher) null));
}
use of org.apache.dubbo.remoting.transport.ChannelHandlerAdapter in project dubbo by alibaba.
the class ExchangersTest method testConnect.
@Test
public void testConnect() throws RemotingException {
String url = "dubbo://127.0.0.1:12345?exchanger=mockExchanger";
Exchangers.connect(url);
Exchangers.connect(url, Mockito.mock(Replier.class));
Exchangers.connect(URL.valueOf(url), Mockito.mock(Replier.class));
Exchangers.connect(url, new ChannelHandlerAdapter(), Mockito.mock(Replier.class));
Exchangers.connect(url, new ExchangeHandlerDispatcher());
Assertions.assertThrows(RuntimeException.class, () -> Exchangers.connect((URL) null, new ExchangeHandlerDispatcher()));
Assertions.assertThrows(RuntimeException.class, () -> Exchangers.connect(url, (ExchangeHandlerDispatcher) null));
}
use of org.apache.dubbo.remoting.transport.ChannelHandlerAdapter in project dubbo by alibaba.
the class GrizzlyTransporterTest method shouldAbleToBindGrizzly.
@Test
public void shouldAbleToBindGrizzly() throws Exception {
int port = NetUtils.getAvailablePort();
URL url = new URL("telnet", "localhost", port, new String[] { BIND_PORT_KEY, String.valueOf(port) });
RemotingServer server = new GrizzlyTransporter().bind(url, new ChannelHandlerAdapter());
assertThat(server.isBound(), is(true));
}
use of org.apache.dubbo.remoting.transport.ChannelHandlerAdapter in project dubbo by alibaba.
the class NettyTransporterTest method shouldConnectToNetty4Server.
@Test
public void shouldConnectToNetty4Server() throws Exception {
final CountDownLatch lock = new CountDownLatch(1);
int port = NetUtils.getAvailablePort();
URL url = new URL("telnet", "localhost", port, new String[] { Constants.BIND_PORT_KEY, String.valueOf(port) });
new NettyTransporter().bind(url, new ChannelHandlerAdapter() {
@Override
public void connected(Channel channel) {
lock.countDown();
}
});
new NettyTransporter().connect(url, new ChannelHandlerAdapter() {
@Override
public void sent(Channel channel, Object message) throws RemotingException {
channel.send(message);
channel.close();
}
});
lock.await();
}
use of org.apache.dubbo.remoting.transport.ChannelHandlerAdapter in project dubbo by alibaba.
the class MulticastNetworkerTest method testJoin.
@Test
public void testJoin() throws RemotingException, InterruptedException {
final String groupURL = "multicast://224.5.6.7:1234";
final String peerURL = "exchange://0.0.0.0:" + NetUtils.getAvailablePort() + "?exchanger=header";
final CountDownLatch countDownLatch = new CountDownLatch(1);
Peer peer1 = Networkers.join(groupURL, peerURL, new ChannelHandlerAdapter() {
@Override
public void received(Channel channel, Object message) {
countDownLatch.countDown();
}
});
Peer peer2 = Networkers.join(groupURL, "exchange://0.0.0.0:" + NetUtils.getAvailablePort() + "?exchanger=header", mock(ChannelHandlerAdapter.class));
while (true) {
long count = countDownLatch.getCount();
if (count > 0) {
break;
}
for (Channel channel : peer1.getChannels()) {
channel.send("hello world!");
}
TimeUnit.MILLISECONDS.sleep(50);
}
Group lookup = Networkers.lookup(groupURL);
assertThat(lookup, not(nullValue()));
peer2.close();
peer1.close();
}
Aggregations