Package org.apache.camel

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


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

}
View Full Code Here

        exchange.getIn().setHeader("foo", 123);

        SimplePredicateParser parser = new SimplePredicateParser("${header.high} == true and ${header.foo} == 123", true);
        Predicate pre = parser.parsePredicate();

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

    public void testSimpleLogicalOr() throws Exception {
        exchange.getIn().setBody("Hello");
        exchange.getIn().setHeader("high", true);
View Full Code Here

        exchange.getIn().setHeader("foo", 123);

        SimplePredicateParser parser = new SimplePredicateParser("${header.high} == false or ${header.foo} == 123", true);
        Predicate pre = parser.parsePredicate();

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

}
View Full Code Here

                    .skipSendToOriginalEndpoint()
                    .process(new Processor() {
                        public void process(Exchange exchange) throws Exception {
                            invoked.incrementAndGet();

                            if (fail.matches(exchange)) {
                                throw new ConnectException("Forced");
                            }
                        }
                    }).to("mock:ok");
            }
View Full Code Here

        exchange.getIn().setBody("12.34.5678");

        SimplePredicateParser parser = new SimplePredicateParser("${body} regex '^\\d{2}\\.\\d{2}\\.\\d{4}$'", true);
        Predicate pre = parser.parsePredicate();

        assertTrue(pre.matches(exchange));
       
        exchange.getIn().setBody("12.2a.22ab");
        assertFalse(pre.matches(exchange));
    }
View Full Code Here

        Predicate pre = parser.parsePredicate();

        assertTrue(pre.matches(exchange));
       
        exchange.getIn().setBody("12.2a.22ab");
        assertFalse(pre.matches(exchange));
    }

}
View Full Code Here

                    .handled(true)
                    .retryWhile(new Predicate() {
                        @Override
                        public boolean matches(Exchange exchange) {
                            Predicate predicate = and(simple("${body.areWeCool} == 'no'"), isNotNull(header("foo")));
                            boolean answer = predicate.matches(exchange);
                            return answer;
                        }
                    });

                from("direct:start")
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.