Package org.apache.camel.impl

Examples of org.apache.camel.impl.DefaultExchange


        assertEquals("converted boolean value", null, value);
    }

    public void testStaticMethodConversionWithExchange() throws Exception {
        CamelContext camel = new DefaultCamelContext();
        Exchange e = new DefaultExchange(camel);
        e.setProperty("prefix", "foo-");
        MyBean bean = converter.convertTo(MyBean.class, e, "5:bar");
        assertEquals("converted using exchange", 5, bean.getFoo(), 5);
        assertEquals("converted using exchange", "foo-bar", bean.getBar());
    }
View Full Code Here


    public void testInstanceMethodConversionWithExchange() throws Exception {
        String[] values = new String[]{"5", "bar"};

        CamelContext camel = new DefaultCamelContext();
        Exchange e = new DefaultExchange(camel);
        e.setProperty("prefix", "foo-");
        MyBean bean = converter.convertTo(MyBean.class, e, values);
        assertEquals("converted using exchange", 5, bean.getFoo(), 5);
        assertEquals("converted using exchange", "foo-bar", bean.getBar());
    }
View Full Code Here

    public void testNormalInvocation() throws Throwable {
        beanMock.a();
        beanMock.b();
        beanMock.c();
        EasyMock.replay(beanMock);
        Exchange result = template.send("direct:start", new DefaultExchange(context));
        if (result.getException() != null) {
            throw result.getException();
        }
        EasyMock.verify(beanMock);
    }
View Full Code Here

    }

    public void testNoMethodSpecified() throws Throwable {
        beanMock.a();
        EasyMock.replay(beanMock);
        Exchange result = template.send("direct:start2", new DefaultExchange(context));
        assertNotNull(result.getException());
        assertEquals(result.getException().getClass(), IllegalStateException.class);
        EasyMock.verify(beanMock);
    }
View Full Code Here

            if (timeout >= 0) {
                entry = queue.read((int)timeout);
            } else {
                entry = queue.read();
            }
            Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
            if (entry != null) {
                if (endpoint.getFormat() == Format.binary) {
                    exchange.getIn().setBody(entry.getData());
                } else {
                    exchange.getIn().setBody(entry.getString());
                }
                return exchange;
            }
        } catch (AS400SecurityException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + e.getMessage(), e);
View Full Code Here

    protected void setUp() throws Exception {
        exchange = createExchange();
    }

    protected Exchange createExchange() {
        Exchange exchange = new DefaultExchange(context);
        Message message = exchange.getIn();
        message.setHeader("fooHeader", "James");

        Person[] people = {
            new Person("James", "London"),
            new Person("Guillaume", "Normandy"),
View Full Code Here

    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.setProperty("foo", 1234);
        Message message = exchange.getIn();
        message.setBody("<hello>world!</hello>");
        message.setHeader("bar", 567);
        message.addAttachment("att", new DataHandler(new URLDataSource(new URL("http://activemq.apache.org/camel/message.html"))));
View Full Code Here


    // setup the default context for testing
    public void testGetCxfInMessage() throws Exception {
        HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
        org.apache.camel.Exchange exchange = new DefaultExchange(context);
        // String
        exchange.getIn().setBody("hello world");
        org.apache.cxf.message.Message message = CxfSoapBinding.getCxfInMessage(
                headerFilterStrategy, exchange, false);
        // test message
        InputStream is = message.getContent(InputStream.class);
        assertNotNull("The input stream should not be null", is);
        assertEquals("Don't get the right message", toString(is), "hello world");

        // DOMSource
        URL request = this.getClass().getResource("RequestBody.xml");
        File requestFile = new File(request.toURI());
        FileInputStream inputStream = new FileInputStream(requestFile);
        XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(inputStream);
        DOMSource source = new DOMSource(StaxUtils.read(xmlReader));
        exchange.getIn().setBody(source);
        message = CxfSoapBinding.getCxfInMessage(headerFilterStrategy, exchange, false);
        is = message.getContent(InputStream.class);
        assertNotNull("The input stream should not be null", is);
        assertEquals("Don't get the right message", toString(is), REQUEST_STRING);

        // File
        exchange.getIn().setBody(requestFile);
        message = CxfSoapBinding.getCxfInMessage(headerFilterStrategy, exchange, false);
        is = message.getContent(InputStream.class);
        assertNotNull("The input stream should not be null", is);
        assertEquals("Don't get the right message", toString(is), REQUEST_STRING);
View Full Code Here

            }
        }
    }

    protected Exchange createExchange() {
        return new DefaultExchange(second.getBuilder().getProcessBuilder().getContext());
    }
View Full Code Here

        }
    }

    @Override
    protected void setUp() throws Exception {
        exchange = new DefaultExchange(new DefaultCamelContext());
        exchange.getIn().setHeader("foo.bar", "cheese");
        exchange.getIn().setHeader("name", "James");
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.impl.DefaultExchange

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.