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

Comparing jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java (file contents):
Revision 1.79 by jsr166, Sun Oct 4 03:58:22 2015 UTC vs.
Revision 1.80 by jsr166, Sun Oct 4 06:39:13 2015 UTC

# Line 272 | Line 272 | public class ThreadPoolExecutorSubclassT
272       * prestartCoreThread starts a thread if under corePoolSize, else doesn't
273       */
274      public void testPrestartCoreThread() {
275 <        ThreadPoolExecutor p =
275 >        final ThreadPoolExecutor p =
276              new CustomTPE(2, 6,
277                            LONG_DELAY_MS, MILLISECONDS,
278                            new ArrayBlockingQueue<Runnable>(10));
# Line 298 | Line 298 | public class ThreadPoolExecutorSubclassT
298       * prestartAllCoreThreads starts all corePoolSize threads
299       */
300      public void testPrestartAllCoreThreads() {
301 <        ThreadPoolExecutor p =
301 >        final ThreadPoolExecutor p =
302              new CustomTPE(2, 6,
303                            LONG_DELAY_MS, MILLISECONDS,
304                            new ArrayBlockingQueue<Runnable>(10));
# Line 752 | Line 752 | public class ThreadPoolExecutorSubclassT
752          final int poolSize = 2;
753          final int count = 5;
754          final AtomicInteger ran = new AtomicInteger(0);
755 <        ThreadPoolExecutor p =
755 >        final ThreadPoolExecutor p =
756              new CustomTPE(poolSize, poolSize, LONG_DELAY_MS, MILLISECONDS,
757                            new ArrayBlockingQueue<Runnable>(10));
758          CountDownLatch threadsStarted = new CountDownLatch(poolSize);
# Line 1321 | Line 1321 | public class ThreadPoolExecutorSubclassT
1321       * setCorePoolSize of negative value throws IllegalArgumentException
1322       */
1323      public void testCorePoolSizeIllegalArgumentException() {
1324 <        ThreadPoolExecutor p =
1324 >        final ThreadPoolExecutor p =
1325              new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1326          try {
1327              p.setCorePoolSize(-1);
# Line 1338 | Line 1338 | public class ThreadPoolExecutorSubclassT
1338       * if given a value less the core pool size
1339       */
1340      public void testMaximumPoolSizeIllegalArgumentException() {
1341 <        ThreadPoolExecutor p =
1341 >        final ThreadPoolExecutor p =
1342              new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1343          try {
1344              p.setMaximumPoolSize(1);
# Line 1355 | Line 1355 | public class ThreadPoolExecutorSubclassT
1355       * if given a negative value
1356       */
1357      public void testMaximumPoolSizeIllegalArgumentException2() {
1358 <        ThreadPoolExecutor p =
1358 >        final ThreadPoolExecutor p =
1359              new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1360          try {
1361              p.setMaximumPoolSize(-1);
# Line 1372 | Line 1372 | public class ThreadPoolExecutorSubclassT
1372       * when given a negative value
1373       */
1374      public void testKeepAliveTimeIllegalArgumentException() {
1375 <        ThreadPoolExecutor p =
1375 >        final ThreadPoolExecutor p =
1376              new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1377  
1378          try {
# Line 1420 | Line 1420 | public class ThreadPoolExecutorSubclassT
1420       * completed submit of callable returns result
1421       */
1422      public void testSubmitCallable() throws Exception {
1423 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1423 >        final ExecutorService e =
1424 >            new CustomTPE(2, 2,
1425 >                          LONG_DELAY_MS, MILLISECONDS,
1426 >                          new ArrayBlockingQueue<Runnable>(10));
1427          try {
1428              Future<String> future = e.submit(new StringTask());
1429              String result = future.get();
# Line 1434 | Line 1437 | public class ThreadPoolExecutorSubclassT
1437       * completed submit of runnable returns successfully
1438       */
1439      public void testSubmitRunnable() throws Exception {
1440 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1440 >        final ExecutorService e =
1441 >            new CustomTPE(2, 2,
1442 >                          LONG_DELAY_MS, MILLISECONDS,
1443 >                          new ArrayBlockingQueue<Runnable>(10));
1444          try {
1445              Future<?> future = e.submit(new NoOpRunnable());
1446              future.get();
# Line 1448 | Line 1454 | public class ThreadPoolExecutorSubclassT
1454       * completed submit of (runnable, result) returns result
1455       */
1456      public void testSubmitRunnable2() throws Exception {
1457 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1457 >        final ExecutorService e =
1458 >            new CustomTPE(2, 2,
1459 >                          LONG_DELAY_MS, MILLISECONDS,
1460 >                          new ArrayBlockingQueue<Runnable>(10));
1461          try {
1462              Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
1463              String result = future.get();
# Line 1462 | Line 1471 | public class ThreadPoolExecutorSubclassT
1471       * invokeAny(null) throws NPE
1472       */
1473      public void testInvokeAny1() throws Exception {
1474 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1474 >        final ExecutorService e =
1475 >            new CustomTPE(2, 2,
1476 >                          LONG_DELAY_MS, MILLISECONDS,
1477 >                          new ArrayBlockingQueue<Runnable>(10));
1478          try {
1479              e.invokeAny(null);
1480              shouldThrow();
# Line 1476 | Line 1488 | public class ThreadPoolExecutorSubclassT
1488       * invokeAny(empty collection) throws IAE
1489       */
1490      public void testInvokeAny2() throws Exception {
1491 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1491 >        final ExecutorService e =
1492 >            new CustomTPE(2, 2,
1493 >                          LONG_DELAY_MS, MILLISECONDS,
1494 >                          new ArrayBlockingQueue<Runnable>(10));
1495          try {
1496              e.invokeAny(new ArrayList<Callable<String>>());
1497              shouldThrow();
# Line 1491 | Line 1506 | public class ThreadPoolExecutorSubclassT
1506       */
1507      public void testInvokeAny3() throws Exception {
1508          CountDownLatch latch = new CountDownLatch(1);
1509 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1509 >        final ExecutorService e =
1510 >            new CustomTPE(2, 2,
1511 >                          LONG_DELAY_MS, MILLISECONDS,
1512 >                          new ArrayBlockingQueue<Runnable>(10));
1513          List<Callable<String>> l = new ArrayList<Callable<String>>();
1514          l.add(latchAwaitingStringTask(latch));
1515          l.add(null);
# Line 1509 | Line 1527 | public class ThreadPoolExecutorSubclassT
1527       * invokeAny(c) throws ExecutionException if no task completes
1528       */
1529      public void testInvokeAny4() throws Exception {
1530 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1530 >        final ExecutorService e =
1531 >            new CustomTPE(2, 2,
1532 >                          LONG_DELAY_MS, MILLISECONDS,
1533 >                          new ArrayBlockingQueue<Runnable>(10));
1534          List<Callable<String>> l = new ArrayList<Callable<String>>();
1535          l.add(new NPETask());
1536          try {
# Line 1526 | Line 1547 | public class ThreadPoolExecutorSubclassT
1547       * invokeAny(c) returns result of some task
1548       */
1549      public void testInvokeAny5() throws Exception {
1550 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1550 >        final ExecutorService e =
1551 >            new CustomTPE(2, 2,
1552 >                          LONG_DELAY_MS, MILLISECONDS,
1553 >                          new ArrayBlockingQueue<Runnable>(10));
1554          try {
1555              List<Callable<String>> l = new ArrayList<Callable<String>>();
1556              l.add(new StringTask());
# Line 1542 | Line 1566 | public class ThreadPoolExecutorSubclassT
1566       * invokeAll(null) throws NPE
1567       */
1568      public void testInvokeAll1() throws Exception {
1569 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1569 >        final ExecutorService e =
1570 >            new CustomTPE(2, 2,
1571 >                          LONG_DELAY_MS, MILLISECONDS,
1572 >                          new ArrayBlockingQueue<Runnable>(10));
1573          try {
1574              e.invokeAll(null);
1575              shouldThrow();
# Line 1556 | Line 1583 | public class ThreadPoolExecutorSubclassT
1583       * invokeAll(empty collection) returns empty collection
1584       */
1585      public void testInvokeAll2() throws Exception {
1586 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1586 >        final ExecutorService e =
1587 >            new CustomTPE(2, 2,
1588 >                          LONG_DELAY_MS, MILLISECONDS,
1589 >                          new ArrayBlockingQueue<Runnable>(10));
1590          try {
1591              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
1592              assertTrue(r.isEmpty());
# Line 1569 | Line 1599 | public class ThreadPoolExecutorSubclassT
1599       * invokeAll(c) throws NPE if c has null elements
1600       */
1601      public void testInvokeAll3() throws Exception {
1602 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1602 >        final ExecutorService e =
1603 >            new CustomTPE(2, 2,
1604 >                          LONG_DELAY_MS, MILLISECONDS,
1605 >                          new ArrayBlockingQueue<Runnable>(10));
1606          List<Callable<String>> l = new ArrayList<Callable<String>>();
1607          l.add(new StringTask());
1608          l.add(null);
# Line 1586 | Line 1619 | public class ThreadPoolExecutorSubclassT
1619       * get of element of invokeAll(c) throws exception on failed task
1620       */
1621      public void testInvokeAll4() throws Exception {
1622 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1622 >        final ExecutorService e =
1623 >            new CustomTPE(2, 2,
1624 >                          LONG_DELAY_MS, MILLISECONDS,
1625 >                          new ArrayBlockingQueue<Runnable>(10));
1626          List<Callable<String>> l = new ArrayList<Callable<String>>();
1627          l.add(new NPETask());
1628          List<Future<String>> futures = e.invokeAll(l);
# Line 1605 | Line 1641 | public class ThreadPoolExecutorSubclassT
1641       * invokeAll(c) returns results of all completed tasks
1642       */
1643      public void testInvokeAll5() throws Exception {
1644 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1644 >        final ExecutorService e =
1645 >            new CustomTPE(2, 2,
1646 >                          LONG_DELAY_MS, MILLISECONDS,
1647 >                          new ArrayBlockingQueue<Runnable>(10));
1648          try {
1649              List<Callable<String>> l = new ArrayList<Callable<String>>();
1650              l.add(new StringTask());
# Line 1623 | Line 1662 | public class ThreadPoolExecutorSubclassT
1662       * timed invokeAny(null) throws NPE
1663       */
1664      public void testTimedInvokeAny1() throws Exception {
1665 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1665 >        final ExecutorService e =
1666 >            new CustomTPE(2, 2,
1667 >                          LONG_DELAY_MS, MILLISECONDS,
1668 >                          new ArrayBlockingQueue<Runnable>(10));
1669          try {
1670              e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1671              shouldThrow();
# Line 1637 | Line 1679 | public class ThreadPoolExecutorSubclassT
1679       * timed invokeAny(,,null) throws NPE
1680       */
1681      public void testTimedInvokeAnyNullTimeUnit() throws Exception {
1682 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1682 >        final ExecutorService e =
1683 >            new CustomTPE(2, 2,
1684 >                          LONG_DELAY_MS, MILLISECONDS,
1685 >                          new ArrayBlockingQueue<Runnable>(10));
1686          List<Callable<String>> l = new ArrayList<Callable<String>>();
1687          l.add(new StringTask());
1688          try {
# Line 1653 | Line 1698 | public class ThreadPoolExecutorSubclassT
1698       * timed invokeAny(empty collection) throws IAE
1699       */
1700      public void testTimedInvokeAny2() throws Exception {
1701 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1701 >        final ExecutorService e =
1702 >            new CustomTPE(2, 2,
1703 >                          LONG_DELAY_MS, MILLISECONDS,
1704 >                          new ArrayBlockingQueue<Runnable>(10));
1705          try {
1706              e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1707              shouldThrow();
# Line 1668 | Line 1716 | public class ThreadPoolExecutorSubclassT
1716       */
1717      public void testTimedInvokeAny3() throws Exception {
1718          CountDownLatch latch = new CountDownLatch(1);
1719 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1719 >        final ExecutorService e =
1720 >            new CustomTPE(2, 2,
1721 >                          LONG_DELAY_MS, MILLISECONDS,
1722 >                          new ArrayBlockingQueue<Runnable>(10));
1723          List<Callable<String>> l = new ArrayList<Callable<String>>();
1724          l.add(latchAwaitingStringTask(latch));
1725          l.add(null);
# Line 1686 | Line 1737 | public class ThreadPoolExecutorSubclassT
1737       * timed invokeAny(c) throws ExecutionException if no task completes
1738       */
1739      public void testTimedInvokeAny4() throws Exception {
1740 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1740 >        final ExecutorService e =
1741 >            new CustomTPE(2, 2,
1742 >                          LONG_DELAY_MS, MILLISECONDS,
1743 >                          new ArrayBlockingQueue<Runnable>(10));
1744          List<Callable<String>> l = new ArrayList<Callable<String>>();
1745          l.add(new NPETask());
1746          try {
# Line 1703 | Line 1757 | public class ThreadPoolExecutorSubclassT
1757       * timed invokeAny(c) returns result of some task
1758       */
1759      public void testTimedInvokeAny5() throws Exception {
1760 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1760 >        final ExecutorService e =
1761 >            new CustomTPE(2, 2,
1762 >                          LONG_DELAY_MS, MILLISECONDS,
1763 >                          new ArrayBlockingQueue<Runnable>(10));
1764          try {
1765              List<Callable<String>> l = new ArrayList<Callable<String>>();
1766              l.add(new StringTask());
# Line 1719 | Line 1776 | public class ThreadPoolExecutorSubclassT
1776       * timed invokeAll(null) throws NPE
1777       */
1778      public void testTimedInvokeAll1() throws Exception {
1779 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1779 >        final ExecutorService e =
1780 >            new CustomTPE(2, 2,
1781 >                          LONG_DELAY_MS, MILLISECONDS,
1782 >                          new ArrayBlockingQueue<Runnable>(10));
1783          try {
1784              e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1785              shouldThrow();
# Line 1733 | Line 1793 | public class ThreadPoolExecutorSubclassT
1793       * timed invokeAll(,,null) throws NPE
1794       */
1795      public void testTimedInvokeAllNullTimeUnit() throws Exception {
1796 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1796 >        final ExecutorService e =
1797 >            new CustomTPE(2, 2,
1798 >                          LONG_DELAY_MS, MILLISECONDS,
1799 >                          new ArrayBlockingQueue<Runnable>(10));
1800          List<Callable<String>> l = new ArrayList<Callable<String>>();
1801          l.add(new StringTask());
1802          try {
# Line 1749 | Line 1812 | public class ThreadPoolExecutorSubclassT
1812       * timed invokeAll(empty collection) returns empty collection
1813       */
1814      public void testTimedInvokeAll2() throws Exception {
1815 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1815 >        final ExecutorService e =
1816 >            new CustomTPE(2, 2,
1817 >                          LONG_DELAY_MS, MILLISECONDS,
1818 >                          new ArrayBlockingQueue<Runnable>(10));
1819          try {
1820              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1821              assertTrue(r.isEmpty());
# Line 1762 | Line 1828 | public class ThreadPoolExecutorSubclassT
1828       * timed invokeAll(c) throws NPE if c has null elements
1829       */
1830      public void testTimedInvokeAll3() throws Exception {
1831 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1831 >        final ExecutorService e =
1832 >            new CustomTPE(2, 2,
1833 >                          LONG_DELAY_MS, MILLISECONDS,
1834 >                          new ArrayBlockingQueue<Runnable>(10));
1835          List<Callable<String>> l = new ArrayList<Callable<String>>();
1836          l.add(new StringTask());
1837          l.add(null);
# Line 1779 | Line 1848 | public class ThreadPoolExecutorSubclassT
1848       * get of element of invokeAll(c) throws exception on failed task
1849       */
1850      public void testTimedInvokeAll4() throws Exception {
1851 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1851 >        final ExecutorService e =
1852 >            new CustomTPE(2, 2,
1853 >                          LONG_DELAY_MS, MILLISECONDS,
1854 >                          new ArrayBlockingQueue<Runnable>(10));
1855          List<Callable<String>> l = new ArrayList<Callable<String>>();
1856          l.add(new NPETask());
1857          List<Future<String>> futures =
# Line 1799 | Line 1871 | public class ThreadPoolExecutorSubclassT
1871       * timed invokeAll(c) returns results of all completed tasks
1872       */
1873      public void testTimedInvokeAll5() throws Exception {
1874 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1874 >        final ExecutorService e =
1875 >            new CustomTPE(2, 2,
1876 >                          LONG_DELAY_MS, MILLISECONDS,
1877 >                          new ArrayBlockingQueue<Runnable>(10));
1878          try {
1879              List<Callable<String>> l = new ArrayList<Callable<String>>();
1880              l.add(new StringTask());
# Line 1818 | Line 1893 | public class ThreadPoolExecutorSubclassT
1893       * timed invokeAll(c) cancels tasks not completed by timeout
1894       */
1895      public void testTimedInvokeAll6() throws Exception {
1896 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1896 >        final ExecutorService e =
1897 >            new CustomTPE(2, 2,
1898 >                          LONG_DELAY_MS, MILLISECONDS,
1899 >                          new ArrayBlockingQueue<Runnable>(10));
1900          try {
1901              for (long timeout = timeoutMillis();;) {
1902                  List<Callable<String>> tasks = new ArrayList<>();
# Line 1876 | Line 1954 | public class ThreadPoolExecutorSubclassT
1954       * allowsCoreThreadTimeOut is by default false.
1955       */
1956      public void testAllowsCoreThreadTimeOut() {
1957 <        ThreadPoolExecutor p = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1957 >        final ThreadPoolExecutor p =
1958 >            new CustomTPE(2, 2,
1959 >                          1000, MILLISECONDS,
1960 >                          new ArrayBlockingQueue<Runnable>(10));
1961          assertFalse(p.allowsCoreThreadTimeOut());
1962          joinPool(p);
1963      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines