Fix ConcurrentBag test

2.3.0
Brett Wooldridge 10 years ago
parent 57b8e91f02
commit 8a61e581c2

@ -18,6 +18,8 @@ package com.zaxxer.hikari;
import static com.zaxxer.hikari.util.UtilityElf.IS_JAVA7; import static com.zaxxer.hikari.util.UtilityElf.IS_JAVA7;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedLongSynchronizer; import java.util.concurrent.locks.AbstractQueuedLongSynchronizer;
@ -79,38 +81,22 @@ public class TestConcurrentBag
bag.dumpState(); bag.dumpState();
try { ByteArrayOutputStream baos = new ByteArrayOutputStream();
bag.requite(reserved); PrintStream ps = new PrintStream(baos, true);
Assert.fail(); TestElf.setSlf4jTargetStream(Java8ConcurrentBag.class, ps);
}
catch (IllegalStateException e) {
// pass
}
try { bag.requite(reserved);
bag.remove(notinuse); Assert.assertTrue(new String(baos.toByteArray()).contains("does not exist"));
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try { bag.remove(notinuse);
bag.unreserve(notinuse); Assert.assertTrue(new String(baos.toByteArray()).contains("not borrowed or reserved"));
Assert.fail();
}
catch (IllegalStateException e) {
// pass
}
try { bag.unreserve(notinuse);
bag.remove(inuse); Assert.assertTrue(new String(baos.toByteArray()).contains("was not reserved"));
bag.remove(inuse);
Assert.fail(); bag.remove(inuse);
} bag.remove(inuse);
catch (IllegalStateException e) { Assert.assertTrue(new String(baos.toByteArray()).contains("not borrowed or reserved"));
// pass
}
bag.close(); bag.close();
try { try {
@ -119,7 +105,7 @@ public class TestConcurrentBag
Assert.assertNotEquals(bagEntry, bag.borrow(100, TimeUnit.MILLISECONDS)); Assert.assertNotEquals(bagEntry, bag.borrow(100, TimeUnit.MILLISECONDS));
} }
catch (IllegalStateException e) { catch (IllegalStateException e) {
// pass Assert.assertTrue(new String(baos.toByteArray()).contains("ignoring add()"));
} }
Assert.assertNotNull(notinuse.toString()); Assert.assertNotNull(notinuse.toString());

Loading…
Cancel
Save