Search in sources :

Example 16 with StringSource

use of org.apache.camel.StringSource in project camel by apache.

the class LogDebugBodyStreamsTest method testLogBodyStreamStringSourceEnabled.

public void testLogBodyStreamStringSourceEnabled() throws Exception {
    context.getGlobalOptions().put(Exchange.LOG_DEBUG_BODY_STREAMS, "true");
    StringSource body = new StringSource("<?xml version=\"1.0\"?><person><name>Claus</name></person>");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", body);
    assertMockEndpointsSatisfied();
    // should be logged anyway
    TraceExchangeFormatter myFormatter = context.getRegistry().lookupByNameAndType("logFormatter", TraceExchangeFormatter.class);
    String msg = myFormatter.getMessage();
    assertTrue(msg.endsWith("Body: <?xml version=\"1.0\"?><person><name>Claus</name></person>]"));
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StringSource(org.apache.camel.StringSource)

Example 17 with StringSource

use of org.apache.camel.StringSource in project camel by apache.

the class MultiCastParallelAndStreamCachingTest method testSourceCache.

public void testSourceCache() throws Exception {
    String input = "<A>a</A>";
    MockEndpoint mock = getMockEndpoint("mock:resulta");
    mock.expectedBodiesReceived(input);
    mock = getMockEndpoint("mock:resultb");
    mock.expectedBodiesReceived(input);
    StringSource ss = new StringSource(input);
    SAXSource saxSource = new SAXSource(SAXSource.sourceToInputSource(ss));
    template.sendBody("direct:start", saxSource);
    assertMockEndpointsSatisfied();
}
Also used : SAXSource(javax.xml.transform.sax.SAXSource) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StringSource(org.apache.camel.StringSource)

Example 18 with StringSource

use of org.apache.camel.StringSource in project camel by apache.

the class ValidatingProcessorTest method testStringSourceMessage.

public void testStringSourceMessage() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:valid");
    mock.expectedMessageCount(1);
    String xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + "<user xmlns=\"http://foo.com/bar\">" + "  <id>1</id>" + "  <username>davsclaus</username>" + "</user>";
    template.sendBody("direct:start", new StringSource(xml));
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StringSource(org.apache.camel.StringSource)

Example 19 with StringSource

use of org.apache.camel.StringSource in project camel by apache.

the class StreamSourceContentBasedRouterTest method testSendStringSource.

public void testSendStringSource() throws Exception {
    x.expectedMessageCount(1);
    y.expectedMessageCount(1);
    sendBody("direct:start", new StringSource("<message>xx</message>"));
    sendBody("direct:start", new StringSource("<message>yy</message>"));
    assertMockEndpointsSatisfied();
}
Also used : StringSource(org.apache.camel.StringSource)

Aggregations

StringSource (org.apache.camel.StringSource)19 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)8 Source (javax.xml.transform.Source)6 Test (org.junit.Test)5 StreamSource (javax.xml.transform.stream.StreamSource)4 File (java.io.File)3 BytesSource (org.apache.camel.BytesSource)3 InputStream (java.io.InputStream)2 StringWriter (java.io.StringWriter)2 Converter (org.apache.camel.Converter)2 StreamCache (org.apache.camel.StreamCache)2 WrappedFile (org.apache.camel.WrappedFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 Reader (java.io.Reader)1