Package org.apache.camel

Examples of org.apache.camel.Predicate.matches()


        }

        SimplePredicateParser parser = new SimplePredicateParser(sb.toString(), true);
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }

    public void testSimpleManyOrLogical() throws Exception {
        exchange.getIn().setBody("Hello");
View Full Code Here


        sb.append(" || ${body} == 'Hello'");

        SimplePredicateParser parser = new SimplePredicateParser(sb.toString(), true);
        Predicate pre = parser.parsePredicate();

        assertTrue("Should match", pre.matches(exchange));
    }

    public void testSimpleExpressionPredicate() throws Exception {
        exchange.getIn().setBody("Hello");
        exchange.getIn().setHeader("number", "1234");
View Full Code Here

    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));
    }

    public void testSimpleMap() throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        map.put("foo", "123");
View Full Code Here

        exchange.getIn().setBody(map);

        SimplePredicateParser parser = new SimplePredicateParser("${body[foo]} == 123", true);
        Predicate pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        parser = new SimplePredicateParser("${body['foo bar']} == 456", true);
        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));
View Full Code Here

        Predicate pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        parser = new SimplePredicateParser("${body['foo bar']} == 456", true);
        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        // the predicate has whitespace in the function
        parser = new SimplePredicateParser("${body[foo bar]} == 456", true);
        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));
View Full Code Here

        assertTrue("Should match", pre.matches(exchange));

        // the predicate has whitespace in the function
        parser = new SimplePredicateParser("${body[foo bar]} == 456", true);
        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));
    }

    protected JndiRegistry createRegistry() throws Exception {
        JndiRegistry jndi = super.createRegistry();
View Full Code Here

        map.put("key3", "none");
        exchange.getIn().setBody(map);

        SimplePredicateParser parser = new SimplePredicateParser("${body[key]} in ${ref:myList}", true);
        Predicate pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        parser = new SimplePredicateParser("${body[key2]} in ${ref:myList}", true);
        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));
View Full Code Here

        Predicate pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        parser = new SimplePredicateParser("${body[key2]} in ${ref:myList}", true);
        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        parser = new SimplePredicateParser("${body[key3]} in ${ref:myList}", true);
        pre = parser.parsePredicate();
        assertFalse("Should not match", pre.matches(exchange));
    }
View Full Code Here

        pre = parser.parsePredicate();
        assertTrue("Should match", pre.matches(exchange));

        parser = new SimplePredicateParser("${body[key3]} in ${ref:myList}", true);
        pre = parser.parsePredicate();
        assertFalse("Should not match", pre.matches(exchange));
    }
}
View Full Code Here

        return jndi;
    }

    public void testSimpleExpressionOrPredicate() throws Exception {
        Predicate predicate = SimpleLanguage.predicate("${header.bar} == 123");
        assertTrue(predicate.matches(exchange));

        predicate = SimpleLanguage.predicate("${header.bar} == 124");
        assertFalse(predicate.matches(exchange));

        Expression expression = SimpleLanguage.expression("${body}");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.