Search in sources :

Example 46 with Message

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

the class StreamedSplitTest method testCamel.

@Test
public void testCamel() throws Exception {
    results.expectedMessageCount(4);
    results.assertIsSatisfied();
    int counter = 0;
    List<Exchange> list = results.getReceivedExchanges();
    for (Exchange exchange : list) {
        Message in = exchange.getIn();
        Map<?, ?> body = in.getBody(Map.class);
        assertNotNull("Should have found body as a Map but was: " + ObjectHelper.className(in.getBody()), body);
        assertEquals("NAME", expectedItemDesc[counter], body.get("NAME"));
        LOG.info("Result: " + counter + " = " + body);
        counter++;
    }
}
Also used : Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 47 with Message

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

the class FixedLengthAllowLongTest method testCamel.

@Test
public void testCamel() throws Exception {
    results.expectedMessageCount(4);
    results.assertIsSatisfied();
    int counter = 0;
    List<Exchange> list = results.getReceivedExchanges();
    for (Exchange exchange : list) {
        Message in = exchange.getIn();
        assertEquals("counter", in.getHeader("camelFlatpackCounter"), counter);
        Map<?, ?> body = in.getBody(Map.class);
        assertNotNull("Should have found body as a Map but was: " + ObjectHelper.className(in.getBody()), body);
        assertEquals("FIRSTNAME", expectedFirstName[counter], body.get("FIRSTNAME"));
        LOG.info("Result: " + counter + " = " + body);
        counter++;
    }
}
Also used : Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 48 with Message

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

the class FixedLengthAllowShortAndLongTest method testFlatpack.

@Test
public void testFlatpack() throws Exception {
    results.expectedMessageCount(4);
    results.assertIsSatisfied();
    int counter = 0;
    List<Exchange> list = results.getReceivedExchanges();
    for (Exchange exchange : list) {
        Message in = exchange.getIn();
        assertEquals("counter", in.getHeader("camelFlatpackCounter"), counter);
        Map<?, ?> body = in.getBody(Map.class);
        assertNotNull("Should have found body as a Map but was: " + ObjectHelper.className(in.getBody()), body);
        assertEquals("FIRSTNAME", expectedFirstName[counter], body.get("FIRSTNAME"));
        LOG.info("Result: " + counter + " = " + body);
        counter++;
    }
}
Also used : Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 49 with Message

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

the class FixedLengthWithUnmarshalTest method testCamel.

@Test
public void testCamel() throws Exception {
    results.expectedMessageCount(4);
    results.assertIsSatisfied();
    int counter = 0;
    List<Exchange> list = results.getReceivedExchanges();
    for (Exchange exchange : list) {
        Message in = exchange.getIn();
        Map<?, ?> body = in.getBody(Map.class);
        assertNotNull("Should have found body as a Map but was: " + ObjectHelper.className(in.getBody()), body);
        assertEquals("FIRSTNAME", expectedFirstName[counter], body.get("FIRSTNAME"));
        LOG.info("Result: " + counter + " = " + body);
        counter++;
    }
}
Also used : Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 50 with Message

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

the class FreemarkerSetHeaderTest method assertRespondsWith.

protected void assertRespondsWith(final String value, String expectedBody) throws InvalidPayloadException, InterruptedException {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    //mock.expectedHeaderReceived("fruit", value);
    mock.expectedBodiesReceived(expectedBody);
    template.request("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            Message in = exchange.getIn();
            in.setBody(value);
        }
    });
    mock.assertIsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) InvalidPayloadException(org.apache.camel.InvalidPayloadException)

Aggregations

Message (org.apache.camel.Message)721 Exchange (org.apache.camel.Exchange)341 Test (org.junit.Test)215 Processor (org.apache.camel.Processor)118 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)104 DefaultMessage (org.apache.camel.impl.DefaultMessage)51 DefaultExchange (org.apache.camel.impl.DefaultExchange)44 Endpoint (org.apache.camel.Endpoint)40 Response (javax.ws.rs.core.Response)38 InputStream (java.io.InputStream)36 HashMap (java.util.HashMap)35 ArrayList (java.util.ArrayList)26 RouteBuilder (org.apache.camel.builder.RouteBuilder)25 Customer (org.apache.camel.component.cxf.jaxrs.testbean.Customer)25 ActionResponse (org.openstack4j.model.common.ActionResponse)25 IOException (java.io.IOException)24 Map (java.util.Map)24 DataHandler (javax.activation.DataHandler)21 Producer (org.apache.camel.Producer)21 CxfOperationException (org.apache.camel.component.cxf.CxfOperationException)19