ExceptionUtil { public static String getStackTrace(Throwable throwable) { StringWriter buffer = new StringWriter(); PrintWriter out = new PrintWriter(buffer); throwable.printStackTrace(out); out.flush(); return buffer.toString(); }  static boolean causedBy(Throwable throwable, Class<? extends Throwable> causeType); static Throwable getRootCause(Throwable throwable); static List<Throwable> getCauses(Throwable throwable); static List<Throwable> getCauses(Throwable throwable, boolean reversed); static RuntimeException toRuntimeException(Exception exception); static RuntimeException toRuntimeException(Exception exception,
            Class<? extends RuntimeException> runtimeExceptionClass); static void throwExceptionOrError(Throwable throwable); static void throwRuntimeExceptionOrError(Throwable throwable); static String getStackTrace(Throwable throwable);  }
@Test public void getStackTrace() { Throwable e = new Throwable(); String stacktrace = ExceptionUtil.getStackTrace(e); assertTrue(stacktrace.contains(Throwable.class.getName())); assertTrue(stacktrace.contains(ExceptionUtilTest.class.getName() + ".getStackTrace")); }