--- jsr166/src/test/tck/ExecutorsTest.java 2009/11/20 22:58:48 1.24 +++ jsr166/src/test/tck/ExecutorsTest.java 2009/11/21 02:33:20 1.26 @@ -10,6 +10,7 @@ import junit.framework.*; import java.util.*; import java.util.concurrent.*; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.math.BigInteger; import java.security.*; @@ -35,7 +36,7 @@ public class ExecutorsTest extends JSR16 public T call() throws Exception { Future ftask = exec.submit(func); try { - return ftask.get(msecs, TimeUnit.MILLISECONDS); + return ftask.get(msecs, MILLISECONDS); } finally { ftask.cancel(true); } @@ -222,7 +223,7 @@ public class ExecutorsTest extends JSR16 public void testNewSingleThreadScheduledExecutor() throws Exception { TrackedCallable callable = new TrackedCallable(); ScheduledExecutorService p1 = Executors.newSingleThreadScheduledExecutor(); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); + Future f = p1.schedule(callable, SHORT_DELAY_MS, MILLISECONDS); assertFalse(callable.done); Thread.sleep(MEDIUM_DELAY_MS); assertTrue(callable.done); @@ -236,7 +237,7 @@ public class ExecutorsTest extends JSR16 public void testnewScheduledThreadPool() throws Exception { TrackedCallable callable = new TrackedCallable(); ScheduledExecutorService p1 = Executors.newScheduledThreadPool(2); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); + Future f = p1.schedule(callable, SHORT_DELAY_MS, MILLISECONDS); assertFalse(callable.done); Thread.sleep(MEDIUM_DELAY_MS); assertTrue(callable.done); @@ -250,7 +251,7 @@ public class ExecutorsTest extends JSR16 public void testunconfigurableScheduledExecutorService() throws Exception { TrackedCallable callable = new TrackedCallable(); ScheduledExecutorService p1 = Executors.unconfigurableScheduledExecutorService(Executors.newScheduledThreadPool(2)); - Future f = p1.schedule(callable, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); + Future f = p1.schedule(callable, SHORT_DELAY_MS, MILLISECONDS); assertFalse(callable.done); Thread.sleep(MEDIUM_DELAY_MS); assertTrue(callable.done); @@ -304,21 +305,21 @@ public class ExecutorsTest extends JSR16 final ThreadGroup egroup = Thread.currentThread().getThreadGroup(); Runnable r = new Runnable() { public void run() { - try { - Thread current = Thread.currentThread(); - threadAssertTrue(!current.isDaemon()); - threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); - ThreadGroup g = current.getThreadGroup(); - SecurityManager s = System.getSecurityManager(); - if (s != null) - threadAssertTrue(g == s.getThreadGroup()); - else - threadAssertTrue(g == egroup); - String name = current.getName(); - threadAssertTrue(name.endsWith("thread-1")); - } catch (SecurityException ok) { - // Also pass if not allowed to change setting - } + try { + Thread current = Thread.currentThread(); + threadAssertTrue(!current.isDaemon()); + threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); + ThreadGroup g = current.getThreadGroup(); + SecurityManager s = System.getSecurityManager(); + if (s != null) + threadAssertTrue(g == s.getThreadGroup()); + else + threadAssertTrue(g == egroup); + String name = current.getName(); + threadAssertTrue(name.endsWith("thread-1")); + } catch (SecurityException ok) { + // Also pass if not allowed to change setting + } } }; ExecutorService e = Executors.newSingleThreadExecutor(Executors.defaultThreadFactory()); @@ -357,23 +358,23 @@ public class ExecutorsTest extends JSR16 final AccessControlContext thisacc = AccessController.getContext(); Runnable r = new Runnable() { public void run() { - try { - Thread current = Thread.currentThread(); - threadAssertTrue(!current.isDaemon()); - threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); - ThreadGroup g = current.getThreadGroup(); - SecurityManager s = System.getSecurityManager(); - if (s != null) - threadAssertTrue(g == s.getThreadGroup()); - else - threadAssertTrue(g == egroup); - String name = current.getName(); - threadAssertTrue(name.endsWith("thread-1")); - threadAssertTrue(thisccl == current.getContextClassLoader()); - threadAssertTrue(thisacc.equals(AccessController.getContext())); - } catch (SecurityException ok) { - // Also pass if not allowed to change settings - } + try { + Thread current = Thread.currentThread(); + threadAssertTrue(!current.isDaemon()); + threadAssertTrue(current.getPriority() <= Thread.NORM_PRIORITY); + ThreadGroup g = current.getThreadGroup(); + SecurityManager s = System.getSecurityManager(); + if (s != null) + threadAssertTrue(g == s.getThreadGroup()); + else + threadAssertTrue(g == egroup); + String name = current.getName(); + threadAssertTrue(name.endsWith("thread-1")); + threadAssertTrue(thisccl == current.getContextClassLoader()); + threadAssertTrue(thisacc.equals(AccessController.getContext())); + } catch (SecurityException ok) { + // Also pass if not allowed to change settings + } } }; ExecutorService e = Executors.newSingleThreadExecutor(Executors.privilegedThreadFactory()); @@ -413,7 +414,7 @@ public class ExecutorsTest extends JSR16 * privilegedCallableUsingCurrentClassLoader throws ACE */ public void testCreatePrivilegedCallableUsingCCLWithNoPrivs() { - Policy savedPolicy = null; + Policy savedPolicy = null; try { savedPolicy = Policy.getPolicy(); AdjustablePolicy policy = new AdjustablePolicy(); @@ -445,7 +446,7 @@ public class ExecutorsTest extends JSR16 * privilegedCallableUsingCurrentClassLoader does not throw ACE */ public void testprivilegedCallableUsingCCLWithPrivs() throws Exception { - Policy savedPolicy = null; + Policy savedPolicy = null; try { savedPolicy = Policy.getPolicy(); AdjustablePolicy policy = new AdjustablePolicy(); @@ -506,7 +507,7 @@ public class ExecutorsTest extends JSR16 * With permissions, calling privilegedCallable succeeds */ public void testprivilegedCallableWithPrivs() throws Exception { - Policy savedPolicy = null; + Policy savedPolicy = null; try { savedPolicy = Policy.getPolicy(); AdjustablePolicy policy = new AdjustablePolicy();