Skip to content

Instantly share code, notes, and snippets.

@Rikkola
Created February 7, 2012 11:04
Show Gist options
  • Save Rikkola/1759140 to your computer and use it in GitHub Desktop.
Save Rikkola/1759140 to your computer and use it in GitHub Desktop.
@Test
public void testSessionModify() throws Exception {
String cmd = "";
cmd += "<batch-execution lookup='ksession1'>\n";
cmd += " <modify fact-handle='" + handle + "'>\n";
cmd += " <setters>";
cmd += " <item accessor='name' value='\"salaboy\"' />\n";
cmd += " </setters>\n";
cmd += " </modify>\n";
cmd += "</batch-execution>\n";
String outXml = new String( (byte[]) template.requestBody( "direct:test-with-session",
cmd ) );
String expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
expectedXml += "<execution-results xmlns:ns2=\"http://drools.org/model\">\n";
expectedXml += " <results/>\n";
expectedXml += " <facts/>\n";
expectedXml += "</execution-results>\n";
assertXMLEqual( expectedXml,
outXml );
cmd = "<batch-execution lookup='ksession1'>\n";
cmd += " <get-object out-identifier='rider' fact-handle='" + handle + "'/>\n";
cmd += "</batch-execution>\n";
byte[] xmlResp = (byte[]) template.requestBody( "direct:test-with-session",
cmd.toString() );
assertNotNull( xmlResp );
ExecutionResults resp = (ExecutionResults) getJaxbContext().createUnmarshaller().unmarshal( new ByteArrayInputStream( xmlResp ) );
assertNotNull( resp );
Person person = (Person) resp.getValue( "rider" );
assertEquals( "salaboy",
person.getName() );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment