ExecutionResults result = unmarshalOutXml( outXml,
ExecutionResults.class );
String stiltonfh = ((FactHandle) result.getFactHandle( "outStilton" )).toExternalForm();
Cheese stilton = (Cheese) result.getValue( "outStilton" );
assertEquals( 30,
stilton.getPrice() );
String expectedXml = getContent( "testModifyObject.expected.1",
stiltonfh );
assertXMLEqual( expectedXml,
outXml );
execContent( "testModifyObject.in.2",
ExecutionResults.class,
stiltonfh );
result = execContent( "testModifyObject.in.3",
ExecutionResults.class,
stiltonfh );
stilton = (Cheese) result.getValue( "outStilton" );
assertEquals( 42,
stilton.getOldPrice() );
assertEquals( 55,
stilton.getPrice() );
//now test for code injection:
ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = false;
execContent( "testModifyObject.in.4",
ExecutionResults.class,
stiltonfh );
ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = true;
// should be the same as before
result = execContent( "testModifyObject.in.5",
ExecutionResults.class,
stiltonfh );
// The value gets turned into a literal to avoid injection
stilton = (Cheese) result.getValue( "outStilton" );
assertEquals( "throwException()",
stilton.getType() );
}