This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch mock in repository https://gitbox.apache.org/repos/asf/camel.git
commit e24fc7af6aec760f5fc9c71e714fb506d667accb Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Apr 16 11:59:02 2019 +0200 Move mock component out of camel-core. Work in progress. --- .../apache/camel/builder/ExpressionBuilder.java | 26 ---------------------- .../org/apache/camel/builder/ValueBuilder.java | 5 ++--- .../camel/component/mock/AssertionClause.java | 2 ++ .../language/simple/SimpleExpressionBuilder.java | 8 +++---- .../camel/support/language/ExpressionModel.java | 12 +++++++--- 5 files changed, 17 insertions(+), 36 deletions(-) diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java index 18ca79a..ed3f8691 100644 --- a/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java +++ b/core/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java @@ -36,7 +36,6 @@ import org.apache.camel.Message; import org.apache.camel.NoSuchLanguageException; import org.apache.camel.RuntimeCamelException; import org.apache.camel.RuntimeExchangeException; -import org.apache.camel.model.language.MethodCallExpression; import org.apache.camel.spi.Language; import org.apache.camel.spi.PropertiesComponent; import org.apache.camel.spi.RouteContext; @@ -814,31 +813,6 @@ public final class ExpressionBuilder { } /** - * Returns the expression for invoking a method (support OGNL syntax) on the given expression - * - * @param exp the expression to evaluate and invoke the method on its result - * @param ognl methods to invoke on the evaluated expression in a simple OGNL syntax - */ - public static Expression ognlExpression(final Expression exp, final String ognl) { - return new ExpressionAdapter() { - public Object evaluate(Exchange exchange) { - Object value = exp.evaluate(exchange, Object.class); - if (value == null) { - return null; - } - // ognl is able to evaluate method name if it contains nested functions - // so we should not eager evaluate ognl as a string - return new MethodCallExpression(value, ognl).evaluate(exchange); - } - - @Override - public String toString() { - return "ognl(" + exp + ", " + ognl + ")"; - } - }; - } - - /** * Returns the expression for the exchanges inbound message body converted * to the given type */ diff --git a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java index c8ac6cb..b521537 100644 --- a/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java +++ b/core/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java @@ -337,14 +337,13 @@ public class ValueBuilder implements Expression, Predicate { } /** - * Invokes the method with the given name (supports OGNL syntax). + * Invokes the method with the given name. * * @param methodName name of method to invoke. * @return the current builder */ public ValueBuilder method(String methodName) { - // TODO: find alternative - Expression newExp = ExpressionBuilder.ognlExpression(expression, methodName); + Expression newExp = ExpressionBuilder.beanExpression(expression + "?method=" + methodName); return onNewValueBuilder(newExp); } diff --git a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java index 5556cba..53e5d40 100644 --- a/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java +++ b/core/camel-core/src/main/java/org/apache/camel/component/mock/AssertionClause.java @@ -34,6 +34,8 @@ import org.apache.camel.support.language.ExpressionModel; */ public abstract class AssertionClause extends MockExpressionClauseSupport<ValueBuilder> implements Runnable { + // TODO: MockValueBuilder + protected final MockEndpoint mock; protected volatile int currentIndex; private final Set<Predicate> predicates = new LinkedHashSet<>(); diff --git a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java index 8189149..73117ff 100644 --- a/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java +++ b/core/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionBuilder.java @@ -1,13 +1,13 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java b/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java index 9b812f1..4861651 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/language/ExpressionModel.java @@ -19,11 +19,17 @@ package org.apache.camel.support.language; import org.apache.camel.CamelContext; import org.apache.camel.Expression; +/** + * Represents a model that can be created as an expression (eg language). + */ public interface ExpressionModel { - // TODO: move to api, and maybe have a @FunctionalInterface - + /** + * Creates an expression + * + * @param camelContext the camel context + * @return the created expression. + */ Expression createExpression(CamelContext camelContext); - }