Package org.apache.camel

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


        // Then use the helper here to get the value and move this method to LanguageTestSupport
        Language language = assertResolveLanguage(getLanguageName());
        Expression expression = language.createExpression(expressionText);
        assertNotNull("Cannot assert type when no type is provided", expectedType);
        assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression);
        Object answer = expression.evaluate(exchange, Object.class);
        assertIsInstanceOf(Animal.class, answer);
    }

    public static final class Animal {
        private String name;
View Full Code Here


    public void testCamelContextPropertiesExpression() throws Exception {
        camelContext.getProperties().put("CamelTestKey", "CamelTestValue");       
        Expression expression = camelContextPropertyExpression("CamelTestKey");
        assertExpression(expression, exchange, "CamelTestValue");       
        expression = camelContextPropertiesExpression();
        Map<String, String> properties = CastUtils.cast(expression.evaluate(exchange, Map.class));
        assertEquals("Get a wrong properties size", properties.size(), 1);
    }

    @Override
    protected void setUp() throws Exception {
View Full Code Here

            }
        }

        ObjectHelper.notNull(exp, "expression");

        Object result = exp.evaluate(exchange, Object.class);
        log.debug("Evaluated expression as: {} with: {}", result, exchange);

        // set message body if transform is enabled
        if (getEndpoint().isTransform()) {
            if (exchange.hasOut()) {
View Full Code Here

            @Override
            public boolean onExchange(Exchange exchange) {
                // filter non matching exchanges
                Expression exp = clause.createExpression(exchange.getContext());
                return exp.evaluate(exchange, Boolean.class);
            }

            public boolean matches() {
                // should be true as we use the onExchange to filter
                return true;
View Full Code Here

                expression = language.createExpression(name);
            }
        }
        if (expression != null) {
            log.trace("Filename evaluated as expression: {}", expression);
            name = expression.evaluate(exchange, String.class);
        }

        // flatten name
        if (name != null && endpoint.isFlatten()) {
            // check for both windows and unix separators
View Full Code Here

                        sb.append(text);
                    } else if (child instanceof SimpleFunctionStart) {
                        try {
                            // pass in null when we evaluate the nested expressions
                            Expression nested = child.createExpression(null);
                            String text = nested.evaluate(exchange, String.class);
                            if (text != null) {
                                sb.append(text);
                            }
                        } catch (SimpleParserException e) {
                            // must rethrow parser exception as illegal syntax with details about the location
View Full Code Here

    }

    public void testTokenizeHeader() throws Exception {
        Expression exp = TokenizeLanguage.tokenize("names", ",");

        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 testTokenizeBody() throws Exception {
        Expression exp = TokenizeLanguage.tokenize(",");

        exchange.getIn().setBody("Hadrian,Charles");

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

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

    public void testTokenizeBodyRegEx() throws Exception {
        Expression exp = TokenizeLanguage.tokenize("(\\W+)\\s*", true);

        exchange.getIn().setBody("The little fox");

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

        assertEquals("The", names.get(0));
        assertEquals("little", names.get(1));
        assertEquals("fox", names.get(2));
View Full Code Here

    public void testTokenizeHeaderRegEx() throws Exception {
        Expression exp = TokenizeLanguage.tokenize("quote", "(\\W+)\\s*", true);

        exchange.getIn().setHeader("quote", "Camel rocks");

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

        assertEquals("Camel", names.get(0));
        assertEquals("rocks", names.get(1));
    }
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.