use of java.io.ByteArrayInputStream in project camel by apache.
the class ConvertBodyTest method testConvertToStringCharset.
public void testConvertToStringCharset() throws Exception {
String body = "Hello World";
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived(body);
template.sendBody("direct:charset3", new ByteArrayInputStream(body.getBytes("utf-16")));
assertMockEndpointsSatisfied();
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class ConvertBodyTest method testConvertToStringCharsetFail.
public void testConvertToStringCharsetFail() throws Exception {
// does not work on AIX
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
boolean aix = osName.indexOf("aix") > -1;
if (aix) {
return;
}
String body = "Hellö Wörld";
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived(body);
template.sendBody("direct:charset3", new ByteArrayInputStream(body.getBytes("utf-8")));
// should NOT be okay as we expected utf-8 but got it in utf-16
result.assertIsNotSatisfied();
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class DefaultTraceEventMessageTest method testDefaultTraceEventMessageBody.
public void testDefaultTraceEventMessageBody() throws Exception {
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(new File("target/test"));
DefaultTraceEventMessage em = new DefaultTraceEventMessage(new Date(), null, exchange);
assertEquals("Get a wrong body string", "[Body is file based: target" + File.separator + "test]", em.getBody());
exchange.getIn().setBody(new ByteArrayInputStream("target/test".getBytes()));
em = new DefaultTraceEventMessage(new Date(), null, exchange);
assertEquals("Get a wrong body string", "[Body is instance of java.io.InputStream]", em.getBody());
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class NoStreamCachingTest method testNoStreamCache.
public void testNoStreamCache() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:a").noStreamCaching().to("mock:a");
}
});
context.start();
a.expectedMessageCount(1);
InputStream message = new ByteArrayInputStream(MESSAGE.getBytes());
template.sendBody("direct:a", message);
assertMockEndpointsSatisfied();
assertTrue(a.assertExchangeReceived(0).getIn().getBody() instanceof ByteArrayInputStream);
assertEquals(a.assertExchangeReceived(0).getIn().getBody(String.class), MESSAGE);
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class StreamCachingInterceptorTest method testConvertInputStreamWithRouteBuilderStreamCaching.
public void testConvertInputStreamWithRouteBuilderStreamCaching() throws Exception {
a.expectedMessageCount(1);
InputStream message = new ByteArrayInputStream(MESSAGE.getBytes());
template.sendBody("direct:a", message);
assertMockEndpointsSatisfied();
assertTrue(a.assertExchangeReceived(0).getIn().getBody() instanceof StreamCache);
assertEquals(a.assertExchangeReceived(0).getIn().getBody(String.class), MESSAGE);
}
Aggregations