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.127 by jsr166, Sat Jan 17 23:14:17 2015 UTC vs.
Revision 1.130 by jsr166, Tue Apr 21 05:00:23 2015 UTC

# Line 265 | Line 265 | public class JSR166TestCase extends Test
265      public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; }
266      public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; }
267      public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; }
268 <    public static boolean atLeastJava9() {
269 <        // As of 2014-05, java9 still uses 52.0 class file version
270 <        return JAVA_SPECIFICATION_VERSION.startsWith("1.9");
271 <    }
268 >    public static boolean atLeastJava9() { return JAVA_CLASS_VERSION >= 53.0; }
269  
270      /**
271       * Collects all JSR166 unit tests as one suite.
# Line 564 | Line 561 | public class JSR166TestCase extends Test
561      public void threadAssertEquals(Object x, Object y) {
562          try {
563              assertEquals(x, y);
564 <        } catch (AssertionFailedError t) {
565 <            threadRecordFailure(t);
566 <            throw t;
567 <        } catch (Throwable t) {
568 <            threadUnexpectedException(t);
564 >        } catch (AssertionFailedError fail) {
565 >            threadRecordFailure(fail);
566 >            throw fail;
567 >        } catch (Throwable fail) {
568 >            threadUnexpectedException(fail);
569          }
570      }
571  
# Line 580 | Line 577 | public class JSR166TestCase extends Test
577      public void threadAssertSame(Object x, Object y) {
578          try {
579              assertSame(x, y);
580 <        } catch (AssertionFailedError t) {
581 <            threadRecordFailure(t);
582 <            throw t;
580 >        } catch (AssertionFailedError fail) {
581 >            threadRecordFailure(fail);
582 >            throw fail;
583          }
584      }
585  
# Line 652 | Line 649 | public class JSR166TestCase extends Test
649                       " did not terminate in a timely manner");
650          } catch (SecurityException ok) {
651              // Allowed in case test doesn't have privs
652 <        } catch (InterruptedException ie) {
652 >        } catch (InterruptedException fail) {
653              fail("Unexpected InterruptedException");
654          }
655      }
# Line 683 | Line 680 | public class JSR166TestCase extends Test
680              // No need to optimize the failing case via Thread.join.
681              delay(millis);
682              assertTrue(thread.isAlive());
683 <        } catch (InterruptedException ie) {
683 >        } catch (InterruptedException fail) {
684              fail("Unexpected InterruptedException");
685          }
686      }
# Line 705 | Line 702 | public class JSR166TestCase extends Test
702              delay(millis);
703              for (Thread thread : threads)
704                  assertTrue(thread.isAlive());
705 <        } catch (InterruptedException ie) {
705 >        } catch (InterruptedException fail) {
706              fail("Unexpected InterruptedException");
707          }
708      }
# Line 727 | Line 724 | public class JSR166TestCase extends Test
724              future.get(timeoutMillis, MILLISECONDS);
725              shouldThrow();
726          } catch (TimeoutException success) {
727 <        } catch (Exception e) {
728 <            threadUnexpectedException(e);
727 >        } catch (Exception fail) {
728 >            threadUnexpectedException(fail);
729          } finally { future.cancel(true); }
730          assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
731      }
# Line 884 | Line 881 | public class JSR166TestCase extends Test
881      void sleep(long millis) {
882          try {
883              delay(millis);
884 <        } catch (InterruptedException ie) {
884 >        } catch (InterruptedException fail) {
885              AssertionFailedError afe =
886                  new AssertionFailedError("Unexpected InterruptedException");
887 <            afe.initCause(ie);
887 >            afe.initCause(fail);
888              throw afe;
889          }
890      }
# Line 979 | Line 976 | public class JSR166TestCase extends Test
976      void awaitTermination(Thread t, long timeoutMillis) {
977          try {
978              t.join(timeoutMillis);
979 <        } catch (InterruptedException ie) {
980 <            threadUnexpectedException(ie);
979 >        } catch (InterruptedException fail) {
980 >            threadUnexpectedException(fail);
981          } finally {
982              if (t.getState() != Thread.State.TERMINATED) {
983                  t.interrupt();
# Line 1006 | Line 1003 | public class JSR166TestCase extends Test
1003          public final void run() {
1004              try {
1005                  realRun();
1006 <            } catch (Throwable t) {
1007 <                threadUnexpectedException(t);
1006 >            } catch (Throwable fail) {
1007 >                threadUnexpectedException(fail);
1008              }
1009          }
1010      }
# Line 1061 | Line 1058 | public class JSR166TestCase extends Test
1058                  threadShouldThrow("InterruptedException");
1059              } catch (InterruptedException success) {
1060                  threadAssertFalse(Thread.interrupted());
1061 <            } catch (Throwable t) {
1062 <                threadUnexpectedException(t);
1061 >            } catch (Throwable fail) {
1062 >                threadUnexpectedException(fail);
1063              }
1064          }
1065      }
# Line 1073 | Line 1070 | public class JSR166TestCase extends Test
1070          public final T call() {
1071              try {
1072                  return realCall();
1073 <            } catch (Throwable t) {
1074 <                threadUnexpectedException(t);
1073 >            } catch (Throwable fail) {
1074 >                threadUnexpectedException(fail);
1075                  return null;
1076              }
1077          }
# Line 1091 | Line 1088 | public class JSR166TestCase extends Test
1088                  return result;
1089              } catch (InterruptedException success) {
1090                  threadAssertFalse(Thread.interrupted());
1091 <            } catch (Throwable t) {
1092 <                threadUnexpectedException(t);
1091 >            } catch (Throwable fail) {
1092 >                threadUnexpectedException(fail);
1093              }
1094              return null;
1095          }
# Line 1132 | Line 1129 | public class JSR166TestCase extends Test
1129      public void await(CountDownLatch latch) {
1130          try {
1131              assertTrue(latch.await(LONG_DELAY_MS, MILLISECONDS));
1132 <        } catch (Throwable t) {
1133 <            threadUnexpectedException(t);
1132 >        } catch (Throwable fail) {
1133 >            threadUnexpectedException(fail);
1134          }
1135      }
1136  
1137      public void await(Semaphore semaphore) {
1138          try {
1139              assertTrue(semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS));
1140 <        } catch (Throwable t) {
1141 <            threadUnexpectedException(t);
1140 >        } catch (Throwable fail) {
1141 >            threadUnexpectedException(fail);
1142          }
1143      }
1144  
# Line 1335 | Line 1332 | public class JSR166TestCase extends Test
1332          @Override protected final void compute() {
1333              try {
1334                  realCompute();
1335 <            } catch (Throwable t) {
1336 <                threadUnexpectedException(t);
1335 >            } catch (Throwable fail) {
1336 >                threadUnexpectedException(fail);
1337              }
1338          }
1339      }
# Line 1350 | Line 1347 | public class JSR166TestCase extends Test
1347          @Override protected final T compute() {
1348              try {
1349                  return realCompute();
1350 <            } catch (Throwable t) {
1351 <                threadUnexpectedException(t);
1350 >            } catch (Throwable fail) {
1351 >                threadUnexpectedException(fail);
1352                  return null;
1353              }
1354          }
# Line 1375 | Line 1372 | public class JSR166TestCase extends Test
1372          public int await() {
1373              try {
1374                  return super.await(2 * LONG_DELAY_MS, MILLISECONDS);
1375 <            } catch (TimeoutException e) {
1375 >            } catch (TimeoutException timedOut) {
1376                  throw new AssertionFailedError("timed out");
1377 <            } catch (Exception e) {
1377 >            } catch (Exception fail) {
1378                  AssertionFailedError afe =
1379 <                    new AssertionFailedError("Unexpected exception: " + e);
1380 <                afe.initCause(e);
1379 >                    new AssertionFailedError("Unexpected exception: " + fail);
1380 >                afe.initCause(fail);
1381                  throw afe;
1382              }
1383          }
# Line 1408 | Line 1405 | public class JSR166TestCase extends Test
1405                  q.remove();
1406                  shouldThrow();
1407              } catch (NoSuchElementException success) {}
1408 <        } catch (InterruptedException ie) {
1412 <            threadUnexpectedException(ie);
1413 <        }
1408 >        } catch (InterruptedException fail) { threadUnexpectedException(fail); }
1409      }
1410  
1411      void assertSerialEquals(Object x, Object y) {
# Line 1429 | Line 1424 | public class JSR166TestCase extends Test
1424              oos.flush();
1425              oos.close();
1426              return bos.toByteArray();
1427 <        } catch (Throwable t) {
1428 <            threadUnexpectedException(t);
1427 >        } catch (Throwable fail) {
1428 >            threadUnexpectedException(fail);
1429              return new byte[0];
1430          }
1431      }
# Line 1443 | Line 1438 | public class JSR166TestCase extends Test
1438              T clone = (T) ois.readObject();
1439              assertSame(o.getClass(), clone.getClass());
1440              return clone;
1441 <        } catch (Throwable t) {
1442 <            threadUnexpectedException(t);
1441 >        } catch (Throwable fail) {
1442 >            threadUnexpectedException(fail);
1443              return null;
1444          }
1445      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines