Search in sources :

Example 66 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class SimpleParserPredicateTest method testSimpleExpressionPredicate.

public void testSimpleExpressionPredicate() throws Exception {
    exchange.getIn().setBody("Hello");
    exchange.getIn().setHeader("number", "1234");
    SimplePredicateParser parser = new SimplePredicateParser("${in.header.number} regex '\\d{4}'", true);
    Predicate pre = parser.parsePredicate();
    assertTrue("Should match", pre.matches(exchange));
}
Also used : Predicate(org.apache.camel.Predicate)

Example 67 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class SimpleParserPredicateTest method testSimpleEqFunctionFunction.

public void testSimpleEqFunctionFunction() throws Exception {
    exchange.getIn().setBody(122);
    exchange.getIn().setHeader("val", 122);
    SimplePredicateParser parser = new SimplePredicateParser("${body} == ${header.val}", true);
    Predicate pre = parser.parsePredicate();
    assertTrue("Should match", pre.matches(exchange));
}
Also used : Predicate(org.apache.camel.Predicate)

Example 68 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class SimpleParserPredicateTest method testSimpleEqFunctionNumeric.

public void testSimpleEqFunctionNumeric() throws Exception {
    exchange.getIn().setBody(122);
    SimplePredicateParser parser = new SimplePredicateParser("${body} == 122", true);
    Predicate pre = parser.parsePredicate();
    assertTrue("Should match", pre.matches(exchange));
}
Also used : Predicate(org.apache.camel.Predicate)

Example 69 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class SimpleParserPredicateTest method testSimpleEqFunctionBooleanSpaces.

public void testSimpleEqFunctionBooleanSpaces() throws Exception {
    exchange.getIn().setBody("Hello");
    exchange.getIn().setHeader("high", true);
    SimplePredicateParser parser = new SimplePredicateParser("${header.high}   ==     true", true);
    Predicate pre = parser.parsePredicate();
    assertTrue("Should match", pre.matches(exchange));
}
Also used : Predicate(org.apache.camel.Predicate)

Example 70 with Predicate

use of org.apache.camel.Predicate in project camel by apache.

the class SimpleParserPredicateTest method testSimpleBooleanValue.

public void testSimpleBooleanValue() throws Exception {
    exchange.getIn().setBody("foo");
    SimplePredicateParser parser = new SimplePredicateParser("true", true);
    Predicate pre = parser.parsePredicate();
    assertTrue(pre.matches(exchange));
    parser = new SimplePredicateParser("false", true);
    pre = parser.parsePredicate();
    assertFalse(pre.matches(exchange));
}
Also used : Predicate(org.apache.camel.Predicate)

Aggregations

Predicate (org.apache.camel.Predicate)124 Exchange (org.apache.camel.Exchange)70 Test (org.junit.Test)40 HashMap (java.util.HashMap)25 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)23 Expression (org.apache.camel.Expression)22 Processor (org.apache.camel.Processor)19 DefaultExchange (org.apache.camel.impl.DefaultExchange)10 RouteBuilder (org.apache.camel.builder.RouteBuilder)9 File (java.io.File)8 Matchers.containsString (org.hamcrest.Matchers.containsString)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 Map (java.util.Map)7 Ignore (org.junit.Ignore)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 AggregateProcessor (org.apache.camel.processor.aggregate.AggregateProcessor)6 AggregationStrategy (org.apache.camel.processor.aggregate.AggregationStrategy)6 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)6 BodyInAggregatingStrategy (org.apache.camel.processor.BodyInAggregatingStrategy)5