@Test
public void getContentReturnsErrorMessageWhenHttpURLConnectionReturnsErrorStream() throws Exception {

    String expected = "Hello, World! This is error message.";
    byte[] actual = expected.getBytes();
    HttpURLConnection connection = mock(HttpURLConnection.class);
    when(connection.getContentLength()).thenReturn(actual.length);
    when(connection.getErrorStream()).thenReturn(new ByteArrayInputStream(actual));
    HttpResponse httpResponse = new HttpResponse(connection);
    assertThat(httpResponse.getContent(), is(expected));
}