ExceptionWrapper extends RuntimeException { @Override public String getMessage() { return message; } ExceptionWrapper(Throwable t); @Override String getMessage();  }
@Test public final void requireNoMessageIsOK() { final Throwable t = new Throwable(); final ExceptionWrapper e = new ExceptionWrapper(t); final String expected = "Throwable() at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:19)"; assertThat(e.getMessage(), equalTo(expected)); }
@Test public final void requireAllWrappedLevelsShowUp() { final Throwable t0 = new Throwable("t0"); final Throwable t1 = new Throwable("t1", t0); final Throwable t2 = new Throwable("t2", t1); final ExceptionWrapper e = new ExceptionWrapper(t2); final String expected = "Throwable(\"t2\") at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:30):" + " Throwable(\"t1\") at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:29):" + " Throwable(\"t0\") at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:28)"; assertThat(e.getMessage(), equalTo(expected)); }
@Test public final void requireMixOfMessageAndNoMessageWorks() { final Throwable t0 = new Throwable("t0"); final Throwable t1 = new Throwable(t0); final Throwable t2 = new Throwable("t2", t1); final ExceptionWrapper e = new ExceptionWrapper(t2); final String expected = "Throwable(\"t2\") at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:43):" + " Throwable(\"java.lang.Throwable: t0\") at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:42):" + " Throwable(\"t0\") at com.yahoo.jdisc.http.server.jetty.ExceptionWrapperTest(ExceptionWrapperTest.java:41)"; assertThat(e.getMessage(), equalTo(expected)); }