javaee7-samples
javaee7-samples copied to clipboard
Create unit tests for Concurrency
Rewrite current Concurrent Tests to use Concurrent Utils; CountDownLatch|CyclicBarrier instead of slow and unsafe Thread.sleep()
e.g. https://github.com/arun-gupta/javaee7-samples/blob/master/concurrency/managedexecutor/src/test/java/org/javaee7/concurrency/managedexecutor/ExecutorInjectTest.java#L72
final CountDownLatch signal = new CountDownLatch(1);
defaultExecutor.submit(new MyRunnableTask(1) {
void run() {
super.run();
signal.countDown();
}
});
Assert.assertTrue(signal.await(2000, TimeUnit.MILLISECONDS))
Changed the tests to use CountDownLatch now. Only created unit tests for managedexecutor. Do you want to create for others ?
https://github.com/javaee-samples/javaee7-samples/pull/136