use of com.linkedin.multipart.exceptions.MultiPartReaderFinishedException in project rest.li by linkedin.
the class TestMIMEReaderClientCallbackExceptions method testMultiPartMIMEReaderCallbackExceptionOnNewPart.
@Test(dataProvider = "allTypesOfBodiesDataSource")
public void testMultiPartMIMEReaderCallbackExceptionOnNewPart(final int chunkSize, final List<MimeBodyPart> bodyPartList) throws Exception {
MimeMultipart multiPartMimeBody = new MimeMultipart();
//Add your body parts
for (final MimeBodyPart bodyPart : bodyPartList) {
multiPartMimeBody.addBodyPart(bodyPart);
}
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
multiPartMimeBody.writeTo(byteArrayOutputStream);
final ByteString requestPayload = ByteString.copy(byteArrayOutputStream.toByteArray());
final CountDownLatch countDownLatch = executeRequestPartialReadWithException(requestPayload, chunkSize, multiPartMimeBody.getContentType(), MultiPartMIMEThrowOnFlag.THROW_ON_NEW_PART, SinglePartMIMEThrowOnFlag.NO_THROW);
countDownLatch.await(_testTimeout, TimeUnit.MILLISECONDS);
Assert.assertTrue(_currentMultiPartMIMEReaderCallback.getStreamError() instanceof IllegalMonitorStateException);
Assert.assertEquals(_currentMultiPartMIMEReaderCallback.getSinglePartMIMEReaderCallbacks().size(), 0);
try {
_currentMultiPartMIMEReaderCallback.getReader().drainAllParts();
Assert.fail();
} catch (MultiPartReaderFinishedException multiPartReaderFinishedException) {
//pass
}
}
Aggregations