test/java/util/concurrent/Executors/Throws.java

Print this page




 105 
 106         try { new ScheduledThreadPoolExecutor(0, fac, reh).shutdownNow(); pass(); }
 107         catch (Throwable t) { unexpected(t); }
 108 
 109     }
 110 
 111     //--------------------- Infrastructure ---------------------------
 112     static volatile int passed = 0, failed = 0;
 113     static void pass() {passed++;}
 114     static void fail() {failed++; Thread.dumpStack();}
 115     static void fail(String msg) {System.out.println(msg); fail();}
 116     static void unexpected(Throwable t) {failed++; t.printStackTrace();}
 117     static void check(boolean cond) {if (cond) pass(); else fail();}
 118     static void equal(Object x, Object y) {
 119         if (x == null ? y == null : x.equals(y)) pass();
 120         else fail(x + " not equal to " + y);}
 121     public static void main(String[] args) throws Throwable {
 122         try {realMain(args);} catch (Throwable t) {unexpected(t);}
 123         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 124         if (failed > 0) throw new AssertionError("Some tests failed");}
 125     private static abstract class Fun {abstract void f() throws Throwable;}
 126     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
 127         for (Fun f : fs)
 128             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
 129             catch (Throwable t) {
 130                 if (k.isAssignableFrom(t.getClass())) pass();
 131                 else unexpected(t);}}
 132 }


 105 
 106         try { new ScheduledThreadPoolExecutor(0, fac, reh).shutdownNow(); pass(); }
 107         catch (Throwable t) { unexpected(t); }
 108 
 109     }
 110 
 111     //--------------------- Infrastructure ---------------------------
 112     static volatile int passed = 0, failed = 0;
 113     static void pass() {passed++;}
 114     static void fail() {failed++; Thread.dumpStack();}
 115     static void fail(String msg) {System.out.println(msg); fail();}
 116     static void unexpected(Throwable t) {failed++; t.printStackTrace();}
 117     static void check(boolean cond) {if (cond) pass(); else fail();}
 118     static void equal(Object x, Object y) {
 119         if (x == null ? y == null : x.equals(y)) pass();
 120         else fail(x + " not equal to " + y);}
 121     public static void main(String[] args) throws Throwable {
 122         try {realMain(args);} catch (Throwable t) {unexpected(t);}
 123         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
 124         if (failed > 0) throw new AssertionError("Some tests failed");}
 125     private abstract static class Fun {abstract void f() throws Throwable;}
 126     static void THROWS(Class<? extends Throwable> k, Fun... fs) {
 127         for (Fun f : fs)
 128             try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
 129             catch (Throwable t) {
 130                 if (k.isAssignableFrom(t.getClass())) pass();
 131                 else unexpected(t);}}
 132 }