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.62 by jsr166, Mon Oct 11 05:40:41 2010 UTC vs.
Revision 1.65 by jsr166, Thu Oct 21 23:22:49 2010 UTC

# Line 131 | Line 131 | public class JSR166TestCase extends Test
131                  System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
132          }
133      }
134 <    
134 >
135      /**
136       * Runs all JSR166 unit tests using junit.textui.TestRunner
137       */
# Line 605 | Line 605 | public class JSR166TestCase extends Test
605      }
606  
607      /**
608 +     * Waits up to the specified number of milliseconds for the given
609 +     * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
610 +     */
611 +    void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) {
612 +        long timeoutNanos = timeoutMillis * 1000L * 1000L;
613 +        long t0 = System.nanoTime();
614 +        for (;;) {
615 +            Thread.State s = thread.getState();
616 +            if (s == Thread.State.BLOCKED ||
617 +                s == Thread.State.WAITING ||
618 +                s == Thread.State.TIMED_WAITING ||
619 +                System.nanoTime() - t0 > timeoutNanos)
620 +                return;
621 +            Thread.yield();
622 +        }
623 +    }
624 +
625 +    /**
626       * Returns a new started daemon Thread running the given runnable.
627       */
628      Thread newStartedThread(Runnable runnable) {
# Line 746 | Line 764 | public class JSR166TestCase extends Test
764  
765      public Callable<String> latchAwaitingStringTask(final CountDownLatch latch) {
766          return new CheckedCallable<String>() {
767 <            public String realCall() {
767 >            protected String realCall() {
768                  try {
769                      latch.await();
770                  } catch (InterruptedException quittingTime) {}
# Line 807 | Line 825 | public class JSR166TestCase extends Test
825          }
826      }
827  
828 +    public Runnable possiblyInterruptedRunnable(final long timeoutMillis) {
829 +        return new CheckedRunnable() {
830 +            protected void realRun() {
831 +                try {
832 +                    Thread.sleep(timeoutMillis);
833 +                } catch (InterruptedException ok) {}
834 +            }};
835 +    }
836 +
837      public class MediumPossiblyInterruptedRunnable extends CheckedRunnable {
838          protected void realRun() {
839              try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines