use of org.mule.runtime.api.streaming.bytes.CursorStream in project mule by mulesoft.
the class ReconnectionWithStreamingTestCase method createMockCursor.
private CursorStream createMockCursor() throws IOException {
CursorStream cursorStream = mock(CursorStream.class);
when(cursorStream.getPosition()).thenReturn(ORIGINAL_POSITION);
when(cursorStream.read(any(byte[].class), anyInt(), anyInt())).thenThrow(new RuntimeException(new ConnectionException("kaboom"))).thenAnswer(i -> {
byte[] buffer = (byte[]) i.getArguments()[0];
buffer[0] = 'h';
buffer[1] = 'n';
return 2;
}).thenReturn(-1);
return cursorStream;
}
use of org.mule.runtime.api.streaming.bytes.CursorStream in project mule by mulesoft.
the class DrStrangeOperations method seekStream.
@MediaType(TEXT_PLAIN)
public String seekStream(@Config DrStrange dr, @Optional(defaultValue = PAYLOAD) InputStream stream, int position) throws IOException {
checkArgument(stream instanceof CursorStream, "Stream was not cursored");
CursorStream cursor = (CursorStream) stream;
cursor.seek(position);
return readStream(dr, cursor);
}
Aggregations