for (int i = 0; i < iterations; i++)
{
try
{
ConnectionListener cl = cm.getManagedConnection(null, null);
assertTrue("Got a null connection!", cl.getManagedConnection() != null);
cs.add(cl);
}
catch (ResourceException re)
{
failed = true;
failedDescription = "Failed to get a connection";
failedException = re;
}
}
assertEquals("1: Wrong number of connections", iterations, cs.size());
firstPart.countDown();
cont.await();
for (Iterator i = cs.iterator(); i.hasNext();)
{
cm.returnManagedConnection((ConnectionListener)i.next(), true);
}
done.countDown();
}
catch (InterruptedException ie)
{
}
}
};
new Thread(t).start();
}
start.countDown();
firstPart.await();
assertTrue("2: Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
try
{
ConnectionListener cl = cm.getManagedConnection(null, null);
cm.returnManagedConnection(cl, true);
failedDescription = "Got a connection";
failedException = new Exception(cl.toString());
failed = true;
}
catch (ResourceException ignore)
{
}