[jboss-svn-commits] JBL Code SVN: r38274 - in labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src: test/java/org/jboss/soa/esb/services/jbpm and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jan 18 11:21:50 EST 2013
Author: tcunning
Date: 2013-01-18 11:21:49 -0500 (Fri, 18 Jan 2013)
New Revision: 38274
Modified:
labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
Log:
JBESB-3897
Catch the ProcessException thrown by MVEL in JBpmObjectMapper.setOnEsbMessage so that the warning at the end can be logged.
Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java 2013-01-15 20:28:48 UTC (rev 38273)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java 2013-01-18 16:21:49 UTC (rev 38274)
@@ -3,6 +3,7 @@
*/
package org.jboss.soa.esb.services.jbpm;
+import org.mvel2.PropertyAccessException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -137,7 +138,11 @@
Object object = getObjectFromJBpmVariableMap(isPrcScope, mapping.getBpm(), ctxInstance, token);
//if that fails then try to get it from the ExecutionContext
if (object==null) {
- object = MVEL.getProperty(mapping.getBpm(), executionContext);
+ try {
+ object = MVEL.getProperty(mapping.getBpm(), executionContext);
+ } catch (PropertyAccessException pae) {
+ // Do nothing if we cannot find it in the executionContext
+ }
}
if (null != object) {
ObjectMapper mapper = new ObjectMapper();
Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java 2013-01-15 20:28:48 UTC (rev 38273)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java 2013-01-18 16:21:49 UTC (rev 38274)
@@ -89,6 +89,41 @@
mapper = new JBpmObjectMapper();
}
+
+
+ @Test
+ public void testMissingObject() throws Exception
+ // Things to look for:
+ // 1) If the variable does not exist in the jbpm variable map, the execution context is tested, but if not present there, an exception is thrown.
+ // It looks like the intention was to arrive at "log.warn("The object " + mapping.getBpm() + " is null and cannot not be set on the message")"
+ {
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
+ Element element = document.getRootElement();
+ DefaultElement bpmToEsbVars = (DefaultElement) element.element("start-state").element("transition").element("action").element("bpmToEsbVars");
+
+ String helloWorldTokenScope = "Hello world token scope";
+ String helloWorldGlobalScope = "Hello world process-instance scope";
+ TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
+ TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
+
+ Token token = processInstance.getRootToken();
+ // Don't set v1, see what happens
+ //processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
+ processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
+ processInstance.getContextInstance().setVariable("h3", objectTokenScope, token);
+ processInstance.getContextInstance().setVariable("i4", objectGlobalScope);
+ ExecutionContext executionContext = new ExecutionContext(token);
+
+ JBpmObjectMapper mapper = new JBpmObjectMapper();
+ Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
+
+ assertTrue(!helloWorldTokenScope.equals(String.valueOf(message.getBody().get("esbObj1"))));
+ assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
+ assertEquals(objectTokenScope.getInternal(), String.valueOf(message.getBody().get("esbObj3")));
+ assertEquals(objectGlobalScope.getInternal(), String.valueOf(message.getBody().get("esbObj4")));
+ }
+
/**
* Tests obtaining variables from the jBPM variableMap and setting them on the EsbMessage.
* We are making sure the jBPM -> EsbMessage works using
More information about the jboss-svn-commits
mailing list