Package org.apache.camel.converter.jaxp

Examples of org.apache.camel.converter.jaxp.StringSource


    public SourceCache() {
    }

    public SourceCache(String data) {
        new StringSource(data);
    }
View Full Code Here


   
    public void testNoConversionForOtherXmlSourceTypes() throws Exception {
        a.expectedMessageCount(3);

        send(converter.toDOMSource(MESSAGE));
        send(new StringSource(MESSAGE));
        send(new BytesSource(MESSAGE.getBytes()));

        assertMockEndpointsSatisfied();
        for (Exchange exchange : a.getExchanges()) {
            assertFalse(exchange.getIn().getHeader(BODY_TYPE, Class.class).toString() + " shouldn't have been converted to StreamCache",
View Full Code Here

    public Object evaluateAsStringSource(Exchange exchange) throws Exception {
        initialize(exchange);

        String text = evaluateAsString(exchange);
        return new StringSource(text);
    }
View Full Code Here

public class LogDebugBodyStreamsTest extends ContextTestSupport {

    public void testLogBodyStreamStringSourceDisabled() throws Exception {
        context.getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, "false");

        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);
View Full Code Here

    }

    public void testLogBodyStreamStringSourceDisabledByDefault() throws Exception {
        context.getProperties().remove(Exchange.LOG_DEBUG_BODY_STREAMS);

        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);
View Full Code Here

    }

    public void testLogBodyStreamStringSourceEnabled() throws Exception {
        context.getProperties().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);
View Full Code Here

        done.expectedBodiesReceived(MESSAGE);
       
        ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
        InOnly exchange = client.createInOnlyExchange();
        exchange.setService(new QName("urn:test", "in-only"));
        exchange.getInMessage().setContent(new StringSource(MESSAGE));
        client.send(exchange);
       
        done.assertIsSatisfied();
    }
View Full Code Here

        return getExpression().evaluate(createDynamicContext(exchange));
    }

    public Object evaluateAsStringSource(E exchange) throws Exception {
        String text = evaluateAsString(exchange);
        return new StringSource(text);
    }
View Full Code Here

        super.setUp();
        ServiceHelper.startService(converter);
    }

    public void testSerialization() throws Exception {
        StringSource expected = new StringSource(expectedBody, "mySystemID", "utf-8");
        expected.setPublicId("myPublicId");

        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutputStream output = new ObjectOutputStream(buffer);
        output.writeObject(expected);
        output.close();


        ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        Object object = in.readObject();
        assertTrue("is a StringSource", object instanceof StringSource);
        StringSource actual = (StringSource) object;

        assertEquals("source.text", expected.getPublicId(), actual.getPublicId());
        assertEquals("source.text", expected.getSystemId(), actual.getSystemId());
        assertEquals("source.text", expected.getEncoding(), actual.getEncoding());
        assertEquals("source.text", expected.getText(), actual.getText());

        String value = converter.convertTo(String.class, actual);
        assertEquals("text value of StringSource", expectedBody, value);
    }
View Full Code Here

    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();
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.converter.jaxp.StringSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.