You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/01/03 07:23:36 UTC

svn commit: r492057 - in /incubator/ode/trunk: bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-obj/src/main/java/org/apache/ode/bpel/o/ bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/ bpel-runtime/src/main/java/org/...

Author: mszefler
Date: Tue Jan  2 22:23:35 2007
New Revision: 492057

URL: http://svn.apache.org/viewvc?view=rev&rev=492057
Log:
Fixed some tests that got out of date.
Report correct fault code when date/duration do not parse.


Modified:
    incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
    incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstants.java
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java
    incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java
    incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/Messages.java
    incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
    incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java
    incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/NegativeTargetNSTest1/test.properties
    incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestTimer/TestTimer.bpel

Modified: incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java (original)
+++ incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java Tue Jan  2 22:23:35 2007
@@ -638,6 +638,7 @@
         constants.qnUninitializedPartnerRole = new QName(getBpwsNamespace(), "uninitializedPartnerRole");
         constants.qnForEachCounterError = new QName(getBpwsNamespace(), "forEachCounterError");
         constants.qnInvalidBranchCondition = new QName(getBpwsNamespace(), "invalidBranchCondition");
+        constants.qnInvalidExpressionValue = new QName(getBpwsNamespace(), "invalidExpressionValue");
         return constants;
     }
 

Modified: incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstants.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstants.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstants.java (original)
+++ incubator/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OConstants.java Tue Jan  2 22:23:35 2007
@@ -41,6 +41,7 @@
     public QName qnUninitializedPartnerRole;
     public QName qnForEachCounterError;
     public QName qnInvalidBranchCondition;
