addExtraClientConfig(clientConfig);
final Client client = new Client(clientLocator, clientConfig);
client.connect();
log.info("client is connected");
MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker();
assertEquals(10, clientInvoker.getNumberOfAvailableConnections());
final HashMap metadata = new HashMap();
metadata.put(DURATION, "20000");
for (int i = 0; i < 20; i++)
{
new Thread()
{
public void run()
{
try
{
client.invoke(WAIT, metadata);
}
catch (Throwable e)
{
log.error("Error", e);
}
}
}.start();
}
Thread.sleep(10000);
assertEquals(10, invocationHandler.counter);
assertEquals(0, clientInvoker.getNumberOfAvailableConnections());
Thread.sleep(20000);
assertEquals(20, invocationHandler.counter);
assertEquals(0, clientInvoker.getNumberOfAvailableConnections());
Thread.sleep(20000);
assertEquals(20, invocationHandler.counter);
assertEquals(10, clientInvoker.getNumberOfAvailableConnections());
client.disconnect();
shutdownServer();
log.info(getName() + " PASSES");
}