[jboss-cvs] JBossAS SVN: r91973 - projects/jboss-threads/trunk/main/src/test/java/org/jboss/threads.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 4 16:08:32 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-08-04 16:08:31 -0400 (Tue, 04 Aug 2009)
New Revision: 91973
Modified:
projects/jboss-threads/trunk/main/src/test/java/org/jboss/threads/ThreadFactoryTestCase.java
Log:
Fix test to use new interrupt API
Modified: projects/jboss-threads/trunk/main/src/test/java/org/jboss/threads/ThreadFactoryTestCase.java
===================================================================
--- projects/jboss-threads/trunk/main/src/test/java/org/jboss/threads/ThreadFactoryTestCase.java 2009-08-04 20:08:16 UTC (rev 91972)
+++ projects/jboss-threads/trunk/main/src/test/java/org/jboss/threads/ThreadFactoryTestCase.java 2009-08-04 20:08:31 UTC (rev 91973)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.CountDownLatch;
/**
*
@@ -73,19 +74,29 @@
public void testInterruptHandler() throws InterruptedException {
final AtomicBoolean wasInterrupted = new AtomicBoolean();
final AtomicBoolean called = new AtomicBoolean();
+ final CountDownLatch latch = new CountDownLatch(1);
final JBossThreadFactory threadFactory = new JBossThreadFactory(null, null, null, null, null, null);
final Thread t = threadFactory.newThread(new Runnable() {
public void run() {
synchronized (this) {
+ final InterruptHandler old = JBossThread.getAndSetInterruptHandler(new InterruptHandler() {
+ public void handleInterrupt(final Thread thread) {
+ called.set(true);
+ }
+ });
try {
+ latch.countDown();
wait();
} catch (InterruptedException e) {
wasInterrupted.set(true);
+ } finally {
+ JBossThread.getAndSetInterruptHandler(old);
}
}
}
});
t.start();
+ latch.await();
t.interrupt();
t.join();
assertTrue("Was not interrupted", wasInterrupted.get());
More information about the jboss-cvs-commits
mailing list