Examples of createExpression()


Examples of org.apache.camel.spi.Language.createExpression()

        return "simple";
    }

    protected void assertExpressionResultInstanceOf(String expressionText, Class<?> expectedType) {
        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(expectedType, answer);
    }
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

public class SqlLanguageTest extends SqlTest {

    public void testExpression() throws Exception {
        Language language = assertResolveLanguage(getLanguageName());

        Expression expression = language.createExpression("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

Examples of org.apache.camel.spi.Language.createExpression()

    @SuppressWarnings("unchecked")
    public void testExpressionWithHeaderVariable() throws Exception {
        Language language = assertResolveLanguage(getLanguageName());

        Expression expression = language.createExpression("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

Examples of org.apache.camel.spi.Language.createExpression()

    public static Expression languageExpression(final String language, final String expression) {
        return new ExpressionAdapter() {
            public Object evaluate(Exchange exchange) {
                Language lan = exchange.getContext().resolveLanguage(language);
                if (lan != null) {
                    return lan.createExpression(expression).evaluate(exchange, Object.class);
                } else {
                    throw new NoSuchLanguageException(language);
                }
            }
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

            public Object evaluate(Exchange exchange) {
                // resolve language using context to have a clear separation of packages
                // must call evaluate to return the nested language evaluate when evaluating
                // stacked expressions
                Language language = exchange.getContext().resolveLanguage("simple");
                return language.createExpression(expression).evaluate(exchange, Object.class);
            }

            @Override
            public String toString() {
                return "simple(" + expression + ")";
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

            public Object evaluate(Exchange exchange) {
                // resolve language using context to have a clear separation of packages
                // must call evaluate to return the nested language evaluate when evaluating
                // stacked expressions
                Language language = exchange.getContext().resolveLanguage("bean");
                return language.createExpression(expression).evaluate(exchange, Object.class);
            }

            @Override
            public String toString() {
                return "bean(" + expression + ")";
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

    protected void assertExpressionResultInstanceOf(String expressionText, Class<?> expectedType) {
        // TODO [hz]: we should refactor TestSupport.assertExpression(Expression, Exchange, Object)
        // into 2 methods, a helper that returns the value and use that helper in assertExpression
        // 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);
    }
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

            if (expressionType != null) {
                expressionValue = expressionType.createExpression(routeContext);
            } else {
                CamelContext camelContext = routeContext.getCamelContext();
                Language language = camelContext.resolveLanguage(getLanguage());
                expressionValue = language.createExpression(getExpression());
                configureExpression(routeContext, expressionValue);
            }
        }
        return expressionValue;
    }
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

        Language language = camelContext.resolveLanguage(languageName);
        if (language == null) {
            throw new IllegalArgumentException("Cannot find the language: " + languageName + " on the classpath");
        }
        String expression = getExpressionFromAnnotation(annotation);
        return language.createExpression(expression);
    }

    protected String getExpressionFromAnnotation(Annotation annotation) {
        // lets try the 'value()' method
        try {
View Full Code Here

Examples of org.apache.camel.spi.Language.createExpression()

     * Asserts that the expression evaluates to one of the two given values
     */
    protected void assertExpression(String expressionText, String expectedValue, String orThisExpectedValue) {
        Language language = assertResolveLanguage(getLanguageName());

        Expression<Exchange> expression = language.createExpression(expressionText);
        assertNotNull("No Expression could be created for text: " + expressionText + " language: " + language, expression);
       
        Object value = expression.evaluate(exchange);

        // lets try convert to the type of the expected
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.