+    public QName qnInvalidExpressionValue;
 
 
     public OConstants(OProcess owner) {

Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java Tue Jan  2 22:23:35 2007
@@ -46,136 +46,140 @@
  * XPath 1.0 Expression Language run-time subsytem.
  */
 public class XPath10ExpressionRuntime implements ExpressionLanguageRuntime {
-  /** Class-level logger. */
-  private static final Log __log = LogFactory.getLog(XPath10ExpressionRuntime.class);
+    /** Class-level logger. */
+    private static final Log __log = LogFactory.getLog(XPath10ExpressionRuntime.class);
 
-  /** Compiled expression cache. */
-  private final Map<String, XPath> _compiledExpressions = new HashMap<String, XPath>();
+    /** Compiled expression cache. */
+    private final Map<String, XPath> _compiledExpressions = new HashMap<String, XPath>();
 
-  /** Registered extension functions. */
-  private final Map _extensionFunctions  = new HashMap();
+    /** Registered extension functions. */
+    private final Map _extensionFunctions = new HashMap();
 
-  public void initialize(Map properties) throws ConfigurationException {
-  }
-
-  public String evaluateAsString(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
-    try {
-      return compile((OXPath10Expression) cexp).stringValueOf(createContext((OXPath10Expression) cexp, ctx));
-    } catch (JaxenException e) {
-      handleJaxenException(e);
-    }
-    throw new AssertionError("UNREACHABLE");
-  }
-
-  public boolean evaluateAsBoolean(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
-    try {
-      return compile((OXPath10Expression) cexp).booleanValueOf(createContext((OXPath10Expression) cexp, ctx));
-    } catch (JaxenException e) {
-      handleJaxenException(e);
-    }
-    throw new AssertionError("UNREACHABLE");
-  }
-
-  public Number evaluateAsNumber(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
-    try {
-      return compile((OXPath10Expression) cexp).numberValueOf(createContext((OXPath10Expression) cexp, ctx));
-    } catch (JaxenException e) {
-      handleJaxenException(e);
-    }
-    throw new AssertionError("UNREACHABLE");
-  }
-
-  public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
-    try {
-      XPath compiledXPath = compile((OXPath10Expression) cexp);
-      Context context = createContext((OXPath10Expression) cexp, ctx);
-
-      List retVal = compiledXPath.selectNodes(context);
-
-      if ((retVal.size() == 1) && !(retVal.get(0) instanceof Node)) {
-        Document d = DOMUtils.newDocument();
-        // Giving our node a parent just in case it's an LValue expression
-        Element wrapper = d.createElement("wrapper");
-        Text text = d.createTextNode(retVal.get(0).toString());
-        wrapper.appendChild(text);
-        d.appendChild(wrapper);
-        retVal = Collections.singletonList(text);
-      }
-
-      return retVal;
-
-    } catch (JaxenException je) {
-      handleJaxenException(je);
-    }
-    throw new AssertionError("UNREACHABLE");
-  }
-
-  public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
-    List retVal = evaluate(cexp, ctx);
-    if (retVal.size() == 0)
-      throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "No results for expression: " + cexp);
-    if (retVal.size() > 1)
-      throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "Multiple results for expression: " + cexp);
-    return (Node) retVal.get(0);
-  }
-
-  public Calendar evaluateAsDate(OExpression cexp, EvaluationContext context) throws FaultException, EvaluationException {
-
-    String literal = evaluateAsString(cexp, context);
-
-    try {
-      return new XMLCalendar(literal);
-    } catch (Exception ex) {
-      __log.error("Date conversion error." ,ex);
-      throw new EvaluationException("Date conversion errror.", ex);
-    }
-  }
-
-  public Duration evaluateAsDuration(OExpression cexp, EvaluationContext context) throws FaultException, EvaluationException {
-    String literal = this.evaluateAsString(cexp, context);
-    try {
-      Duration duration = new org.apache.ode.utils.xsd.Duration(literal);
-      return duration;
-    } catch (Exception ex) {
-      __log.error("Date conversion error.", ex);
-      throw new EvaluationException("Duration conversion error." ,ex);
-    }
-  }
-
-	private Context createContext(OXPath10Expression oxpath, EvaluationContext ctx) {
-    JaxenContexts bpelSupport = new JaxenContexts(oxpath, _extensionFunctions, ctx);
-    ContextSupport support = new ContextSupport(new JaxenNamespaceContextAdapter(oxpath.namespaceCtx),
-                                                bpelSupport, bpelSupport, 
-                                                new BpelDocumentNavigator(ctx.getRootNode()));
-    Context jctx = new Context(support);
-
-    if (ctx.getRootNode() != null)
-      jctx.setNodeSet(Collections.singletonList(ctx.getRootNode()));
-
-    return jctx;
-  }
-
-
-  private XPath compile(OXPath10Expression exp) throws JaxenException {
-    XPath xpath = _compiledExpressions.get(exp.xpath);
-    if (xpath == null) {
-      xpath = new DOMXPath(exp.xpath);
-      synchronized(_compiledExpressions) {
-        _compiledExpressions.put(exp.xpath, xpath);
-      }
-    }
-    return xpath;
-  }
-
-  private void handleJaxenException(JaxenException je) throws EvaluationException,FaultException {
-    if (je instanceof WrappedFaultException) {
-      throw ((WrappedFaultException)je).getFaultException();
-    } else if (je.getCause() instanceof WrappedFaultException) {
-      throw ((WrappedFaultException)je.getCause())
-            .getFaultException();
-    } else {
-      throw new EvaluationException(je.getMessage(),je);
-    }
+    public void initialize(Map properties) throws ConfigurationException {
+    }
+
+    public String evaluateAsString(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
+        try {
+            return compile((OXPath10Expression) cexp).stringValueOf(createContext((OXPath10Expression) cexp, ctx));
+        } catch (JaxenException e) {
+            handleJaxenException(e);
+        }
+        throw new AssertionError("UNREACHABLE");
+    }
+
+    public boolean evaluateAsBoolean(OExpression cexp, EvaluationContext ctx) throws FaultException,
+            EvaluationException {
+        try {
+            return compile((OXPath10Expression) cexp).booleanValueOf(createContext((OXPath10Expression) cexp, ctx));
+        } catch (JaxenException e) {
+            handleJaxenException(e);
+        }
+        throw new AssertionError("UNREACHABLE");
+    }
+
+    public Number evaluateAsNumber(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
+        try {
+            return compile((OXPath10Expression) cexp).numberValueOf(createContext((OXPath10Expression) cexp, ctx));
+        } catch (JaxenException e) {
+            handleJaxenException(e);
+        }
+        throw new AssertionError("UNREACHABLE");
+    }
+
+    public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
+        try {
+            XPath compiledXPath = compile((OXPath10Expression) cexp);
+            Context context = createContext((OXPath10Expression) cexp, ctx);
+
+            List retVal = compiledXPath.selectNodes(context);
+
+            if ((retVal.size() == 1) && !(retVal.get(0) instanceof Node)) {
+                Document d = DOMUtils.newDocument();
+                // Giving our node a parent just in case it's an LValue
+                // expression
+                Element wrapper = d.createElement("wrapper");
+                Text text = d.createTextNode(retVal.get(0).toString());
+                wrapper.appendChild(text);
+                d.appendChild(wrapper);
+                retVal = Collections.singletonList(text);
+            }
+
+            return retVal;
+
+        } catch (JaxenException je) {
+            handleJaxenException(je);
+        }
+        throw new AssertionError("UNREACHABLE");
+    }
+
+    public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
+        List retVal = evaluate(cexp, ctx);
+        if (retVal.size() == 0)
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "No results for expression: " + cexp);
+        if (retVal.size() > 1)
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "Multiple results for expression: "
+                    + cexp);
+        return (Node) retVal.get(0);
+    }
+
+    public Calendar evaluateAsDate(OExpression cexp, EvaluationContext context) throws FaultException,
+            EvaluationException {
+
+        String literal = evaluateAsString(cexp, context);
+
+        try {
+            return new XMLCalendar(literal);
+        } catch (Exception ex) {
+            String errmsg = "Invalid date: " + literal;
+            __log.error(errmsg, ex);
+            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue, errmsg);
+        }
+    }
+
+    public Duration evaluateAsDuration(OExpression cexp, EvaluationContext context) throws FaultException,
+            EvaluationException {
+        String literal = this.evaluateAsString(cexp, context);
+        try {
+            Duration duration = new org.apache.ode.utils.xsd.Duration(literal);
+            return duration;
+        } catch (Exception ex) {
+            String errmsg = "Invalid duration: " + literal;
+            __log.error(errmsg, ex);
+            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue, errmsg);
+        }
+    }
+
+    private Context createContext(OXPath10Expression oxpath, EvaluationContext ctx) {
+        JaxenContexts bpelSupport = new JaxenContexts(oxpath, _extensionFunctions, ctx);
+        ContextSupport support = new ContextSupport(new JaxenNamespaceContextAdapter(oxpath.namespaceCtx), bpelSupport,
+                bpelSupport, new BpelDocumentNavigator(ctx.getRootNode()));
+        Context jctx = new Context(support);
+
+        if (ctx.getRootNode() != null)
+            jctx.setNodeSet(Collections.singletonList(ctx.getRootNode()));
+
+        return jctx;
+    }
+
+    private XPath compile(OXPath10Expression exp) throws JaxenException {
+        XPath xpath = _compiledExpressions.get(exp.xpath);
+        if (xpath == null) {
+            xpath = new DOMXPath(exp.xpath);
+            synchronized (_compiledExpressions) {
+                _compiledExpressions.put(exp.xpath, xpath);
+            }
+        }
+        return xpath;
+    }
+
+    private void handleJaxenException(JaxenException je) throws EvaluationException, FaultException {
+        if (je instanceof WrappedFaultException) {
+            throw ((WrappedFaultException) je).getFaultException();
+        } else if (je.getCause() instanceof WrappedFaultException) {
+            throw ((WrappedFaultException) je.getCause()).getFaultException();
+        } else {
+            throw new EvaluationException(je.getMessage(), je);
+        }
 
-  }
+    }
 }

Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java Tue Jan  2 22:23:35 2007
@@ -134,8 +134,9 @@
         try {
             return new XMLCalendar(literal);
         } catch (Exception ex) {
-            __log.error("Date conversion error." ,ex);
-            throw new EvaluationException("Date conversion errror.", ex);
+            String errmsg = "Invalid date: " + literal;
+            __log.error(errmsg, ex);
+            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue,errmsg);
         }
     }
 
