public void testFillPool() throws Exception
{
Stack jsLinkStack = new Stack();
JetspeedLink jsLink = null;
PoolService poolService = (PoolService) TurbineServices.
getInstance().getService(PoolService.SERVICE_NAME);
int poolCapacity;
jsLink = JetspeedLinkFactory.getInstance();
String linkClassName = jsLink.getClass().getName();
poolCapacity = poolService.getCapacity( linkClassName);
System.out.println("Class Name " + linkClassName);
System.out.println("Pool Capacity " + poolCapacity);
// Fill stack with objects
for (int counter = 0; counter < poolCapacity; counter++)
{
jsLink = JetspeedLinkFactory.getInstance();
assertNotNull( "Get loop - Got JetspeedLink", jsLink);
assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
jsLinkStack.push(jsLink);
}
// Fill up the pool
while (jsLinkStack.empty() == false)
JetspeedLinkFactory.putInstance( (JetspeedLink) jsLinkStack.pop());
assertEquals( "Pool is full", poolCapacity, poolService.getSize(linkClassName));
// Empty pool
for (int counter = 0; counter < poolCapacity; counter++)
{
jsLink = JetspeedLinkFactory.getInstance();
assertNotNull( "Get loop - Got JetspeedLink", jsLink);
assertTrue( "Get loop - jsLink instance of JetspeedLink", (jsLink instanceof JetspeedLink));
}
assertEquals( "Pool is empty", 0, poolService.getSize(linkClassName));
}