@Test public void return_attachment_with_open_data_stream() throws Exception { ResponseOnFileStub rsp = ResponseOnFileStub.newInstance(200, "attachment.txt", "text", 12); when(httpClient.get("/test_db/some_doc_id/some_attachment")).thenReturn(rsp); AttachmentInputStream a = dbCon.getAttachment("some_doc_id", "some_attachment"); assertNotNull(a); assertFalse(rsp.isConnectionReleased()); assertEquals("detta är ett påhäng med ett ö i", IOUtils.toString(a, "UTF-8")); assertEquals(rsp.getContentType(), a.getContentType()); assertEquals(rsp.getContentLength(), a.getContentLength()); }