ReceiveMessageAction receiveAction = new ReceiveMessageAction();
receiveAction.setEndpoint(endpoint);
receiveAction.setValidator(validator);
PayloadTemplateMessageBuilder controlMessageBuilder = new PayloadTemplateMessageBuilder();
XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
validationContext.setMessageBuilder(controlMessageBuilder);
Map<String, String> messageElements = new HashMap<String, String>();
messageElements.put("/pfx:TestRequest/pfx:Message", "Hello World!");
validationContext.setPathValidationExpressions(messageElements);
Map<String, String> namespaces = new HashMap<String, String>();
namespaces.put("pfx", "http://citrusframework.org/unittest");
validationContext.setNamespaces(namespaces);
Message controlMessage = new DefaultMessage("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +
"<ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>");
reset(endpoint, consumer, endpointConfiguration);
expect(endpoint.createConsumer()).andReturn(consumer).anyTimes();
expect(endpoint.getEndpointConfiguration()).andReturn(endpointConfiguration).anyTimes();
expect(endpointConfiguration.getTimeout()).andReturn(5000L).anyTimes();
expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();
expect(endpoint.getActor()).andReturn(null).anyTimes();
replay(endpoint, consumer, endpointConfiguration);
validationContext.setSchemaValidation(false);
List<ValidationContext> validationContexts = new ArrayList<ValidationContext>();
validationContexts.add(validationContext);
receiveAction.setValidationContexts(validationContexts);
receiveAction.execute(context);