mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
return error stream, if input stream could not be returned
This commit is contained in:
@@ -92,6 +92,28 @@ public class DefaultAdvancedHttpResponseTest
|
||||
assertEquals("test", content.asCharSource(Charsets.UTF_8).read());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Test
|
||||
public void testContentAsByteSourceWithFailedRequest() throws IOException
|
||||
{
|
||||
ByteArrayInputStream bais =
|
||||
new ByteArrayInputStream("test".getBytes(Charsets.UTF_8));
|
||||
|
||||
when(connection.getInputStream()).thenThrow(IOException.class);
|
||||
when(connection.getErrorStream()).thenReturn(bais);
|
||||
|
||||
AdvancedHttpResponse response = new DefaultAdvancedHttpResponse(connection,
|
||||
404, "NOT FOUND");
|
||||
ByteSource content = response.contentAsByteSource();
|
||||
|
||||
assertEquals("test", content.asCharSource(Charsets.UTF_8).read());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user