CannotCloseException extends RuntimeException { private static String format(final String url) { return String.format(MESSAGE_WITH_INFO, url); } CannotCloseException();  CannotCloseException(final String info);  CannotCloseException(final String info, final Throwable cause);  CannotCloseException(final Throwable cause);   }
@Test public void construct_url_cause_successful() { final String info = "a message which describes the cause"; final IOException tunneled = new IOException(); final CannotCloseException e = new CannotCloseException(info, tunneled); final String expected = String.format(CannotCloseException.MESSAGE_WITH_INFO, info); assertThat(e.getMessage()).isEqualTo(expected); assertThat(e.getCause()).isSameAs(tunneled); }
@Test public void construct_url_successful() { final String info = "a message which describes the cause"; final CannotCloseException e = new CannotCloseException(info); final String expected = String.format(CannotCloseException.MESSAGE_WITH_INFO, info); assertThat(e.getMessage()).isEqualTo(expected); }