Search in sources :

Example 16 with StringReader

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));
}
Also used : BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader)

Example 17 with StringReader

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);
}
Also used : BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader)

Example 18 with StringReader

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();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 19 with StringReader

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();
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 20 with StringReader

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());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) StringReader(java.io.StringReader) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

StringReader (java.io.StringReader)3695 Test (org.junit.Test)837 IOException (java.io.IOException)488 Reader (java.io.Reader)402 InputSource (org.xml.sax.InputSource)369 TokenStream (org.apache.lucene.analysis.TokenStream)298 BufferedReader (java.io.BufferedReader)277 Tokenizer (org.apache.lucene.analysis.Tokenizer)238 StringWriter (java.io.StringWriter)226 ArrayList (java.util.ArrayList)225 JSONReader (com.alibaba.fastjson.JSONReader)195 Document (org.w3c.dom.Document)181 DocumentBuilder (javax.xml.parsers.DocumentBuilder)165 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)141 Map (java.util.Map)139 ParserResult (org.jabref.logic.importer.ParserResult)130 MockTokenizer (org.apache.lucene.analysis.MockTokenizer)120 HashMap (java.util.HashMap)117 Element (org.w3c.dom.Element)108 StreamSource (javax.xml.transform.stream.StreamSource)106