{
MuleMessage msg = new DefaultMuleMessage("message", muleContext);
// Add properties to scope
MessagePropertiesTransformer add = new MessagePropertiesTransformer();
add.setScope(PropertyScope.INVOCATION);
Map<String, Object> addProps = new HashMap<String, Object>();
addProps.put("foo", "bar");
addProps.put("foo2", "baz");
add.setAddProperties(addProps);
add.setMuleContext(muleContext);
add.initialise();
msg = (DefaultMuleMessage) add.transform(msg, (String)null);
assertEquals("bar", msg.getInvocationProperty("foo"));
assertNull(msg.getOutboundProperty("foo"));
assertNull(msg.getSessionProperty("foo"));
// Remove property from the wrong scope
MessagePropertiesTransformer deleteWrongScope = new MessagePropertiesTransformer();
deleteWrongScope.setScope(PropertyScope.OUTBOUND);
deleteWrongScope.setDeleteProperties("foo");
deleteWrongScope.setMuleContext(muleContext);
deleteWrongScope.initialise();
msg = (DefaultMuleMessage) deleteWrongScope.transform(msg, (String)null);
assertEquals("bar", msg.getInvocationProperty("foo"));
// Remove property from the correct scope
MessagePropertiesTransformer delete = new MessagePropertiesTransformer();
delete.setScope(PropertyScope.INVOCATION);
delete.setDeleteProperties(Collections.singletonList("foo"));
delete.setMuleContext(muleContext);
delete.initialise();
msg = (DefaultMuleMessage) delete.transform(msg, (String)null);
assertNull(msg.getInvocationProperty("foo"));
assertEquals("baz", msg.getInvocationProperty("foo2"));
}