Field field = SocketServerInvoker.class.getDeclaredField("clientpool");
field.setAccessible(true);
LRUPool clientpool = (LRUPool) field.get(invoker);
assertEquals(1, clientpool.size());
Set clientpoolContents = clientpool.getContents();
ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next();
// Get threadpool.
field = SocketServerInvoker.class.getDeclaredField("threadpool");
field.setAccessible(true);
LinkedList threadpool = (LinkedList) field.get(invoker);
assertEquals(0, threadpool.size());
// Wait for ServerThread to time out.
Thread.sleep(8000);
// Verify original ServerThread remains in clientpool.
assertEquals(0, threadpool.size());
assertEquals(1, clientpool.size());
clientpoolContents = clientpool.getContents();
assertEquals(serverThread1, clientpoolContents.iterator().next());
// Make another invocation and verify ServerThread was reused.
client.invoke("xyz");
assertEquals(1, clientpool.size());
clientpoolContents = clientpool.getContents();
ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next();
assertEquals(serverThread1, serverThread2);
client.disconnect();
shutdownServer();
log.info(getName() + " PASSES");