Search in sources :

Example 1 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class CassandraComponentConsumerTest method testConsumeAll.

@Test
public void testConsumeAll() throws Exception {
    if (!canTest()) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:resultAll");
    mock.expectedMinimumMessageCount(1);
    mock.whenAnyExchangeReceived(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Object body = exchange.getIn().getBody();
            assertTrue(body instanceof List);
        }
    });
    mock.await(1, TimeUnit.SECONDS);
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) List(java.util.List) Test(org.junit.Test)

Example 2 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class CassandraComponentConsumerTest method testConsumeOne.

@Test
public void testConsumeOne() throws Exception {
    if (!canTest()) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:resultOne");
    mock.expectedMinimumMessageCount(1);
    mock.whenAnyExchangeReceived(new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            Object body = exchange.getIn().getBody();
            assertTrue(body instanceof Row);
        }
    });
    mock.await(1, TimeUnit.SECONDS);
    assertMockEndpointsSatisfied();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Row(com.datastax.driver.core.Row) Test(org.junit.Test)

Example 3 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class MarshalDomainObjectTest method testMarshalDomainObjectTwice.

@Test
public void testMarshalDomainObjectTwice() throws Exception {
    // some platform cannot test using Castor as it uses a SUN dependent Xerces
    if (isJavaVendor("IBM")) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(2);
    PurchaseOrder order = new PurchaseOrder();
    order.setName("Tiger");
    order.setAmount(1);
    order.setPrice(99.95);
    template.sendBody("direct:in", order);
    template.sendBody("direct:in", order);
    mock.assertIsSatisfied();
    String body1 = mock.getExchanges().get(0).getIn().getBody(String.class);
    String body2 = mock.getExchanges().get(1).getIn().getBody(String.class);
    assertEquals("The body should marshalled to the same", body1, body2);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 4 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class SpringMarshalDomainObjectTest method testMarshalDomainObject.

@Test
public void testMarshalDomainObject() throws Exception {
    // some platform cannot test using Castor as it uses a SUN dependent Xerces
    if (isJavaVendor("IBM")) {
        return;
    }
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    PurchaseOrder order = new PurchaseOrder();
    order.setName("Tiger");
    order.setAmount(1);
    order.setPrice(99.95);
    template.sendBody("direct:in", order);
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 5 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class CassandraAggregationTest method testAggregationRoute.

@Test
public void testAggregationRoute() throws Exception {
    if (!canTest()) {
        return;
    }
    // Given
    MockEndpoint mockOutput = getMockEndpoint("mock:output");
    mockOutput.expectedMessageCount(2);
    mockOutput.expectedBodiesReceivedInAnyOrder("A,C,E", "B,D");
    // When
    send("1", "A");
    send("2", "B");
    send("1", "C");
    send("2", "D");
    send("1", "E");
    // Then
    mockOutput.assertIsSatisfied(4000L);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3393 Test (org.junit.Test)2016 Exchange (org.apache.camel.Exchange)506 RouteBuilder (org.apache.camel.builder.RouteBuilder)302 Processor (org.apache.camel.Processor)148 File (java.io.File)144 HashMap (java.util.HashMap)130 ObjectName (javax.management.ObjectName)90 MBeanServer (javax.management.MBeanServer)85 Message (org.apache.camel.Message)85 InputStream (java.io.InputStream)73 ArrayList (java.util.ArrayList)63 CamelExecutionException (org.apache.camel.CamelExecutionException)63 List (java.util.List)57 CamelContext (org.apache.camel.CamelContext)57 ProducerTemplate (org.apache.camel.ProducerTemplate)51 Tx (org.nhindirect.common.tx.model.Tx)49 ByteArrayInputStream (java.io.ByteArrayInputStream)47 Map (java.util.Map)43 RuntimeCamelException (org.apache.camel.RuntimeCamelException)38