use of com.linkedin.multipart.exceptions.SinglePartBindException in project rest.li by linkedin.
the class TestMIMEReaderStateTransitions method testRegisterSinglePartMIMEReaderCallbackTwice.
// /////////////////////////////////////////////////////////////////////////////////////
// SinglePartMIMEReader exceptions:
@Test
public void testRegisterSinglePartMIMEReaderCallbackTwice() {
final EntityStream entityStream = mock(EntityStream.class);
final StreamRequest streamRequest = mock(StreamRequest.class);
when(streamRequest.getEntityStream()).thenReturn(entityStream);
when(streamRequest.getHeader(MultiPartMIMEUtils.CONTENT_TYPE_HEADER)).thenReturn("multipart/mixed; boundary=\"--123\"");
MultiPartMIMEReader reader = MultiPartMIMEReader.createAndAcquireStream(streamRequest);
final MultiPartMIMEReader.SinglePartMIMEReader singlePartMIMEReader = reader.new SinglePartMIMEReader(Collections.<String, String>emptyMap());
// This is a undesired single part state
singlePartMIMEReader.setState(MultiPartMIMEReader.SingleReaderState.REQUESTED_DATA);
try {
singlePartMIMEReader.registerReaderCallback(EMPTY_SINGLE_PART_MIME_READER_CALLBACK);
Assert.fail();
} catch (SinglePartBindException singlePartBindException) {
}
}
Aggregations