@Test
public void testReceiveMessageActionParser() {
assertActionCount(8);
assertActionClassAndName(ReceiveMessageAction.class, "receive");
ControlMessageValidationContext validationContext;
PayloadTemplateMessageBuilder messageBuilder;
GroovyScriptMessageBuilder groovyMessageBuilder;
// 1st action
ReceiveMessageAction action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);
messageBuilder = (PayloadTemplateMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNull(messageBuilder.getPayloadResourcePath());
Assert.assertNotNull(messageBuilder.getPayloadData());
Assert.assertEquals(messageBuilder.getPayloadData().trim(), "<TestMessage>Hello Citrus</TestMessage>");
Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 1);
Assert.assertEquals(messageBuilder.getMessageHeaders().get("operation"), "Test");
Assert.assertEquals(messageBuilder.getMessageInterceptors().size(), 0);
Assert.assertNull(action.getDataDictionary());
// 2nd action
action = getNextTestActionFromTest();
Assert.assertEquals(action.getMessageSelector().size(), 1);
Assert.assertEquals(action.getMessageSelector().get("operation"), "Test");
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);
messageBuilder = (PayloadTemplateMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNotNull(messageBuilder.getPayloadResourcePath());
Assert.assertEquals(messageBuilder.getPayloadResourcePath(), "classpath:com/consol/citrus/actions/test-request-payload.xml");
Assert.assertNull(messageBuilder.getPayloadData());
Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0);
Assert.assertEquals(messageBuilder.getMessageInterceptors().size(), 0);
// 3rd action
action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertEquals(action.getMessageSelectorString(), "operation = 'Test'");
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
// 4th action
action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof GroovyScriptMessageBuilder);
groovyMessageBuilder = (GroovyScriptMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNull(groovyMessageBuilder.getScriptResourcePath());
Assert.assertNotNull(groovyMessageBuilder.getScriptData());
Assert.assertEquals(groovyMessageBuilder.getScriptData().trim(), "println '<TestMessage>Hello Citrus</TestMessage>'");
Assert.assertEquals(groovyMessageBuilder.getMessageHeaders().size(), 2);
Assert.assertEquals(groovyMessageBuilder.getMessageHeaders().get("header1"), "Test");
Assert.assertEquals(groovyMessageBuilder.getMessageHeaders().get("header2"), "Test");
// 5th action
action = getNextTestActionFromTest();
Assert.assertTrue(action.getMessageSelector().isEmpty());
Assert.assertNull(action.getMessageSelectorString());
Assert.assertEquals(action.getEndpoint(), beanDefinitionContext.getBean("myMessageEndpoint", Endpoint.class));
Assert.assertNull(action.getEndpointUri());
Assert.assertEquals(action.getValidationContexts().size(), 2);
Assert.assertTrue(action.getValidationContexts().get(0) instanceof ControlMessageValidationContext);
validationContext = (ControlMessageValidationContext)action.getValidationContexts().get(0);
Assert.assertTrue(validationContext.getMessageBuilder() instanceof GroovyScriptMessageBuilder);
groovyMessageBuilder = (GroovyScriptMessageBuilder)validationContext.getMessageBuilder();
Assert.assertNotNull(groovyMessageBuilder.getScriptResourcePath());
Assert.assertEquals(groovyMessageBuilder.getScriptResourcePath(), "classpath:com/consol/citrus/script/example.groovy");
Assert.assertNull(groovyMessageBuilder.getScriptData());