Search in sources :

Example 46 with MockEndpoint

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

the class TransactionalClientWithAnnotatedBeanTest method testTransactionRollback.

@Override
public void testTransactionRollback() throws Exception {
    MockEndpoint book = getMockEndpoint("mock:book");
    book.expectedMessageCount(1);
    super.testTransactionRollback();
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 47 with MockEndpoint

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

the class AdviceWithTransactionIssueTest method testAdviceWithWeaveById.

@Test
public void testAdviceWithWeaveById() throws Exception {
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {

        @Override
        public void configure() throws Exception {
            weaveById("mock-b*").after().to("mock:last");
        }
    });
    context.start();
    MockEndpoint mockLast = getMockEndpoint("mock:last");
    mockLast.expectedBodiesReceived("bar");
    mockLast.setExpectedMessageCount(1);
    template.sendBody("seda:start", "bar");
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) AdviceWithRouteBuilder(org.apache.camel.builder.AdviceWithRouteBuilder) Test(org.junit.Test)

Example 48 with MockEndpoint

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

the class CamelRouteRefInjectionIssueTest method testTheRouteRefInjection.

public void testTheRouteRefInjection() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Hello World!");
    template.sendBody("direct:start", "Hello World!");
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 49 with MockEndpoint

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

the class FileWireTapWithXMLPayloadIssueTest method testWireTapXpathExpression.

public void testWireTapXpathExpression() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    MockEndpoint tap = getMockEndpoint("mock:wiretap");
    tap.expectedMessageCount(1);
    assertMockEndpointsSatisfied();
    String dataResult = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
    String dataTap = tap.getReceivedExchanges().get(0).getIn().getBody(String.class);
    assertEquals(dataResult, dataTap);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 50 with MockEndpoint

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

the class SpringJmxRecipientListRegisterAlwaysTest method testJmxEndpointsAddedDynamicallyAlwaysRegister.

public void testJmxEndpointsAddedDynamicallyAlwaysRegister() throws Exception {
    MockEndpoint x = getMockEndpoint("mock:x");
    MockEndpoint y = getMockEndpoint("mock:y");
    MockEndpoint z = getMockEndpoint("mock:z");
    x.expectedBodiesReceived("answer");
    y.expectedBodiesReceived("answer");
    z.expectedBodiesReceived("answer");
    template.sendBodyAndHeader("direct:a", "answer", "recipientListHeader", "mock:x,mock:y,mock:z");
    assertMockEndpointsSatisfied();
    MBeanServer mbeanServer = getMBeanServer();
    // this endpoint is part of the route and should be registered
    ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"direct://a\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(name));
    // endpoints added after routes has been started is now also registered
    name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://x\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(name));
    name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://y\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(name));
    name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://z\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(name));
    // however components is always registered
    name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=components,name=\"mock\"");
    assertTrue("Should be registered", mbeanServer.isRegistered(name));
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3401 Test (org.junit.Test)2024 Exchange (org.apache.camel.Exchange)511 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