Search in sources :

Example 1 with ConditionSupport

use of org.apache.camel.impl.ConditionSupport 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 2 with ConditionSupport

use of org.apache.camel.impl.ConditionSupport 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 3 with ConditionSupport

use of org.apache.camel.impl.ConditionSupport 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 4 with ConditionSupport

use of org.apache.camel.impl.ConditionSupport 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)4 BreakpointSupport (org.apache.camel.impl.BreakpointSupport)4 ConditionSupport (org.apache.camel.impl.ConditionSupport)4 Processor (org.apache.camel.Processor)3 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