Search in sources :

Example 1 with SinglePartBindException

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) {
    }
}
Also used : EntityStream(com.linkedin.r2.message.stream.entitystream.EntityStream) SinglePartBindException(com.linkedin.multipart.exceptions.SinglePartBindException) StreamRequest(com.linkedin.r2.message.stream.StreamRequest) Test(org.testng.annotations.Test)

Aggregations

SinglePartBindException (com.linkedin.multipart.exceptions.SinglePartBindException)1 StreamRequest (com.linkedin.r2.message.stream.StreamRequest)1 EntityStream (com.linkedin.r2.message.stream.entitystream.EntityStream)1 Test (org.testng.annotations.Test)1