@Test public void testNoSessionInsertCustomXstream() throws Exception { String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += "<insert out-identifier=\"salaboy\">\n"; cmd += "<org.kie.pipeline.camel.Person name=\"salaboy\">\n"; cmd += "</org.kie.pipeline.camel.Person>\n"; cmd += "</insert>\n"; cmd += "<fire-all-rules/>\n"; cmd += "</batch-execution>\n"; String outXml = new String((byte[])template.requestBody("direct:test-no-session-custom", cmd)); XStream xstream = BatchExecutionHelper.newXStreamMarshaller(); PersonConverter converter = new PersonConverter(); xstream.registerConverter(converter); ExecutionResults result = (ExecutionResults)xstream.fromXML(outXml); Person person = (Person)result.getValue("salaboy"); assertEquals("salaboy", person.getName()); String expectedXml = ""; expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>"; expectedXml += "<result identifier=\"salaboy\">"; expectedXml += "<org.kie.pipeline.camel.Person name=\"salaboy\"/>"; expectedXml += "</result>"; expectedXml += "<fact-handle identifier=\"salaboy\" external-form=\"" + ((InternalFactHandle)result.getFactHandle("salaboy")).toExternalForm() + "\"/>"; expectedXml += "</execution-results>"; assertXMLEqual(expectedXml, outXml); }
@Test public void testSessionInsert() throws Exception { String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += " <insert out-identifier=\"salaboy\">\n"; cmd += " <org.kie.pipeline.camel.Person>\n"; cmd += " <name>salaboy</name>\n"; cmd += " </org.kie.pipeline.camel.Person>\n"; cmd += " </insert>\n"; cmd += " <fire-all-rules/>\n"; cmd += "</batch-execution>\n"; String outXml = new String((byte[])template.requestBody("direct:test-with-session", cmd)); ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML(outXml); Person person = (Person)result.getValue("salaboy"); assertEquals("salaboy", person.getName()); String expectedXml = ""; expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>"; expectedXml += "<result identifier=\"salaboy\">"; expectedXml += "<org.kie.pipeline.camel.Person>"; expectedXml += "<name>salaboy</name>"; expectedXml += "</org.kie.pipeline.camel.Person>"; expectedXml += "</result>"; expectedXml += "<fact-handle identifier=\"salaboy\" external-form=\"" + ((InternalFactHandle)result.getFactHandle("salaboy")).toExternalForm() + "\"/>"; expectedXml += "</execution-results>"; assertXMLEqual(expectedXml, outXml); }
@Test public void testNoSessionInsertCustomXstream() throws Exception { String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += "<insert out-identifier=\"salaboy\">\n"; cmd += "<org.drools.pipeline.camel.Person name=\"salaboy\">\n"; cmd += "</org.drools.pipeline.camel.Person>\n"; cmd += "</insert>\n"; cmd += "<fire-all-rules/>\n"; cmd += "</batch-execution>\n"; String outXml = new String( (byte[]) template.requestBody( "direct:test-no-session-custom", cmd ) ); XStream xstream = BatchExecutionHelper.newXStreamMarshaller(); PersonConverter converter = new PersonConverter(); xstream.registerConverter( converter ); ExecutionResults result = (ExecutionResults) xstream.fromXML( outXml ); Person person = (Person) result.getValue( "salaboy" ); assertEquals( "salaboy", person.getName() ); String expectedXml = ""; expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>"; expectedXml += "<result identifier=\"salaboy\">"; expectedXml += "<org.drools.pipeline.camel.Person name=\"salaboy\"/>"; expectedXml += "</result>"; expectedXml += "<fact-handle identifier=\"salaboy\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "salaboy" )).toExternalForm() + "\"/>"; expectedXml += "</execution-results>"; assertXMLEqual( expectedXml, outXml ); }
@Test public void testNoSessionInsert() throws Exception { String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += "<insert out-identifier=\"salaboy\">\n"; cmd += "<org.kie.pipeline.camel.Person>\n"; cmd += "<name>salaboy</name>\n"; cmd += "</org.kie.pipeline.camel.Person>\n"; cmd += "</insert>\n"; cmd += "<fire-all-rules/>\n"; cmd += "</batch-execution>\n"; String outXml = new String((byte[])template.requestBody("direct:test-no-session", cmd)); ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML(outXml); Person person = (Person)result.getValue("salaboy"); assertEquals("salaboy", person.getName()); String expectedXml = ""; expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>"; expectedXml += "<result identifier=\"salaboy\">"; expectedXml += "<org.kie.pipeline.camel.Person>"; expectedXml += "<name>salaboy</name>"; expectedXml += "</org.kie.pipeline.camel.Person>"; expectedXml += "</result>"; expectedXml += "<fact-handle identifier=\"salaboy\" external-form=\"" + ((InternalFactHandle)result.getFactHandle("salaboy")).toExternalForm() + "\"/>"; expectedXml += "</execution-results>"; assertXMLEqual(expectedXml, outXml); }
@Test public void testSessionInsert() throws Exception { String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += " <insert out-identifier=\"salaboy\">\n"; cmd += " <org.drools.pipeline.camel.Person>\n"; cmd += " <name>salaboy</name>\n"; cmd += " </org.drools.pipeline.camel.Person>\n"; cmd += " </insert>\n"; cmd += " <fire-all-rules/>\n"; cmd += "</batch-execution>\n"; String outXml = new String( (byte[]) template.requestBody( "direct:test-with-session", cmd ) ); ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml ); Person person = (Person) result.getValue( "salaboy" ); assertEquals( "salaboy", person.getName() ); String expectedXml = ""; expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>"; expectedXml += "<result identifier=\"salaboy\">"; expectedXml += "<org.drools.pipeline.camel.Person>"; expectedXml += "<name>salaboy</name>"; expectedXml += "</org.drools.pipeline.camel.Person>"; expectedXml += "</result>"; expectedXml += "<fact-handle identifier=\"salaboy\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "salaboy" )).toExternalForm() + "\"/>"; expectedXml += "</execution-results>"; assertXMLEqual( expectedXml, outXml ); }
@Test public void testNoSessionInsert() throws Exception { String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += "<insert out-identifier=\"salaboy\">\n"; cmd += "<org.drools.pipeline.camel.Person>\n"; cmd += "<name>salaboy</name>\n"; cmd += "</org.drools.pipeline.camel.Person>\n"; cmd += "</insert>\n"; cmd += "<fire-all-rules/>\n"; cmd += "</batch-execution>\n"; String outXml = new String( (byte[]) template.requestBody( "direct:test-no-session", cmd ) ); ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml ); Person person = (Person) result.getValue( "salaboy" ); assertEquals( "salaboy", person.getName() ); String expectedXml = ""; expectedXml += "<?xml version='1.0' encoding='UTF-8'?><execution-results>"; expectedXml += "<result identifier=\"salaboy\">"; expectedXml += "<org.drools.pipeline.camel.Person>"; expectedXml += "<name>salaboy</name>"; expectedXml += "</org.drools.pipeline.camel.Person>"; expectedXml += "</result>"; expectedXml += "<fact-handle identifier=\"salaboy\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "salaboy" )).toExternalForm() + "\"/>"; expectedXml += "</execution-results>"; assertXMLEqual( expectedXml, outXml ); }
expectedXml += " </org.kie.camel.embedded.camel.testdomain.Cheese1>\n"; expectedXml += " </result>\n"; expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle)result.getFactHandle("outStilton")).toExternalForm() + "\" /> \n"; expectedXml += "</execution-results>\n"; expectedXml2 += " </org.kie.camel.embedded.camel.testdomain.Cheese2>\n"; expectedXml2 += " </result>\n"; expectedXml2 += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle)result2.getFactHandle("outStilton")).toExternalForm() + "\" /> \n"; expectedXml2 += "</execution-results>\n";
expectedXml += " </org.drools.camel.testdomain.Cheese1>\n"; expectedXml += " </result>\n"; expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n"; expectedXml += "</execution-results>\n"; expectedXml2 += " </org.drools.camel.testdomain.Cheese2>\n"; expectedXml2 += " </result>\n"; expectedXml2 += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result2.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n"; expectedXml2 += "</execution-results>\n";
expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle)result.getFactHandle("outStilton")).toExternalForm() + "\" /> \n"; expectedXml += "</execution-results>\n";
expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n"; expectedXml += "</execution-results>\n";
expectedXml += " </org.kie.camel.embedded.camel.testdomain.Cheese>\n"; expectedXml += " </result>\n"; expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle)result.getFactHandle("outStilton")).toExternalForm() + "\" /> \n"; expectedXml += "</execution-results>\n";
expectedXml += " </org.drools.camel.testdomain.Cheese>\n"; expectedXml += " </result>\n"; expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n"; expectedXml += "</execution-results>\n";