Iterator it = invocationHandler.callbackHandlers.iterator();
ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next();
Client callbackClient = serverInvokerCallbackHandler.getCallbackClient();
assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker);
MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker();
Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
field.setAccessible(true);
List pool = (List) field.get(clientInvoker);
// field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
// field.setAccessible(true);
assertEquals(0, pool.size());
// Long usedPooled = (Long) field.get(clientInvoker);
// assertEquals(0, usedPooled.intValue());
assertEquals(0, clientInvoker.getNumberOfUsedConnections());
int invocationCount = TEST_MAX_POOL_SIZE;
for (int i = 0; i < invocationCount; i++)
{
client.invokeOneway(CALLBACK_TEST);
}
Thread.sleep(2000); // +2000
assertEquals(invocationCount, callbackHandler.callbackCounter);
assertEquals(0, pool.size());
// usedPooled = (Long) field.get(clientInvoker);
// assertEquals(invocationCount, usedPooled.intValue());
assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections());
for (int i = 0; i < invocationCount; i++)
{
client.invokeOneway(CALLBACK_TEST);
}
assertEquals(invocationCount, callbackHandler.callbackCounter);
assertEquals(0, pool.size());
// usedPooled = (Long) field.get(clientInvoker);
// assertEquals(invocationCount, usedPooled.intValue());
assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections());
Thread.sleep(1000); // +3000
assertEquals(invocationCount, callbackHandler.callbackCounter);
assertEquals(0, pool.size());
// usedPooled = (Long) field.get(clientInvoker);
// assertEquals(invocationCount, usedPooled.intValue());
assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections());
Thread.sleep(3000); // +6000
assertEquals(2 * invocationCount, callbackHandler.callbackCounter);
assertEquals(0, pool.size());
// usedPooled = (Long) field.get(clientInvoker);
// assertEquals(invocationCount, usedPooled.intValue());
assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections());
Thread.sleep(4000); // +10000
assertEquals(2 * invocationCount, callbackHandler.callbackCounter);
assertEquals(invocationCount, pool.size());
// usedPooled = (Long) field.get(clientInvoker);
// assertEquals(0, usedPooled.intValue());
assertEquals(0, clientInvoker.getNumberOfUsedConnections());
client.removeListener(callbackHandler);
client.disconnect();
}