use of org.mule.runtime.core.api.streaming.bytes.InMemoryCursorStreamProvider in project mule by mulesoft.
the class CursorStreamProviderTestCase method dataLengthMatchesMaxBufferSizeExactly.
@Test
public void dataLengthMatchesMaxBufferSizeExactly() throws Exception {
data = randomAlphabetic(maxBufferSize);
final ByteArrayInputStream dataStream = new ByteArrayInputStream(data.getBytes());
InMemoryCursorStreamConfig config = new InMemoryCursorStreamConfig(new DataSize(maxBufferSize, BYTE), new DataSize(0, BYTE), new DataSize(maxBufferSize, BYTE));
streamProvider = new InMemoryCursorStreamProvider(dataStream, config, bufferManager);
withCursor(cursor -> assertThat(IOUtils.toString(cursor), equalTo(data)));
}
use of org.mule.runtime.core.api.streaming.bytes.InMemoryCursorStreamProvider in project mule by mulesoft.
the class InputStreamToByteArrayTestCase method transformCursorStreamProvider.
@Test
public void transformCursorStreamProvider() throws Exception {
InputStream inputStream = new ByteArrayInputStream(DONKEY.getBytes());
CursorStreamProvider provider = new InMemoryCursorStreamProvider(inputStream, InMemoryCursorStreamConfig.getDefault(), new SimpleByteBufferManager());
assertThat(transformer.transform(provider), equalTo(DONKEY.getBytes()));
}
use of org.mule.runtime.core.api.streaming.bytes.InMemoryCursorStreamProvider in project mule by mulesoft.
the class InMemoryCursorStreamProviderFactory method resolve.
/**
* {@inheritDoc}
*
* @return a new {@link InMemoryCursorStreamProvider} wrapped in an {@link Either}
*/
@Override
protected Object resolve(InputStream inputStream, CoreEvent event) {
InMemoryCursorStreamProvider inMemoryCursorStreamProvider = new InMemoryCursorStreamProvider(inputStream, config, getBufferManager());
inMemoryCursorStreamProvider.setAnnotations(getAnnotations());
return inMemoryCursorStreamProvider;
}
use of org.mule.runtime.core.api.streaming.bytes.InMemoryCursorStreamProvider in project mule by mulesoft.
the class FunctionExecutionTestCase method xpathWithDefaultNode.
@Test
public void xpathWithDefaultNode() throws Exception {
InputStream stream = getDocumentStream();
InMemoryCursorStreamProvider streamProvider = new InMemoryCursorStreamProvider(stream, InMemoryCursorStreamConfig.getDefault(), new SimpleByteBufferManager());
Object value = flowRunner("xpathWithDefaultNode").withVariable("xmlPayload", streamProvider).run().getMessage().getPayload().getValue();
assertThat(value, is("xpathWithDefaultNode"));
}
use of org.mule.runtime.core.api.streaming.bytes.InMemoryCursorStreamProvider in project mule by mulesoft.
the class PetStoreSerializableParameterTestCase method cursorStreamProviderParameter.
@Test
public void cursorStreamProviderParameter() throws Exception {
InputStream inputStream = new ByteArrayInputStream(DONKEY.getBytes());
CursorStreamProvider provider = new InMemoryCursorStreamProvider(inputStream, InMemoryCursorStreamConfig.getDefault(), new SimpleByteBufferManager());
Message message = flowRunner("dynamicSerializableParameter").withVariable("animal", provider).run().getMessage();
assertThat(message.getPayload().getValue(), is(DONKEY));
}
Aggregations