use of org.apache.zookeeper.client.ZKClientConfig in project zookeeper by apache.
the class ClientCnxnSocketTest method testWhenInvalidJuteMaxBufferIsConfiguredIOExceptionIsThrown.
@Test
public void testWhenInvalidJuteMaxBufferIsConfiguredIOExceptionIsThrown() {
ZKClientConfig clientConfig = new ZKClientConfig();
String value = "SomeInvalidInt";
clientConfig.setProperty(ZKConfig.JUTE_MAXBUFFER, value);
// verify ClientCnxnSocketNIO creation
try {
new ClientCnxnSocketNIO(clientConfig);
fail("IOException is expected.");
} catch (IOException e) {
assertTrue(e.getMessage().contains(value));
}
// verify ClientCnxnSocketNetty creation
try {
new ClientCnxnSocketNetty(clientConfig);
fail("IOException is expected.");
} catch (IOException e) {
assertTrue(e.getMessage().contains(value));
}
}
use of org.apache.zookeeper.client.ZKClientConfig in project zookeeper by apache.
the class ClientReconnectTest method testClientReconnect.
@Test
public void testClientReconnect() throws IOException, InterruptedException {
HostProvider hostProvider = mock(HostProvider.class);
when(hostProvider.size()).thenReturn(1);
InetSocketAddress inaddr = new InetSocketAddress("127.0.0.1", 1111);
when(hostProvider.next(anyLong())).thenReturn(inaddr);
ZooKeeper zk = mock(ZooKeeper.class);
when(zk.getClientConfig()).thenReturn(new ZKClientConfig());
sc = SocketChannel.open();
ClientCnxnSocketNIO nioCnxn = new MockCnxn();
ClientWatchManager watcher = mock(ClientWatchManager.class);
ClientCnxn clientCnxn = new ClientCnxn("tmp", hostProvider, 5000, zk, watcher, nioCnxn, false);
clientCnxn.start();
countDownLatch.await(5000, TimeUnit.MILLISECONDS);
Assert.assertTrue(countDownLatch.getCount() == 0);
clientCnxn.close();
}
Aggregations