Assert.assertEquals(t1, t2);
}
@Test
public void blockOnTake() throws Exception {
final TransformerPool pool = new TransformerPool(templates, 3);
// draw down the pool
pool.take();
pool.take();
final Transformer t = pool.take();
// spin up a thread to offer back
new Thread() {
public void run() {
try {
Thread.sleep(2000);
pool.give(t);
} catch (Exception ex) {
ex.printStackTrace();
Assert.fail();
}
}
}.start();
// This will block until the give from our thread above
Transformer t2 = pool.take();
Assert.assertEquals(t, t2);
}