[jboss-svn-commits] JBL Code SVN: r34361 - in labs/jbossrules/trunk: drools-camel/src/main/java/org/drools/camel/component and 8 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 29 19:40:06 EDT 2010


Author: mark.proctor at jboss.com
Date: 2010-07-29 19:40:05 -0400 (Thu, 29 Jul 2010)
New Revision: 34361

Added:
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ObjectFactory.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/BatchTest.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/JSonBatchExecutionTest.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchTest.java
   labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt
   labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/json.mvt
   labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/xstream.mvt
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbObjectObjectPair.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbStringObjectPair.java
Removed:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbPair.java
Modified:
   labs/jbossrules/trunk/drools-camel/pom.xml
   labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java
   labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/XStreamHelper.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ChangeCollector.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Cheese.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Person.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/TestVariable.java
   labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchExecutionTest.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/process/SignalEventCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/FireAllRulesCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListAdapter.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListWrapper.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbMapAdapter.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbUnknownAdapter.java
Log:
JBRULES-2347 Camel
-getting json, xstream and jaxb better tested

Modified: labs/jbossrules/trunk/drools-camel/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-camel/pom.xml	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/pom.xml	2010-07-29 23:40:05 UTC (rev 34361)
@@ -163,6 +163,16 @@
 			<scope>test</scope>
 		</dependency>	
 
+		<dependency>		
+			<groupId>org.codehaus.jackson</groupId>
+			<artifactId>jackson-core-asl</artifactId>
+			<scope>test</scope>
+		</dependency>	
+		<dependency>		
+			<groupId>org.codehaus.jackson</groupId>
+			<artifactId>jackson-mapper-asl</artifactId>
+			<scope>test</scope>
+		</dependency>		
 		
 		
 		<!-- web app deps -->

