Search in sources :

Example 16 with StreamSource

use of javax.xml.transform.stream.StreamSource in project camel by apache.

the class XmlConverterTest method testToStreamSourceByByteArray.

public void testToStreamSourceByByteArray() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    XmlConverter conv = new XmlConverter();
    byte[] bytes = context.getTypeConverter().convertTo(byte[].class, "<foo>bar</foo>");
    StreamSource out = conv.toStreamSource(bytes, exchange);
    assertNotNull(out);
    assertEquals("<foo>bar</foo>", conv.toString(out, null));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) StreamSource(javax.xml.transform.stream.StreamSource)

Example 17 with StreamSource

use of javax.xml.transform.stream.StreamSource in project camel by apache.

the class XmlConverterTest method testToStreamSourceBySaxSource.

public void testToStreamSourceBySaxSource() throws Exception {
    XmlConverter conv = new XmlConverter();
    SAXSource source = conv.toSAXSource("<foo>bar</foo>", null);
    StreamSource out = conv.toStreamSource(source, null);
    assertNotSame(source, out);
    assertEquals("<foo>bar</foo>", conv.toString(out, null));
}
Also used : SAXSource(javax.xml.transform.sax.SAXSource) StreamSource(javax.xml.transform.stream.StreamSource)

Example 18 with StreamSource

use of javax.xml.transform.stream.StreamSource 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 StreamSource

use of javax.xml.transform.stream.StreamSource 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 StreamSource

use of javax.xml.transform.stream.StreamSource in project camel by apache.

the class JmsXMLRouteTest method testLondonWithFileStreamAsObject.

@Test
public void testLondonWithFileStreamAsObject() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:london");
    mock.expectedMessageCount(1);
    mock.message(0).body(String.class).contains("James");
    Source source = new StreamSource(new FileInputStream(TEST_LONDON));
    assertNotNull(source);
    template.sendBody("direct:object", source);
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StreamSource(javax.xml.transform.stream.StreamSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) StringSource(org.apache.camel.StringSource) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

StreamSource (javax.xml.transform.stream.StreamSource)338 Source (javax.xml.transform.Source)115 StringReader (java.io.StringReader)101 StreamResult (javax.xml.transform.stream.StreamResult)85 Transformer (javax.xml.transform.Transformer)74 Test (org.junit.Test)73 InputStream (java.io.InputStream)68 TransformerFactory (javax.xml.transform.TransformerFactory)58 ByteArrayInputStream (java.io.ByteArrayInputStream)56 IOException (java.io.IOException)52 DOMSource (javax.xml.transform.dom.DOMSource)49 TransformerException (javax.xml.transform.TransformerException)48 StringWriter (java.io.StringWriter)45 SchemaFactory (javax.xml.validation.SchemaFactory)44 InputSource (org.xml.sax.InputSource)44 Schema (javax.xml.validation.Schema)43 SAXException (org.xml.sax.SAXException)42 SAXSource (javax.xml.transform.sax.SAXSource)33 Validator (javax.xml.validation.Validator)31 File (java.io.File)27