expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(message);
expect(endpoint.getActor()).andReturn(null).anyTimes();
replay(endpoint, consumer, endpointConfiguration);
PayloadTemplateMessageBuilder controlMessageBuilder = new PayloadTemplateMessageBuilder();
XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
validationContext.setMessageBuilder(controlMessageBuilder);
controlMessageBuilder.setPayloadData("<root>"
+ "<element attributeA='attribute-value' attributeB='attribute-value' >"
+ "<sub-elementA attribute='A'>to be overwritten</sub-elementA>"
+ "<sub-elementB attribute='B'>to be overwritten</sub-elementB>"
+ "<sub-elementC attribute='C'>text-value</sub-elementC>"
+ "</element>"
+ "</root>");
HashMap<String, String> messageElements = new HashMap<String, String>();
messageElements.put("//root/element/sub-elementA", "text-value");
messageElements.put("//sub-elementB", "text-value");
XpathMessageConstructionInterceptor interceptor = new XpathMessageConstructionInterceptor(messageElements);
controlMessageBuilder.add(interceptor);
List<ValidationContext> validationContexts = new ArrayList<ValidationContext>();
validationContexts.add(validationContext);
receiveMessageBean.setValidationContexts(validationContexts);
HashMap<String, String> validateElements = new HashMap<String, String>();
validateElements.put("//root/element/sub-elementA", "text-value");
validateElements.put("//sub-elementB", "text-value");
validationContext.setPathValidationExpressions(validateElements);
receiveMessageBean.execute(context);
}