Package org.apache.camel

Examples of org.apache.camel.BytesSource


    }

    @Converter
    public static Serializable convertToSerializable(StreamCache cache, Exchange exchange) throws IOException {
        byte[] data = convertToByteArray(cache, exchange);
        return new BytesSource(data);
    }
View Full Code Here


        conv.toResult(null, null);
    }

    public void testToBytesSource() throws Exception {
        XmlConverter conv = new XmlConverter();
        BytesSource bs = conv.toBytesSource("<foo>bar</foo>".getBytes());
        assertNotNull(bs);
        assertEquals("<foo>bar</foo>", new String(bs.getData()));
    }
View Full Code Here

* @version
*/
public class BytesSourceTest extends ContextTestSupport {

    public void testBytesSourceCtr() {
        BytesSource bs = new BytesSource("foo".getBytes());
        assertNotNull(bs.getData());
        assertEquals("BytesSource[foo]", bs.toString());
        assertNull(bs.getSystemId());

        assertNotNull(bs.getInputStream());
        assertNotNull(bs.getReader());
    }
View Full Code Here

        assertNotNull(bs.getInputStream());
        assertNotNull(bs.getReader());
    }

    public void testBytesSourceCtrSystemId() {
        BytesSource bs = new BytesSource("foo".getBytes(), "Camel");
        assertNotNull(bs.getData());
        assertEquals("BytesSource[foo]", bs.toString());
        assertEquals("Camel", bs.getSystemId());

        assertNotNull(bs.getInputStream());
        assertNotNull(bs.getReader());
    }
View Full Code Here

    /**
     * Converts the given byte[] to a Source
     */
    @Converter
    public BytesSource toBytesSource(byte[] data) {
        return new BytesSource(data);
    }
View Full Code Here

        assertBuyStocks(result);
    }

    @Test
    public void toXmlObjectFromSource() throws IOException, XmlException, NoTypeConversionAvailableException {
        XmlObject result = XmlBeansConverter.toXmlObject(new BytesSource(PAYLOAD.getBytes()), new DefaultExchange(new DefaultCamelContext()));
        assertBuyStocks(result);
    }
View Full Code Here

    public Object evaluateAsBytesSource(Exchange exchange) throws Exception {
        LOG.debug("evaluateAsBytesSource: {} for exchange: {}", expression, exchange);
        initialize(exchange);

        byte[] bytes = evaluateAsBytes(exchange);
        return new BytesSource(bytes);
    }
View Full Code Here

    /**
     * Converts the given byte[] to a Source
     */
    @Converter
    public BytesSource toBytesSource(byte[] data) {
        return new BytesSource(data);
    }
View Full Code Here

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

        byte[] bytes = evaluateAsBytes(exchange);
        return new BytesSource(bytes);
    }
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",
                        exchange.getIn().getBody() instanceof StreamCache);
View Full Code Here

TOP

Related Classes of org.apache.camel.BytesSource

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.