use of jakarta.mail.BodyPart in project resteasy by resteasy.
the class HeaderFlushedOutputStreamTest method testGet.
/**
* @tpTestDetails Test get method
* @tpSince RESTEasy 3.0.16
*/
@Test
public void testGet() throws Exception {
Response response = client.target(TEST_URI).request().get();
Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
BufferedInputStream in = new BufferedInputStream(response.readEntity(InputStream.class));
String contentType = response.getHeaderString("content-type");
ByteArrayDataSource ds = new ByteArrayDataSource(in, contentType);
MimeMultipart mimeMultipart = new MimeMultipart(ds);
Assert.assertEquals("Wrong count of parts of response", mimeMultipart.getCount(), 1);
BodyPart part = mimeMultipart.getBodyPart(0);
InputStream is = part.getInputStream();
Assert.assertEquals("Wrong count of parts of response", 3, part.getSize());
char[] output = new char[3];
output[0] = (char) is.read();
output[1] = (char) is.read();
output[2] = (char) is.read();
String str = new String(output);
Assert.assertEquals("Wrong content of first part of response", "bla", str);
}
Aggregations