You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by dc...@apache.org on 2010/06/08 15:58:16 UTC
svn commit: r952651 - in /ode/trunk/bpel-compiler/src:
main/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImpl.java
test/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImplTest.java
Author: dcarver
Date: Tue Jun 8 13:58:15 2010
New Revision: 952651
URL: http://svn.apache.org/viewvc?rev=952651&view=rev
Log:
ODE-840 - Fix XPath extraction regex that caused regression from ODE-807 fix.
Modified:
ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImpl.java
ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImplTest.java
Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImpl.java?rev=952651&r1=952650&r2=952651&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImpl.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImpl.java Tue Jun 8 13:58:15 2010
@@ -256,7 +256,8 @@ public class XPath20ExpressionCompilerIm
private List<String> extractFunctionExprs(String xpathStr) {
ArrayList<String> functionExprs = new ArrayList<String>();
// Match the prefix : function name ( all contents except the ) and the closing )'s that may occur
- final String FUNCTION_REGEX = "\\w+:\\w+\\([.[^\\)]]*\\)*";
+// final String FUNCTION_REGEX = "\\w+:\\w+\\([.[^\\)]]*\\)*";
+ final String FUNCTION_REGEX = "(\\w+:)?\\w+\\((.+)?\\)";
int firstFunction = xpathStr.indexOf("("),
lastFunction = xpathStr.lastIndexOf("(");
if ((firstFunction > 0 && firstFunction < lastFunction)) {
Modified: ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImplTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImplTest.java?rev=952651&r1=952650&r2=952651&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImplTest.java (original)
+++ ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/elang/xpath20/compiler/XPath20ExpressionCompilerImplTest.java Tue Jun 8 13:58:15 2010
@@ -41,7 +41,7 @@ public class XPath20ExpressionCompilerIm
methods[i].setAccessible(true);
Object ret = methods[i].invoke(xp20Exp, params);
List<?> values = (List<?>) ret;
- Assert.assertEquals(0, values.size());
+ Assert.assertEquals(1, values.size());
}
}
}
@@ -70,17 +70,36 @@ public class XPath20ExpressionCompilerIm
xp20Exp.getClass().getDeclaredMethods();
for (int i = 0; i < methods.length; ++i) {
if (methods[i].getName().equals(EXTRACT_FUNCTION_EXPRS)) {
- final Object params[] = { "concat(current-date() + xs:dayTimeDuration(concat(\"P\", $DAYS_TO_NEXT_REMINDER, \"D\")), \"T\", \"08:30:00.000+08:00\")" };
+ String multipleFunctions = "concat(current-date() + xs:dayTimeDuration(concat(\"P\", $DAYS_TO_NEXT_REMINDER, \"D\")), \"T\", \"08:30:00.000+08:00\")";
+ final Object params[] = { multipleFunctions };
methods[i].setAccessible(true);
Object ret = methods[i].invoke(xp20Exp, params);
List<?> values = (List<?>) ret;
Assert.assertEquals(1, values.size());
- Assert.assertEquals("Unexpected Function value", "xs:dayTimeDuration(concat(\"P\", $DAYS_TO_NEXT_REMINDER, \"D\"))", (String)values.get(0));
+ Assert.assertEquals("Unexpected Function value", multipleFunctions, (String)values.get(0));
}
}
}
-
-
+
+ @Test
+ public void testExtractFunctionsExprs() throws Exception {
+ XPath20ExpressionCompilerImpl xp20Exp = new XPath20ExpressionCompilerImpl(TEST_NAMESPACE);
+ final Method[] methods =
+ xp20Exp.getClass().getDeclaredMethods();
+ String ODE_840 = "bpel:doXslTransform(\"1.0.1/some.xsl\", $Variable.body, \"someParameter\", $OtherVariable.body, \"someParameter2\", $SwsHeaderRQ, \"someParameter3\", true(), \"someXpathParameter\", $XPath)";
+
+ for (int i = 0; i < methods.length; ++i) {
+ if (methods[i].getName().equals(EXTRACT_FUNCTION_EXPRS)) {
+ final Object params[] = { ODE_840};
+ methods[i].setAccessible(true);
+ Object ret = methods[i].invoke(xp20Exp, params);
+ List<?> values = (List<?>) ret;
+ Assert.assertEquals(1, values.size());
+ Assert.assertEquals("Unexpected Function value", ODE_840, (String)values.get(0));
+ }
+ }
+
+ }
}