JExceptionReporter { public static void showDialog(Throwable exception) { showDialog(exception, null); } private  JExceptionReporter(); static void showDialog(Throwable exception); static void showDialog(final Throwable exception, final String message);  }
@Test public void showException() throws Exception { final String MSG = "Foo is not Bar"; showDialog(new IllegalArgumentException(MSG)); ((DialogFixture) windowFixture).requireModal(); assertEquals("IllegalArgumentException", windowFixture.component().getTitle()); JLabelFixture label = windowFixture.label(); label.requireText(Pattern.compile(".*" + MSG + ".*")); }
@Test public void showExceptionWithUserMessage() throws Exception { final String EXCEPTION_MSG = "Foo is not Bar"; final String USER_MSG = "You should see this message"; showDialog(new IllegalArgumentException(EXCEPTION_MSG), USER_MSG); assertEquals("IllegalArgumentException", windowFixture.component().getTitle()); JLabelFixture label = windowFixture.label(); label.requireText(Pattern.compile(".*" + USER_MSG + ".*")); }
@Test public void emptyUserMessage() throws Exception { final String EXCEPTION_MSG = "You should see this message"; final String USER_MSG = ""; showDialog(new IllegalArgumentException(EXCEPTION_MSG), USER_MSG); assertEquals("IllegalArgumentException", windowFixture.component().getTitle()); JLabelFixture label = windowFixture.label(); label.requireText(Pattern.compile(".*" + EXCEPTION_MSG + ".*")); }
@Test(expected=IllegalArgumentException.class) public void nullExceptionArg() throws Exception { JExceptionReporter.showDialog(null); }
@Test(expected=IllegalArgumentException.class) public void nullExceptionArg2() throws Exception { JExceptionReporter.showDialog(null, "User message"); }