BatchExecutionCommandImpl cmd = new BatchExecutionCommandImpl();
cmd.setLookup("ksession1");
SetGlobalCommand setGlobal = new SetGlobalCommand( "list",
new WrappedList() );
setGlobal.setOutIdentifier( "list" );
cmd.getCommands().add( setGlobal );
cmd.getCommands().add( new InsertObjectCommand( new Person( "baunax" ) ) );
cmd.getCommands().add( new FireAllRulesCommand() );
cmd.getCommands().add( new GetGlobalCommand( "list" ) );
Marshaller marshaller = getJaxbContext().createMarshaller();
marshaller.setProperty( "jaxb.formatted.output",
true );
StringWriter xml = new StringWriter();
marshaller.marshal( cmd,
xml );
System.out.println( xml.toString() );
byte[] response = (byte[]) template.requestBody( "direct:test-with-session",
xml.toString() );
assertNotNull( response );
System.out.println( "response:\n" + new String( response ) );
Unmarshaller unmarshaller = getJaxbContext().createUnmarshaller();
ExecutionResults res = (ExecutionResults) unmarshaller.unmarshal( new ByteArrayInputStream( response ) );
WrappedList resp = (WrappedList) res.getValue( "list" );
assertNotNull( resp );
assertEquals( resp.size(),
2 );
assertEquals( "baunax",
resp.get( 0 ).getName() );
assertEquals( "Hadrian",
resp.get( 1 ).getName() );
}