/** If the exception is wrapped, unwrap it. */ public static Throwable getActualException(Throwable e) { if (e instanceof ExecutionException) e = e.getCause(); if (e instanceof MBeanException || e instanceof RuntimeMBeanException || e instanceof RuntimeOperationsException || e instanceof ReflectionException) { Throwable t = e.getCause(); if (t != null) return t; } return e; }
public static void main(String[] args) { int errorCount = 0; for (int i = 0; i < NTESTS; i++) { try { System.out.println("Test " + i + ":"); test(i); } catch (Throwable e) { errorCount++; boolean first = true; do { System.err.println(first ? "Exception:" : "Caused by:"); first = false; e.printStackTrace(); Throwable nexte; nexte = e.getCause(); if (nexte == null) { // old JMX if (e instanceof MBeanException) nexte = ((MBeanException) e).getTargetException(); } e = nexte; } while (e != null); } } if (errorCount == 0) { System.out.println("All ModelMBean tests successfuly passed"); System.out.println("Bye! Bye!"); // JTReg doesn't like System.exit(0); return; } else { System.err.println("ERROR: " + errorCount + " tests failed"); System.exit(errorCount); } }