You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/06/16 07:04:08 UTC
svn commit: r785080 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/language/simple/
camel-core/src/test/java/org/apache/camel/language/
components/camel-spring/src/main/java/org/apache/camel/spring/spi/
Author: davsclaus
Date: Tue Jun 16 05:04:08 2009
New Revision: 785080
URL: http://svn.apache.org/viewvc?rev=785080&view=rev
Log:
CAMEL-1716: Fixed simple language operator being greedy. Thanks to Oliver Hecker for patch.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleOperatorTest.java
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java?rev=785080&r1=785079&r2=785080&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java Tue Jun 16 05:04:08 2009
@@ -42,7 +42,7 @@
// this is a regex for a given group in a simple expression that uses operators
protected static final String GROUP_PATTERN =
- "\\$\\{(\\S+)\\}\\s+(==|>|>=|<|<=|!=|contains|not contains|regex|not regex|in|not in|is|not is|range|not range)\\s+('.*'|\\S+)";
+ "\\$\\{(\\S+)\\}\\s+(==|>|>=|<|<=|!=|contains|not contains|regex|not regex|in|not in|is|not is|range|not range)\\s+('.*?'|\\S+)";
// this is the operator reg ex pattern used to match if a given expression is operator based or not
protected static final Pattern PATTERN = Pattern.compile("^(" + GROUP_PATTERN + ")(\\s+(and|or)\\s+(" + GROUP_PATTERN + "))?$");
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleOperatorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleOperatorTest.java?rev=785080&r1=785079&r2=785080&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleOperatorTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/SimpleOperatorTest.java Tue Jun 16 05:04:08 2009
@@ -47,6 +47,16 @@
assertExpression("${in.header.foo} == abc and ${in.header.bar} < 200", true);
}
+ public void testAndWithQuotation() throws Exception {
+ assertExpression("${in.header.foo} == 'abc' and ${in.header.bar} == '123'", true);
+ assertExpression("${in.header.foo} == 'abc' and ${in.header.bar} == '444'", false);
+ assertExpression("${in.header.foo} == 'def' and ${in.header.bar} == '123'", false);
+ assertExpression("${in.header.foo} == 'def' and ${in.header.bar} == '444'", false);
+
+ assertExpression("${in.header.foo} == 'abc' and ${in.header.bar} > '100'", true);
+ assertExpression("${in.header.foo} == 'abc' and ${in.header.bar} < '200'", true);
+ }
+
public void testOr() throws Exception {
assertExpression("${in.header.foo} == abc or ${in.header.bar} == 123", true);
assertExpression("${in.header.foo} == abc or ${in.header.bar} == 444", true);
@@ -59,6 +69,18 @@
assertExpression("${in.header.foo} == def or ${in.header.bar} < 100", false);
}
+ public void testOrWithQuotation() throws Exception {
+ assertExpression("${in.header.foo} == 'abc' or ${in.header.bar} == '123'", true);
+ assertExpression("${in.header.foo} == 'abc' or ${in.header.bar} == '444'", true);
+ assertExpression("${in.header.foo} == 'def' or ${in.header.bar} == '123'", true);
+ assertExpression("${in.header.foo} == 'def' or ${in.header.bar} == '444'", false);
+
+ assertExpression("${in.header.foo} == 'abc' or ${in.header.bar} < '100'", true);
+ assertExpression("${in.header.foo} == 'abc' or ${in.header.bar} < '200'", true);
+ assertExpression("${in.header.foo} == 'def' or ${in.header.bar} < '200'", true);
+ assertExpression("${in.header.foo} == 'def' or ${in.header.bar} < '100'", false);
+ }
+
public void testEqualOperator() throws Exception {
// string to string comparison
assertExpression("${in.header.foo} == 'abc'", true);
Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java?rev=785080&r1=785079&r2=785080&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandlerBuilder.java Tue Jun 16 05:04:08 2009
@@ -56,7 +56,7 @@
public Processor createErrorHandler(RouteContext routeContext, Processor processor) throws Exception {
if (transactionTemplate == null) {
// lookup in context if no transaction template has been configured
- LOG.debug("No TransactionTemplate configured on TransactedErrorHandlerBuilder. Will try find it in the registry.");
+ LOG.debug("No TransactionTemplate configured on TransactionErrorHandlerBuilder. Will try find it in the registry.");
if (transactionTemplate == null) {
Map<String, TransactedPolicy> map = routeContext.lookupByType(TransactedPolicy.class);
@@ -81,10 +81,10 @@
transactionTemplate = map.values().iterator().next();
} else if (LOG.isDebugEnabled()) {
if (map == null || map.isEmpty()) {
- LOG.debug("No TransactionTemplate found in registry.");
+ LOG.trace("No TransactionTemplate found in registry.");
} else {
LOG.debug("Found " + map.size() + " TransactionTemplate in registry. "
- + "Cannot determine which one to use. Please configure a TransactionTemplate on the TransactedErrorHandlerBuilder");
+ + "Cannot determine which one to use. Please configure a TransactionTemplate on the TransactionErrorHandlerBuilder");
}
}
}
@@ -95,10 +95,10 @@
transactionTemplate = new TransactionTemplate(map.values().iterator().next());
} else if (LOG.isDebugEnabled()) {
if (map == null || map.isEmpty()) {
- LOG.debug("No PlatformTransactionManager found in registry.");
+ LOG.trace("No PlatformTransactionManager found in registry.");
} else {
LOG.debug("Found " + map.size() + " PlatformTransactionManager in registry. "
- + "Cannot determine which one to use for TransactionTemplate. Please configure a TransactionTemplate on the TransactedErrorHandlerBuilder");
+ + "Cannot determine which one to use for TransactionTemplate. Please configure a TransactionTemplate on the TransactionErrorHandlerBuilder");
}
}
}
@@ -108,7 +108,7 @@
}
}
- ObjectHelper.notNull(transactionTemplate, "transactionTemplate");
+ ObjectHelper.notNull(transactionTemplate, "transactionTemplate", this);
TransactionErrorHandler answer = new TransactionErrorHandler(processor, getLogger(), getOnRedelivery(),
getRedeliveryPolicy(), getHandledPolicy(), getExceptionPolicyStrategy(), transactionTemplate);