inXml,
String.class );
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader( getClassLoader(ksession) );
ExecutionResults result = template.requestBody( "direct:unmarshal",
outXml,
ExecutionResults.class );
org.drools.definition.type.FactType fT = ksession.getKnowledgeBase().getFactType("org.drools","Cheese1");
int price = (Integer)fT.get(result.getValue( "outStilton" ), "price");
assertEquals( 30,
price );
FactHandle factHandle = (FactHandle) result.getFactHandle( "outStilton" );
// stilton = (Cheese) ksession.getObject( factHandle );
// assertEquals( 30,
// stilton.getPrice() );
String outXml2 = template.requestBody( "direct:execWithLookup",
inXml2,
String.class );
Thread.currentThread().setContextClassLoader( getClassLoader(ksession2) );
ExecutionResults result2 = template.requestBody( "direct:unmarshal",
outXml2,
ExecutionResults.class );
org.drools.definition.type.FactType fT2 = ksession2.getKnowledgeBase().getFactType("org.drools","Cheese2");
int price2 = (Integer)fT2.get(result2.getValue( "outStilton" ), "price");
assertEquals( 35, price2 );
// Cheese2 stilton2 = (Cheese2) result2.getValue( "outStilton" );
// assertEquals( 35,
// stilton2.getPrice() );
//
factHandle = (FactHandle) result2.getFactHandle( "outStilton" );
// stilton2 = (Cheese2) ksession2.getObject( factHandle );
// assertEquals( 35,
// stilton2.getPrice() );
Thread.currentThread().setContextClassLoader( originalClassLoader );
String expectedXml = "";
expectedXml += "<execution-results>\n";
expectedXml += " <result identifier=\"outStilton\">\n";
expectedXml += " <org.drools.Cheese1>\n";
expectedXml += " <type>stilton</type>\n";
expectedXml += " <oldPrice>0</oldPrice>\n";
expectedXml += " <price>30</price>\n";
expectedXml += " </org.drools.Cheese1>\n";
expectedXml += " </result>\n";
expectedXml += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n";
expectedXml += "</execution-results>\n";
String expectedXml2 = "";
expectedXml2 += "<execution-results>\n";
expectedXml2 += " <result identifier=\"outStilton\">\n";
expectedXml2 += " <org.drools.Cheese2>\n";
expectedXml2 += " <type>stilton</type>\n";
expectedXml2 += " <oldPrice>0</oldPrice>\n";
expectedXml2 += " <price>35</price>\n";
expectedXml2 += " </org.drools.Cheese2>\n";
expectedXml2 += " </result>\n";
expectedXml2 += " <fact-handle identifier=\"outStilton\" external-form=\"" + ((InternalFactHandle) result2.getFactHandle( "outStilton" )).toExternalForm() + "\" /> \n";
expectedXml2 += "</execution-results>\n";
assertXMLEqual( expectedXml,
outXml );