test/java/util/concurrent/ScheduledThreadPoolExecutor/DelayOverflow.java

Print this page




 144 
 145             check(runLatch.await(10L, TimeUnit.SECONDS));
 146             equal(runLatch.getCount(), 0L);
 147 
 148             pool.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
 149             pool.shutdown();
 150         }
 151     }
 152 
 153     //--------------------- Infrastructure ---------------------------
 154     volatile int passed = 0, failed = 0;
 155     void pass() {passed++;}
 156     void fail() {failed++; Thread.dumpStack();}
 157     void fail(String msg) {System.err.println(msg); fail();}
 158     void unexpected(Throwable t) {failed++; t.printStackTrace();}
 159     void check(boolean cond) {if (cond) pass(); else fail();}
 160     void equal(Object x, Object y) {
 161         if (x == null ? y == null : x.equals(y)) pass();
 162         else fail(x + " not equal to " + y);}
 163     public static void main(String[] args) throws Throwable {
 164         Class<?> k = new Object(){}.getClass().getEnclosingClass();
 165         try {k.getMethod("instanceMain",String[].class)
 166                 .invoke( k.newInstance(), (Object) args);}
 167         catch (Throwable e) {throw e.getCause();}}
 168     public void instanceMain(String[] args) throws Throwable {
 169         try {test(args);} catch (Throwable t) {unexpected(t);}
 170         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 171         if (failed > 0) throw new AssertionError("Some tests failed");}
 172 }


 144 
 145             check(runLatch.await(10L, TimeUnit.SECONDS));
 146             equal(runLatch.getCount(), 0L);
 147 
 148             pool.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
 149             pool.shutdown();
 150         }
 151     }
 152 
 153     //--------------------- Infrastructure ---------------------------
 154     volatile int passed = 0, failed = 0;
 155     void pass() {passed++;}
 156     void fail() {failed++; Thread.dumpStack();}
 157     void fail(String msg) {System.err.println(msg); fail();}
 158     void unexpected(Throwable t) {failed++; t.printStackTrace();}
 159     void check(boolean cond) {if (cond) pass(); else fail();}
 160     void equal(Object x, Object y) {
 161         if (x == null ? y == null : x.equals(y)) pass();
 162         else fail(x + " not equal to " + y);}
 163     public static void main(String[] args) throws Throwable {
 164         new DelayOverflow().instanceMain(args);}
 165     void instanceMain(String[] args) throws Throwable {



 166         try {test(args);} catch (Throwable t) {unexpected(t);}
 167         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 168         if (failed > 0) throw new AssertionError("Some tests failed");}
 169 }