use of java.io.ByteArrayInputStream in project camel by apache.
the class GZIPHelper method compressGzip.
public static InputStream compressGzip(String contentEncoding, InputStream in) throws IOException {
if (isGzip(contentEncoding)) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(os);
try {
IOHelper.copy(in, gzip);
gzip.finish();
return new ByteArrayInputStream(os.toByteArray());
} finally {
IOHelper.close(gzip, "gzip");
IOHelper.close(os, "byte array output stream");
}
} else {
return in;
}
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class BeanWithInputStreamBodyTest method testBeanWithInputStreamBodyMethod.
public void testBeanWithInputStreamBodyMethod() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").bean(MyCoolBean.class, "doSomething").to("mock:result");
}
});
context.start();
getMockEndpoint("mock:result").expectedBodiesReceived("There is 11 bytes");
InputStream bais = new ByteArrayInputStream("Hello World".getBytes());
template.sendBody("direct:start", bais);
assertMockEndpointsSatisfied();
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class BeanParameterBindingStreamCachingTest method testBean.
public void testBean() throws Exception {
getMockEndpoint("mock:result").expectedBodiesReceived("abcABC");
template.sendBody("direct:start", new ByteArrayInputStream("aBc".getBytes()));
assertMockEndpointsSatisfied();
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class MockEndpointTest method testSetMultipleExpectedHeaders4.
public void testSetMultipleExpectedHeaders4() throws Exception {
// to test the header value with Stream which can only be consumed once
InputStream is = new ByteArrayInputStream("Test".getBytes());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedHeaderReceived("foo", 123);
mock.expectedHeaderReceived("bar", "Test");
Map<String, Object> map = new HashMap<String, Object>();
map.put("foo", 123);
map.put("bar", is);
template.sendBodyAndHeaders("direct:a", "Hello World", map);
mock.assertIsSatisfied();
}
use of java.io.ByteArrayInputStream in project camel by apache.
the class LogInputStreamTest method testB.
public void testB() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:b");
mock.expectedMessageCount(1);
mock.message(0).body().convertToString().isEqualTo("Hello World");
InputStream is = new ByteArrayInputStream("Hello World".getBytes());
template.sendBody("direct:b", is);
assertMockEndpointsSatisfied();
}
Aggregations