[jboss-svn-commits] JBL Code SVN: r31571 - labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 11 11:30:34 EST 2010
Author: baunax
Date: 2010-02-11 11:30:33 -0500 (Thu, 11 Feb 2010)
New Revision: 31571
Modified:
labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java
Log:
fixed testSessionInsert
Modified: labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java 2010-02-11 16:18:48 UTC (rev 31570)
+++ labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxbTest.java 2010-02-11 16:30:33 UTC (rev 31571)
@@ -17,6 +17,7 @@
import org.drools.builder.help.KnowledgeBuilderHelper;
import org.drools.command.runtime.BatchExecutionCommand;
import org.drools.command.runtime.process.StartProcessCommand;
+import org.drools.command.runtime.rule.FireAllRulesCommand;
import org.drools.command.runtime.rule.InsertObjectCommand;
import org.drools.io.ResourceFactory;
import org.drools.pipeline.camel.Person;
@@ -39,29 +40,35 @@
public void testSessionInsert() throws Exception {
- String cmd = "";
- cmd += "<batch-execution lookup='ksession1'>\n";
- cmd += " <insert out-identifier='lucaz'>\n";
- cmd += " <Person xmlns='http://drools.org/model' >\n";
- cmd += " <name>lucaz</name>\n";
- cmd += " <age>25</age>\n";
- cmd += " </Person>\n";
- cmd += " </insert>\n";
- cmd += " <insert out-identifier='jose'>\n";
- cmd += " <Person xmlns='http://drools.org/model' >\n";
- cmd += " <name>unknow</name>\n";
- cmd += " <age>29</age>\n";
- cmd += " </Person>\n";
- cmd += " </insert>\n";
- cmd += " <fire-all-rules />";
- cmd += "</batch-execution>\n";
+ BatchExecutionCommand cmd = new BatchExecutionCommand();
+ cmd.setLookup("ksession1");
+ cmd.getCommands().add(new InsertObjectCommand(new Person("lucaz", 25), "person1"));
+ cmd.getCommands().add(new InsertObjectCommand(new Person("hadrian", 25), "person2"));
+ cmd.getCommands().add(new InsertObjectCommand(new Person("baunax", 21), "person3"));
+ cmd.getCommands().add(new FireAllRulesCommand());
+
+ StringWriter xmlReq = new StringWriter();
+ Marshaller marshaller = jaxbContext.createMarshaller();
+ marshaller.setProperty("jaxb.formatted.output", true);
+ marshaller.marshal(cmd, xmlReq);
+
+ System.out.println(xmlReq.toString());
+
+ byte[] xmlResp = (byte[]) template.requestBodyAndHeader("direct:test-with-session", xmlReq.toString(), "jaxb-context", jaxbContext);
+ assertNotNull(xmlResp);
+ System.out.println(new String(xmlResp));
- String outXml = new String((byte[])template.requestBodyAndHeader("direct:test-with-session", cmd, "jaxb-context", jaxbContext));
-
- System.out.println(outXml);
-
- assertNotNull(outXml);
-
+ ExecutionResults resp = (ExecutionResults) jaxbContext.createUnmarshaller().unmarshal(new ByteArrayInputStream(xmlResp));
+ assertNotNull(resp);
+
+ assertEquals(3, resp.getIdentifiers().size());
+ assertNotNull(resp.getValue("person1"));
+ assertNotNull(resp.getValue("person2"));
+ assertNotNull(resp.getValue("person3"));
+
+ assertNotNull(resp.getFactHandle("person1"));
+ assertNotNull(resp.getFactHandle("person2"));
+ assertNotNull(resp.getFactHandle("person3"));
}
public void testSessionGetObject() throws Exception {
More information about the jboss-svn-commits
mailing list