@@ -144,8 +145,9 @@
         try {
             return new Duration(literal);
         } catch (Exception ex) {
-            __log.error("Date conversion error.", ex);
-            throw new EvaluationException("Duration conversion error." ,ex);
+            String errmsg = "Invalid duration: " + literal;
+            __log.error(errmsg, ex);
+            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue,errmsg);
         }
     }
 

Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/Messages.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/Messages.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/Messages.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/Messages.java Tue Jan  2 22:23:35 2007
@@ -188,5 +188,9 @@
     public String msgDeployFailedProcessNotFound(QName pid, String du) {
         return format("Deploy failed; process \"{0}\" not found in deployment unit \"{1}\".",pid,du);
     }
+
+    public String msgDeployFailCompileErrors() {
+        return format("Deploy failed; BPEL compilation errors." );
+    }
     
 }

Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java Tue Jan  2 22:23:35 2007
@@ -22,6 +22,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.compiler.api.CompilationException;
 import org.apache.ode.bpel.dd.DeployDocument;
 import org.apache.ode.bpel.dd.TDeployment;
 import org.apache.ode.bpel.iapi.ContextException;
@@ -144,7 +145,14 @@
 
         // Create the DU and compile/scan it before acquiring lock.
         final DeploymentUnitDir du = new DeploymentUnitDir(deploymentUnitDirectory);
