public void testReleaseResource() throws Exception {
try {
// acquire all the resources
Assert.assertEquals(3, pool1.getFreeInstances().size());
Resource foo = pool1.getResource();
Resource bar = pool1.getResource();
Resource blah = pool1.getResource();
Assert.assertEquals(0, pool1.getFreeInstances().size());
// release one
pool1.releaseResource(foo);
Assert.assertEquals(1, pool1.getFreeInstances().size());
// try to release "foo" again - should not change the free instances count
// this will log a warning - first we log that this is expected
UIMAFramework.getLogger().log(Level.WARNING, "Unit test is expecting to log ResourcePool warning.");
pool1.releaseResource(foo);
Assert.assertEquals(1, pool1.getFreeInstances().size());
// show that we can then check out a new one
Resource test = pool1.getResource();
Assert.assertNotNull(test);
Assert.assertEquals(0, pool1.getFreeInstances().size());
// release the others
pool1.releaseResource(test);