ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.65 by jsr166, Thu Oct 21 23:22:49 2010 UTC vs.
Revision 1.71 by jsr166, Mon Nov 22 06:53:32 2010 UTC

# Line 11 | Line 11 | import java.util.PropertyPermission;
11   import java.util.concurrent.*;
12   import java.util.concurrent.atomic.AtomicReference;
13   import static java.util.concurrent.TimeUnit.MILLISECONDS;
14 + import static java.util.concurrent.TimeUnit.NANOSECONDS;
15   import java.security.CodeSource;
16   import java.security.Permission;
17   import java.security.PermissionCollection;
# Line 259 | Line 260 | public class JSR166TestCase extends Test
260          SHORT_DELAY_MS = getShortDelay();
261          SMALL_DELAY_MS  = SHORT_DELAY_MS * 5;
262          MEDIUM_DELAY_MS = SHORT_DELAY_MS * 10;
263 <        LONG_DELAY_MS   = SHORT_DELAY_MS * 50;
263 >        LONG_DELAY_MS   = SHORT_DELAY_MS * 200;
264      }
265  
266      /**
# Line 288 | Line 289 | public class JSR166TestCase extends Test
289       * earlier by threadRecordFailure.
290       */
291      public void tearDown() throws Exception {
292 <        Throwable t = threadFailure.get();
292 >        Throwable t = threadFailure.getAndSet(null);
293          if (t != null) {
294              if (t instanceof Error)
295                  throw (Error) t;
# Line 446 | Line 447 | public class JSR166TestCase extends Test
447          try {
448              exec.shutdown();
449              assertTrue("ExecutorService did not terminate in a timely manner",
450 <                       exec.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
450 >                       exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS));
451          } catch (SecurityException ok) {
452              // Allowed in case test doesn't have privs
453          } catch (InterruptedException ie) {
# Line 615 | Line 616 | public class JSR166TestCase extends Test
616              Thread.State s = thread.getState();
617              if (s == Thread.State.BLOCKED ||
618                  s == Thread.State.WAITING ||
619 <                s == Thread.State.TIMED_WAITING ||
619 <                System.nanoTime() - t0 > timeoutNanos)
619 >                s == Thread.State.TIMED_WAITING)
620                  return;
621 +            else if (s == Thread.State.TERMINATED)
622 +                fail("Unexpected thread termination");
623 +            else if (System.nanoTime() - t0 > timeoutNanos) {
624 +                threadAssertTrue(thread.isAlive());
625 +                return;
626 +            }
627              Thread.yield();
628          }
629      }
630  
631      /**
632 +     * Returns the number of milliseconds since time given by
633 +     * startNanoTime, which must have been previously returned from a
634 +     * call to {@link System.nanoTime()}.
635 +     */
636 +    long millisElapsedSince(long startNanoTime) {
637 +        return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
638 +    }
639 +
640 +    /**
641       * Returns a new started daemon Thread running the given runnable.
642       */
643      Thread newStartedThread(Runnable runnable) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines