use of com.netflix.ribbon.transport.netty.MyUDPClient in project ribbon by Netflix.
the class UdpClientTest method testUdpClientTimeout.
@Test
public void testUdpClientTimeout() throws Exception {
int port = choosePort();
UdpServer<DatagramPacket, DatagramPacket> server = new HelloUdpServer(port, 5000).createServer();
server.start();
BaseLoadBalancer lb = new BaseLoadBalancer();
Server myServer = new Server("localhost", port);
lb.setServersList(Lists.newArrayList(myServer));
MyUDPClient client = new MyUDPClient(lb, DefaultClientConfigImpl.getClientConfigWithDefaultValues());
try {
String response = client.submit("Is there anybody out there?").map(new Func1<DatagramPacket, String>() {
@Override
public String call(DatagramPacket datagramPacket) {
return datagramPacket.content().toString(Charset.defaultCharset());
}
}).toBlocking().first();
fail("Exception expected");
} catch (Exception e) {
assertTrue(e.getCause() instanceof TimeoutException);
assertEquals(1, client.getLoadBalancerContext().getServerStats(myServer).getSuccessiveConnectionFailureCount());
} finally {
server.shutdown();
}
}
Aggregations