ResultHandlerImpl resultHandler = new ResultHandlerImpl();
getPipelineStateful( ksession ).insert( inXml,
resultHandler );
String outXml = (String) resultHandler.getObject();
ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );
Cheese stilton = (Cheese) result.getValue( "outStilton" );
assertEquals( 30,
stilton.getPrice() );
FactHandle factHandle = ((FactHandle) result.getFactHandle( "outStilton" ));
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\" external-form=\"" + factHandle.toExternalForm() + "\" /> \n";
expectedXml += "</execution-results>\n";
assertXMLEqual( expectedXml,
outXml );
inXml = "";
inXml += "<batch-execution>";
inXml += " <modify fact-handle='" + factHandle.toExternalForm() + "'> <set accessor='oldPrice' value='\"42\"' /><set accessor='price' value='50' /></modify>";
inXml += " <fire-all-rules />";
inXml += "</batch-execution>";
getPipelineStateful( ksession ).insert( inXml,
resultHandler );
inXml = "";
inXml += "<batch-execution>";
inXml += " <get-object out-identifier='outCheddar' fact-handle='" + factHandle.toExternalForm() + "' />";
inXml += "</batch-execution>";
getPipelineStateful( ksession ).insert( inXml,
resultHandler );
outXml = (String) resultHandler.getObject();
result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );
Cheese cheddar = (Cheese) result.getValue( "outCheddar" );
assertEquals( 42,
cheddar.getOldPrice() );
assertEquals( 55,
cheddar.getPrice() );