use of com.datastax.oss.driver.internal.core.session.PoolManager in project java-driver by datastax.
the class InsightsClientTest method mockConnectionPools.
private void mockConnectionPools(DefaultDriverContext driverContext) {
Node node1 = mock(Node.class);
EndPoint endPoint1 = mock(EndPoint.class);
when(endPoint1.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 10));
when(node1.getEndPoint()).thenReturn(endPoint1);
when(node1.getOpenConnections()).thenReturn(1);
ChannelPool channelPool1 = mock(ChannelPool.class);
when(channelPool1.getInFlight()).thenReturn(10);
Node node2 = mock(Node.class);
EndPoint endPoint2 = mock(EndPoint.class);
when(endPoint2.resolve()).thenReturn(new InetSocketAddress("127.0.0.1", 20));
when(node2.getEndPoint()).thenReturn(endPoint2);
when(node2.getOpenConnections()).thenReturn(2);
ChannelPool channelPool2 = mock(ChannelPool.class);
when(channelPool2.getInFlight()).thenReturn(20);
Map<Node, ChannelPool> channelPools = ImmutableMap.of(node1, channelPool1, node2, channelPool2);
PoolManager poolManager = mock(PoolManager.class);
when(poolManager.getPools()).thenReturn(channelPools);
when(driverContext.getPoolManager()).thenReturn(poolManager);
}
Aggregations