Modified: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/DroolsPolicy.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -115,12 +115,10 @@
 
             List<ProcessorDefinition> outputs = nav.getOutputs();
             for ( int i = 0; i <  outputs.size(); i++  ) {
-            //for ( Iterator<ProcessorDefinition> it = nav.getOutputs().iterator(); it.hasNext(); ) {
                 ProcessorDefinition child = outputs.get( i );//it.next();
                 if ( child instanceof ToDefinition) {
                     ToDefinition to = ( ToDefinition ) child;
                     if (to.getUri().startsWith( "cxfrs" ) && !visited.contains( to ) ) {                        
-//                        it.remove();
                         BeanDefinition beanDef = new BeanDefinition();
                         beanDef.setBeanType( PreCxfrs.class );
                         outputs.add( i, beanDef ); // insert before cxfrs
@@ -128,19 +126,6 @@
                         beanDef.setBeanType( PostCxfrs.class );
                         outputs.add( i+2, beanDef ); // insert after cxfrs
                         i = i + 2;// adjust for the two inserts
-                        
-//                        System.out.println( to.getUri( ) );
-//                        ToDefinition newTo = new ToDefinition( to.getUri() );
-//                        beanDef.addOutput( newTo );
-//                        newOutputs.add( beanDef );
-//                        
-//                        BeanDefinition beanDef2 = new BeanDefinition();
-//                        beanDef2.setBeanType( DummyProcess.class );
-//                        //beanDef.addOutput( beanDef2 );
-//                        to.addOutput( beanDef2 );
-//                        to.bean(  DummyProcess.class );
-//                        
-//                        visited.add( to );
                     }
                     
                 } else if ( child instanceof MarshalDefinition ) {

Modified: labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/XStreamHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/XStreamHelper.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/main/java/org/drools/camel/component/XStreamHelper.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -87,8 +87,6 @@
                  QueryCommand.class.getName() );
         map.put( "query-results",
                  FlatQueryResults.class.getName() );
-        map.put( "query-results",
-                 NativeQueryResults.class.getName() );
         map.put( "fact-handle",
                  DefaultFactHandle.class.getName() );
 

Modified: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ChangeCollector.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ChangeCollector.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ChangeCollector.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -21,21 +21,32 @@
 import org.drools.event.rule.ObjectInsertedEvent;
 import org.drools.event.rule.ObjectUpdatedEvent;
 import org.drools.event.rule.ObjectRetractedEvent;
+import org.drools.xml.jaxb.util.JaxbListAdapter;
+import org.drools.xml.jaxb.util.JaxbUnknownAdapter;
 
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * @author Michael Neale
- */
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+ at XmlRootElement
+ at XmlAccessorType(XmlAccessType.NONE)
 public class ChangeCollector implements WorkingMemoryEventListener {
 
+    @XmlElement
+    @XmlJavaTypeAdapter(JaxbListAdapter.class)
     private List<String> retracted;
+    
+    @XmlElement
+    @XmlJavaTypeAdapter(JaxbListAdapter.class)
     private List changes;
 
 
-
-
     public List<String> getRetracted() {
         return retracted;
     }

Modified: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Cheese.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Cheese.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Cheese.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -21,6 +21,8 @@
 import java.io.Serializable;
 import java.util.Date;
 
+import javax.xml.bind.annotation.XmlRootElement;
+
 /*
  * Copyright 2005 JBoss Inc
  *
@@ -37,6 +39,7 @@
  * limitations under the License.
  */
 
+ at XmlRootElement
 public class Cheese
     implements
     Serializable {
@@ -95,7 +98,7 @@
     }
 
     public String toString() {
-        return "Cheese( type='" + this.type + "', price=" + this.price + " )";
+        return "Cheese( type='" + this.type + "', price=" + this.price + ", old price:" + this.oldPrice + ")";
     }
 
     public int hashCode() {
@@ -135,5 +138,7 @@
     }
 
 
-
+    public int throwException() {
+        throw new RuntimeException("eeeeee");
+    }
 }

Added: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ObjectFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ObjectFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/ObjectFactory.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+ at XmlRegistry
+public class ObjectFactory {
+    public ChangeCollector createChangeCollector() {
+        return new ChangeCollector();
+    }
+    
+    public Cheese createCheese() {
+        return new Cheese();
+    }
+    
+    public Person createPerson() {
+        return new Person();
+    }  
+    
+    public TestVariable createTestVariable() {
+        return new TestVariable();
+    }       
+}  

Modified: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Person.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/Person.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -23,6 +23,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.bind.annotation.XmlRootElement;
+
+ at XmlRootElement
 public class Person
     implements
     Serializable {

Modified: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/TestVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/TestVariable.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/TestVariable.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -15,15 +15,22 @@
  */
 
 package org.drools;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
 /**
  * 
  */
 
-
+ at XmlRootElement
 public class TestVariable {
     
     private String name;
     
+    public TestVariable() {
+        
+    }
+    
     public TestVariable(String name) {
         this.name = name;
     }

Added: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/BatchTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/BatchTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/BatchTest.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,1566 @@
+package org.drools.camel.component;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.dataformat.JaxbDataFormat;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.drools.ChangeCollector;
+import org.drools.Cheese;
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.Person;
+import org.drools.builder.DirectoryLookupFactoryService;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.command.runtime.rule.ModifyCommand;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.InternalRuleBase;
+import org.drools.core.util.StringUtils;
+import org.drools.definition.KnowledgePackage;
+import org.drools.grid.ExecutionNode;
+import org.drools.grid.local.LocalConnection;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.impl.StatelessKnowledgeSessionImpl;
+import org.drools.io.Resource;
+import org.drools.io.ResourceFactory;
+import org.drools.process.core.context.variable.VariableScope;
+import org.drools.process.instance.context.variable.VariableScopeInstance;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.process.ProcessInstance;
+import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkItemHandler;
+import org.drools.runtime.process.WorkItemManager;
+import org.drools.runtime.process.WorkflowProcessInstance;
+import org.drools.runtime.rule.FactHandle;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.mvel2.templates.SimpleTemplateRegistry;
+import org.mvel2.templates.TemplateCompiler;
+import org.mvel2.templates.TemplateRegistry;
+import org.mvel2.templates.TemplateRuntime;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+ at RunWith(JUnit4.class)
+public abstract class BatchTest extends ContextTestSupport {
+    protected ExecutionNode   node;
+    protected CommandExecutor exec;
+    protected String          dataformat;
+    protected String          copyToDataFormat;
+
+    public BatchTest() {
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                JaxbDataFormat jaxbDf = new JaxbDataFormat();
+                jaxbDf.setContextPath( "org.drools" );
+                
+                from( "direct:exec" ).policy( new DroolsPolicy() ).unmarshal( dataformat ).to( "drools://node/ksession1" ).marshal( dataformat );
+                from( "direct:execWithLookup" ).policy( new DroolsPolicy() ).unmarshal( dataformat ).to( "drools://node" ).marshal( dataformat );
+                from( "direct:unmarshal" ).policy( new DroolsPolicy() ).unmarshal( dataformat );
+                from( "direct:marshal" ).policy( new DroolsPolicy() ).marshal( dataformat );
+                from( "direct:to-xstream" ).policy( new DroolsPolicy() ).unmarshal( dataformat ).marshal( "xstream" );
+                from( "direct:to-jaxb" ).policy( new DroolsPolicy() ).unmarshal( dataformat ).marshal( jaxbDf );
+            }
+        };
+    }
+
+    public String prettyPrintXml(String xmlSource) {
+        try {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            Document doc = builder.parse( new InputSource( new StringReader( xmlSource ) ) );
+
+            TransformerFactory tfactory = TransformerFactory.newInstance();
+            tfactory.setAttribute( "indent-number",
+                                   4 );
+            Transformer serializer;
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+            serializer = tfactory.newTransformer();
+            serializer.setOutputProperty( OutputKeys.INDENT,
+                                          "yes" );
+            serializer.transform( new DOMSource( doc ),
+                                  new StreamResult( new OutputStreamWriter( baos,
+                                                                            "UTF-8" ) ) );
+            return new String( baos.toByteArray() );
+        } catch ( Exception e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    protected Context createJndiContext() throws Exception {
+        Context context = super.createJndiContext();
+
+        LocalConnection connection = new LocalConnection();
+        node = connection.getExecutionNode( null );
+        node.setId( "node" );
+        context.bind( "node",
+                      node );
+        node.get( DirectoryLookupFactoryService.class ).register( "ksession1",
+                                                                  this.exec );
+        return context;
+    }
+
+    public void setExec(CommandExecutor exec) {
+        this.exec = exec;
+        try {
+            super.setUp();
+        } catch ( Exception e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    protected final TemplateRegistry tempReg = new SimpleTemplateRegistry();
+
+    protected PrintWriter                      writer;
+
+    @Before
+    public void before() throws Exception {
+        tempReg.addNamedTemplate( "tempReg",
+                                  TemplateCompiler.compileTemplate( getClass().getResourceAsStream( dataformat + ".mvt" ),
+                                                                    null ) );
+        TemplateRuntime.execute( tempReg.getNamedTemplate( "tempReg" ),
+                                 null,
+                                 tempReg );
+
+        XMLUnit.setIgnoreComments( true );
+        XMLUnit.setIgnoreWhitespace( true );
+        XMLUnit.setIgnoreAttributeOrder( true );
+        XMLUnit.setNormalizeWhitespace( true );
+        XMLUnit.setNormalize( true );
+
+        if ( !StringUtils.isEmpty( copyToDataFormat )) {
+            writer = new PrintWriter(new BufferedWriter( new FileWriter( copyToDataFormat + ".mvt", true )));
+        }
+    }
+
+    @After
+    public void after() throws Exception {
+        if ( !StringUtils.isEmpty( copyToDataFormat )) {
+            writer.close();
+        }
+    }
+
+    public String getContent(String name,
+                             String... vars) {
+        Map<String, String> map = new HashMap<String, String>();
+        int counter = 1;
+        for ( String var : vars ) {
+            map.put( "var" + counter++,
+                     var );
+        }
+
+        if ( !StringUtils.isEmpty( copyToDataFormat )) {
+                writer.println();
+                writer.println("@declare{\"" + name + "\"}");
+        }
+        String s = (String) TemplateRuntime.execute( tempReg.getNamedTemplate( name ),
+                                                     map );
+        if ( !StringUtils.isEmpty( copyToDataFormat )) {
+                writer.print(prettyPrintXml( template.requestBody("direct:to-" + copyToDataFormat, s, String.class) ) );
+                writer.println("@end{}");
+        }
+
+        return roundTripFromXml( s.trim() );
+    }
+
+    public String execContent(String name) {
+        return execContent( name,
+                            String.class );
+    }
+
+    public <T> T execContent(String name,
+                             Class<T> cls) {
+        return execContent( name,
+                            cls,
+                            new String[0] );
+    }
+
+    public <T> T execContent(String name,
+                             Class<T> cls,
+                             String... vars) {
+        String s = execContent( name,
+                                vars );
+        if ( cls.isAssignableFrom( String.class ) ) {
+            return (T) s;
+        } else {
+            return unmarshalOutXml( s,
+                                    cls );
+        }
+    }
+
+    public String execContent(String name,
+                              String... vars) {
+        String inXml = getContent( name,
+                                   vars );
+        return execInXml( inXml );
+    }
+
+    public String execInXml(String inXml) {
+        String outXml = template.requestBody( "direct:exec",
+                                              inXml,
+                                              String.class );
+        return roundTripFromXml( outXml );
+    }
+
+    public <T> T unmarshalOutXml(String outXml,
+                                 Class<T> cls) {
+        Object object = template.requestBody( "direct:unmarshal",
+                                              outXml,
+                                              Object.class );
+        return (T) roundTripFromObject( object );
+    }
+
+    public abstract void assertXMLEqual(String expectedXml,
+                                        String resultXml);
+
+    public String roundTripFromXml(String inXml) {
+        Object object = template.requestBody( "direct:unmarshal",
+                                              inXml );
+        inXml = template.requestBody( "direct:marshal",
+                                      object,
+                                      String.class );
+        object = template.requestBody( "direct:unmarshal",
+                                       inXml );
+        return template.requestBody( "direct:marshal",
+                                     object,
+                                     String.class );
+    }
+
+    public Object roundTripFromObject(Object object) {
+        String inXml = template.requestBody( "direct:marshal",
+                                             object,
+                                             String.class );
+        object = template.requestBody( "direct:unmarshal",
+                                       inXml );
+        inXml = template.requestBody( "direct:marshal",
+                                      object,
+                                      String.class );
+        return template.requestBody( "direct:unmarshal",
+                                     inXml );
+    }
+
+    private StatelessKnowledgeSession getStatelessKnowledgeSession(Resource resource) throws Exception {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+        kbuilder.add( resource,
+                      ResourceType.DRL );
+
+        if ( kbuilder.hasErrors() ) {
+            fail( kbuilder.getErrors().toString() );
+        }
+
+        assertFalse( kbuilder.hasErrors() );
+        Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
+
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+
+        kbase.addKnowledgePackages( pkgs );
+        StatelessKnowledgeSession session = kbase.newStatelessKnowledgeSession();
+
+        return session;
+    }
+
+    private StatefulKnowledgeSession getStatefulKnowledgeSession(Resource resource) throws Exception {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+        kbuilder.add( resource,
+                      ResourceType.DRL );
+
+        if ( kbuilder.hasErrors() ) {
+            System.out.println( kbuilder.getErrors() );
+            throw new RuntimeException( kbuilder.getErrors().toString() );
+        }
+
+        assertFalse( kbuilder.hasErrors() );
+        Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
+
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+
+        kbase.addKnowledgePackages( pkgs );
+        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
+
+        return session;
+    }
+
+    @Test
+    public void testListenForChanges() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "import org.drools.ChangeCollector \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese(price==25) \n";
+        str += " \n";
+        str += "  then \n";
+        str += "end\n";
+
+        str += "rule rule2 \n";
+        str += "  when \n";
+        str += "    p : Person(name=='mic') \n";
+        str += "    c : Cheese(price != 42) \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    c.setPrice( 42 ); \n";
+        str += "    update(c); \n";
+        str += "end\n";
+
+        str += "rule rule3 \n";
+        str += "  when \n";
+        str += "    p : Person(name=='mark') \n";
+        str += "    c : Cheese(price == 42) \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    retract(c); \n";
+        str += "end\n";
+
+        str += "rule ruleBootStrap \n";
+        str += "salience 10000\n";
+        str += "  when \n";
+        str += "    $c : ChangeCollector() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    kcontext.getKnowledgeRuntime().addEventListener($c); \n";
+        str += "end\n";
+
+        str += "rule ruleCleanup \n";
+        str += "salience -10000\n";
+        str += "  when \n";
+        str += "    $c : ChangeCollector() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    kcontext.getKnowledgeRuntime().removeEventListener($c); \n";
+        str += "    retract($c); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testListenForChanges.in.1" );
+
+        outXml = execContent( "testListenForChanges.in.2" );
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        assertXMLEqual( getContent( "testListenForChanges.expected.1",
+                                    ((FactHandle) result.getFactHandle( "changes" )).toExternalForm(),
+                                    ((FactHandle) result.getFactHandle( "person" )).toExternalForm() ),
+                        outXml );
+
+        ChangeCollector collector = (ChangeCollector) result.getValue( "changes" );
+        Cheese c = (Cheese) collector.getChanges().get( 0 );
+        assertEquals( 42,
+                      c.getPrice() );
+
+        result = execContent( "testListenForChanges.in.3",
+                              ExecutionResults.class );
+
+        collector = (ChangeCollector) result.getValue( "changes" );
+        assertEquals( "stilton",
+                      collector.getRetracted().get( 0 ) );
+
+    }
+
+    @Test
+    public void testInsertWithDefaults() throws Exception {
+
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testInsertWithDefaults.in.1" );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        Cheese stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        FactHandle factHandle = (FactHandle) result.getFactHandle( "outStilton" );
+        stilton = (Cheese) ksession.getObject( factHandle );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        String expectedXml = getContent( "testInsertWithDefaults.expected.1",
+                                         ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
+
+        assertXMLEqual( expectedXml,
+                        outXml );
+    }
+
+    @Test
+    public void testInsertWithReturnObjectFalse() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testInsertWithReturnObjectFalse.in.1" );
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        String expectedXml = getContent( "testInsertWithReturnObjectFalse.expected.1",
+                                         ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
+
+        assertXMLEqual( expectedXml,
+                        outXml );
+    }
+
+    @Test
+    public void testFactHandleReturn() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "global java.util.List list1 \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    System.err.println(42); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        FactHandle fh = ksession.insert( new Person( "mic",
+                                                     42 ) );
+        List<FactHandle> list = new ArrayList<FactHandle>();
+        list.add( fh );
+
+        ksession.setGlobal( "list1",
+                            list );
+
+        String outXml = execContent( "testFactHandleReturn.in.1" );
+
+        assertXMLEqual( getContent( "testFactHandleReturn.expected.1",
+                                    fh.toExternalForm() ),
+                        outXml );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        List outList = (List) result.getValue( "out-list" );
+        assertEquals( 1,
+                      outList.size() );
+        assertEquals( fh.toExternalForm(),
+                      ((FactHandle) outList.get( 0 )).toExternalForm() );
+        assertNotSame( fh,
+                       outList.get( 0 ) );
+    }
+
+    @Test
+    public void testGetObject() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        ExecutionResults result = execContent( "testGetObject.in.1",
+                                               ExecutionResults.class );
+
+        Cheese stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        String outXml = execContent( "testGetObject.in.2",
+                                     ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
+        result = unmarshalOutXml( outXml,
+                                  ExecutionResults.class );
+
+        stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( 30,
+                      stilton.getPrice() );
+    }
+
+    @Test
+    public void testRetractObject() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        ExecutionResults result = execContent( "testRetractObject.in.1",
+                                               ExecutionResults.class );
+
+        Cheese stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        String outXml = execContent( "testRetractObject.in.2",
+                                     ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
+
+        outXml = execContent( "testRetractObject.in.3",
+                              ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() );
+        result = unmarshalOutXml( outXml,
+                                  ExecutionResults.class );
+
+        assertNull( result.getValue( "outStilton" ) );
+    }
+
+    @Test
+    public void testModifyObject() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testModifyObject.in.1" );
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        String stiltonfh = ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm();
+
+        Cheese stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        String expectedXml = getContent( "testModifyObject.expected.1",
+                                         stiltonfh );
+
+        assertXMLEqual( expectedXml,
+                        outXml );
+
+        execContent( "testModifyObject.in.2",
+                     ExecutionResults.class,
+                     stiltonfh );
+
+        result = execContent( "testModifyObject.in.3",
+                              ExecutionResults.class,
+                              stiltonfh );
+
+        stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( 42,
+                      stilton.getOldPrice() );
+        assertEquals( 55,
+                      stilton.getPrice() );
+
+        //now test for code injection:
+        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = false;
+
+        execContent( "testModifyObject.in.4",
+                     ExecutionResults.class,
+                     stiltonfh );
+
+        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = true;
+
+        // should be the same as before
+        result = execContent( "testModifyObject.in.5",
+                              ExecutionResults.class,
+                              stiltonfh );
+
+        // The value gets turned into a literal to avoid injection
+        stilton = (Cheese) result.getValue( "outStilton" );
+        assertEquals( "throwException()",
+                      stilton.getType() );
+
+    }
+
+    @Test
+    public void testInsertElements() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "global java.util.List list1 \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "     list1.add( $c );";
+        str += "end\n";
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testInsertElements.in.1" );
+
+        assertXMLEqual( getContent( "testInsertElements.expected.1" ),
+                        outXml );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        List list = (List) result.getValue( "list1" );
+        Cheese stilton25 = new Cheese( "stilton",
+                                       30 );
+        Cheese stilton30 = new Cheese( "stilton",
+                                       35 );
+
+        Set expectedList = new HashSet();
+        expectedList.add( stilton25 );
+        expectedList.add( stilton30 );
+
+        assertEquals( expectedList,
+                      new HashSet( list ) );
+    }
+
+    @Test
+    public void testInsertElementsWithReturnObjects() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "global java.util.List list1 \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "    list1.add( $c );";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testInsertElementsWithReturnObjects.in.1" );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        List list1 = (List) result.getValue( "list1" );
+        assertEquals( 2,
+                      list1.size() );
+        assertTrue( list1.contains( new Cheese( "stilton",
+                                                35 ) ) );
+        assertTrue( list1.contains( new Cheese( "stilton",
+                                                30 ) ) );
+
+        List myFacts = (List) result.getValue( "myfacts" );
+        assertEquals( 2,
+                      list1.size() );
+        assertTrue( myFacts.contains( new Cheese( "stilton",
+                                                  35 ) ) );
+        assertTrue( myFacts.contains( new Cheese( "stilton",
+                                                  30 ) ) );
+
+        List<FactHandle> factHandles = (List<FactHandle>) result.getFactHandle( "myfacts" );
+        List list = new ArrayList();
+        list.add( ksession.getObject( ((InternalFactHandle) factHandles.get( 0 )) ) );
+        list.add( ksession.getObject( ((InternalFactHandle) factHandles.get( 1 )) ) );
+        assertTrue( list.contains( new Cheese( "stilton",
+                                               35 ) ) );
+        assertTrue( list.contains( new Cheese( "stilton",
+                                               30 ) ) );
+
+        assertXMLEqual( getContent( "testInsertElementsWithReturnObjects.expected.1",
+                                    factHandles.get( 0 ).toExternalForm(),
+                                    factHandles.get( 1 ).toExternalForm() ),
+                        outXml );
+
+    }
+
+    @Test
+    public void testSetGlobal() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "global java.util.List list1 \n";
+        str += "global java.util.List list2 \n";
+        str += "global java.util.List list3 \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( 30 ); \n";
+        str += "    list1.add( $c ); \n";
+        str += "    list2.add( $c ); \n";
+        str += "    list3.add( $c ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testSetGlobal.in.1" );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        assertXMLEqual( getContent( "testSetGlobal.expected.1",
+                                    ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() ),
+                        outXml );
+
+        Cheese stilton = new Cheese( "stilton",
+                                     30 );
+
+        assertNull( result.getValue( "list1" ) );
+
+        List list2 = (List) result.getValue( "list2" );
+        assertEquals( 1,
+                      list2.size() );
+        assertEquals( stilton,
+                      list2.get( 0 ) );
+
+        List list3 = (List) result.getValue( "outList3" );
+        assertEquals( 1,
+                      list3.size() );
+        assertEquals( stilton,
+                      list3.get( 0 ) );
+    }
+
+    @Test
+    public void testGetGlobal() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "global java.util.List list1 \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    list1.add( $c ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testGetGlobal.in.1" );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        assertXMLEqual( getContent( "testGetGlobal.expected.1",
+                                    ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm() ),
+                        outXml );
+
+        List resultsList = (List) result.getValue( "out-list" );
+        assertEquals( 1,
+                      resultsList.size() );
+        assertEquals( new Cheese( "stilton",
+                                  25 ),
+                      resultsList.get( 0 ) );
+
+    }
+
+    @Test
+    public void testGetObjects() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        String inXml = "";
+        inXml = "{\"batch-execution\":{\"commands\":[";
+        inXml += "  {\"insert-elements\":{\"objects\":[";
+        inXml += "   {   \"org.drools.Cheese\":{\"type\":\"stilton\",\"price\":25,\"oldPrice\":0}}, ";
+        inXml += "   {   \"org.drools.Cheese\":{\"type\":\"stilton\",\"price\":30,\"oldPrice\":0}} ";
+        inXml += "   ]}}";
+        inXml += ",  {\"get-objects\":{\"out-identifier\":\"list1\"}}";
+        inXml += "]}}";
+
+        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testGetObjects.in.1" );
+
+        // Can't compare content a hashmap of objects keeps changing order
+        // assertXMLEqual( getContent( "testGetObjects.expected.1" ),
+        //                outXml );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        List list = (List) result.getValue( "list1" );
+        Cheese stilton25 = new Cheese( "stilton",
+                                       30 );
+        Cheese stilton30 = new Cheese( "stilton",
+                                       35 );
+
+        Set expectedList = new HashSet();
+        expectedList.add( stilton25 );
+        expectedList.add( stilton30 );
+
+        assertEquals( expectedList,
+                      new HashSet( list ) );
+    }
+
+    @Test
+    public void testQuery() throws Exception {
+        String str = "";
+        str += "package org.drools.test  \n";
+        str += "import org.drools.Cheese \n";
+        str += "query cheeses \n";
+        str += "    stilton : Cheese(type == 'stilton') \n";
+        str += "    cheddar : Cheese(type == 'cheddar', price == stilton.price) \n";
+        str += "end\n";
+        str += "query cheesesWithParams(String a, String b) \n";
+        str += "    stilton : Cheese(type == a) \n";
+        str += "    cheddar : Cheese(type == b, price == stilton.price) \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testQuery.in.1" );
+
+        
+        // Order is not determinstic, so can't test.
+//         assertXMLEqual( getContent( "testQuery.expected.1" ),
+//                        outXml );
+        getContent( "testQuery.expected.1" ); // just to force a tostring for comparison
+        
+        ExecutionResults batchResult = unmarshalOutXml( outXml,
+                                                        ExecutionResults.class );
+
+        Cheese stilton1 = new Cheese( "stilton",
+                                      1 );
+        Cheese cheddar1 = new Cheese( "cheddar",
+                                      1 );
+        Cheese stilton2 = new Cheese( "stilton",
+                                      2 );
+        Cheese cheddar2 = new Cheese( "cheddar",
+                                      2 );
+
+        Set set = new HashSet();
+        List list = new ArrayList();
+        list.add( stilton1 );
+        list.add( cheddar1 );
+        set.add( list );
+
+        list = new ArrayList();
+        list.add( stilton2 );
+        list.add( cheddar2 );
+        set.add( list );
+
+        org.drools.runtime.rule.QueryResults results = (org.drools.runtime.rule.QueryResults) batchResult.getValue( "cheeses" );
+        assertEquals( 2,
+                      results.size() );
+        assertEquals( 2,
+                      results.getIdentifiers().length );
+        Set newSet = new HashSet();
+        for ( org.drools.runtime.rule.QueryResultsRow result : results ) {
+            list = new ArrayList();
+            list.add( result.get( "stilton" ) );
+            list.add( result.get( "cheddar" ) );
+            newSet.add( list );
+        }
+        assertEquals( set,
+                      newSet );
+    }
+
+    @Test
+    public void testManualFireAllRules() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "global java.util.List list1 \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "    list1.add( $c );";
+        str += "end\n";
+
+        StatelessKnowledgeSession ksession = getStatelessKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testManualFireAllRules.in.1" );
+
+        ExecutionResults result = unmarshalOutXml( outXml,
+                                                   ExecutionResults.class );
+
+        assertXMLEqual( getContent( "testManualFireAllRules.expected.1",
+                                    ((FactHandle) result.getFactHandle( "outBrie" )).toExternalForm() ),
+                        outXml );
+
+        // brie should not have been added to the list
+        List list = (List) result.getValue( "list1" );
+        Cheese stilton25 = new Cheese( "stilton",
+                                       30 );
+        Cheese stilton30 = new Cheese( "stilton",
+                                       35 );
+
+        Set expectedList = new HashSet();
+        expectedList.add( stilton25 );
+        expectedList.add( stilton30 );
+
+        assertEquals( expectedList,
+                      new HashSet( list ) );
+
+        // brie should not have changed
+        Cheese brie10 = new Cheese( "brie",
+                                    10 );
+        brie10.setOldPrice( 5 );
+        assertEquals( brie10,
+                      result.getValue( "outBrie" ) );
+    }
+
+    @Test
+    public void testProcess() throws Exception {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+        String str = "";
+        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
+        str += "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        str += "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
+        str += "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.actions\" package-name=\"org.drools\" version=\"1\" >\n";
+        str += "\n";
+        str += "  <header>\n";
+        str += "    <imports>\n";
+        str += "      <import name=\"org.drools.TestVariable\" />\n";
+        str += "    </imports>\n";
+        str += "    <globals>\n";
+        str += "      <global identifier=\"list1\" type=\"java.util.List\" />\n";
+        str += "    </globals>\n";
+        str += "    <variables>\n";
+        str += "      <variable name=\"person\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"TestVariable\" />\n";
+        str += "      </variable>\n";
+        str += "    </variables>\n";
+        str += "  </header>\n";
+        str += "\n";
+        str += "  <nodes>\n";
+        str += "    <start id=\"1\" name=\"Start\" />\n";
+        str += "    <actionNode id=\"2\" name=\"MyActionNode\" >\n";
+        str += "      <action type=\"expression\" dialect=\"mvel\" >System.out.println(\"Triggered\");\n";
+        str += "list1.add(person.name);\n";
+        str += "</action>\n";
+        str += "    </actionNode>\n";
+        str += "    <end id=\"3\" name=\"End\" />\n";
+        str += "  </nodes>\n";
+        str += "\n";
+        str += "  <connections>\n";
+        str += "    <connection from=\"1\" to=\"2\" />\n";
+        str += "    <connection from=\"2\" to=\"3\" />\n";
+        str += "  </connections>\n" + "\n";
+        str += "</process>";
+
+        Reader source = new StringReader( str );
+        kbuilder.add( ResourceFactory.newReaderResource( source ),
+                      ResourceType.DRF );
+        if ( kbuilder.hasErrors() ) {
+            fail( kbuilder.getErrors().toString() );
+        }
+
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+        StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
+        List<String> list = new ArrayList<String>();
+        ksession.setGlobal( "list1",
+                            list );
+        setExec( ksession );
+
+        String outXml = execContent( "testProcess.in.1" );
+
+        assertXMLEqual( getContent( "testProcess.expected.1" ),
+                        outXml );
+
+        ExecutionResults results = unmarshalOutXml( outXml,
+                                                    ExecutionResults.class );
+
+        list = (List) results.getValue( "out-list" );
+
+        assertEquals( 1,
+                      list.size() );
+        assertEquals( "John Doe",
+                      list.get( 0 ) );
+    }
+
+    @Test
+    public void testProcessInstanceSignalEvent() throws Exception {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+        String str = "";
+        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
+        str += "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        str += "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
+        str += "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.event\" package-name=\"org.drools\" version=\"1\" >\n";
+        str += "\n";
+        str += "  <header>\n";
+        str += "    <variables>\n";
+        str += "      <variable name=\"MyVar\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        <value>SomeText</value>\n";
+        str += "      </variable>\n";
+        str += "    </variables>\n";
+        str += "  </header>\n";
+        str += "\n";
+        str += "  <nodes>\n";
+        str += "    <start id=\"1\" name=\"Start\" />\n";
+        str += "    <eventNode id=\"2\" name=\"Event\" variableName=\"MyVar\" >\n";
+        str += "      <eventFilters>\n";
+        str += "        <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n";
+        str += "      </eventFilters>\n";
+        str += "    </eventNode>\n";
+        str += "    <join id=\"3\" name=\"Join\" type=\"1\" />\n";
+        str += "    <end id=\"4\" name=\"End\" />\n";
+        str += "  </nodes>\n";
+        str += "\n";
+        str += "  <connections>\n";
+        str += "    <connection from=\"1\" to=\"3\" />\n";
+        str += "    <connection from=\"2\" to=\"3\" />\n";
+        str += "    <connection from=\"3\" to=\"4\" />\n";
+        str += "  </connections>\n";
+        str += "\n";
+        str += "</process>";
+
+        kbuilder.add( ResourceFactory.newByteArrayResource( str.getBytes() ),
+                      ResourceType.DRF );
+
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+        setExec( ksession );
+
+        ProcessInstance processInstance = ksession.startProcess( "org.drools.event" );
+        assertEquals( ProcessInstance.STATE_ACTIVE,
+                      processInstance.getState() );
+
+        execContent( "testProcessInstanceSignalEvent.in.1" );
+
+        assertEquals( ProcessInstance.STATE_COMPLETED,
+                      processInstance.getState() );
+        assertEquals( "MyValue",
+                      ((VariableScopeInstance) ((org.drools.process.instance.ProcessInstance) processInstance).getContextInstance( VariableScope.VARIABLE_SCOPE )).getVariable( "MyVar" ) );
+    }
+
+    @Test
+    public void testProcessRuntimeSignalEvent() throws Exception {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+        String str = "";
+        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
+        str += "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        str += "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
+        str += "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.event\" package-name=\"org.drools\" version=\"1\" >\n";
+        str += "\n";
+        str += "  <header>\n";
+        str += "    <variables>\n";
+        str += "      <variable name=\"MyVar\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        <value>SomeText</value>\n";
+        str += "      </variable>\n";
+        str += "    </variables>\n";
+        str += "  </header>\n";
+        str += "\n";
+        str += "  <nodes>\n";
+        str += "    <start id=\"1\" name=\"Start\" />\n";
+        str += "    <eventNode id=\"2\" name=\"Event\" scope=\"external\" variableName=\"MyVar\" >\n";
+        str += "      <eventFilters>\n";
+        str += "        <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n";
+        str += "      </eventFilters>\n";
+        str += "    </eventNode>\n";
+        str += "    <join id=\"3\" name=\"Join\" type=\"1\" />\n";
+        str += "    <end id=\"4\" name=\"End\" />\n";
+        str += "  </nodes>\n";
+        str += "\n";
+        str += "  <connections>\n";
+        str += "    <connection from=\"1\" to=\"3\" />\n";
+        str += "    <connection from=\"2\" to=\"3\" />\n";
+        str += "    <connection from=\"3\" to=\"4\" />\n";
+        str += "  </connections>\n";
+        str += "\n";
+        str += "</process>";
+
+        kbuilder.add( ResourceFactory.newByteArrayResource( str.getBytes() ),
+                      ResourceType.DRF );
+
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+        setExec( ksession );
+
+        ProcessInstance processInstance = ksession.startProcess( "org.drools.event" );
+        assertEquals( ProcessInstance.STATE_ACTIVE,
+                      processInstance.getState() );
+
+        execContent( "testProcessRuntimeSignalEvent.in.1" );
+
+        assertEquals( ProcessInstance.STATE_COMPLETED,
+                      processInstance.getState() );
+        assertEquals( "MyValue",
+                      ((VariableScopeInstance) ((org.drools.process.instance.ProcessInstance) processInstance).getContextInstance( VariableScope.VARIABLE_SCOPE )).getVariable( "MyVar" ) );
+    }
+
+    @Test
+    public void testCompleteWorkItem() {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+        String str = "";
+        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
+        str += "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        str += "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
+        str += "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.actions\" package-name=\"org.drools\" version=\"1\" >\n";
+        str += "\n";
+        str += "  <header>\n";
+        str += "    <variables>\n";
+        str += "      <variable name=\"UserName\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        <value>John Doe</value>\n";
+        str += "      </variable>\n";
+        str += "      <variable name=\"Person\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"org.drools.Person\" />\n";
+        str += "      </variable>\n";
+        str += "      <variable name=\"MyObject\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"java.lang.Object\" />\n";
+        str += "      </variable>\n";
+        str += "      <variable name=\"Number\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n";
+        str += "      </variable>\n";
+        str += "    </variables>\n";
+        str += "  </header>\n";
+        str += "\n";
+        str += "  <nodes>\n";
+        str += "    <start id=\"1\" name=\"Start\" />\n";
+        str += "    <workItem id=\"2\" name=\"HumanTask\" >\n";
+        str += "      <work name=\"Human Task\" >\n";
+        str += "        <parameter name=\"ActorId\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "          <value>#{UserName}</value>\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Content\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "          <value>#{Person.name}</value>\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"TaskName\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "          <value>Do something</value>\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Priority\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Comment\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Attachment\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"java.lang.Object\" />\n";
+        str += "        </parameter>\n";
+        str += "      </work>\n";
+        str += "      <mapping type=\"in\" from=\"MyObject\" to=\"Attachment\" />";
+        str += "      <mapping type=\"in\" from=\"Person.name\" to=\"Comment\" />";
+        str += "      <mapping type=\"out\" from=\"Result\" to=\"MyObject\" />";
+        str += "      <mapping type=\"out\" from=\"Result.length()\" to=\"Number\" />";
+        str += "    </workItem>\n";
+        str += "    <end id=\"3\" name=\"End\" />\n";
+        str += "  </nodes>\n";
+        str += "\n";
+        str += "  <connections>\n";
+        str += "    <connection from=\"1\" to=\"2\" />\n";
+        str += "    <connection from=\"2\" to=\"3\" />\n";
+        str += "  </connections>\n";
+        str += "\n";
+        str += "</process>";
+
+        Reader source = new StringReader( str );
+        kbuilder.add( ResourceFactory.newReaderResource( source ),
+                      ResourceType.DRF );
+
+        kbuilder.add( ResourceFactory.newByteArrayResource( str.getBytes() ),
+                      ResourceType.DRF );
+
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+        kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+        setExec( ksession );
+
+        TestWorkItemHandler handler = new TestWorkItemHandler();
+        ksession.getWorkItemManager().registerWorkItemHandler( "Human Task",
+                                                               handler );
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put( "UserName",
+                        "John Doe" );
+        Person person = new Person();
+        person.setName( "John Doe" );
+        parameters.put( "Person",
+                        person );
+        WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess( "org.drools.actions",
+                                                                                                   parameters );
+        assertEquals( ProcessInstance.STATE_ACTIVE,
+                      processInstance.getState() );
+        WorkItem workItem = handler.getWorkItem();
+        assertNotNull( workItem );
+        assertEquals( "John Doe",
+                      workItem.getParameter( "ActorId" ) );
+        assertEquals( "John Doe",
+                      workItem.getParameter( "Content" ) );
+        assertEquals( "John Doe",
+                      workItem.getParameter( "Comment" ) );
+
+        assertEquals( WorkItem.PENDING,
+                      workItem.getState() );
+
+        execContent( "testCompleteWorkItem.in.1",
+                     Long.toString( workItem.getId() ) );
+
+        assertEquals( WorkItem.COMPLETED,
+                      workItem.getState() );
+
+        assertEquals( ProcessInstance.STATE_COMPLETED,
+                      processInstance.getState() );
+
+        parameters = new HashMap<String, Object>();
+        parameters.put( "UserName",
+                        "Jane Doe" );
+        parameters.put( "MyObject",
+                        "SomeString" );
+        person = new Person();
+        person.setName( "Jane Doe" );
+        parameters.put( "Person",
+                        person );
+        processInstance = (WorkflowProcessInstance) ksession.startProcess( "org.drools.actions",
+                                                                           parameters );
+        assertEquals( ProcessInstance.STATE_ACTIVE,
+                      processInstance.getState() );
+        workItem = handler.getWorkItem();
+        assertNotNull( workItem );
+        assertEquals( "Jane Doe",
+                      workItem.getParameter( "ActorId" ) );
+        assertEquals( "SomeString",
+                      workItem.getParameter( "Attachment" ) );
+        assertEquals( "Jane Doe",
+                      workItem.getParameter( "Content" ) );
+        assertEquals( "Jane Doe",
+                      workItem.getParameter( "Comment" ) );
+
+        assertEquals( WorkItem.PENDING,
+                      workItem.getState() );
+
+        execContent( "testCompleteWorkItem.in.2",
+                     Long.toString( workItem.getId() ) );
+
+        assertEquals( WorkItem.COMPLETED,
+                      workItem.getState() );
+
+        assertEquals( ProcessInstance.STATE_COMPLETED,
+                      processInstance.getState() );
+        assertEquals( "SomeOtherString",
+                      processInstance.getVariable( "MyObject" ) );
+        assertEquals( 15,
+                      processInstance.getVariable( "Number" ) );
+    }
+
+    @Test
+    public void testAbortWorkItem() {
+        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+
+        String str = "";
+        str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
+        str += "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        str += "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
+        str += "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.actions\" package-name=\"org.drools\" version=\"1\" >\n";
+        str += "\n";
+        str += "  <header>\n";
+        str += "    <variables>\n";
+        str += "      <variable name=\"UserName\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        <value>John Doe</value>\n";
+        str += "      </variable>\n";
+        str += "      <variable name=\"Person\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"org.drools.Person\" />\n";
+        str += "      </variable>\n";
+        str += "      <variable name=\"MyObject\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"java.lang.Object\" />\n";
+        str += "      </variable>\n";
+        str += "      <variable name=\"Number\" >\n";
+        str += "        <type name=\"org.drools.process.core.datatype.impl.type.IntegerDataType\" />\n";
+        str += "      </variable>\n";
+        str += "    </variables>\n";
+        str += "  </header>\n";
+        str += "\n";
+        str += "  <nodes>\n";
+        str += "    <start id=\"1\" name=\"Start\" />\n";
+        str += "    <workItem id=\"2\" name=\"HumanTask\" >\n";
+        str += "      <work name=\"Human Task\" >\n";
+        str += "        <parameter name=\"ActorId\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "          <value>#{UserName}</value>\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Content\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "          <value>#{Person.name}</value>\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"TaskName\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "          <value>Do something</value>\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Priority\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Comment\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.StringDataType\" />\n";
+        str += "        </parameter>\n";
+        str += "        <parameter name=\"Attachment\" >\n";
+        str += "          <type name=\"org.drools.process.core.datatype.impl.type.ObjectDataType\" className=\"java.lang.Object\" />\n";
+        str += "        </parameter>\n";
+        str += "      </work>\n";
+        str += "      <mapping type=\"in\" from=\"MyObject\" to=\"Attachment\" />";
+        str += "      <mapping type=\"in\" from=\"Person.name\" to=\"Comment\" />";
+        str += "      <mapping type=\"out\" from=\"Result\" to=\"MyObject\" />";
+        str += "      <mapping type=\"out\" from=\"Result.length()\" to=\"Number\" />";
+        str += "    </workItem>\n";
+        str += "    <end id=\"3\" name=\"End\" />\n";
+        str += "  </nodes>\n";
+        str += "\n";
+        str += "  <connections>\n";
+        str += "    <connection from=\"1\" to=\"2\" />\n";
+        str += "    <connection from=\"2\" to=\"3\" />\n";
+        str += "  </connections>\n";
+        str += "\n";
+        str += "</process>";
+
+        Reader source = new StringReader( str );
+        kbuilder.add( ResourceFactory.newReaderResource( source ),
+                      ResourceType.DRF );
+
+        Collection<KnowledgePackage> kpkgs = kbuilder.getKnowledgePackages();
+        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+        kbase.addKnowledgePackages( kpkgs );
+        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
+        setExec( ksession );
+
+        TestWorkItemHandler handler = new TestWorkItemHandler();
+        ksession.getWorkItemManager().registerWorkItemHandler( "Human Task",
+                                                               handler );
+        Map<String, Object> parameters = new HashMap<String, Object>();
+        parameters.put( "UserName",
+                        "John Doe" );
+        Person person = new Person();
+        person.setName( "John Doe" );
+        parameters.put( "Person",
+                        person );
+        WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess( "org.drools.actions",
+                                                                                                   parameters );
+        assertEquals( ProcessInstance.STATE_ACTIVE,
+                      processInstance.getState() );
+        WorkItem workItem = handler.getWorkItem();
+        assertNotNull( workItem );
+
+        assertEquals( WorkItem.PENDING,
+                      workItem.getState() );
+
+        execContent( "testAbortWorkItem.in.1",
+                     Long.toString( workItem.getId() ) );
+
+        assertEquals( WorkItem.ABORTED,
+                      workItem.getState() );
+    }
+
+    @Test
+    public void testInsertObjectWithDeclaredFact() throws Exception {
+        String str = "";
+        str += "package org.foo \n";
+        str += "declare Whee \n\ttype: String\n\tprice: Integer\n\toldPrice: Integer\nend\n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Whee() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        ExecutionResults results = null;
+        String outXml = null;
+        ClassLoader orig = null;
+        ClassLoader cl = ((InternalRuleBase) ((StatefulKnowledgeSessionImpl) ksession).getRuleBase()).getRootClassLoader();
+        try {
+            orig = Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader( cl );
+            outXml = execContent( "testInsertObjectWithDeclaredFact.in.1" );
+            results = unmarshalOutXml( outXml,
+                                       ExecutionResults.class );
+        } finally {
+            Thread.currentThread().setContextClassLoader( orig );
+        }
+        FactHandle factHandle = (FactHandle) results.getFactHandle( "outStilton" );
+        Object object = results.getValue( "outStilton" );
+
+        assertEquals( "org.foo.Whee",
+                      object.getClass().getName() );
+        assertXMLEqual( getContent( "testInsertObjectWithDeclaredFact.expected.1",
+                                    factHandle.toExternalForm() ),
+                        outXml );
+
+    }
+
+    @Test
+    public void testInsertObjectWithDeclaredFactAndQuery() throws Exception {
+        String str = "";
+        str += "package org.foo \n";
+        str += "declare Whee \n\ttype: String\n\tprice: Integer\n\toldPrice: Integer\nend\n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Whee(price < 30) \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n update($c);\n";
+        str += "end\n";
+        str += "query results\n";
+        str += "    w: Whee(price > 0)";
+        str += "end\n";
+
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+        ClassLoader cl = ((InternalRuleBase) ((StatefulKnowledgeSessionImpl) ksession).getRuleBase()).getRootClassLoader();
+        ClassLoader orig = null;
+        try {
+            orig = Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader( cl );
+
+            String outXml = execContent( "testInsertObjectWithDeclaredFactAndQuery.in.1" );
+
+            ExecutionResults results = unmarshalOutXml( outXml,
+                                                        ExecutionResults.class );
+            FactHandle fh = (FactHandle) results.getFactHandle( "outStilton" );
+
+            outXml = execContent( "testInsertObjectWithDeclaredFactAndQuery.in.2" );
+
+            assertXMLEqual( getContent( "testInsertObjectWithDeclaredFactAndQuery.expected.1",
+                                        fh.toExternalForm() ),
+                            outXml );
+        } finally {
+            Thread.currentThread().setContextClassLoader( orig );
+        }
+    }
+
+    @Test
+    public void testExecutionNodeLookup() throws Exception {
+        String str = "";
+        str += "package org.drools \n";
+        str += "import org.drools.Cheese \n";
+        str += "rule rule1 \n";
+        str += "  when \n";
+        str += "    $c : Cheese() \n";
+        str += " \n";
+        str += "  then \n";
+        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+        str += "end\n";
+        
+        StatefulKnowledgeSession ksession = getStatefulKnowledgeSession( ResourceFactory.newByteArrayResource( str.getBytes() ) );
+        setExec( ksession );
+
+        String outXml = execContent( "testExecutionNodeLookup.in.1" );
+        ExecutionResults results = unmarshalOutXml( outXml, ExecutionResults.class );
+        
+        Cheese stilton = (Cheese) results.getValue( "outStilton" );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        FactHandle factHandle = (FactHandle) results.getFactHandle( "outStilton" );
+        stilton = (Cheese) ksession.getObject( factHandle );
+        assertEquals( 30,
+                      stilton.getPrice() );
+
+        assertXMLEqual( getContent( "testExecutionNodeLookup.expected.1", factHandle.toExternalForm() ),
+                        outXml );
+    }    
+    
+    public static class TestWorkItemHandler
+        implements
+        WorkItemHandler {
+        private WorkItem workItem;
+
+        public void executeWorkItem(WorkItem workItem,
+                                    WorkItemManager manager) {
+            this.workItem = workItem;
+        }
+
+        public void abortWorkItem(WorkItem workItem,
+                                  WorkItemManager manager) {
+        }
+
+        public WorkItem getWorkItem() {
+            return workItem;
+        }
+    }
+
+}

