### Question:
EJBException extends RuntimeException { public void printStackTrace(PrintStream ps) { if (causeException == null || super.getCause() == null || causeException == super.getCause()) { super.printStackTrace(ps); } else synchronized (ps) { ps.println(this); causeException.printStackTrace(ps); super.printStackTrace(ps); } } EJBException();  EJBException(Exception causeException);  EJBException(String message);  EJBException(String message, Exception causeException); Exception getCausedByException(); @Override Throwable getCause(); String getMessage(); void printStackTrace(PrintStream ps); void printStackTrace(PrintWriter pw); void printStackTrace();  }### Answer:
@Test public void testPrintStackTrace() throws Exception { for (String s : printStackTraces(exceptionDefaultConstructor)) { assertStackTrace(s, "javax.ejb.EJBException", "\tat"); } for (String s : printStackTraces(exceptionWithNullMessage)) { assertStackTrace(s, "javax.ejb.EJBException", "\tat"); } for (String s : printStackTraces(exceptionWithMessage)) { assertStackTrace(s, "javax.ejb.EJBException", "\tat"); } for (String s : printStackTraces(exceptionWithCausedBy)) { assertStackTrace(s, "javax.ejb.EJBException: msg; nested exception", "\tat", "Caused by", "\tat", "\t..."); } for (String s : printStackTraces(exceptionWithInitCause)) { assertStackTrace(s, "javax.ejb.EJBException", "\tat", "Caused by", "\tat", "\t..."); } for (String s : printStackTraces(exceptionWithCausedByAndInitCause)) { assertStackTrace(s, "javax.ejb.EJBException: msg; nested exception", "\tat", "Caused by", "\tat", "\t..."); } for (String s : printStackTraces(new EJBException(new Exception("cause1")).initCause(new Exception("cause2")))) { assertStackTrace(s, "javax.ejb.EJBException: nested exception is: java.lang.Exception: cause1", "java.lang.Exception: cause1", "\tat", "javax.ejb.EJBException: nested exception is: java.lang.Exception: cause1", "\tat", "Caused by: java.lang.Exception: cause2", "\t..."); } }