Search in sources :

Example 1 with TraceEventMessage

use of org.apache.camel.processor.interceptor.TraceEventMessage in project camel by apache.

the class OnCompletionGlobalTraceTest method testSynchronizeFailure.

public void testSynchronizeFailure() throws Exception {
    getMockEndpoint("mock:sync").expectedMessageCount(1);
    getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
    getMockEndpoint("mock:trace").expectedMessageCount(3);
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(0);
    try {
        template.sendBody("direct:start", "Kabom");
        fail("Should throw exception");
    } catch (CamelExecutionException e) {
        assertEquals("Kabom", e.getCause().getMessage());
    }
    assertMockEndpointsSatisfied();
    TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
    assertEquals("direct://start", msg1.getFromEndpointUri());
    assertEquals("ref:myProcessor", msg1.getToNode());
    assertTrue(msg2.getPreviousNode().startsWith("OnCompletion"));
    assertEquals("log://global", msg2.getToNode());
    assertEquals("log://global", msg3.getPreviousNode());
    assertEquals("mock://sync", msg3.getToNode());
}
Also used : CamelExecutionException(org.apache.camel.CamelExecutionException) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) TraceEventMessage(org.apache.camel.processor.interceptor.TraceEventMessage)

Example 2 with TraceEventMessage

use of org.apache.camel.processor.interceptor.TraceEventMessage in project camel by apache.

the class OnCompletionGlobalTraceTest method testSynchronizeComplete.

public void testSynchronizeComplete() throws Exception {
    getMockEndpoint("mock:sync").expectedBodiesReceived("Bye World");
    getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
    getMockEndpoint("mock:trace").expectedMessageCount(4);
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Bye World");
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg4 = getMockEndpoint("mock:trace").getReceivedExchanges().get(3).getIn().getBody(TraceEventMessage.class);
    assertEquals("direct://start", msg1.getFromEndpointUri());
    assertEquals("ref:myProcessor", msg1.getToNode());
    assertEquals("ref:myProcessor", msg2.getPreviousNode());
    assertEquals("mock://result", msg2.getToNode());
    assertTrue(msg3.getPreviousNode().startsWith("OnCompletion"));
    assertEquals("log://global", msg3.getToNode());
    assertEquals("log://global", msg4.getPreviousNode());
    assertEquals("mock://sync", msg4.getToNode());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) TraceEventMessage(org.apache.camel.processor.interceptor.TraceEventMessage)

Example 3 with TraceEventMessage

use of org.apache.camel.processor.interceptor.TraceEventMessage in project camel by apache.

the class DefaultErrorHandlerOnExceptionTraceTest method testOk.

public void testOk() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("Bye World");
    getMockEndpoint("mock:trace").expectedMessageCount(2);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
    assertEquals("direct://start", msg1.getFromEndpointUri());
    assertEquals("ref:myProcessor", msg1.getToNode());
    assertEquals("ref:myProcessor", msg2.getPreviousNode());
    assertEquals("mock://result", msg2.getToNode());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) TraceEventMessage(org.apache.camel.processor.interceptor.TraceEventMessage)

Example 4 with TraceEventMessage

use of org.apache.camel.processor.interceptor.TraceEventMessage in project camel by apache.

the class DefaultErrorHandlerOnExceptionTraceTest method testWithError.

public void testWithError() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:boom");
    mock.expectedMessageCount(1);
    getMockEndpoint("mock:trace").expectedMessageCount(4);
    template.sendBody("direct:start", "Kabom");
    assertMockEndpointsSatisfied();
    TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg4 = getMockEndpoint("mock:trace").getReceivedExchanges().get(3).getIn().getBody(TraceEventMessage.class);
    assertEquals("direct://start", msg1.getFromEndpointUri());
    assertEquals("ref:myProcessor", msg1.getToNode());
    assertEquals("ref:myProcessor", msg2.getPreviousNode());
    assertEquals("OnException[IllegalArgumentException]", msg2.getToNode());
    assertEquals("OnException[IllegalArgumentException]", msg3.getPreviousNode());
    assertEquals("log://boom", msg3.getToNode());
    assertEquals("log://boom", msg4.getPreviousNode());
    assertEquals("mock://boom", msg4.getToNode());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) TraceEventMessage(org.apache.camel.processor.interceptor.TraceEventMessage)

Example 5 with TraceEventMessage

use of org.apache.camel.processor.interceptor.TraceEventMessage in project camel by apache.

the class InterceptSimpleRouteTraceTest method testIntercept.

public void testIntercept() throws Exception {
    getMockEndpoint("mock:foo").expectedMessageCount(1);
    getMockEndpoint("mock:bar").expectedMessageCount(1);
    getMockEndpoint("mock:result").expectedMessageCount(1);
    getMockEndpoint("mock:intercepted").expectedMessageCount(3);
    getMockEndpoint("mock:trace").expectedMessageCount(6);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg4 = getMockEndpoint("mock:trace").getReceivedExchanges().get(3).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg5 = getMockEndpoint("mock:trace").getReceivedExchanges().get(4).getIn().getBody(TraceEventMessage.class);
    TraceEventMessage msg6 = getMockEndpoint("mock:trace").getReceivedExchanges().get(5).getIn().getBody(TraceEventMessage.class);
    assertEquals("direct://start", msg1.getFromEndpointUri());
    assertEquals("mock://intercepted", msg1.getToNode());
    assertEquals("mock://intercepted", msg2.getPreviousNode());
    assertEquals("mock://foo", msg2.getToNode());
    assertEquals("mock://foo", msg3.getPreviousNode());
    assertEquals("mock://intercepted", msg3.getToNode());
    assertEquals("mock://intercepted", msg4.getPreviousNode());
    assertEquals("mock://bar", msg4.getToNode());
    assertEquals("mock://bar", msg5.getPreviousNode());
    assertEquals("mock://intercepted", msg5.getToNode());
    assertEquals("mock://intercepted", msg6.getPreviousNode());
    assertEquals("mock://result", msg6.getToNode());
}
Also used : TraceEventMessage(org.apache.camel.processor.interceptor.TraceEventMessage)

Aggregations

TraceEventMessage (org.apache.camel.processor.interceptor.TraceEventMessage)5 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 CamelExecutionException (org.apache.camel.CamelExecutionException)1