Package org.apache.camel

Examples of org.apache.camel.Expression.evaluate()


        lan.setHeaderName("names");
        lan.setRegex(false);
        lan.setToken(",");
        Expression exp = lan.createExpression();

        List names = exp.evaluate(exchange, List.class);
        assertEquals(3, names.size());

        assertEquals("Claus", names.get(0));
        assertEquals("James", names.get(1));
        assertEquals("Willem", names.get(2));
View Full Code Here


    public void testTokenizePairSpecial() throws Exception {
        Expression exp = TokenizeLanguage.tokenizePair("!", "@", false);

        exchange.getIn().setBody("2011-11-11\n!James@!Claus@\n2 records");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(2, names.size());

        assertEquals("James", names.get(0));
        assertEquals("Claus", names.get(1));
    }
View Full Code Here

    public void testTokenizePair() throws Exception {
        Expression exp = TokenizeLanguage.tokenizePair("[START]", "[END]", false);

        exchange.getIn().setBody("2011-11-11\n[START]James[END]\n[START]Claus[END]\n2 records");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(2, names.size());

        assertEquals("James", names.get(0));
        assertEquals("Claus", names.get(1));
    }
View Full Code Here

    public void testTokenizePairIncludeTokens() throws Exception {
        Expression exp = TokenizeLanguage.tokenizePair("[START]", "[END]", true);

        exchange.getIn().setBody("2011-11-11\n[START]James[END]\n[START]Claus[END]\n2 records");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(2, names.size());

        assertEquals("[START]James[END]", names.get(0));
        assertEquals("[START]Claus[END]", names.get(1));
    }
View Full Code Here

    public void testTokenizeXMLPair() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>"null);

        exchange.getIn().setBody("<persons><person>James</person><person>Claus</person><person>Jonathan</person><person>Hadrian</person></persons>");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(4, names.size());

        assertEquals("<person>James</person>", names.get(0));
        assertEquals("<person>Claus</person>", names.get(1));
        assertEquals("<person>Jonathan</person>", names.get(2));
View Full Code Here

    public void testTokenizeXMLPairNoXMLTag() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("person"null);

        exchange.getIn().setBody("<persons><person>James</person><person>Claus</person><person>Jonathan</person><person>Hadrian</person></persons>");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(4, names.size());

        assertEquals("<person>James</person>", names.get(0));
        assertEquals("<person>Claus</person>", names.get(1));
        assertEquals("<person>Jonathan</person>", names.get(2));
View Full Code Here

        Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);

        exchange.getIn().setBody("<?xml version=\"1.0\"?><!-- bla bla --><persons>\n<person>James</person>\n<person>Claus</person>\n"
                + "<!-- more bla bla --><person>Jonathan</person>\n<person>Hadrian</person>\n</persons>   ");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(4, names.size());

        assertEquals("<person>James</person>", names.get(0));
        assertEquals("<person>Claus</person>", names.get(1));
        assertEquals("<person>Jonathan</person>", names.get(2));
View Full Code Here

    public void testTokenizeXMLPairEmpty() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);

        exchange.getIn().setBody("<?xml version=\"1.0\"?><!-- bla bla --><persons></persons>   ");

        List names = exp.evaluate(exchange, List.class);
        assertEquals(0, names.size());
    }

    public void testTokenizeXMLPairNoData() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);
View Full Code Here

    public void testTokenizeXMLPairNoData() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);

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

        List names = exp.evaluate(exchange, List.class);
        assertEquals(0, names.size());
    }

    public void testTokenizeXMLPairNullData() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);
View Full Code Here

    public void testTokenizeXMLPairNullData() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>", null);

        exchange.getIn().setBody(null);

        List names = exp.evaluate(exchange, List.class);
        assertNull(names);
    }

    public void testTokenizeXMLPairWithDefaultNamespace() throws Exception {
        Expression exp = TokenizeLanguage.tokenizeXML("<person>", "<persons>");
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.