use of java.io.StringReader in project camel by apache.
the class IOConverterTest method testStringByBufferedReader.
public void testStringByBufferedReader() throws Exception {
BufferedReader br = IOHelper.buffered(new StringReader("Hello World"));
assertEquals("Hello World", IOConverter.toString(br));
}
use of java.io.StringReader in project camel by apache.
the class IOConverterTest method testToStringBufferReader.
public void testToStringBufferReader() throws Exception {
BufferedReader br = IOHelper.buffered(new StringReader("Hello World"));
String s = IOConverter.toString(br);
assertNotNull(s);
assertEquals("Hello World", s);
}
use of java.io.StringReader in project camel by apache.
the class StreamCachingOnlyRouteTest method testStreamCachingPerRoute.
public void testStreamCachingPerRoute() throws Exception {
MockEndpoint c = getMockEndpoint("mock:c");
c.expectedMessageCount(1);
new StreamSource(new StringReader("A"));
template.sendBody("direct:c", new StreamSource(new StringReader("C")));
assertMockEndpointsSatisfied();
}
use of java.io.StringReader in project camel by apache.
the class StreamSourceContentBasedRouterTest method testSendStreamSource.
public void testSendStreamSource() throws Exception {
x.expectedMessageCount(1);
y.expectedMessageCount(1);
sendBody("direct:start", new StreamSource(new StringReader("<message>xx</message>")));
sendBody("direct:start", new StreamSource(new StringReader("<message>yy</message>")));
assertMockEndpointsSatisfied();
}
use of java.io.StringReader in project camel by apache.
the class MessageHelperTest method testMessageDump.
public void testMessageDump() throws Exception {
JAXBContext jaxb = JAXBContext.newInstance(MessageDump.class);
Unmarshaller unmarshaller = jaxb.createUnmarshaller();
CamelContext context = new DefaultCamelContext();
context.start();
message = new DefaultExchange(context).getIn();
// xml message body
message.setBody("Hello World");
message.setHeader("foo", 123);
String out = MessageHelper.dumpAsXml(message, true);
MessageDump dump = (MessageDump) unmarshaller.unmarshal(new StringReader(out));
assertNotNull(dump);
assertEquals("java.lang.String", dump.getBody().getType());
assertEquals("Hello World", dump.getBody().getValue());
assertEquals(1, dump.getHeaders().size());
assertEquals("foo", dump.getHeaders().get(0).getKey());
assertEquals("java.lang.Integer", dump.getHeaders().get(0).getType());
assertEquals("123", dump.getHeaders().get(0).getValue());
}
Aggregations