Search in sources :

Example 1 with BreakpointSupport

use of org.apache.camel.impl.BreakpointSupport in project camel by apache.

the class DebugSingleStepTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    breakpoint = new BreakpointSupport() {

        public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            String body = exchange.getIn().getBody(String.class);
            logs.add("Single stepping at " + definition.getLabel() + " with body: " + body);
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) BreakpointSupport(org.apache.camel.impl.BreakpointSupport)

Example 2 with BreakpointSupport

use of org.apache.camel.impl.BreakpointSupport in project camel by apache.

the class DebugTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    breakpoint = new BreakpointSupport() {

        public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            String body = exchange.getIn().getBody(String.class);
            logs.add("Breakpoint at " + definition + " with body: " + body);
        }

        public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
            String body = exchange.getIn().getBody(String.class);
            logs.add("Breakpoint event " + event.getClass().getSimpleName() + " with body: " + body);
        }
    };
    camelCondition = new ConditionSupport() {

        public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            return body().contains("Camel").matches(exchange);
        }
    };
    mockCondition = new ConditionSupport() {

        public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            // match when sending to mocks
            if (definition instanceof ToDefinition) {
                ToDefinition to = (ToDefinition) definition;
                return to.getUriOrRef().startsWith("mock");
            }
            return false;
        }
    };
    doneCondition = new ConditionSupport() {

        @Override
        public boolean matchEvent(Exchange exchange, EventObject event) {
            return event instanceof ExchangeCompletedEvent;
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) ToDefinition(org.apache.camel.model.ToDefinition) Processor(org.apache.camel.Processor) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport) ExchangeCompletedEvent(org.apache.camel.management.event.ExchangeCompletedEvent) EventObject(java.util.EventObject)

Example 3 with BreakpointSupport

use of org.apache.camel.impl.BreakpointSupport in project camel by apache.

the class DebugExceptionBreakpointTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    breakpoint = new BreakpointSupport() {

        @Override
        public void afterProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, long timeTaken) {
            Exception e = exchange.getException();
            logs.add("Breakpoint at " + definition.getShortName() + " caused by: " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
        }
    };
    exceptionCondition = new ConditionSupport() {

        @Override
        public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            return exchange.getException() != null;
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport)

Example 4 with BreakpointSupport

use of org.apache.camel.impl.BreakpointSupport in project camel by apache.

the class DebugExceptionEventBreakpointTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    breakpoint = new BreakpointSupport() {

        public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
            AbstractExchangeEvent aee = (AbstractExchangeEvent) event;
            Exception e = aee.getExchange().getException();
            logs.add("Breakpoint at " + definition + " caused by: " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
        }
    };
    exceptionCondition = new ConditionSupport() {

        public boolean matchEvent(Exchange exchange, EventObject event) {
            return event instanceof ExchangeFailedEvent;
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) ExchangeFailedEvent(org.apache.camel.management.event.ExchangeFailedEvent) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport) AbstractExchangeEvent(org.apache.camel.management.event.AbstractExchangeEvent) EventObject(java.util.EventObject)

Example 5 with BreakpointSupport

use of org.apache.camel.impl.BreakpointSupport in project camel by apache.

the class DebugSingleStepConditionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    breakpoint = new BreakpointSupport() {

        public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            String body = exchange.getIn().getBody(String.class);
            logs.add("Single stepping at " + definition.getLabel() + " with body: " + body);
        }
    };
    beerCondition = new ConditionSupport() {

        public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
            return "beer".equals(exchange.getFromRouteId());
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) BreakpointSupport(org.apache.camel.impl.BreakpointSupport) ConditionSupport(org.apache.camel.impl.ConditionSupport)

Aggregations

Exchange (org.apache.camel.Exchange)5 BreakpointSupport (org.apache.camel.impl.BreakpointSupport)5 Processor (org.apache.camel.Processor)4 ConditionSupport (org.apache.camel.impl.ConditionSupport)4 EventObject (java.util.EventObject)2 AbstractExchangeEvent (org.apache.camel.management.event.AbstractExchangeEvent)1 ExchangeCompletedEvent (org.apache.camel.management.event.ExchangeCompletedEvent)1 ExchangeFailedEvent (org.apache.camel.management.event.ExchangeFailedEvent)1 ToDefinition (org.apache.camel.model.ToDefinition)1