You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2018/10/12 07:55:19 UTC
[camel] 05/43: [CAMEL-10535] Remove simple backwards parser
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2db8c73915b250a6fb689f54ef32aa1ded4663c6
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Sep 10 08:36:55 2018 +0200
[CAMEL-10535] Remove simple backwards parser
---
.../camel/builder/ExpressionClauseSupport.java | 2 +-
.../simple/SimpleBackwardsCompatibleParser.java | 75 -------------
.../camel/language/simple/SimpleLanguage.java | 20 ++--
.../ControlBusLanguageSimpleStartRouteTest.java | 8 +-
.../simple/SimpleBackwardsCompatibleTest.java | 10 +-
.../apache/camel/language/simple/SimpleTest.java | 120 ++++++++++-----------
.../language/simple/SimpleWhiteSpaceTest.java | 10 +-
.../apache/camel/processor/CorrectRouteIdTest.java | 6 +-
.../camel/processor/SetBodyProcessorTest.java | 2 +-
.../util/DumpModelAsXmlSplitBodyRouteTest.java | 2 +-
10 files changed, 77 insertions(+), 178 deletions(-)
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index 79347d4..d815f2c 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -112,7 +112,7 @@ public class ExpressionClauseSupport<T> {
*/
public T body() {
// reuse simple as this allows the model to represent this as a known JAXB type
- return expression(new SimpleExpression("body"));
+ return expression(new SimpleExpression("${body}"));
}
/**
diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleParser.java b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleParser.java
deleted file mode 100644
index f730bbf..0000000
--- a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleParser.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.language.simple;
-
-import org.apache.camel.Expression;
-import org.apache.camel.Predicate;
-import org.apache.camel.language.simple.ast.SimpleFunctionExpression;
-import org.apache.camel.language.simple.types.SimpleToken;
-import org.apache.camel.language.simple.types.SimpleTokenType;
-import org.apache.camel.language.simple.types.TokenType;
-import org.apache.camel.util.ExpressionToPredicateAdapter;
-
-/**
- * A backwards compatible parser, which supports the old simple language
- * syntax by which simple functions can be given without using start and
- * end tokens.
- * <p/>
- * For example "body" would be parsed as the body function, where as the
- * new parser would require that to be entered as "${body}".
- * <p/>
- * This parser is to be removed when the old syntax is no longer supported.
- *
- * @deprecated will be removed in Camel 3.0
- */
-@Deprecated
-public final class SimpleBackwardsCompatibleParser {
-
- private SimpleBackwardsCompatibleParser() {
- // static methods
- }
-
- public static Expression parseExpression(String expression, boolean allowEscape) {
- return doParseExpression(expression, allowEscape);
- }
-
- public static Predicate parsePredicate(String expression, boolean allowEscape) {
- Expression answer = doParseExpression(expression, allowEscape);
- if (answer != null) {
- return ExpressionToPredicateAdapter.toPredicate(answer);
- } else {
- return null;
- }
- }
-
- private static Expression doParseExpression(String expression, boolean allowEscape) {
- // should have no function tokens
- for (int i = 0; i < expression.length(); i++) {
- SimpleToken token = SimpleTokenizer.nextToken(expression, i, allowEscape, TokenType.functionStart, TokenType.functionEnd);
- if (token.getType().getType() == TokenType.functionStart || token.getType().getType() == TokenType.functionEnd) {
- return null;
- }
- }
-
- // okay there is no function tokens, then try to parse it as a simple function expression
- SimpleToken token = new SimpleToken(new SimpleTokenType(TokenType.functionStart, expression), 0);
- SimpleFunctionExpression function = new SimpleFunctionExpression(token);
- function.addText(expression);
- return function.createExpression(expression, false);
- }
-
-}
diff --git a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
index 059ecf3..8c54503 100644
--- a/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
+++ b/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
@@ -158,13 +158,9 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
expression = loadResource(expression);
- // support old simple language syntax
- answer = SimpleBackwardsCompatibleParser.parsePredicate(expression, allowEscape);
- if (answer == null) {
- // use the new parser
- SimplePredicateParser parser = new SimplePredicateParser(expression, allowEscape, cacheExpression);
- answer = parser.parsePredicate();
- }
+ SimplePredicateParser parser = new SimplePredicateParser(expression, allowEscape, cacheExpression);
+ answer = parser.parsePredicate();
+
if (cachePredicate != null && answer != null) {
cachePredicate.put(expression, answer);
}
@@ -182,13 +178,9 @@ public class SimpleLanguage extends LanguageSupport implements StaticService {
expression = loadResource(expression);
- // support old simple language syntax
- answer = SimpleBackwardsCompatibleParser.parseExpression(expression, allowEscape);
- if (answer == null) {
- // use the new parser
- SimpleExpressionParser parser = new SimpleExpressionParser(expression, allowEscape, cacheExpression);
- answer = parser.parseExpression();
- }
+ SimpleExpressionParser parser = new SimpleExpressionParser(expression, allowEscape, cacheExpression);
+ answer = parser.parseExpression();
+
if (cacheExpression != null && answer != null) {
cacheExpression.put(expression, answer);
}
diff --git a/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusLanguageSimpleStartRouteTest.java b/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusLanguageSimpleStartRouteTest.java
index e949065..afb62c4 100644
--- a/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusLanguageSimpleStartRouteTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/controlbus/ControlBusLanguageSimpleStartRouteTest.java
@@ -34,12 +34,12 @@ public class ControlBusLanguageSimpleStartRouteTest extends ContextTestSupport {
template.sendBody("seda:foo", "Hello World");
// start the route using control bus
- template.sendBody("controlbus:language:simple", "camelContext.startRoute('foo')");
+ template.sendBody("controlbus:language:simple", "${camelContext.startRoute('foo')}");
assertMockEndpointsSatisfied();
// now stop the route, using a header
- template.sendBodyAndHeader("controlbus:language:simple", "camelContext.stopRoute(header.me)", "me", "foo");
+ template.sendBodyAndHeader("controlbus:language:simple", "${camelContext.stopRoute(${header.me})}", "me", "foo");
assertEquals("Stopped", context.getRouteStatus("foo").name());
}
@@ -48,12 +48,12 @@ public class ControlBusLanguageSimpleStartRouteTest extends ContextTestSupport {
public void testControlBusStatus() throws Exception {
assertEquals("Stopped", context.getRouteStatus("foo").name());
- String status = template.requestBody("controlbus:language:simple", "camelContext.getRouteStatus('foo')", String.class);
+ String status = template.requestBody("controlbus:language:simple", "${camelContext.getRouteStatus('foo')}", String.class);
assertEquals("Stopped", status);
context.startRoute("foo");
- status = template.requestBody("controlbus:language:simple", "camelContext.getRouteStatus('foo')", String.class);
+ status = template.requestBody("controlbus:language:simple", "${camelContext.getRouteStatus('foo')}", String.class);
assertEquals("Started", status);
}
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleTest.java
index db5b27e..3fba79c 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleBackwardsCompatibleTest.java
@@ -33,24 +33,18 @@ public class SimpleBackwardsCompatibleTest extends LanguageTestSupport {
@Test
public void testSimpleBody() throws Exception {
assertExpression(exchange, "${body}", "<hello id='m123'>world!</hello>");
- assertExpression(exchange, "$simple{body}", "<hello id='m123'>world!</hello>");
- assertExpression(exchange, "body", "<hello id='m123'>world!</hello>");
assertPredicate("${body}", true);
- assertPredicate("body", true);
}
@Test
public void testSimpleHeader() throws Exception {
exchange.getIn().setHeader("foo", 123);
assertExpression(exchange, "${header.foo}", 123);
- assertExpression(exchange, "header.foo", 123);
assertPredicate("${header.foo}", true);
- assertPredicate("header.foo", true);
assertPredicate("${header.unknown}", false);
- assertPredicate("header.unknown", false);
}
@Test
@@ -59,7 +53,7 @@ public class SimpleBackwardsCompatibleTest extends LanguageTestSupport {
exchange.getIn().setHeader("high", true);
exchange.getIn().setHeader("foo", 123);
- SimplePredicateParser parser = new SimplePredicateParser("${header.high} == true and ${header.foo} == 123", true);
+ SimplePredicateParser parser = new SimplePredicateParser("${header.high} == true && ${header.foo} == 123", true, null);
Predicate pre = parser.parsePredicate();
assertTrue("Should match", pre.matches(exchange));
@@ -71,7 +65,7 @@ public class SimpleBackwardsCompatibleTest extends LanguageTestSupport {
exchange.getIn().setHeader("high", true);
exchange.getIn().setHeader("foo", 123);
- SimplePredicateParser parser = new SimplePredicateParser("${header.high} == false or ${header.foo} == 123", true);
+ SimplePredicateParser parser = new SimplePredicateParser("${header.high} == false || ${header.foo} == 123", true, null);
Predicate pre = parser.parsePredicate();
assertTrue("Should match", pre.matches(exchange));
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 69505cd..e775d8e 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -94,12 +94,9 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testRefExpression() throws Exception {
- assertExpressionResultInstanceOf("ref:myAnimal", Animal.class);
assertExpressionResultInstanceOf("${ref:myAnimal}", Animal.class);
- assertExpression("ref:myAnimal", "Donkey");
assertExpression("${ref:myAnimal}", "Donkey");
- assertExpression("ref:unknown", null);
assertExpression("${ref:unknown}", null);
assertExpression("Hello ${ref:myAnimal}", "Hello Donkey");
assertExpression("Hello ${ref:unknown}", "Hello ");
@@ -147,7 +144,7 @@ public class SimpleTest extends LanguageTestSupport {
assertNotNull(exp);
assertEquals(exchange, exp.evaluate(exchange, Object.class));
- assertExpression("exchange", exchange);
+ assertExpression("${exchange}", exchange);
}
@Test
@@ -156,8 +153,8 @@ public class SimpleTest extends LanguageTestSupport {
assertNotNull(exp);
assertEquals(exchange.getExchangeId(), exp.evaluate(exchange, Object.class));
- assertExpression("exchange.exchangeId", exchange.getExchangeId());
- assertExpression("exchange.class.name", "org.apache.camel.impl.DefaultExchange");
+ assertExpression("${exchange.exchangeId}", exchange.getExchangeId());
+ assertExpression("${exchange.class.name}", "org.apache.camel.impl.DefaultExchange");
}
@Test
@@ -199,12 +196,12 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testBodyExpressionWithArray() throws Exception {
exchange.getIn().setBody(new MyClass());
- Expression exp = SimpleLanguage.simple("body.myArray");
+ Expression exp = SimpleLanguage.simple("${body.myArray}");
assertNotNull(exp);
Object val = exp.evaluate(exchange, Object.class);
assertIsInstanceOf(Object[].class, val);
- exp = SimpleLanguage.simple("body.myArray.length");
+ exp = SimpleLanguage.simple("${body.myArray.length}");
assertNotNull(exp);
val = exp.evaluate(exchange, Object.class);
assertIsInstanceOf(Integer.class, val);
@@ -213,31 +210,31 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testSimpleExpressions() throws Exception {
- assertExpression("exchangeId", exchange.getExchangeId());
- assertExpression("id", exchange.getIn().getMessageId());
- assertExpression("body", "<hello id='m123'>world!</hello>");
- assertExpression("in.body", "<hello id='m123'>world!</hello>");
- assertExpression("in.header.foo", "abc");
- assertExpression("in.headers.foo", "abc");
- assertExpression("header.foo", "abc");
- assertExpression("headers.foo", "abc");
- assertExpression("routeId", exchange.getFromRouteId());
+ assertExpression("${exchangeId}", exchange.getExchangeId());
+ assertExpression("${id}", exchange.getIn().getMessageId());
+ assertExpression("${body}", "<hello id='m123'>world!</hello>");
+ assertExpression("${in.body}", "<hello id='m123'>world!</hello>");
+ assertExpression("${in.header.foo}", "abc");
+ assertExpression("${in.headers.foo}", "abc");
+ assertExpression("${header.foo}", "abc");
+ assertExpression("${headers.foo}", "abc");
+ assertExpression("${routeId}", exchange.getFromRouteId());
exchange.setFromRouteId("myRouteId");
- assertExpression("routeId", "myRouteId");
+ assertExpression("${routeId}", "myRouteId");
}
@Test
public void testTrimSimpleExpressions() throws Exception {
- assertExpression(" \texchangeId\n".trim(), exchange.getExchangeId());
- assertExpression("\nid\r".trim(), exchange.getIn().getMessageId());
- assertExpression("\t\r body".trim(), "<hello id='m123'>world!</hello>");
- assertExpression("\nin.body\r".trim(), "<hello id='m123'>world!</hello>");
+ assertExpression(" \t${exchangeId}\n".trim(), exchange.getExchangeId());
+ assertExpression("\n${id}\r".trim(), exchange.getIn().getMessageId());
+ assertExpression("\t\r ${body}".trim(), "<hello id='m123'>world!</hello>");
+ assertExpression("\n${in.body}\r".trim(), "<hello id='m123'>world!</hello>");
}
@Test
public void testSimpleThreadName() throws Exception {
String name = Thread.currentThread().getName();
- assertExpression("threadName", name);
+ assertExpression("${threadName}", name);
assertExpression("The name is ${threadName}", "The name is " + name);
}
@@ -245,34 +242,34 @@ public class SimpleTest extends LanguageTestSupport {
public void testSimpleOutExpressions() throws Exception {
exchange.getOut().setBody("Bye World");
exchange.getOut().setHeader("quote", "Camel rocks");
- assertExpression("out.body", "Bye World");
- assertExpression("out.header.quote", "Camel rocks");
- assertExpression("out.headers.quote", "Camel rocks");
+ assertExpression("${out.body}", "Bye World");
+ assertExpression("${out.header.quote}", "Camel rocks");
+ assertExpression("${out.headers.quote}", "Camel rocks");
}
@Test
public void testSimplePropertyExpressions() throws Exception {
exchange.setProperty("medal", "gold");
- assertExpression("property.medal", "gold");
+ assertExpression("${property.medal}", "gold");
}
@Test
public void testSimpleExchangePropertyExpressions() throws Exception {
exchange.setProperty("medal", "gold");
- assertExpression("exchangeProperty.medal", "gold");
+ assertExpression("${exchangeProperty.medal}", "gold");
}
@Test
public void testSimpleSystemPropertyExpressions() throws Exception {
System.setProperty("who", "I was here");
- assertExpression("sys.who", "I was here");
+ assertExpression("${sys.who}", "I was here");
}
@Test
public void testSimpleSystemEnvironmentExpressions() throws Exception {
String path = System.getenv("PATH");
if (path != null) {
- assertExpression("sysenv.PATH", path);
+ assertExpression("${sysenv.PATH}", path);
}
}
@@ -280,13 +277,13 @@ public class SimpleTest extends LanguageTestSupport {
public void testSimpleSystemEnvironmentExpressionsIfLowercase() throws Exception {
String path = System.getenv("PATH");
if (path != null) {
- assertExpression("sysenv.path", path);
+ assertExpression("${sysenv.path}", path);
}
}
@Test
public void testSimpleCamelId() throws Exception {
- assertExpression("camelId", context.getName());
+ assertExpression("${camelId}", context.getName());
}
@Test
@@ -554,24 +551,24 @@ public class SimpleTest extends LanguageTestSupport {
propertyCalendar.set(1976, Calendar.JUNE, 22);
exchange.setProperty("birthday", propertyCalendar.getTime());
- assertExpression("date:header.birthday", inHeaderCalendar.getTime());
- assertExpression("date:header.birthday:yyyyMMdd", "19740420");
- assertExpression("date:header.birthday+24h:yyyyMMdd", "19740421");
+ assertExpression("${date:header.birthday}", inHeaderCalendar.getTime());
+ assertExpression("${date:header.birthday:yyyyMMdd}", "19740420");
+ assertExpression("${date:header.birthday+24h:yyyyMMdd}", "19740421");
- assertExpression("date:in.header.birthday", inHeaderCalendar.getTime());
- assertExpression("date:in.header.birthday:yyyyMMdd", "19740420");
- assertExpression("date:in.header.birthday+24h:yyyyMMdd", "19740421");
+ assertExpression("${date:in.header.birthday}", inHeaderCalendar.getTime());
+ assertExpression("${date:in.header.birthday:yyyyMMdd}", "19740420");
+ assertExpression("${date:in.header.birthday+24h:yyyyMMdd}", "19740421");
- assertExpression("date:out.header.birthday", outHeaderCalendar.getTime());
- assertExpression("date:out.header.birthday:yyyyMMdd", "19750521");
- assertExpression("date:out.header.birthday+24h:yyyyMMdd", "19750522");
+ assertExpression("${date:out.header.birthday}", outHeaderCalendar.getTime());
+ assertExpression("${date:out.header.birthday:yyyyMMdd}", "19750521");
+ assertExpression("${date:out.header.birthday+24h:yyyyMMdd}", "19750522");
- assertExpression("date:property.birthday", propertyCalendar.getTime());
- assertExpression("date:property.birthday:yyyyMMdd", "19760622");
- assertExpression("date:property.birthday+24h:yyyyMMdd", "19760623");
+ assertExpression("${date:property.birthday}", propertyCalendar.getTime());
+ assertExpression("${date:property.birthday:yyyyMMdd}", "19760622");
+ assertExpression("${date:property.birthday+24h:yyyyMMdd}", "19760623");
try {
- assertExpression("date:yyyyMMdd", "19740420");
+ assertExpression("${date:yyyyMMdd}", "19740420");
fail("Should thrown an exception");
} catch (IllegalArgumentException e) {
assertEquals("Command not supported for dateExpression: yyyyMMdd", e.getMessage());
@@ -585,8 +582,8 @@ public class SimpleTest extends LanguageTestSupport {
cal.set(Calendar.MILLISECOND, 123);
exchange.getIn().setHeader("birthday", cal.getTime());
- assertExpression("date:header.birthday - 10s:yyyy-MM-dd'T'HH:mm:ss:SSS", "1974-04-20T08:55:37:123");
- assertExpression("date:header.birthday:yyyy-MM-dd'T'HH:mm:ss:SSS", "1974-04-20T08:55:47:123");
+ assertExpression("${date:header.birthday - 10s:yyyy-MM-dd'T'HH:mm:ss:SSS}", "1974-04-20T08:55:37:123");
+ assertExpression("${date:header.birthday:yyyy-MM-dd'T'HH:mm:ss:SSS}", "1974-04-20T08:55:47:123");
}
@Test
@@ -597,8 +594,8 @@ public class SimpleTest extends LanguageTestSupport {
cal.set(Calendar.MILLISECOND, 123);
exchange.getIn().setHeader("birthday", cal.getTime());
- assertExpression("date-with-timezone:header.birthday:GMT+8:yyyy-MM-dd'T'HH:mm:ss:SSS", "1974-04-20T08:55:47:123");
- assertExpression("date-with-timezone:header.birthday:GMT:yyyy-MM-dd'T'HH:mm:ss:SSS", "1974-04-20T00:55:47:123");
+ assertExpression("${date-with-timezone:header.birthday:GMT+8:yyyy-MM-dd'T'HH:mm:ss:SSS}", "1974-04-20T08:55:47:123");
+ assertExpression("${date-with-timezone:header.birthday:GMT:yyyy-MM-dd'T'HH:mm:ss:SSS}", "1974-04-20T00:55:47:123");
}
@Test
@@ -616,7 +613,7 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testLanguagesInContext() throws Exception {
// evaluate so we know there is 1 language in the context
- assertExpression("id", exchange.getIn().getMessageId());
+ assertExpression("${id}", exchange.getIn().getMessageId());
assertEquals(1, context.getLanguageNames().size());
assertEquals("simple", context.getLanguageNames().get(0));
@@ -656,15 +653,15 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testPredicates() throws Exception {
- assertPredicate("body");
- assertPredicate("header.foo");
- assertPredicate("header.madeUpHeader", false);
+ assertPredicate("${body}");
+ assertPredicate("${header.foo}");
+ assertPredicate("${header.madeUpHeader}", false);
}
@Test
public void testExceptionMessage() throws Exception {
exchange.setException(new IllegalArgumentException("Just testing"));
- assertExpression("exception.message", "Just testing");
+ assertExpression("${exception.message}", "Just testing");
assertExpression("Hello ${exception.message} World", "Hello Just testing World");
}
@@ -672,7 +669,7 @@ public class SimpleTest extends LanguageTestSupport {
public void testExceptionStacktrace() throws Exception {
exchange.setException(new IllegalArgumentException("Just testing"));
- String out = SimpleLanguage.simple("exception.stacktrace").evaluate(exchange, String.class);
+ String out = SimpleLanguage.simple("${exception.stacktrace}").evaluate(exchange, String.class);
assertNotNull(out);
assertTrue(out.startsWith("java.lang.IllegalArgumentException: Just testing"));
assertTrue(out.contains("at org.apache.camel.language."));
@@ -682,7 +679,7 @@ public class SimpleTest extends LanguageTestSupport {
public void testException() throws Exception {
exchange.setException(new IllegalArgumentException("Just testing"));
- Exception out = SimpleLanguage.simple("exception").evaluate(exchange, Exception.class);
+ Exception out = SimpleLanguage.simple("${exception}").evaluate(exchange, Exception.class);
assertNotNull(out);
assertIsInstanceOf(IllegalArgumentException.class, out);
assertEquals("Just testing", out.getMessage());
@@ -740,10 +737,6 @@ public class SimpleTest extends LanguageTestSupport {
// set an empty body
exchange.getIn().setBody(null);
- assertExpression("header.foo", "abc");
- assertExpression("headers.foo", "abc");
- assertExpression("in.header.foo", "abc");
- assertExpression("in.headers.foo", "abc");
assertExpression("${header.foo}", "abc");
assertExpression("${headers.foo}", "abc");
assertExpression("${in.header.foo}", "abc");
@@ -752,7 +745,6 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testHeadersWithBracket() throws Exception {
- assertExpression("headers[foo]", "abc");
assertExpression("${headers[foo]}", "abc");
assertExpression("${in.headers[foo]}", "abc");
}
@@ -767,7 +759,6 @@ public class SimpleTest extends LanguageTestSupport {
private void assertOnglOnHeadersWithSquareBrackets(String key) {
exchange.getIn().setHeader(key, new OrderLine(123, "Camel in Action"));
- assertExpression("headers[" + key + "].name", "Camel in Action");
assertExpression("${headers[" + key + "].name}", "Camel in Action");
assertExpression("${in.headers[" + key + "].name}", "Camel in Action");
assertExpression("${in.headers['" + key + "'].name}", "Camel in Action");
@@ -783,8 +774,7 @@ public class SimpleTest extends LanguageTestSupport {
public void assertOnglOnExchangePropertiesWithBracket(String key) throws Exception {
exchange.setProperty(key, new OrderLine(123, "Camel in Action"));
- assertExpression("exchangeProperty[" + key + "].name", "Camel in Action");
- assertExpression("${exchangeProperty[" + key + "].name}", "Camel in Action");
+ assertExpression("${exchangeProperty[" + key + "].name}", "Camel in Action");
assertExpression("${exchangeProperty['" + key + "'].name}", "Camel in Action");
}
@@ -806,9 +796,7 @@ public class SimpleTest extends LanguageTestSupport {
Map<String, Object> headers = exchange.getIn().getHeaders();
assertEquals(2, headers.size());
- assertExpression("headers", headers);
assertExpression("${headers}", headers);
- assertExpression("in.headers", headers);
assertExpression("${in.headers}", headers);
}
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleWhiteSpaceTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleWhiteSpaceTest.java
index 87fb01a..a33e7bc 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleWhiteSpaceTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleWhiteSpaceTest.java
@@ -29,31 +29,31 @@ public class SimpleWhiteSpaceTest extends LanguageTestSupport {
@Test
public void testExpressionWithSpace() {
exchange.getIn().setBody("some text");
- assertPredicate("${in.body} contains 'some' and ${in.body} contains 'text'", true);
+ assertPredicate("${in.body} contains 'some' && ${in.body} contains 'text'", true);
}
@Test
public void testExpressionWithTabs() {
exchange.getIn().setBody("some text");
- assertPredicate("${in.body} contains 'some' and\t${in.body} contains 'text'", true);
+ assertPredicate("${in.body} contains 'some' &&\t${in.body} contains 'text'", true);
}
@Test
public void testUnixMultiLineExpression() {
exchange.getIn().setBody("some text");
- assertPredicate("${in.body} contains 'some' and\n${in.body} contains 'text'", true);
+ assertPredicate("${in.body} contains 'some' &&\n${in.body} contains 'text'", true);
}
@Test
public void testWindowsMultiLineExpression() {
exchange.getIn().setBody("some text");
- assertPredicate("${in.body} contains 'some' and\r\n${in.body} contains 'text'", true);
+ assertPredicate("${in.body} contains 'some' &&\r\n${in.body} contains 'text'", true);
}
@Test
public void testMacMultiLineExpression() {
exchange.getIn().setBody("some text");
- assertPredicate("${in.body} contains 'some' and\r${in.body} contains 'text'", true);
+ assertPredicate("${in.body} contains 'some' &&\r${in.body} contains 'text'", true);
}
@Test
diff --git a/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java b/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java
index f17b175..17d17f4 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/CorrectRouteIdTest.java
@@ -39,18 +39,18 @@ public class CorrectRouteIdTest extends ContextTestSupport {
@Override
public void configure() throws Exception {
from("direct:foo").routeId("foo")
- .setHeader("foo").simple("routeId")
+ .setHeader("foo").simple("${routeId}")
.to("mock:foo")
.to("seda:bar")
.to("mock:result");
from("seda:bar").routeId("bar")
- .setHeader("bar").simple("routeId")
+ .setHeader("bar").simple("${routeId}")
.to("mock:bar")
.to("direct:baz");
from("direct:baz").routeId("baz")
- .setHeader("baz").simple("routeId")
+ .setHeader("baz").simple("${routeId}")
.to("mock:baz");
}
};
diff --git a/camel-core/src/test/java/org/apache/camel/processor/SetBodyProcessorTest.java b/camel-core/src/test/java/org/apache/camel/processor/SetBodyProcessorTest.java
index e87fd7f..34a7ed5 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/SetBodyProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/SetBodyProcessorTest.java
@@ -86,7 +86,7 @@ public class SetBodyProcessorTest extends ContextTestSupport {
.to("mock:result");
from("direct:start2")
- .setBody(simple("header.text.replace('a','b')")).to("mock:test");
+ .setBody(simple("${header.text.replace('a','b')}")).to("mock:test");
}
};
}
diff --git a/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java b/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
index 15f0531..60bf1cd 100644
--- a/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
@@ -42,7 +42,7 @@ public class DumpModelAsXmlSplitBodyRouteTest extends ContextTestSupport {
assertEquals(1, nodes.getLength());
Element node = (Element)nodes.item(0);
assertNotNull("Node <simple> expected to be instanceof Element", node);
- assertEquals("body", node.getTextContent());
+ assertEquals("${body}", node.getTextContent());
nodes = doc.getElementsByTagName("split");
assertEquals(1, nodes.getLength());