-        du.compile();
+        try {
+            du.compile();
+        } catch (CompilationException ce) {
+            String errmsg = __msgs.msgDeployFailCompileErrors();
+            __log.error(errmsg,ce);
+            throw new ContextException(errmsg,ce);
+        }
+        
         du.scan();
         DeployDocument dd = du.getDeploymentDescriptor();
         final ArrayList<ProcessConfImpl> processes = new ArrayList<ProcessConfImpl>();

Modified: incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java (original)
+++ incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java Tue Jan  2 22:23:35 2007
@@ -30,8 +30,10 @@
 
 import junit.framework.TestCase;
 
+import org.apache.ode.bpel.compiler.api.CompilationException;
 import org.apache.ode.bpel.engine.BpelServerImpl;
 import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.bpel.iapi.ContextException;
 import org.apache.ode.bpel.iapi.Message;
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
 import org.apache.ode.bpel.iapi.ProcessStore;
@@ -153,7 +155,7 @@
                 server.register(store.getProcessConfiguration(procName));
             }
 
-        } catch (BpelEngineException bpelE) {
+        } catch (ContextException bpelE) {
 			Properties testProps = new Properties();
 			testProps.load(testPropsFile.toURL().openStream());
 			String responsePattern = testProps.getProperty("response1");

Modified: incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/NegativeTargetNSTest1/test.properties
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/NegativeTargetNSTest1/test.properties?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/NegativeTargetNSTest1/test.properties (original)
+++ incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/NegativeTargetNSTest1/test.properties Tue Jan  2 22:23:35 2007
@@ -2,4 +2,4 @@
 service=NegativeTargetNSTest1Service
 operation=request
 request1=<message><requestID>Start NegativeTargetNSTest1</requestID><requestText>Event NegativeTargetNSTest1</requestText></message>
-response1=.*Compilation failure.*
+response1=.*BPEL compilation errors.*

Modified: incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestTimer/TestTimer.bpel
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestTimer/TestTimer.bpel?view=diff&rev=492057&r1=492056&r2=492057
==============================================================================
--- incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestTimer/TestTimer.bpel (original)
+++ incubator/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestTimer/TestTimer.bpel Tue Jan  2 22:23:35 2007
@@ -64,7 +64,7 @@
 		<invoke name="probe1" partnerLink="probe" portType="prb:probeMessagePT" operation="probe" inputVariable="probeInput" outputVariable="probeInput"/>
 		
 		<wait>
-			<for>'PT10s'</for>
+			<for>'PT10S'</for>
 		</wait>
 		
 		<invoke name="probe2" partnerLink="probe" portType="prb:probeMessagePT" operation="probe" inputVariable="probeInput" outputVariable="probeInput"/>