CanNotOpenStreamException extends RuntimeException { private static String format(final String url) { return String.format(MESSAGE_WITH_URL, url); } CanNotOpenStreamException();  CanNotOpenStreamException(final String url);  CanNotOpenStreamException(final String url, final Throwable cause);  CanNotOpenStreamException(final Throwable cause);   }
@Test public void construct_url_cause_successful() { final String url = "http: final IOException tunneled = new IOException(); final CanNotOpenStreamException e = new CanNotOpenStreamException(url, tunneled); final String expected = String.format(CanNotOpenStreamException.MESSAGE_WITH_URL, url); assertThat(e.getMessage()).isEqualTo(expected); assertThat(e.getCause()).isSameAs(tunneled); }
@Test public void construct_url_successful() { final String url = "http: final CanNotOpenStreamException e = new CanNotOpenStreamException(url); final String expected = String.format(CanNotOpenStreamException.MESSAGE_WITH_URL, url); assertThat(e.getMessage()).isEqualTo(expected); }