Added: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/JSonBatchExecutionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/JSonBatchExecutionTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/JSonBatchExecutionTest.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,175 @@
+package org.drools.camel.component;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jettison.badgerfish.BadgerFishDOMDocumentParser;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
+import org.drools.ChangeCollector;
+import org.drools.Cheese;
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.DirectoryLookupFactoryService;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.common.InternalFactHandle;
+import org.drools.definition.KnowledgePackage;
+import org.drools.grid.ExecutionNode;
+import org.drools.grid.local.LocalConnection;
+import org.drools.io.Resource;
+import org.drools.io.ResourceFactory;
+import org.drools.rule.builder.dialect.java.AbstractJavaRuleBuilder;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.ExecutionResults;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.mvel2.integration.impl.MapVariableResolverFactory;
+import org.mvel2.templates.SimpleTemplateRegistry;
+import org.mvel2.templates.TemplateCompiler;
+import org.mvel2.templates.TemplateRegistry;
+import org.mvel2.templates.TemplateRuntime;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class JSonBatchExecutionTest  extends BatchTest {//extends ContextTestSupport {
+    
+    public JSonBatchExecutionTest() {
+        super();
+        this.dataformat = "json";
+        //copyToDataFormat = "jaxb";
+    }
+        
+    
+    public void assertXMLEqual(String expectedXml,
+                                String resultXml) {
+        try {            
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode tree1 = mapper.readTree(expectedXml);
+            JsonNode tree2 = mapper.readTree(resultXml);
+            assertTrue( "Expected:" + expectedXml + "\nwas:" + resultXml, tree1.equals(tree2) );   
+        } catch ( Exception e ) {
+            throw new RuntimeException( "XML Assertion failure",
+                                        e );
+        }
+    }
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        //new PrintWriter(new BufferedWriter( new FileWriter( "jaxb.mvt", false )));
+    }
+
+
+
+//
+
+//    public void testVsmPipeline() throws Exception {
+//        String str = "";
+//        str += "package org.drools \n";
+//        str += "import org.drools.Cheese \n";
+//        str += "rule rule1 \n";
+//        str += "  when \n";
+//        str += "    $c : Cheese() \n";
+//        str += " \n";
+//        str += "  then \n";
+//        str += "    $c.setPrice( $c.getPrice() + 5 ); \n";
+//        str += "end\n";
+//
+//        String inXml = "";
+//        inXml += "{\"batch-execution\":{\"lookup\":\"ksession1\", \"commands\":[";
+//        inXml += "{\"insert\":{\"object\":{\"org.drools.Cheese\":{\"type\":\"stilton\",\"price\":25,\"oldPrice\":0}}, \"out-identifier\":\"outStilton\" } }";
+//        inXml += ", {\"fire-all-rules\":\"\"}";
+//        inXml += "]}}";        
+//        inXml = roundTripFromXml( inXml );        
+//        
+//        LocalConnection connection = new LocalConnection();
+//        ExecutionNode node = connection.getExecutionNode(null);
+//
+//        StatefulKnowledgeSession ksession = getExecutionNodeSessionStateful(node, ResourceFactory.newByteArrayResource( str.getBytes() ) );
+//
+//        node.get(DirectoryLookupFactoryService.class).register("ksession1", ksession);
+//
+//        XStreamResolverStrategy xstreamStrategy = new XStreamResolverStrategy() {
+//            public XStream lookup(String name) {
+//                return BatchExecutionHelper.newJSonMarshaller();
+//            }
+//        };
+//
+//        ResultHandlerImpl resultHandler = new ResultHandlerImpl();
+//        getPipelineSessionStateful(node, xstreamStrategy).insert(inXml, resultHandler);
+//        String outXml = (String) resultHandler.getObject();
+//
+//        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newJSonMarshaller().fromXML( outXml );
+//        Cheese stilton = (Cheese) result.getValue( "outStilton" );
+//        assertEquals( 30,
+//                      stilton.getPrice() );
+//
+//        FactHandle factHandle = (FactHandle) result.getFactHandle( "outStilton" );
+//        stilton = (Cheese) ksession.getObject( factHandle );
+//        assertEquals( 30,
+//                      stilton.getPrice() );
+//
+////        String expectedXml = "";
+////        expectedXml += "<execution-results>\n";
+////        expectedXml += "  <result identifier=\"outStilton\">\n";
+////        expectedXml += "    <org.drools.Cheese>\n";
+////        expectedXml += "      <type>stilton</type>\n";
+////        expectedXml += "      <oldPrice>0</oldPrice>\n";
+////        expectedXml += "      <price>30</price>\n";
+////        expectedXml += "    </org.drools.Cheese>\n";
+////        expectedXml += "  </result>\n";
+////        expectedXml += "  <fact-handle identifier=\"outStilton\" externalForm=\"" + ((InternalFactHandle) result.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n";
+////        expectedXml += "</execution-results>\n";
+////
+////        assertXMLEqual( expectedXml,
+////                        outXml );
+//    }
+
+//    private StatefulKnowledgeSession getExecutionNodeSessionStateful(ExecutionNode node, Resource resource) throws Exception {
+//        KnowledgeBuilder kbuilder = node.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilder();
+//        kbuilder.add( resource,
+//                      ResourceType.DRL );
+//
+//        if ( kbuilder.hasErrors() ) {
+//            System.out.println( kbuilder.getErrors() );
+//        }
+//
+//        assertFalse( kbuilder.hasErrors() );
+//        Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
+//
+//        KnowledgeBase kbase = node.get(KnowledgeBaseFactoryService.class).newKnowledgeBase();
+//
+//        kbase.addKnowledgePackages( pkgs );
+//        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
+//
+//        return session;
+//    }
+
+}

