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 testBodyExpressionNotStringType() throws Exception {
        exchange.getIn().setBody(123);
        Expression exp = SimpleLanguage.simple("${body}");
        assertNotNull(exp);
        Object val = exp.evaluate(exchange, Object.class);
        assertIsInstanceOf(Integer.class, val);
        assertEquals(123, val);
    }

    public void testSimpleExpressions() throws Exception {
View Full Code Here

    public void testBeanTypeExpression() throws Exception {
        Expression exp = BeanLanguage.bean(MyUser.class, null);
        Exchange exchange = createExchangeWithBody("Claus");

        Object result = exp.evaluate(exchange);
        assertEquals("Hello Claus", result);
    }

    public void testBeanTypeAndMethodExpression() throws Exception {
        Expression exp = BeanLanguage.bean(MyUser.class, "hello");
View Full Code Here

    public void testBeanTypeAndMethodExpression() throws Exception {
        Expression exp = BeanLanguage.bean(MyUser.class, "hello");
        Exchange exchange = createExchangeWithBody("Claus");

        Object result = exp.evaluate(exchange);
        assertEquals("Hello Claus", result);
    }

    public void testBeanInstanceAndMethodExpression() throws Exception {
        MyUser user = new MyUser();
View Full Code Here

    public void testBeanInstanceAndMethodExpression() throws Exception {
        MyUser user = new MyUser();
        Expression exp = BeanLanguage.bean(user, "hello");
        Exchange exchange = createExchangeWithBody("Claus");

        Object result = exp.evaluate(exchange);
        assertEquals("Hello Claus", result);
    }

    protected String getLanguageName() {
        return "bean";
View Full Code Here

        }
        if (expression != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Filename evaluated as expression: " + expression);
            }
            Object result = expression.evaluate(message.getExchange());
            name = message.getExchange().getContext().getTypeConverter().convertTo(String.class, result);
        }

        File endpointFile = endpoint.getFile();
        if (endpointFile.isDirectory()) {
View Full Code Here

    protected CamelContext context = new DefaultCamelContext();
    protected Exchange exchange;

    public void testExpression() throws Exception {
        Expression expression = sql("SELECT * FROM org.apache.camel.builder.sql.Person where city = 'London'");
        Object value = expression.evaluate(exchange);
        assertIsInstanceOf(List.class, value);

        List list = (List)value;
        assertEquals("List size", 2, list.size());

View Full Code Here

        }
    }

    public void testExpressionWithHeaderVariable() throws Exception {
        Expression expression = sql("SELECT * FROM org.apache.camel.builder.sql.Person where name = :fooHeader");
        Object value = expression.evaluate(exchange);
        assertIsInstanceOf(List.class, value);

        List<Person> list = (List<Person>)value;
        assertEquals("List size", 1, list.size());

View Full Code Here

        }
        if (expression != null) {
            if (log.isDebugEnabled()) {
                log.debug("Filename evaluated as expression: " + expression);
            }
            Object result = expression.evaluate(message.getExchange());
            name = message.getExchange().getContext().getTypeConverter().convertTo(String.class, result);
        }       

        String endpointFile = fileConfig.getFile();
        if (fileConfig.isDirectory()) {
View Full Code Here

                Exchange exchange = getReceivedExchanges().get(0);
                assertTrue("No exchange received for counter: " + 0, exchange != null);

                Object actualBody = exchange.getIn().getBody();
                Expression exp = createExpression(getCamelContext());
                Object expectedBody = exp.evaluate(exchange, Object.class);

                assertEquals("Body of message: " + 0, expectedBody, actualBody);
            }
        };
        expects(clause);
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.