Skip to content

Commit

Permalink
CompletionListenerFuture enhanced tests, coordinate with thread start…
Browse files Browse the repository at this point in the history
… to trigger problems more reliable, tracked by jsr107/jsr107spec#320
  • Loading branch information
cruftex committed Jun 10, 2016
1 parent 0b0911f commit b03d217
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.Test;

import java.lang.UnsupportedOperationException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -118,15 +119,19 @@ public void testIsDone() {
@Test
public void testWakeup() throws InterruptedException {
/* Currently test only with 1 thread to be compatible with 1.0. Can be incremented later. */
final int THREAD_COUNT = 1;
final int THREAD_COUNT = 2;
final long TIMEOUT_MILLIS = 1 * 60 * 1000;
final CompletionListenerFuture future = new CompletionListenerFuture();
/* Waits until threads are running. */
final CountDownLatch countDown = new CountDownLatch(THREAD_COUNT + 1);
Thread[] threads = new Thread[THREAD_COUNT];
for (int i = 0; i < THREAD_COUNT; i++) {
Thread t = threads[i] = new Thread() {
@Override
public void run() {
try {
countDown.countDown();
countDown.await();
future.get();
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -135,6 +140,9 @@ public void run() {
};
t.start();
}
countDown.countDown();
countDown.await();
Thread.sleep(42);
future.onCompletion();
for (int i = 0; i < THREAD_COUNT; i++) {
Thread t = threads[i];
Expand Down

0 comments on commit b03d217

Please sign in to comment.