Modified: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchExecutionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchExecutionTest.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchExecutionTest.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -1914,25 +1914,5 @@
 
         return session;
     }
-//
-//    private StatefulKnowledgeSession getExecutionNodeSessionStateful(ExecutionNode node, Resource resource) throws Exception {
-//        KnowledgeBuilder kbuilder = node.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilder();
-//        kbuilder.add( resource,
-//                      ResourceType.DRL );
-//
-//        if ( kbuilder.hasErrors() ) {
-//            System.out.println( kbuilder.getErrors() );
-//        }
-//
-//        assertFalse( kbuilder.hasErrors() );
-//        Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
-//
-//        KnowledgeBase kbase = node.get(KnowledgeBaseFactoryService.class).newKnowledgeBase();
-//
-//        kbase.addKnowledgePackages( pkgs );
-//        StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
-//
-//        return session;
-//    }
 
 }

Added: labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchTest.java
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/java/org/drools/camel/component/XStreamBatchTest.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,39 @@
+package org.drools.camel.component;
+
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
+import org.junit.Ignore;
+
+ at Ignore
+public class XStreamBatchTest extends BatchTest {
+    
+    public XStreamBatchTest() {
+        this.dataformat = "xstream";
+    }
+    
+    @Override
+    public void setUp() throws Exception {
+        XMLUnit.setIgnoreComments( true );
+        XMLUnit.setIgnoreWhitespace( true );
+        XMLUnit.setIgnoreAttributeOrder( true );
+        XMLUnit.setNormalizeWhitespace( true );
+        XMLUnit.setNormalize( true );
+    }
+
+    public void assertXMLEqual(String expectedXml,
+                                String resultXml) {
+        try {
+            Diff diff = new Diff( expectedXml,
+                                  resultXml );
+            diff.overrideElementQualifier( new RecursiveElementNameAndTextQualifier() );
+            XMLAssert.assertXMLEqual( diff,
+                                      true );
+        } catch ( Exception e ) {
+            throw new RuntimeException( "XML Assertion failure",
+                                        e );
+        }
+    }    
+    
+}

