Search in sources :

Example 1 with SinglePartNotInitializedException

use of com.linkedin.multipart.exceptions.SinglePartNotInitializedException in project rest.li by linkedin.

the class TestMIMEReaderStateTransitions method testSinglePartMIMEReaderRequestData.

@Test
public void testSinglePartMIMEReaderRequestData() {
    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());
    singlePartMIMEReader.setState(MultiPartMIMEReader.SingleReaderState.CREATED);
    try {
        singlePartMIMEReader.requestPartData();
        Assert.fail();
    } catch (SinglePartNotInitializedException singlePartNotInitializedException) {
    }
}
Also used : EntityStream(com.linkedin.r2.message.stream.entitystream.EntityStream) SinglePartNotInitializedException(com.linkedin.multipart.exceptions.SinglePartNotInitializedException) StreamRequest(com.linkedin.r2.message.stream.StreamRequest) Test(org.testng.annotations.Test)

Aggregations

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