Source:
public void verifyLogout() throws Exception { ServiceInstance s1 = serviceInstancePool.retain("host1.test.de", "username1", "password1"); Assert.assertEquals("host1.test.de/username1/password1/1/valid", s1.toString()); ServiceInstance s2 = serviceInstancePool.retain("host2.test.de", "username2", "password2"); Assert.assertEquals("host2.test.de/username2/password2/2/valid", s2.toString()); ((DummyServiceInstance) s2).valid = false; ServiceInstance s3 = serviceInstancePool.retain("host3.test.de", "username3", "password3"); Assert.assertEquals("host3.test.de/username3/password3/3/valid", s3.toString()); serviceInstancePool.release(s3); ServiceInstance s4 = serviceInstancePool.retain("host4.test.de", "username4", "password4"); Assert.assertEquals("host4.test.de/username4/password4/4/valid", s4.toString()); serviceInstancePool.release(s4); ((DummyServiceInstance) s4).valid = false; Assert.assertEquals(2, serviceInstancePool.lockedEntryCount()); Assert.assertEquals(2, serviceInstancePool.unlockedEntryCount()); Assert.assertTrue(((DummyServiceInstance) s1).valid); Assert.assertFalse(((DummyServiceInstance) s2).valid); Assert.assertTrue(((DummyServiceInstance) s3).valid); Assert.assertFalse(((DummyServiceInstance) s4).valid); await().until(() -> serviceInstancePool.lockedEntryCount() == 1 && serviceInstancePool.unlockedEntryCount() == 0); Assert.assertNotNull(s1); Assert.assertNotNull(s2); Assert.assertNotNull(s3); Assert.assertNotNull(s4); Assert.assertTrue(((DummyServiceInstance) s1).valid); Assert.assertFalse(((DummyServiceInstance) s2).valid); Assert.assertFalse(((DummyServiceInstance) s3).valid); Assert.assertFalse(((DummyServiceInstance) s4).valid); }

Target:
public void verifyLogout() throws Exception { ServiceInstance s1 = serviceInstancePool.retain("host1.test.de", "username1", "password1"); Assert.assertEquals("host1.test.de/username1/password1/1/valid", s1.toString()); ServiceInstance s2 = serviceInstancePool.retain("host2.test.de", "username2", "password2"); Assert.assertEquals("host2.test.de/username2/password2/2/valid", s2.toString()); ((DummyServiceInstance) s2).valid = false; ServiceInstance s3 = serviceInstancePool.retain("host3.test.de", "username3", "password3"); Assert.assertEquals("host3.test.de/username3/password3/3/valid", s3.toString()); serviceInstancePool.release(s3); ServiceInstance s4 = serviceInstancePool.retain("host4.test.de", "username4", "password4"); Assert.assertEquals("host4.test.de/username4/password4/4/valid", s4.toString()); serviceInstancePool.release(s4); ((DummyServiceInstance) s4).valid = false; Assert.assertEquals(2, serviceInstancePool.lockedEntryCount()); Assert.assertEquals(2, serviceInstancePool.unlockedEntryCount()); Assert.assertTrue(((DummyServiceInstance) s1).valid); Assert.assertFalse(((DummyServiceInstance) s2).valid); Assert.assertTrue(((DummyServiceInstance) s3).valid); Assert.assertFalse(((DummyServiceInstance) s4).valid); await().until(() -> serviceInstancePool.lockedEntryCount() == 1 && serviceInstancePool.unlockedEntryCount() == 0); Assert.assertNotNull(s1); Assert.assertNotNull(s2); Assert.assertNotNull(s3); Assert.assertNotNull(s4); Assert.assertEquals(true,((DummyServiceInstance) s1).valid); Assert.assertEquals(false, ((DummyServiceInstance) s2).valid); Assert.assertEquals(false, ((DummyServiceInstance) s3).valid); Assert.assertEquals(false, ((DummyServiceInstance) s4).valid); }