Added: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/jaxb.mvt	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,803 @@
+
+ at declare{"testListenForChanges.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testListenForChanges.in.2"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="person" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="person">
+            <age>0</age>
+            <alive>false</alive>
+            <name>mic</name>
+            <sex>0</sex>
+        </object>
+    </insert>
+    <insert out-identifier="changes" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="changeCollector">
+            <retracted/>
+            <changes/>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testListenForChanges.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="changes">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="changeCollector">
+                <retracted/>
+                <changes>
+                    <element xsi:type="cheese">
+                        <oldPrice>0</oldPrice>
+                        <price>42</price>
+                        <type>stilton</type>
+                    </element>
+                </changes>
+            </value>
+        </item>
+        <item key="person">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="person">
+                <age>0</age>
+                <alive>false</alive>
+                <name>mic</name>
+                <sex>0</sex>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="changes">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:-1:20716393:20716393:3:null</value>
+        </item>
+        <item key="person">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:2:3112190:5463471:2:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testListenForChanges.in.3"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="person" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="person">
+            <age>0</age>
+            <alive>false</alive>
+            <name>mark</name>
+            <sex>0</sex>
+        </object>
+    </insert>
+    <insert out-identifier="changes" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="changeCollector">
+            <retracted/>
+            <changes/>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertWithDefaults.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertWithDefaults.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="outStilton">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="outStilton">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:1:27806520:-1889973673:1:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testInsertWithReturnObjectFalse.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="false">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertWithReturnObjectFalse.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results/>
+    <facts>
+        <item key="outStilton">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:1:30649454:-1889973673:1:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testFactHandleReturn.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <get-global identifier="list1" out-identifier="out-list"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testFactHandleReturn.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="out-list">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element external-form="0:1:19458313:6714693:1:DEFAULT" xsi:type="defaultFactHandle"/>
+            </value>
+        </item>
+    </results>
+    <facts/>
+</execution-results>
+ at end{}
+
+ at declare{"testGetObject.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="10"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testGetObject.in.2"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <get-object fact-handle="0:1:25089808:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testRetractObject.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="10"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testRetractObject.in.2"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <retract fact-handle="0:1:3751575:-1889973673:1:DEFAULT"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testRetractObject.in.3"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <get-object fact-handle="0:1:3751575:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="outStilton">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="outStilton">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:1:2020896:-1889973673:1:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testModifyObject.in.2"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <modify fact-handle="0:1:2020896:-1889973673:1:DEFAULT">
+        <setters>
+            <item accessor="oldPrice" value="42"/>
+            <item accessor="price" value="50"/>
+        </setters>
+    </modify>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.3"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <get-object fact-handle="0:1:2020896:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.4"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <modify fact-handle="0:1:2020896:-1889973673:1:DEFAULT">
+        <setters>
+            <item accessor="type" value="throwException()"/>
+            <item accessor="price" value="100"/>
+        </setters>
+    </modify>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.5"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <get-object fact-handle="0:1:2020896:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertElements.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <insert-elements return-objects="true">
+        <list>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>25</price>
+                <type>stilton</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </element>
+        </list>
+    </insert-elements>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertElements.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="list1">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>35</price>
+                    <type>stilton</type>
+                </element>
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>30</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+    </results>
+    <facts/>
+</execution-results>
+ at end{}
+
+ at declare{"testInsertElementsWithReturnObjects.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <insert-elements outIdentifier="myfacts" return-objects="true">
+        <list>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>25</price>
+                <type>stilton</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </element>
+        </list>
+    </insert-elements>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertElementsWithReturnObjects.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="myfacts">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>30</price>
+                    <type>stilton</type>
+                </element>
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>35</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+        <item key="list1">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>35</price>
+                    <type>stilton</type>
+                </element>
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>30</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="myfacts">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element external-form="0:1:4329028:-1889973673:1:DEFAULT" xsi:type="defaultFactHandle"/>
+                <element external-form="0:2:11970043:-1889973518:2:DEFAULT" xsi:type="defaultFactHandle"/>
+            </value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testSetGlobal.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <set-global identifier="list1" out="false">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <set-global identifier="list2" out="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <set-global identifier="list3" out="true" out-identifier="outList3">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>5</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testSetGlobal.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="list2">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>30</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+        <item key="outStilton">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </value>
+        </item>
+        <item key="outList3">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>30</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="outStilton">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:1:14649554:-1889974293:1:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testGetGlobal.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <get-global identifier="list1" out-identifier="out-list"/>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testGetGlobal.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="out-list">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>25</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+        <item key="outStilton">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>25</price>
+                <type>stilton</type>
+            </value>
+        </item>
+        <item key="list1">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>25</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="outStilton">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:1:8855997:-1889973673:1:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testGetObjects.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert-elements return-objects="true">
+        <list>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>25</price>
+                <type>stilton</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </element>
+        </list>
+    </insert-elements>
+    <get-objects out-identifier="list1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testQuery.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert-elements return-objects="true">
+        <list>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>2</price>
+                <type>stilton</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>1</price>
+                <type>cheddar</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>2</price>
+                <type>cheddar</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>1</price>
+                <type>stilton</type>
+            </element>
+        </list>
+    </insert-elements>
+    <query name="cheeses" out-identifier="cheeses"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testQuery.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="cheeses">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="query-results">
+                <identifiers>
+                    <item key="cheddar">
+                        <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">0</value>
+                    </item>
+                    <item key="stilton">
+                        <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">1</value>
+                    </item>
+                </identifiers>
+                <results>
+                    <item xmlns:ns3="http://jaxb.dev.java.net/array" xsi:type="ns3:anyTypeArray">
+                        <item xsi:type="cheese">
+                            <oldPrice>0</oldPrice>
+                            <price>2</price>
+                            <type>cheddar</type>
+                        </item>
+                        <item xsi:type="cheese">
+                            <oldPrice>0</oldPrice>
+                            <price>2</price>
+                            <type>stilton</type>
+                        </item>
+                    </item>
+                    <item xmlns:ns3="http://jaxb.dev.java.net/array" xsi:type="ns3:anyTypeArray">
+                        <item xsi:type="cheese">
+                            <oldPrice>0</oldPrice>
+                            <price>1</price>
+                            <type>cheddar</type>
+                        </item>
+                        <item xsi:type="cheese">
+                            <oldPrice>0</oldPrice>
+                            <price>1</price>
+                            <type>stilton</type>
+                        </item>
+                    </item>
+                </results>
+                <fact-handles>
+                    <item xmlns:ns3="http://jaxb.dev.java.net/array" xsi:type="ns3:anyTypeArray">
+                        <item external-form="0:3:29292935:742337872:3:DEFAULT" xsi:type="defaultFactHandle"/>
+                        <item external-form="0:1:18538167:-1889974386:1:DEFAULT" xsi:type="defaultFactHandle"/>
+                    </item>
+                    <item xmlns:ns3="http://jaxb.dev.java.net/array" xsi:type="ns3:anyTypeArray">
+                        <item external-form="0:2:2419450:742337841:2:DEFAULT" xsi:type="defaultFactHandle"/>
+                        <item external-form="0:4:15736146:-1889974417:4:DEFAULT" xsi:type="defaultFactHandle"/>
+                    </item>
+                </fact-handles>
+            </value>
+        </item>
+    </results>
+    <facts/>
+</execution-results>
+ at end{}
+
+ at declare{"testManualFireAllRules.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper"/>
+    </set-global>
+    <insert-elements return-objects="true">
+        <list>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>25</price>
+                <type>stilton</type>
+            </element>
+            <element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </element>
+        </list>
+    </insert-elements>
+    <fire-all-rules max="-1"/>
+    <insert out-identifier="outBrie" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>10</price>
+            <type>brie</type>
+        </object>
+    </insert>
+</batch-execution>
+ at end{}
+
+ at declare{"testManualFireAllRules.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="outBrie">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>10</price>
+                <type>brie</type>
+            </value>
+        </item>
+        <item key="list1">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>35</price>
+                    <type>stilton</type>
+                </element>
+                <element xsi:type="cheese">
+                    <oldPrice>0</oldPrice>
+                    <price>30</price>
+                    <type>stilton</type>
+                </element>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="outBrie">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:4:2742328:3033699:4:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}
+
+ at declare{"testProcess.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <start-process processId="org.drools.actions">
+        <parameter>
+            <item key="person">
+                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="testVariable">
+                    <name>John Doe</name>
+                </value>
+            </item>
+        </parameter>
+    </start-process>
+    <get-global identifier="list1" out-identifier="out-list"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testProcess.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="out-list">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="jaxbListWrapper">
+                <element xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">John Doe</element>
+            </value>
+        </item>
+    </results>
+    <facts/>
+</execution-results>
+ at end{}
+
+ at declare{"testProcessInstanceSignalEvent.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <signal-event event-type="MyEvent" process-instance-id="1">
+        <event xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">MyValue</event>
+    </signal-event>
+</batch-execution>
+ at end{}
+
+ at declare{"testProcessRuntimeSignalEvent.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <signal-event event-type="MyEvent" process-instance-id="-1">
+        <event xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">MyValue</event>
+    </signal-event>
+</batch-execution>
+ at end{}
+
+ at declare{"testCompleteWorkItem.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<completeWorkItemCommand id="1"/>
+ at end{}
+
+ at declare{"testCompleteWorkItem.in.2"}
+<?xml version="1.0" encoding="UTF-8"?>
+<completeWorkItemCommand id="2"/>
+ at end{}
+
+ at declare{"testAbortWorkItem.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<abortWorkItemCommand id="1"/>
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFact.in.1"}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.in.1"}
+
+ at declare{"testExecutionNodeLookup.in.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+            <oldPrice>0</oldPrice>
+            <price>25</price>
+            <type>stilton</type>
+        </object>
+    </insert>
+    <fire-all-rules max="-1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testExecutionNodeLookup.expected.1"}
+<?xml version="1.0" encoding="UTF-8"?>
+<execution-results>
+    <results>
+        <item key="outStilton">
+            <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="cheese">
+                <oldPrice>0</oldPrice>
+                <price>30</price>
+                <type>stilton</type>
+            </value>
+        </item>
+    </results>
+    <facts>
+        <item key="outStilton">
+            <value xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">0:1:31196317:-1889973673:1:DEFAULT</value>
+        </item>
+    </facts>
+</execution-results>
+ at end{}

Added: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/json.mvt
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/json.mvt	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/json.mvt	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,358 @@
+ at declare{"testListenForChanges.in.1"}
+{
+   "batch-execution":{
+      "commands":[
+         {
+            "insert":{
+               "out-identifier":"outStilton",
+               "return-object":true,
+               "object":{
+                  "org.drools.Cheese":{
+                     "type":"stilton",
+                     "price":25,
+                     "oldPrice":0
+                  }
+               }
+            }
+         },
+         {
+            "fire-all-rules":""
+         }
+      ]
+   }
+}
+ at end{}
+
+ at declare{"testListenForChanges.in.2"}
+{
+   "batch-execution":{
+      "commands":[
+         {
+            "insert":{
+               "out-identifier":"person",
+               "return-object":true,
+               "object":{
+                  "org.drools.Person":{
+                     "name":"mic",
+                     "age":0,
+                     "sex":"",
+                     "alive":false
+                  }
+               }
+            }
+         },
+         {
+            "insert":{
+               "out-identifier":"changes",
+               "return-object":true,
+               "object":{
+                  "org.drools.ChangeCollector":""
+               }
+            }
+         },
+         {
+            "fire-all-rules":""
+         }
+      ]
+   }
+}
+ at end{}
+
+ at declare{"testListenForChanges.expected.1"}
+{
+   "execution-results":{
+      "results":{
+         "result":[
+            {
+               "identifier":"changes",
+               "value":{
+                  "org.drools.ChangeCollector":{
+                     "changes":{
+                        "org.drools.Cheese":{
+                           "type":"stilton",
+                           "price":42,
+                           "oldPrice":0
+                        }
+                     }
+                  }
+               }
+            },
+            {
+               "identifier":"person",
+               "value":{
+                  "org.drools.Person":{
+                     "name":"mic",
+                     "age":0,
+                     "sex":"",
+                     "alive":false
+                  }
+               }
+            }
+         ],
+         "fact-handle":[
+            {
+               "identifier":"changes",
+               "external-form":"@{var1}"
+            },
+            {
+               "identifier":"person",
+               "external-form":"@{var2}"
+            }
+         ]
+      }
+   }
+}
+ at end{}
+
+ at declare{"testListenForChanges.in.3"}
+{
+   "batch-execution":{
+      "commands":[
+         {
+            "insert":{
+               "object":{
+                  "org.drools.Person":{
+                     "name":"mark"
+                  }
+               },
+               "out-identifier":"person"
+            }
+         },
+         {
+            "insert":{
+               "object":{
+                  "org.drools.ChangeCollector":{
+
+                  }
+               },
+               "out-identifier":"changes"
+            }
+         },
+         {
+            "fire-all-rules":""
+         }
+      ]
+   }
+}
+ at end{}
+
+ at declare{"testInsertWithDefaults.in.1"}
+{
+   "batch-execution":{
+      "commands":[
+         {
+            "insert":{
+               "object":{
+                  "org.drools.Cheese":{
+                     "type":"stilton",
+                     "price":25,
+                     "oldPrice":0
+                  }
+               },
+               "out-identifier":"outStilton"
+            }
+         },
+         {
+            "fire-all-rules":""
+         }
+      ]
+   }
+}
+ at end{}
+
+ at declare{"testInsertWithDefaults.expected.1"}
+{
+   "execution-results":{
+      "results":{
+         "result":{
+            "identifier":"outStilton",
+            "value":{
+               "org.drools.Cheese":{
+                  "type":"stilton",
+                  "price":30,
+                  "oldPrice":0
+               }
+            }
+         },
+         "fact-handle":{
+            "identifier":"outStilton",
+            "external-form":"@{var1}"
+         }
+      }
+   }
+}
+ at end{}
+
+ at declare{"testInsertWithReturnObjectFalse.in.1"}
+{"batch-execution":{"commands":[{"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}, "return-object":false, "out-identifier":"outStilton" } }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testInsertWithReturnObjectFalse.expected.1"}
+{"execution-results":{"results":{"fact-handle":{"identifier":"outStilton","external-form":"@{var1}"}}}}
+ at end{}
+
+ at declare{"testFactHandleReturn.in.1"}
+{"batch-execution":{"commands":[  {"get-global":{"identifier":"list1","out-identifier":"out-list"}}]}}
+ at end{}
+
+ at declare{"testFactHandleReturn.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"out-list","value":{"list":{"fact-handle":{"external-form":"@{var1}"}}}}}}}
+ at end{}
+
+ at declare{"testGetObject.in.1"}
+{"batch-execution":{"commands":[{"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}, "out-identifier":"outStilton" } }, {"fire-all-rules":{"max":10}}]}}
+ at end{}
+
+ at declare{"testGetObject.in.2"}
+{"batch-execution":{"commands":[  {"get-object":{       "out-identifier":'outStilton',      "fact-handle":"@{var1}"}}]}}
+ at end{}
+
+ at declare{"testRetractObject.in.1"}
+{"batch-execution":{"commands":[{"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}, "out-identifier":"outStilton" } }, {"fire-all-rules":{"max":10}}]}}
+ at end{}
+
+
+ at declare{"testRetractObject.in.2"}
+{"batch-execution":{"commands":[  { "retract":{"fact-handle":"@{var1}"}}]}}
+ at end{}
+
+ at declare{"testRetractObject.in.3"}
+{"batch-execution":{"commands":[  {"get-object":{       "out-identifier":'outStilton',      "fact-handle":"@{var1}"}}]}}
+ at end{}
+
+ at declare{"testModifyObject.in.1"}
+{"batch-execution":{"commands":[{"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}, "out-identifier":"outStilton" } }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testModifyObject.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"outStilton","value":{"org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}},"fact-handle":{"identifier":"outStilton","external-form":"@{var1}"}}}}
+ at end{}
+
+ at declare{"testModifyObject.in.2"}
+{"batch-execution":{"commands":[  {"modify":{"fact-handle":"@{var1}", "setters":[{"accessor":"oldPrice","set":42}, {"accessor":"price","set":50}]} }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testModifyObject.in.3"}
+{"batch-execution":{"commands":[  {"get-object":{ "out-identifier":'outStilton', "fact-handle":"@{var1}"}}]}}
+ at end{}
+
+ at declare{"testModifyObject.in.4"}
+{"batch-execution":{"commands":[  {"modify":{"fact-handle":"@{var1}",  "setters":[{"accessor":"type","set":throwException()}, {"accessor":"price","set":100}]} }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testModifyObject.in.5"}
+{"batch-execution":{"commands":[  {"get-object":{ "out-identifier":'outStilton', "fact-handle":"@{var1}"}}]}}
+ at end{}
+
+ at declare{"testInsertElements.in.1"}
+{"batch-execution":{"commands":[   {"set-global":{"identifier":"list1","out"=true                   ,"object":{"list":{"object":[]}}   } } ,  {"insert-elements":{"objects":[   {   "org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}},    {   "org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}    ]}}, {"fire-all-rules":""}]}}    
+ at end{}
+
+ at declare{"testInsertElements.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"list1","value":{"list":{"org.drools.Cheese":[{"type":"stilton","price":35,"oldPrice":0},{"type":"stilton","price":30,"oldPrice":0}]}}}}}}
+ at end{}
+
+
+ at declare{"testInsertElementsWithReturnObjects.in.1"}
+{"batch-execution":{"commands":[   {"set-global":{"identifier":"list1","out":"true","object":{"list":{"object":[]}}   } } ,  {"insert-elements":{"out-identifier":"myfacts","return-objects":true,"objects":[   {   "org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}},    {   "org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}    ]}}, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testInsertElementsWithReturnObjects.expected.1"}
+{"execution-results":{"results":{"result":[{"identifier":"myfacts","value":{"list":{"org.drools.Cheese":[{"type":"stilton","price":30,"oldPrice":0},{"type":"stilton","price":35,"oldPrice":0}]}}},{"identifier":"list1","value":{"list":{"org.drools.Cheese":[{"type":"stilton","price":35,"oldPrice":0},{"type":"stilton","price":30,"oldPrice":0}]}}}],"fact-handles":{"identifier":"myfacts","string":["@{var1}", "@{var2}"]}}}}
+ at end{}
+
+ at declare{"testSetGlobal.in.1"}
+    {"batch-execution":{"commands":[ {"set-global":{"identifier":"list1","object":{"list":{"object":[]}}} } , {"set-global":{"identifier":"list2","out":true,"object":{"list":{"object":[]}}} } , {"set-global":{"identifier":"list3","out-identifier":"outList3","object":{"list":{"object":[]}}} } , {"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":5}}, "out-identifier":"outStilton" } }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testSetGlobal.expected.1"}
+{"execution-results":{"results":{"result":[{"identifier":"list2","value":{"list":{"org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}}},{"identifier":"outStilton","value":{"org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}},{"identifier":"outList3","value":{"list":{"org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}}}],"fact-handle":{"identifier":"outStilton","external-form":"@{var1}"}}}}
+ at end{}
+
+ at declare{"testGetGlobal.in.1"}
+{"batch-execution":{"commands":[   {"set-global":{"identifier":"list1","out"=true                   ,"object":{"list":{"object":[]}}   } } ,  {"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}, "out-identifier":"outStilton" } },  {"get-global":{"identifier":"list1","out-identifier"="out-list"}}, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testGetGlobal.expected.1"}
+{"execution-results":{"results":{"result":[{"identifier":"out-list","value":{"list":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}}},{"identifier":"outStilton","value":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}},{"identifier":"list1","value":{"list":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}}}],"fact-handle":{"identifier":"outStilton","external-form":"@{var1}"}}}}
+ at end{}
+
+ at declare{"testGetObjects.in.1"}
+{"batch-execution":{"commands":[  {"insert-elements":{"objects":[   {   "org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}},    {   "org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}    ]}},  {"get-objects":{"out-identifier":"list1"}}]}}
+ at end{}
+
+ at declare{"testGetObjects.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"list1","value":{"list":{"org.drools.Cheese":[{"type":"stilton","price":35,"oldPrice":0},{"type":"stilton","price":30,"oldPrice":0}]}}}}}}
+ at end{}
+
+ at declare{"testQuery.in.1"}
+{"batch-execution":{"commands":[  {"insert-elements":{"objects":[   {   "org.drools.Cheese":{"type":"stilton","price":2}},    {   "org.drools.Cheese":{"type":"cheddar","price":1}},    {   "org.drools.Cheese":{"type":"cheddar","price":2}},    {   "org.drools.Cheese":{"type":"stilton","price":1}}     ]}},  {"query":{"out-identifier":"cheeses","name":"cheeses"}}]}}
+ at end{}
+
+ at declare{"testQuery.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"cheeses","value":{"query-results":{"identifiers":{"string":["cheddar","stilton"]},"row":[{"item":[{"external-form":"0:3:29292935:742337872:3:DEFAULT","object":{"org.drools.Cheese":{"type":"cheddar","price":2,"oldPrice":0}}},{"external-form":"0:1:18538167:-1889974386:1:DEFAULT","object":{"org.drools.Cheese":{"type":"stilton","price":2,"oldPrice":0}}}]},{"item":[{"external-form":"0:2:2419450:742337841:2:DEFAULT","object":{"org.drools.Cheese":{"type":"cheddar","price":1,"oldPrice":0}}},{"external-form":"0:4:15736146:-1889974417:4:DEFAULT","object":{"org.drools.Cheese":{"type":"stilton","price":1,"oldPrice":0}}}]}]}}}}}}
+ at end{}
+
+ at declare{"testManualFireAllRules.in.1"}
+{"batch-execution":{"commands":[   {"set-global":{"identifier":"list1","out":true                   ,"object":{"list":{"object":[]}}   } } ,  {"insert-elements":{"objects":[   {   "org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}},    {   "org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}    ]}}, {"fire-all-rules":""}, {"insert":{"object":{"org.drools.Cheese":{"type":"brie","price":10,"oldPrice":0}}, "out-identifier":"outBrie" } }]}}
+ at end{}
+
+ at declare{"testManualFireAllRules.expected.1"}
+{"execution-results":{"results":{"result":[{"identifier":"outBrie","value":{"org.drools.Cheese":{"type":"brie","price":10,"oldPrice":0}}},{"identifier":"list1","value":{"list":{"org.drools.Cheese":[{"type":"stilton","price":35,"oldPrice":0},{"type":"stilton","price":30,"oldPrice":0}]}}}],"fact-handle":{"identifier":"outBrie","external-form":"@{var1}"}}}}
+ at end{}
+
+ at declare{"testProcess.in.1"}
+{"batch-execution":{"commands":[   {"start-process":      {"process-id":"org.drools.actions",     "parameters":[        {"identifier":"person",         "object":{"@class":"org.drools.TestVariable",                     "name":"John Doe"}}]}},    {"get-global":{"identifier":"list1","out-identifier":"out-list"}}]}}
+ at end{}
+
+ at declare{"testProcess.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"out-list","value":{"list":{"string":"John Doe"}}}}}}
+ at end{}
+
+ at declare{"testProcessInstanceSignalEvent.in.1"}
+{"batch-execution":{"commands":[{"signal-event":{"process-instance-id":1,"event-type":"MyEvent"                   ,"object":{"string":["MyValue"]} } }]}}
+ at end{}
+
+ at declare{"testProcessRuntimeSignalEvent.in.1"}
+{"batch-execution":{"commands":[   {"signal-event":{"event-type":"MyEvent"                    ,"object":{"string":["MyValue"]} } }]}}
+ at end{}
+
+ at declare{"testCompleteWorkItem.in.1"}
+{"complete-work-item":{"id":@{var1}}}
+ at end{}
+
+ at declare{"testCompleteWorkItem.in.2"}
+{"complete-work-item":{"id":@{var1},"results":{"identifier":"Result","object":{"@class":"string","$":"SomeOtherString"}}}}
+ at end{}
+
+ at declare{"testAbortWorkItem.in.1"}
+{"abort-work-item":{"id":@{var1}}}
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFact.in.1"}
+{"batch-execution":{"commands":[{"insert":{"object":{"org.foo.Whee":{"type":"stilton","price":25,"oldPrice":0}}, "out-identifier":"outStilton" } }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFact.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"outStilton","value":{"org.foo.Whee":{"type":"stilton","price":30,"oldPrice":0}}},"fact-handle":{"identifier":"outStilton","external-form":"@{var1}"}}}}
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.in.1"}
+{"batch-execution":{"commands":[{"insert":{"out-identifier":"outStilton", "object":{"org.foo.Whee":{"type":"stilton","price":25,"oldPrice":0}} } }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.in.2"}
+{"batch-execution":{"commands":[   {"query":{"out-identifier":"matchingthings","name":"results"}}]}}
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"matchingthings","value":{"query-results":{"identifiers":{"string":"w"},"row":{"item":{"external-form":"@{var1}","object":{"org.foo.Whee":{"type":"stilton","price":30,"oldPrice":0}}}}}}}}}}
+ at end{}
+
+ at declare{"testExecutionNodeLookup.in.1"}
+{"batch-execution":{"commands":[{"insert":{"object":{"org.drools.Cheese":{"type":"stilton","price":25,"oldPrice":0}}, "return-object":true, "out-identifier":"outStilton" } }, {"fire-all-rules":""}]}}
+ at end{}
+
+ at declare{"testExecutionNodeLookup.expected.1"}
+{"execution-results":{"results":{"result":{"identifier":"outStilton","value":{"org.drools.Cheese":{"type":"stilton","price":30,"oldPrice":0}}},"fact-handle":{"identifier":"outStilton","external-form":"@{var1}"}}}}
+ at end{}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/xstream.mvt
===================================================================
--- labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/xstream.mvt	                        (rev 0)
+++ labs/jbossrules/trunk/drools-camel/src/test/resources/org/drools/camel/component/xstream.mvt	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,720 @@
+
+ at declare{"testListenForChanges.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testListenForChanges.in.2"}
+
+<batch-execution>
+    <insert out-identifier="person" return-object="true">
+        <org.drools.Person>
+            <name>mic</name>
+            <age>0</age>
+            <sex/>
+            <alive>false</alive>
+        </org.drools.Person>
+    </insert>
+    <insert out-identifier="changes" return-object="true">
+        <org.drools.ChangeCollector/>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testListenForChanges.expected.1"}
+
+<execution-results>
+    <result identifier="changes">
+        <org.drools.ChangeCollector>
+            <changes>
+                <org.drools.Cheese>
+                    <type>stilton</type>
+                    <price>42</price>
+                    <oldPrice>0</oldPrice>
+                </org.drools.Cheese>
+            </changes>
+        </org.drools.ChangeCollector>
+    </result>
+    <result identifier="person">
+        <org.drools.Person>
+            <name>mic</name>
+            <age>0</age>
+            <sex/>
+            <alive>false</alive>
+        </org.drools.Person>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="changes"/>
+    <fact-handle external-form="@{var2}" identifier="person"/>
+</execution-results>
+ at end{}
+
+ at declare{"testListenForChanges.in.3"}
+
+<batch-execution>
+    <insert out-identifier="person" return-object="true">
+        <org.drools.Person>
+            <name>mark</name>
+            <age>0</age>
+            <sex/>
+            <alive>false</alive>
+        </org.drools.Person>
+    </insert>
+    <insert out-identifier="changes" return-object="true">
+        <org.drools.ChangeCollector/>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertWithDefaults.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertWithDefaults.expected.1"}
+
+<execution-results>
+    <result identifier="outStilton">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}
+
+ at declare{"testInsertWithReturnObjectFalse.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="false">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertWithReturnObjectFalse.expected.1"}
+
+<execution-results>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}
+
+ at declare{"testFactHandleReturn.in.1"}
+
+<batch-execution>
+    <get-global identifier="list1" out-identifier="out-list"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testFactHandleReturn.expected.1"}
+
+<execution-results>
+    <result identifier="out-list">
+        <list>
+            <fact-handle external-form="@{var1}"/>
+        </list>
+    </result>
+</execution-results>
+ at end{}
+
+ at declare{"testGetObject.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules max="10"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testGetObject.in.2"}
+
+<batch-execution>
+    <get-object fact-handle="0:1:19419730:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testRetractObject.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules max="10"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testRetractObject.in.2"}
+
+<batch-execution>
+    <retract fact-handle="0:1:16031375:-1889973673:1:DEFAULT"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testRetractObject.in.3"}
+
+<batch-execution>
+    <get-object fact-handle="0:1:16031375:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.expected.1"}
+
+<execution-results>
+    <result identifier="outStilton">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}
+
+ at declare{"testModifyObject.in.2"}
+
+<batch-execution>
+    <modify fact-handle="0:1:8501308:-1889973673:1:DEFAULT">
+        <set accessor="oldPrice" value="42"/>
+        <set accessor="price" value="50"/>
+    </modify>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.3"}
+
+<batch-execution>
+    <get-object fact-handle="0:1:8501308:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.4"}
+
+<batch-execution>
+    <modify fact-handle="0:1:8501308:-1889973673:1:DEFAULT">
+        <set accessor="type" value="throwException()"/>
+        <set accessor="price" value="100"/>
+    </modify>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testModifyObject.in.5"}
+
+<batch-execution>
+    <get-object fact-handle="0:1:8501308:-1889973673:1:DEFAULT" out-identifier="outStilton"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertElements.in.1"}
+
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <list/>
+    </set-global>
+    <insert-elements>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert-elements>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertElements.expected.1"}
+
+<execution-results>
+    <result identifier="list1">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>35</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>30</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+</execution-results>
+ at end{}
+
+ at declare{"testInsertElementsWithReturnObjects.in.1"}
+
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <list/>
+    </set-global>
+    <insert-elements out-identifier="myfacts" return-objects="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert-elements>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertElementsWithReturnObjects.expected.1"}
+
+<execution-results>
+    <result identifier="myfacts">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>30</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>35</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <result identifier="list1">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>35</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>30</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <fact-handles identifier="myfacts">
+        <fact-handle external-form="@{var1}"/>
+        <fact-handle external-form="@{var2}"/>
+    </fact-handles>
+</execution-results>
+ at end{}
+
+ at declare{"testSetGlobal.in.1"}
+
+<batch-execution>
+    <set-global identifier="list1">
+        <list/>
+    </set-global>
+    <set-global identifier="list2" out="true">
+        <list/>
+    </set-global>
+    <set-global identifier="list3" out-identifier="outList3">
+        <list/>
+    </set-global>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>5</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testSetGlobal.expected.1"}
+
+<execution-results>
+    <result identifier="list2">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>30</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <result identifier="outStilton">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </result>
+    <result identifier="outList3">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>30</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}
+
+ at declare{"testGetGlobal.in.1"}
+
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <list/>
+    </set-global>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <get-global identifier="list1" out-identifier="out-list"/>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testGetGlobal.expected.1"}
+
+<execution-results>
+    <result identifier="out-list">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>25</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <result identifier="outStilton">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </result>
+    <result identifier="list1">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>25</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}
+
+ at declare{"testGetObjects.in.1"}
+
+<batch-execution>
+    <insert-elements>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert-elements>
+    <get-objects out-identifier="list1"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testQuery.in.1"}
+
+<batch-execution>
+    <insert-elements>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>2</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>cheddar</type>
+            <price>1</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>cheddar</type>
+            <price>2</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>1</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert-elements>
+    <query name="cheeses" out-identifier="cheeses"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testManualFireAllRules.in.1"}
+
+<batch-execution>
+    <set-global identifier="list1" out="true">
+        <list/>
+    </set-global>
+    <insert-elements>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert-elements>
+    <fire-all-rules/>
+    <insert out-identifier="outBrie" return-object="true">
+        <org.drools.Cheese>
+            <type>brie</type>
+            <price>10</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+</batch-execution>
+ at end{}
+
+ at declare{"testManualFireAllRules.expected.1"}
+
+<execution-results>
+    <result identifier="outBrie">
+        <org.drools.Cheese>
+            <type>brie</type>
+            <price>10</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </result>
+    <result identifier="list1">
+        <list>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>35</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+            <org.drools.Cheese>
+                <type>stilton</type>
+                <price>30</price>
+                <oldPrice>0</oldPrice>
+            </org.drools.Cheese>
+        </list>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outBrie"/>
+</execution-results>
+ at end{}
+
+ at declare{"testProcess.in.1"}
+
+<batch-execution>
+    <start-process processId="org.drools.actions">
+        <parameter identifier="person">
+            <org.drools.TestVariable>
+                <name>John Doe</name>
+            </org.drools.TestVariable>
+        </parameter>
+    </start-process>
+    <get-global identifier="list1" out-identifier="out-list"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testProcess.expected.1"}
+
+<execution-results>
+    <result identifier="out-list">
+        <list>
+            <string>John Doe</string>
+        </list>
+    </result>
+</execution-results>
+ at end{}
+
+ at declare{"testProcessInstanceSignalEvent.in.1"}
+
+<batch-execution>
+    <signal-event event-type="MyEvent" process-instance-id="1">
+        <string>MyValue</string>
+    </signal-event>
+</batch-execution>
+ at end{}
+
+ at declare{"testProcessRuntimeSignalEvent.in.1"}
+
+<batch-execution>
+    <signal-event event-type="MyEvent">
+        <string>MyValue</string>
+    </signal-event>
+</batch-execution>
+ at end{}
+
+ at declare{"testCompleteWorkItem.in.1"}
+
+<complete-work-item id="1"/>
+ at end{}
+
+ at declare{"testCompleteWorkItem.in.2"}
+
+<complete-work-item id="2">
+    <result identifier="Result">
+        <string>SomeOtherString</string>
+    </result>
+</complete-work-item>
+ at end{}
+
+ at declare{"testAbortWorkItem.in.1"}
+
+<abort-work-item id="1"/>
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFact.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.foo.Whee>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.foo.Whee>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFact.expected.1"}
+
+<execution-results>
+    <result identifier="outStilton">
+        <org.foo.Whee>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.foo.Whee>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.foo.Whee>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.foo.Whee>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.in.2"}
+
+<batch-execution>
+    <query name="results" out-identifier="matchingthings"/>
+</batch-execution>
+ at end{}
+
+ at declare{"testInsertObjectWithDeclaredFactAndQuery.expected.1"}
+
+<execution-results>
+    <result identifier="matchingthings">
+        <query-results>
+            <identifiers/>
+            <row/>
+        </query-results>
+    </result>
+</execution-results>
+ at end{}
+
+ at declare{"testExecutionNodeLookup.in.1"}
+
+<batch-execution>
+    <insert out-identifier="outStilton" return-object="true">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>25</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </insert>
+    <fire-all-rules/>
+</batch-execution>
+ at end{}
+
+ at declare{"testExecutionNodeLookup.expected.1"}
+
+<execution-results>
+    <result identifier="outStilton">
+        <org.drools.Cheese>
+            <type>stilton</type>
+            <price>30</price>
+            <oldPrice>0</oldPrice>
+        </org.drools.Cheese>
+    </result>
+    <fact-handle external-form="@{var1}" identifier="outStilton"/>
+</execution-results>
+ at end{}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/BatchExecutionCommand.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -81,7 +81,7 @@
 	
 	private static final long serialVersionUID = 510l;
 	
-	@XmlAttribute(required=true)
+	@XmlAttribute
 	@XStreamAsAttribute
 	private String lookup;
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/SetGlobalCommand.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -40,7 +40,7 @@
     private String  identifier;
 	
 	@XmlElement
-	//@XmlJavaTypeAdapter(JaxbUnknownAdapter.class)
+	@XmlJavaTypeAdapter(JaxbUnknownAdapter.class)
     private Object  object;
 
     @XmlAttribute(name="out-identifier")

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/process/SignalEventCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/process/SignalEventCommand.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/process/SignalEventCommand.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -20,21 +20,26 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.drools.command.Context;
 import org.drools.command.impl.GenericCommand;
 import org.drools.command.impl.KnowledgeCommandContext;
 import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.process.ProcessInstance;
+import org.drools.xml.jaxb.util.JaxbUnknownAdapter;
 
 @XmlAccessorType(XmlAccessType.NONE)
 public class SignalEventCommand implements GenericCommand<Object> {
 	
 	@XmlAttribute(name="process-instance-id")
 	private long processInstanceId = -1;
+	
 	@XmlAttribute(name="event-type", required=true)
 	private String eventType;
+	
 	@XmlElement(name="event")
+	@XmlJavaTypeAdapter(JaxbUnknownAdapter.class)
 	private Object event;	
 	
     public SignalEventCommand() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/FireAllRulesCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/FireAllRulesCommand.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/FireAllRulesCommand.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -19,6 +19,7 @@
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
 
 import org.drools.command.Context;
 import org.drools.command.impl.GenericCommand;
@@ -36,6 +37,7 @@
 	@XmlAttribute
     private int          max          = -1;
     private AgendaFilter agendaFilter = null;
+    
     @XmlAttribute(name="out-identifier")
     private String       outIdentifier;
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/command/runtime/rule/InsertObjectCommand.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -22,6 +22,7 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.drools.command.Context;
 import org.drools.command.impl.GenericCommand;
@@ -30,6 +31,7 @@
 import org.drools.reteoo.ReteooWorkingMemory;
 import org.drools.runtime.StatefulKnowledgeSession;
 import org.drools.runtime.rule.FactHandle;
+import org.drools.xml.jaxb.util.JaxbUnknownAdapter;
 
 @XmlAccessorType(XmlAccessType.NONE)
 public class InsertObjectCommand
@@ -39,11 +41,13 @@
 	private static final long serialVersionUID = 510l;
 
 	@XmlElement
+	@XmlJavaTypeAdapter(JaxbUnknownAdapter.class)
 	private Object  object;
 
-	@XmlAttribute(name="out-identifier", required=true)
+	@XmlAttribute(name="out-identifier")
     private String  outIdentifier;
 
+	@XmlAttribute(name="return-object")
     private boolean returnObject = true;
     
     public InsertObjectCommand() {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/FlatQueryResults.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -33,16 +33,25 @@
 import org.drools.runtime.rule.QueryResults;
 import org.drools.runtime.rule.QueryResultsRow;
 import org.drools.xml.jaxb.util.JaxbFlatQueryResultsAdapter;
+import org.drools.xml.jaxb.util.JaxbMapAdapter;
 
 @XmlAccessorType( XmlAccessType.FIELD )
 @XmlType(name="query-results")
+ at XmlRootElement
 public class FlatQueryResults
     implements
     QueryResults {
-    private Map<String, Integer> identifiers;
-    @XmlJavaTypeAdapter(JaxbFlatQueryResultsAdapter.class)
+    
+    
+    @XmlJavaTypeAdapter(JaxbMapAdapter.class)
+    @XmlElement(name="identifiers")    
+    private Map<String, Integer> identifiers;    
+    
 	@XmlElement(name="results")
+    @XmlJavaTypeAdapter(JaxbFlatQueryResultsAdapter.class)	
     private ArrayList<ArrayList<Object>>           results;
+    
+    
     @XmlJavaTypeAdapter(JaxbFlatQueryResultsAdapter.class)
 	@XmlElement(name="fact-handles")
     private ArrayList<ArrayList<FactHandle>> factHandles;

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListAdapter.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListAdapter.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -25,6 +25,9 @@
 
     @Override
     public JaxbListWrapper marshal(List v) throws Exception {
+        if ( v == null ) {
+            return new JaxbListWrapper( new Object[0] ); 
+        }
         return new JaxbListWrapper( v.toArray( new Object[v.size()]) );
     }
 

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListWrapper.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbListWrapper.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -29,7 +29,7 @@
 
 @XmlAccessorType(XmlAccessType.NONE)
 @XmlRootElement(name="list")
-public class JaxbListWrapper<T>  {
+public class JaxbListWrapper  {
     
     Object[] elements;
     

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbMapAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbMapAdapter.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbMapAdapter.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -30,16 +30,16 @@
 import org.drools.runtime.rule.impl.NativeQueryResults;
 
 
-public class JaxbMapAdapter extends XmlAdapter<JaxbPair[], Map<Object,Object>> {
+public class JaxbMapAdapter extends XmlAdapter<JaxbStringObjectPair[], Map<String,Object>> {
 
 	@Override
-	public JaxbPair[] marshal(Map<Object, Object> value) throws Exception {
+	public JaxbStringObjectPair[] marshal(Map<String, Object> value) throws Exception {
 		if (value == null || value.isEmpty()) {
-			return new JaxbPair[0];
+			return new JaxbStringObjectPair[0];
 		}
 		
-		List<JaxbPair> ret = new ArrayList<JaxbPair>(value.size());
-		for (Map.Entry<Object, Object> entry : value.entrySet()) {
+		List<JaxbStringObjectPair> ret = new ArrayList<JaxbStringObjectPair>(value.size());
+		for (Map.Entry<String, Object> entry : value.entrySet()) {
 		    Object obj = entry.getValue();
 		    Class<? extends Object> vClass = obj.getClass();
 		    
@@ -50,16 +50,16 @@
 	        } else if (List.class.isAssignableFrom(vClass) && !JaxbListWrapper.class.equals(vClass)) {    
 	            obj = new JaxbListWrapper( ((List<?>) obj).toArray( new Object[((List<?>) obj).size()]) );;
 	        }
-			ret.add(new JaxbPair(entry.getKey(), obj));
+			ret.add(new JaxbStringObjectPair(entry.getKey(), obj));
 		}
 		
-		return ret.toArray(new JaxbPair[value.size()]);
+		return ret.toArray(new JaxbStringObjectPair[value.size()]);
 	}
 
 	@Override
-	public Map<Object, Object> unmarshal(JaxbPair[] value) throws Exception {
-		Map<Object, Object> r = new HashMap<Object, Object>();
-		for( JaxbPair p : value ) {
+	public Map<String, Object> unmarshal(JaxbStringObjectPair[] value) throws Exception {
+		Map<String, Object> r = new HashMap<String, Object>();
+		for( JaxbStringObjectPair p : value ) {
 		    if ( p.getValue() instanceof JaxbListWrapper) {
 		        r.put(p.getKey(), Arrays.asList( ((JaxbListWrapper)p.getValue()).getElements() ) );
 		    } else {

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbObjectObjectPair.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbObjectObjectPair.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbObjectObjectPair.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools.xml.jaxb.util;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+ at XmlAccessorType(XmlAccessType.NONE)
+public class JaxbObjectObjectPair {
+
+	@XmlAttribute(name = "key")
+	private Object key;
+
+	@XmlElement
+	@XmlJavaTypeAdapter(JaxbUnknownAdapter.class)
+	private Object value;
+
+	public JaxbObjectObjectPair() {
+	}
+
+	public JaxbObjectObjectPair(Object key, Object value) {
+		this.key = key;
+		this.value = value;
+	}
+
+	public Object getKey() {
+		return key;
+	}
+
+	public void setKey(Object key) {
+		this.key = key;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public void setValue(Object value) {
+		this.value = value;
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((key == null) ? 0 : key.hashCode());
+		result = prime * result + ((value == null) ? 0 : value.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		JaxbObjectObjectPair other = (JaxbObjectObjectPair) obj;
+		if (key == null) {
+			if (other.key != null)
+				return false;
+		} else if (!key.equals(other.key))
+			return false;
+		if (value == null) {
+			if (other.value != null)
+				return false;
+		} else if (!value.equals(other.value))
+			return false;
+		return true;
+	}
+	
+	@Override
+	public String toString() {
+		return "JaxbPair [key=" + key + ", value=" + value + "]";
+	}
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbPair.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbPair.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbPair.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -1,93 +0,0 @@
-/**
- * Copyright 2010 JBoss Inc
- *
- * Licensed 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.drools.xml.jaxb.util;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAnyElement;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-
- at XmlAccessorType(XmlAccessType.NONE)
-public class JaxbPair {
-
-	@XmlAttribute(name = "key")
-	private Object key;
-
-	@XmlElement
-	private Object value;
-
-	public JaxbPair() {
-	}
-
-	public JaxbPair(Object key, Object value) {
-		this.key = key;
-		this.value = value;
-	}
-
-	public Object getKey() {
-		return key;
-	}
-
-	public void setKey(String key) {
-		this.key = key;
-	}
-
-	public Object getValue() {
-		return value;
-	}
-
-	public void setValue(Object value) {
-		this.value = value;
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result + ((key == null) ? 0 : key.hashCode());
-		result = prime * result + ((value == null) ? 0 : value.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		JaxbPair other = (JaxbPair) obj;
-		if (key == null) {
-			if (other.key != null)
-				return false;
-		} else if (!key.equals(other.key))
-			return false;
-		if (value == null) {
-			if (other.value != null)
-				return false;
-		} else if (!value.equals(other.value))
-			return false;
-		return true;
-	}
-	
-	@Override
-	public String toString() {
-		return "JaxbPair [key=" + key + ", value=" + value + "]";
-	}
-}

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbStringObjectPair.java (from rev 34339, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbPair.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbStringObjectPair.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbStringObjectPair.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed 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.drools.xml.jaxb.util;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+ at XmlAccessorType(XmlAccessType.NONE)
+ at XmlRootElement(name="list")
+public class JaxbStringObjectPair {
+
+	@XmlAttribute(name = "key")
+	private String key;
+
+	@XmlElement
+	@XmlJavaTypeAdapter(JaxbUnknownAdapter.class)
+	private Object value;
+
+	public JaxbStringObjectPair() {
+	}
+
+	public JaxbStringObjectPair(String key, Object value) {
+		this.key = key;
+		this.value = value;
+	}
+
+	public String getKey() {
+		return key;
+	}
+
+	public void setKey(String key) {
+		this.key = key;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public void setValue(Object value) {
+		this.value = value;
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((key == null) ? 0 : key.hashCode());
+		result = prime * result + ((value == null) ? 0 : value.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		JaxbStringObjectPair other = (JaxbStringObjectPair) obj;
+		if (key == null) {
+			if (other.key != null)
+				return false;
+		} else if (!key.equals(other.key))
+			return false;
+		if (value == null) {
+			if (other.value != null)
+				return false;
+		} else if (!value.equals(other.value))
+			return false;
+		return true;
+	}
+	
+	@Override
+	public String toString() {
+		return "JaxbPair [key=" + key + ", value=" + value + "]";
+	}
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbUnknownAdapter.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbUnknownAdapter.java	2010-07-29 23:29:00 UTC (rev 34360)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/xml/jaxb/util/JaxbUnknownAdapter.java	2010-07-29 23:40:05 UTC (rev 34361)
@@ -39,10 +39,10 @@
         } else if ( o instanceof Map ){
             Map<Object, Object>  value = ( Map<Object, Object>  ) o;
             if (value == null || value.isEmpty()) {
-                return new JaxbPair[0];
+                return new JaxbStringObjectPair[0];
             }
             
-            List<JaxbPair> ret = new ArrayList<JaxbPair>(value.size());
+            List<JaxbObjectObjectPair> ret = new ArrayList<JaxbObjectObjectPair>(value.size());
             for (Map.Entry<Object, Object> entry : value.entrySet()) {
                 Object obj = entry.getValue();
                 Class<? extends Object> vClass = obj.getClass();
@@ -54,10 +54,10 @@
                 } else if (List.class.isAssignableFrom(vClass) && !JaxbListWrapper.class.equals(vClass)) {    
                     obj = new JaxbListWrapper( ((List<?>) obj).toArray( new Object[((List<?>) obj).size()]) );;
                 }
-                ret.add(new JaxbPair(entry.getKey(), obj));
+                ret.add(new JaxbObjectObjectPair((String)entry.getKey(), obj));
             }
             
-            return ret.toArray(new JaxbPair[value.size()]);
+            return ret.toArray(new JaxbObjectObjectPair[value.size()]);
         } else {
             return o;
         }
@@ -68,10 +68,10 @@
         if ( o instanceof JaxbListWrapper ) {
             JaxbListWrapper v = ( JaxbListWrapper ) o;
             return Arrays.asList( v.getElements() );
-        } else if (o instanceof JaxbPair[] ) {
-            JaxbPair[] value = ( JaxbPair[] ) o; 
+        } else if (o instanceof JaxbObjectObjectPair[] ) {
+            JaxbObjectObjectPair[] value = ( JaxbObjectObjectPair[] ) o; 
             Map<Object, Object> r = new HashMap<Object, Object>();
-            for( JaxbPair p : value ) {
+            for( JaxbObjectObjectPair p : value ) {
                 if ( p.getValue() instanceof JaxbListWrapper) {
                     r.put(p.getKey(), Arrays.asList( ((JaxbListWrapper)p.getValue()).getElements() ) );
                 } else {



More information about the jboss-svn-commits mailing list