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.115 by jsr166, Wed May 14 21:06:38 2014 UTC vs.
Revision 1.121 by jsr166, Wed Jul 9 16:51:40 2014 UTC

# Line 116 | Line 116 | public class JSR166TestCase extends Test
116          Boolean.getBoolean("jsr166.expensiveTests");
117  
118      /**
119 +     * If true, also run tests that are not part of the official tck
120 +     * because they test unspecified implementation details.
121 +     */
122 +    protected static final boolean testImplementationDetails =
123 +        Boolean.getBoolean("jsr166.testImplementationDetails");
124 +
125 +    /**
126       * If true, report on stdout all "slow" tests, that is, ones that
127       * take more than profileThreshold milliseconds to execute.
128       */
# Line 160 | Line 167 | public class JSR166TestCase extends Test
167      }
168  
169      protected void runTestProfiled() throws Throwable {
170 +        // Warmup run, notably to trigger all needed classloading.
171 +        super.runTest();
172          long t0 = System.nanoTime();
173          try {
174              super.runTest();
175          } finally {
176 <            long elapsedMillis =
168 <                (System.nanoTime() - t0) / (1000L * 1000L);
176 >            long elapsedMillis = millisElapsedSince(t0);
177              if (elapsedMillis >= profileThreshold)
178                  System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
179          }
# Line 622 | Line 630 | public class JSR166TestCase extends Test
630      void joinPool(ExecutorService exec) {
631          try {
632              exec.shutdown();
633 <            assertTrue("ExecutorService did not terminate in a timely manner",
634 <                       exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS));
633 >            if (!exec.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS))
634 >                fail("ExecutorService " + exec +
635 >                     " did not terminate in a timely manner");
636          } catch (SecurityException ok) {
637              // Allowed in case test doesn't have privs
638          } catch (InterruptedException ie) {
# Line 901 | Line 910 | public class JSR166TestCase extends Test
910       * startNanoTime, which must have been previously returned from a
911       * call to {@link System.nanoTime()}.
912       */
913 <    long millisElapsedSince(long startNanoTime) {
913 >    static long millisElapsedSince(long startNanoTime) {
914          return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
915      }
916  
917 + //     void assertTerminatesPromptly(long timeoutMillis, Runnable r) {
918 + //         long startTime = System.nanoTime();
919 + //         try {
920 + //             r.run();
921 + //         } catch (Throwable fail) { threadUnexpectedException(fail); }
922 + //         if (millisElapsedSince(startTime) > timeoutMillis/2)
923 + //             throw new AssertionFailedError("did not return promptly");
924 + //     }
925 +
926 + //     void assertTerminatesPromptly(Runnable r) {
927 + //         assertTerminatesPromptly(LONG_DELAY_MS/2, r);
928 + //     }
929 +
930 +    /**
931 +     * Checks that timed f.get() returns the expected value, and does not
932 +     * wait for the timeout to elapse before returning.
933 +     */
934 +    <T> void checkTimedGet(Future<T> f, T expectedValue, long timeoutMillis) {
935 +        long startTime = System.nanoTime();
936 +        try {
937 +            assertEquals(expectedValue, f.get(timeoutMillis, MILLISECONDS));
938 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
939 +        if (millisElapsedSince(startTime) > timeoutMillis/2)
940 +            throw new AssertionFailedError("timed get did not return promptly");
941 +    }
942 +
943 +    <T> void checkTimedGet(Future<T> f, T expectedValue) {
944 +        checkTimedGet(f, expectedValue, LONG_DELAY_MS);
945 +    }
946 +
947      /**
948       * Returns a new started daemon Thread running the given runnable.
949       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines