use of org.apache.pulsar.client.impl.conf.ClientConfigurationData in project incubator-pulsar by apache.
the class ClientCnxTest method testClientCnxTimeout.
@Test
public void testClientCnxTimeout() throws Exception {
EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(1, new DefaultThreadFactory("testClientCnxTimeout"));
ClientConfigurationData conf = new ClientConfigurationData();
conf.setOperationTimeoutMs(10);
ClientCnx cnx = new ClientCnx(conf, eventLoop);
ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
ChannelFuture listenerFuture = mock(ChannelFuture.class);
when(listenerFuture.addListener(anyObject())).thenReturn(listenerFuture);
when(ctx.writeAndFlush(anyObject())).thenReturn(listenerFuture);
Field ctxField = PulsarHandler.class.getDeclaredField("ctx");
ctxField.setAccessible(true);
ctxField.set(cnx, ctx);
try {
cnx.newLookup(null, 123).get();
} catch (Exception e) {
assertTrue(e.getCause() instanceof PulsarClientException.TimeoutException);
}
}
use of org.apache.pulsar.client.impl.conf.ClientConfigurationData in project incubator-pulsar by apache.
the class ConnectionPoolTest method testSingleIpAddress.
@Test
public void testSingleIpAddress() throws Exception {
ClientConfigurationData conf = new ClientConfigurationData();
EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(1, new DefaultThreadFactory("test"));
ConnectionPool pool = Mockito.spy(new ConnectionPool(conf, eventLoop));
conf.setServiceUrl(serviceUrl);
PulsarClientImpl client = new PulsarClientImpl(conf, eventLoop, pool);
List<InetAddress> result = Lists.newArrayList();
result.add(InetAddress.getByName("127.0.0.1"));
Mockito.when(pool.resolveName("non-existing-dns-name")).thenReturn(CompletableFuture.completedFuture(result));
client.createProducer("persistent://sample/standalone/ns/my-topic");
client.close();
}
Aggregations