How to use execute method of com.consol.citrus.dsl.runner.ReceiveMessageTestRunnerTest class

Best Citrus code snippet using com.consol.citrus.dsl.runner.ReceiveMessageTestRunnerTest.execute

Source:ReceiveMessageTestRunnerTest.java Github

copy

Full Screen

...90 when(messageEndpoint.getActor()).thenReturn(null);91 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("<Message>Hello</Message>"));92 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {93 @Override94 public void execute() {95 receive(action -> action.endpoint(messageEndpoint));96 }97 };98 TestCase test = builder.getTestCase();99 Assert.assertEquals(test.getActionCount(), 1);100 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);101 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));102 Assert.assertEquals(action.getName(), "receive");103 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());104 Assert.assertEquals(action.getEndpoint(), messageEndpoint);105 Assert.assertEquals(action.getValidationContexts().size(), 3);106 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);107 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);108 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);109 }110 @Test111 public void testReceiveBuilder() {112 reset(messageEndpoint, messageConsumer, configuration);113 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);114 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);115 when(configuration.getTimeout()).thenReturn(100L);116 when(messageEndpoint.getActor()).thenReturn(null);117 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("Foo").setHeader("operation", "foo"));118 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {119 @Override120 public void execute() {121 receive(action -> action.endpoint(messageEndpoint)122 .messageType(MessageType.PLAINTEXT)123 .message(new DefaultMessage("Foo").setHeader("operation", "foo")));124 }125 };126 TestCase test = builder.getTestCase();127 Assert.assertEquals(test.getActionCount(), 1);128 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);129 130 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));131 Assert.assertEquals(action.getName(), "receive");132 133 Assert.assertEquals(action.getMessageType(), MessageType.PLAINTEXT.name());134 Assert.assertEquals(action.getEndpoint(), messageEndpoint);135 Assert.assertEquals(action.getValidationContexts().size(), 3);136 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);137 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);138 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);139 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);140 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "Foo");141 Assert.assertNotNull(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getHeader("operation"));142 }143 @Test144 public void testReceiveBuilderWithPayloadModel() {145 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);146 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);147 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);148 when(configuration.getTimeout()).thenReturn(100L);149 when(messageEndpoint.getActor()).thenReturn(null);150 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(151 new DefaultMessage("<TestRequest><Message>Hello Citrus!</Message></TestRequest>")152 .setHeader("operation", "foo"));153 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));154 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());155 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());156 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());157 when(applicationContextMock.getBeansOfType(Marshaller.class)).thenReturn(Collections.<String, Marshaller>singletonMap("marshaller", marshaller));158 when(applicationContextMock.getBean(Marshaller.class)).thenReturn(marshaller);159 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {160 @Override161 public void execute() {162 receive(action -> action.endpoint(messageEndpoint)163 .payloadModel(new TestRequest("Hello Citrus!")));164 }165 };166 TestCase test = builder.getTestCase();167 Assert.assertEquals(test.getActionCount(), 1);168 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);169 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));170 Assert.assertEquals(action.getName(), "receive");171 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());172 Assert.assertEquals(action.getEndpoint(), messageEndpoint);173 Assert.assertEquals(action.getValidationContexts().size(), 3);174 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);175 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);176 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);177 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);178 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(),179 "<TestRequest><Message>Hello Citrus!</Message></TestRequest>");180 }181 @Test182 public void testReceiveBuilderWithPayloadModelExplicitMarshaller() {183 reset(messageEndpoint, messageConsumer, configuration);184 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);185 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);186 when(configuration.getTimeout()).thenReturn(100L);187 when(messageEndpoint.getActor()).thenReturn(null);188 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(189 new DefaultMessage("<TestRequest><Message>Hello Citrus!</Message></TestRequest>")190 .setHeader("operation", "foo"));191 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {192 @Override193 public void execute() {194 receive(action -> action.endpoint(messageEndpoint)195 .payload(new TestRequest("Hello Citrus!"), marshaller));196 }197 };198 TestCase test = builder.getTestCase();199 Assert.assertEquals(test.getActionCount(), 1);200 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);201 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));202 Assert.assertEquals(action.getName(), "receive");203 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());204 Assert.assertEquals(action.getEndpoint(), messageEndpoint);205 Assert.assertEquals(action.getValidationContexts().size(), 3);206 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);207 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);208 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);209 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);210 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello Citrus!</Message></TestRequest>");211 }212 @Test213 public void testReceiveBuilderWithPayloadModelExplicitMarshallerName() {214 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);215 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);216 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);217 when(configuration.getTimeout()).thenReturn(100L);218 when(messageEndpoint.getActor()).thenReturn(null);219 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(220 new DefaultMessage("<TestRequest><Message>Hello Citrus!</Message></TestRequest>")221 .setHeader("operation", "foo"));222 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));223 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());224 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());225 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());226 when(applicationContextMock.containsBean("myMarshaller")).thenReturn(true);227 when(applicationContextMock.getBean("myMarshaller")).thenReturn(marshaller);228 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {229 @Override230 public void execute() {231 receive(action -> action.endpoint(messageEndpoint)232 .payload(new TestRequest("Hello Citrus!"), "myMarshaller"));233 }234 };235 TestCase test = builder.getTestCase();236 Assert.assertEquals(test.getActionCount(), 1);237 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);238 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));239 Assert.assertEquals(action.getName(), "receive");240 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());241 Assert.assertEquals(action.getEndpoint(), messageEndpoint);242 Assert.assertEquals(action.getValidationContexts().size(), 3);243 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);244 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);245 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);246 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);247 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello Citrus!</Message></TestRequest>");248 }249 250 @Test251 public void testReceiveBuilderWithPayloadString() {252 reset(messageEndpoint, messageConsumer, configuration);253 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);254 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);255 when(configuration.getTimeout()).thenReturn(100L);256 when(messageEndpoint.getActor()).thenReturn(null);257 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(258 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")259 .setHeader("operation", "foo"));260 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {261 @Override262 public void execute() {263 receive(action -> action.endpoint(messageEndpoint)264 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>"));265 }266 };267 TestCase test = builder.getTestCase();268 Assert.assertEquals(test.getActionCount(), 1);269 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);270 271 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));272 Assert.assertEquals(action.getName(), "receive");273 274 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());275 Assert.assertEquals(action.getEndpoint(), messageEndpoint);276 Assert.assertEquals(action.getValidationContexts().size(), 3);277 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);278 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);279 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);280 281 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);282 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");283 }284 285 @Test286 public void testReceiveBuilderWithPayloadResource() throws IOException {287 reset(resource, messageEndpoint, messageConsumer, configuration);288 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);289 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);290 when(configuration.getTimeout()).thenReturn(100L);291 when(messageEndpoint.getActor()).thenReturn(null);292 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(293 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")294 .setHeader("operation", "foo"));295 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<TestRequest><Message>Hello World!</Message></TestRequest>".getBytes()));296 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {297 @Override298 public void execute() {299 receive(action -> action.endpoint(messageEndpoint)300 .payload(resource));301 }302 };303 TestCase test = builder.getTestCase();304 Assert.assertEquals(test.getActionCount(), 1);305 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);306 307 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));308 Assert.assertEquals(action.getName(), "receive");309 310 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());311 Assert.assertEquals(action.getEndpoint(), messageEndpoint);312 Assert.assertEquals(action.getValidationContexts().size(), 3);313 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);314 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);315 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);316 317 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);318 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");319 }320 321 @Test322 public void testReceiveBuilderWithEndpointName() {323 TestContext context = applicationContext.getBean(TestContext.class);324 context.setApplicationContext(applicationContextMock);325 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);326 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);327 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);328 when(configuration.getTimeout()).thenReturn(100L);329 when(messageEndpoint.getActor()).thenReturn(null);330 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(331 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")332 .setHeader("operation", "foo"));333 when(applicationContextMock.getBean(TestContext.class)).thenReturn(context);334 when(applicationContextMock.getBean("fooMessageEndpoint", Endpoint.class)).thenReturn(messageEndpoint);335 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());336 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());337 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());338 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {339 @Override340 public void execute() {341 receive(action -> action.endpoint("fooMessageEndpoint")342 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>"));343 }344 };345 TestCase test = builder.getTestCase();346 Assert.assertEquals(test.getActionCount(), 1);347 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);348 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));349 Assert.assertEquals(action.getName(), "receive");350 Assert.assertEquals(action.getEndpointUri(), "fooMessageEndpoint");351 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());352 }353 354 @Test355 public void testReceiveBuilderWithTimeout() {356 reset(messageEndpoint, messageConsumer, configuration);357 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);358 when(messageEndpoint.getActor()).thenReturn(null);359 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(360 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")361 .setHeader("operation", "foo"));362 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {363 @Override364 public void execute() {365 receive(action -> action.endpoint(messageEndpoint)366 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")367 .timeout(1000L));368 }369 };370 TestCase test = builder.getTestCase();371 Assert.assertEquals(test.getActionCount(), 1);372 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);373 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));374 Assert.assertEquals(action.getName(), "receive");375 Assert.assertEquals(action.getEndpoint(), messageEndpoint);376 Assert.assertEquals(action.getReceiveTimeout(), 1000L);377 }378 379 @Test380 public void testReceiveBuilderWithHeaders() {381 reset(messageEndpoint, messageConsumer, configuration);382 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);383 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);384 when(configuration.getTimeout()).thenReturn(100L);385 when(messageEndpoint.getActor()).thenReturn(null);386 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(387 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")388 .setHeader("some", "value")389 .setHeader("operation", "sayHello")390 .setHeader("foo", "bar"));391 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {392 @Override393 public void execute() {394 receive(action -> action.endpoint(messageEndpoint)395 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")396 .headers(Collections.singletonMap("some", "value"))397 .header("operation", "sayHello")398 .header("foo", "bar"));399 receive(action -> action.endpoint(messageEndpoint)400 .header("operation", "sayHello")401 .header("foo", "bar")402 .headers(Collections.singletonMap("some", "value"))403 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>"));404 }405 };406 TestCase test = builder.getTestCase();407 Assert.assertEquals(test.getActionCount(), 2);408 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);409 Assert.assertEquals(test.getActions().get(1).getClass(), ReceiveMessageAction.class);410 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));411 Assert.assertEquals(action.getName(), "receive");412 Assert.assertEquals(action.getEndpoint(), messageEndpoint);413 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());414 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);415 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");416 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("some"));417 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));418 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("foo"));419 action = ((ReceiveMessageAction)test.getActions().get(1));420 Assert.assertEquals(action.getName(), "receive");421 Assert.assertEquals(action.getEndpoint(), messageEndpoint);422 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());423 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);424 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");425 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("some"));426 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));427 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("foo"));428 }429 @Test430 public void testReceiveBuilderWithHeaderData() {431 reset(messageEndpoint, messageConsumer, configuration);432 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);433 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);434 when(configuration.getTimeout()).thenReturn(100L);435 when(messageEndpoint.getActor()).thenReturn(null);436 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(437 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")438 .setHeader("operation", "foo")439 .addHeaderData("<Header><Name>operation</Name><Value>foo</Value></Header>"));440 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {441 @Override442 public void execute() {443 receive(action -> action.endpoint(messageEndpoint)444 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")445 .header("<Header><Name>operation</Name><Value>foo</Value></Header>"));446 receive(action -> action.endpoint(messageEndpoint)447 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))448 .header("<Header><Name>operation</Name><Value>foo</Value></Header>"));449 }450 };451 TestCase test = builder.getTestCase();452 Assert.assertEquals(test.getActionCount(), 2);453 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);454 Assert.assertEquals(test.getActions().get(1).getClass(), ReceiveMessageAction.class);455 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));456 Assert.assertEquals(action.getName(), "receive");457 Assert.assertEquals(action.getEndpoint(), messageEndpoint);458 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());459 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);460 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");461 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);462 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo</Value></Header>");463 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderResources().size(), 0L);464 action = ((ReceiveMessageAction) test.getActions().get(1));465 Assert.assertEquals(action.getName(), "receive");466 Assert.assertEquals(action.getEndpoint(), messageEndpoint);467 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());468 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);469 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");470 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);471 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo</Value></Header>");472 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderResources().size(), 0L);473 }474 @Test475 public void testReceiveBuilderWithMultipleHeaderData() {476 reset(messageEndpoint, messageConsumer, configuration);477 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);478 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);479 when(configuration.getTimeout()).thenReturn(100L);480 when(messageEndpoint.getActor()).thenReturn(null);481 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(482 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")483 .setHeader("operation", "foo")484 .addHeaderData("<Header><Name>operation</Name><Value>foo1</Value></Header>")485 .addHeaderData("<Header><Name>operation</Name><Value>foo2</Value></Header>"));486 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {487 @Override488 public void execute() {489 receive(action -> action.endpoint(messageEndpoint)490 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")491 .header("<Header><Name>operation</Name><Value>foo1</Value></Header>")492 .header("<Header><Name>operation</Name><Value>foo2</Value></Header>"));493 receive(action -> action.endpoint(messageEndpoint)494 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))495 .header("<Header><Name>operation</Name><Value>foo1</Value></Header>")496 .header("<Header><Name>operation</Name><Value>foo2</Value></Header>"));497 }498 };499 TestCase test = builder.getTestCase();500 Assert.assertEquals(test.getActionCount(), 2);501 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);502 Assert.assertEquals(test.getActions().get(1).getClass(), ReceiveMessageAction.class);503 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));504 Assert.assertEquals(action.getName(), "receive");505 Assert.assertEquals(action.getEndpoint(), messageEndpoint);506 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());507 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);508 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");509 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().size(), 2L);510 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo1</Value></Header>");511 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(1), "<Header><Name>operation</Name><Value>foo2</Value></Header>");512 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderResources().size(), 0L);513 action = ((ReceiveMessageAction)test.getActions().get(1));514 Assert.assertEquals(action.getName(), "receive");515 Assert.assertEquals(action.getEndpoint(), messageEndpoint);516 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());517 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);518 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");519 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().size(), 2L);520 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo1</Value></Header>");521 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(1), "<Header><Name>operation</Name><Value>foo2</Value></Header>");522 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderResources().size(), 0L);523 }524 @Test525 public void testReceiveBuilderWithHeaderFragment() {526 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);527 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);528 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);529 when(configuration.getTimeout()).thenReturn(100L);530 when(messageEndpoint.getActor()).thenReturn(null);531 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(532 new DefaultMessage()533 .addHeaderData("<TestRequest><Message>Hello Citrus!</Message></TestRequest>")534 .setHeader("operation", "foo"));535 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));536 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());537 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());538 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());539 when(applicationContextMock.getBeansOfType(Marshaller.class)).thenReturn(Collections.<String, Marshaller>singletonMap("marshaller", marshaller));540 when(applicationContextMock.getBean(Marshaller.class)).thenReturn(marshaller);541 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {542 @Override543 public void execute() {544 receive(action -> action.endpoint(messageEndpoint)545 .headerFragment(new TestRequest("Hello Citrus!")));546 }547 };548 TestCase test = builder.getTestCase();549 Assert.assertEquals(test.getActionCount(), 1);550 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);551 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));552 Assert.assertEquals(action.getName(), "receive");553 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());554 Assert.assertEquals(action.getEndpoint(), messageEndpoint);555 Assert.assertEquals(action.getValidationContexts().size(), 3);556 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);557 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);558 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);559 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);560 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);561 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(0),562 "<TestRequest><Message>Hello Citrus!</Message></TestRequest>");563 }564 @Test565 public void testReceiveBuilderWithHeaderFragmentExplicitMarshaller() {566 reset(messageEndpoint, messageConsumer, configuration);567 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);568 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);569 when(configuration.getTimeout()).thenReturn(100L);570 when(messageEndpoint.getActor()).thenReturn(null);571 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(572 new DefaultMessage()573 .addHeaderData("<TestRequest><Message>Hello Citrus!</Message></TestRequest>")574 .setHeader("operation", "foo"));575 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {576 @Override577 public void execute() {578 receive(action -> action.endpoint(messageEndpoint)579 .headerFragment(new TestRequest("Hello Citrus!"), marshaller));580 }581 };582 TestCase test = builder.getTestCase();583 Assert.assertEquals(test.getActionCount(), 1);584 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);585 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));586 Assert.assertEquals(action.getName(), "receive");587 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());588 Assert.assertEquals(action.getEndpoint(), messageEndpoint);589 Assert.assertEquals(action.getValidationContexts().size(), 3);590 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);591 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);592 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);593 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);594 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);595 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<TestRequest><Message>Hello Citrus!</Message></TestRequest>");596 }597 @Test598 public void testReceiveBuilderWithHeaderFragmentExplicitMarshallerName() {599 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);600 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);601 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);602 when(configuration.getTimeout()).thenReturn(100L);603 when(messageEndpoint.getActor()).thenReturn(null);604 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(605 new DefaultMessage()606 .addHeaderData("<TestRequest><Message>Hello Citrus!</Message></TestRequest>")607 .setHeader("operation", "foo"));608 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));609 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());610 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());611 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());612 when(applicationContextMock.containsBean("myMarshaller")).thenReturn(true);613 when(applicationContextMock.getBean("myMarshaller")).thenReturn(marshaller);614 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {615 @Override616 public void execute() {617 receive(action -> action.endpoint(messageEndpoint)618 .headerFragment(new TestRequest("Hello Citrus!"), "myMarshaller"));619 }620 };621 TestCase test = builder.getTestCase();622 Assert.assertEquals(test.getActionCount(), 1);623 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);624 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));625 Assert.assertEquals(action.getName(), "receive");626 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());627 Assert.assertEquals(action.getEndpoint(), messageEndpoint);628 Assert.assertEquals(action.getValidationContexts().size(), 3);629 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);630 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);631 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);632 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);633 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);634 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<TestRequest><Message>Hello Citrus!</Message></TestRequest>");635 }636 637 @Test638 public void testReceiveBuilderWithHeaderResource() throws IOException {639 reset(resource, messageEndpoint, messageConsumer, configuration);640 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);641 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);642 when(configuration.getTimeout()).thenReturn(100L);643 when(messageEndpoint.getActor()).thenReturn(null);644 when(messageConsumer.receive(any(TestContext.class), anyLong()))645 .thenReturn(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")646 .setHeader("operation", "foo")647 .addHeaderData("<Header><Name>operation</Name><Value>foo</Value></Header>"))648 .thenReturn(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")649 .setHeader("operation", "bar")650 .addHeaderData("<Header><Name>operation</Name><Value>bar</Value></Header>"));651 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<Header><Name>operation</Name><Value>foo</Value></Header>".getBytes()))652 .thenReturn(new ByteArrayInputStream("<Header><Name>operation</Name><Value>bar</Value></Header>".getBytes()));653 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {654 @Override655 public void execute() {656 receive(action -> action.endpoint(messageEndpoint)657 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")658 .header(resource));659 receive(action -> action.endpoint(messageEndpoint)660 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))661 .header(resource));662 }663 };664 TestCase test = builder.getTestCase();665 Assert.assertEquals(test.getActionCount(), 2);666 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);667 Assert.assertEquals(test.getActions().get(1).getClass(), ReceiveMessageAction.class);668 669 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));670 Assert.assertEquals(action.getName(), "receive");671 672 Assert.assertEquals(action.getEndpoint(), messageEndpoint);673 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());674 675 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);676 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");677 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);678 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo</Value></Header>");679 680 action = ((ReceiveMessageAction)test.getActions().get(1));681 Assert.assertEquals(action.getName(), "receive");682 683 Assert.assertEquals(action.getEndpoint(), messageEndpoint);684 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());685 686 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);687 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");688 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().size(), 1L);689 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>bar</Value></Header>");690 }691 @Test692 public void testReceiveBuilderWithMultipleHeaderResource() throws IOException {693 reset(resource, messageEndpoint, messageConsumer, configuration);694 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);695 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);696 when(configuration.getTimeout()).thenReturn(100L);697 when(messageEndpoint.getActor()).thenReturn(null);698 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(699 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")700 .setHeader("operation", "foo")701 .addHeaderData("<Header><Name>operation</Name><Value>sayHello</Value></Header>")702 .addHeaderData("<Header><Name>operation</Name><Value>foo</Value></Header>")703 .addHeaderData("<Header><Name>operation</Name><Value>bar</Value></Header>"));704 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("<Header><Name>operation</Name><Value>foo</Value></Header>".getBytes()))705 .thenReturn(new ByteArrayInputStream("<Header><Name>operation</Name><Value>bar</Value></Header>".getBytes()))706 .thenReturn(new ByteArrayInputStream("<Header><Name>operation</Name><Value>foo</Value></Header>".getBytes()))707 .thenReturn(new ByteArrayInputStream("<Header><Name>operation</Name><Value>bar</Value></Header>".getBytes()));708 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {709 @Override710 public void execute() {711 receive(action -> action.endpoint(messageEndpoint)712 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")713 .header("<Header><Name>operation</Name><Value>sayHello</Value></Header>")714 .header(resource)715 .header(resource));716 receive(action -> action.endpoint(messageEndpoint)717 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))718 .header("<Header><Name>operation</Name><Value>sayHello</Value></Header>")719 .header(resource)720 .header(resource));721 }722 };723 TestCase test = builder.getTestCase();724 Assert.assertEquals(test.getActionCount(), 2);725 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);726 Assert.assertEquals(test.getActions().get(1).getClass(), ReceiveMessageAction.class);727 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));728 Assert.assertEquals(action.getName(), "receive");729 Assert.assertEquals(action.getEndpoint(), messageEndpoint);730 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());731 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);732 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");733 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getHeaderData().size(), 3L);734 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>sayHello</Value></Header>");735 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(1), "<Header><Name>operation</Name><Value>foo</Value></Header>");736 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getHeaderData().get(2), "<Header><Name>operation</Name><Value>bar</Value></Header>");737 action = ((ReceiveMessageAction)test.getActions().get(1));738 Assert.assertEquals(action.getName(), "receive");739 Assert.assertEquals(action.getEndpoint(), messageEndpoint);740 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());741 Assert.assertTrue(action.getMessageBuilder() instanceof StaticMessageContentBuilder);742 Assert.assertEquals(((StaticMessageContentBuilder) action.getMessageBuilder()).getMessage().getPayload(), "<TestRequest><Message>Hello World!</Message></TestRequest>");743 Assert.assertEquals(((StaticMessageContentBuilder) action.getMessageBuilder()).getHeaderData().size(), 3L);744 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(0), "<Header><Name>operation</Name><Value>sayHello</Value></Header>");745 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(1), "<Header><Name>operation</Name><Value>foo</Value></Header>");746 Assert.assertEquals(((StaticMessageContentBuilder)action.getMessageBuilder()).getHeaderData().get(2), "<Header><Name>operation</Name><Value>bar</Value></Header>");747 }748 749 @Test750 public void testReceiveBuilderWithValidator() {751 reset(messageEndpoint, messageConsumer, configuration);752 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);753 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);754 when(configuration.getTimeout()).thenReturn(100L);755 when(messageEndpoint.getActor()).thenReturn(null);756 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("TestMessage").setHeader("operation", "sayHello"));757 final PlainTextMessageValidator validator = new PlainTextMessageValidator();758 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {759 @Override760 public void execute() {761 receive(action -> action.endpoint(messageEndpoint)762 .messageType(MessageType.PLAINTEXT)763 .payload("TestMessage")764 .header("operation", "sayHello")765 .validator(validator));766 }767 };768 TestCase test = builder.getTestCase();769 Assert.assertEquals(test.getActionCount(), 1);770 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);771 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));772 Assert.assertEquals(action.getName(), "receive");773 Assert.assertEquals(action.getEndpoint(), messageEndpoint);774 Assert.assertEquals(action.getMessageType(), MessageType.PLAINTEXT.name());775 Assert.assertEquals(action.getValidators().size(), 1L);776 Assert.assertEquals(action.getValidators().get(0), validator);777 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);778 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getPayloadData(), "TestMessage");779 Assert.assertTrue(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));780 }781 782 @Test783 public void testReceiveBuilderWithValidatorName() {784 final PlainTextMessageValidator validator = new PlainTextMessageValidator();785 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);786 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);787 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);788 when(configuration.getTimeout()).thenReturn(100L);789 when(messageEndpoint.getActor()).thenReturn(null);790 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("TestMessage").setHeader("operation", "sayHello"));791 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));792 when(applicationContextMock.getBean("plainTextValidator", MessageValidator.class)).thenReturn(validator);793 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());794 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());795 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());796 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {797 @Override798 public void execute() {799 receive(action -> action.endpoint(messageEndpoint)800 .messageType(MessageType.PLAINTEXT)801 .payload("TestMessage")802 .header("operation", "sayHello")803 .validator("plainTextValidator"));804 }805 };806 TestCase test = builder.getTestCase();807 Assert.assertEquals(test.getActionCount(), 1);808 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);809 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));810 Assert.assertEquals(action.getName(), "receive");811 Assert.assertEquals(action.getEndpoint(), messageEndpoint);812 Assert.assertEquals(action.getMessageType(), MessageType.PLAINTEXT.name());813 Assert.assertEquals(action.getValidators().size(), 1L);814 Assert.assertEquals(action.getValidators().get(0), validator);815 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);816 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "TestMessage");817 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));818 }819 @Test820 public void testReceiveBuilderWithDictionary() {821 final DataDictionary dictionary = new NodeMappingDataDictionary();822 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);823 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);824 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);825 when(configuration.getTimeout()).thenReturn(100L);826 when(messageEndpoint.getActor()).thenReturn(null);827 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("TestMessage").setHeader("operation", "sayHello"));828 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));829 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());830 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());831 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());832 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {833 @Override834 public void execute() {835 receive(action -> action.endpoint(messageEndpoint)836 .messageType(MessageType.PLAINTEXT)837 .payload("TestMessage")838 .header("operation", "sayHello")839 .dictionary(dictionary));840 }841 };842 TestCase test = builder.getTestCase();843 Assert.assertEquals(test.getActionCount(), 1);844 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);845 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));846 Assert.assertEquals(action.getName(), "receive");847 Assert.assertEquals(action.getEndpoint(), messageEndpoint);848 Assert.assertEquals(action.getMessageType(), MessageType.PLAINTEXT.name());849 Assert.assertEquals(action.getDataDictionary(), dictionary);850 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);851 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "TestMessage");852 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));853 }854 @Test855 public void testReceiveBuilderWithDictionaryName() {856 final DataDictionary dictionary = new NodeMappingDataDictionary();857 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);858 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);859 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);860 when(configuration.getTimeout()).thenReturn(100L);861 when(messageEndpoint.getActor()).thenReturn(null);862 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("TestMessage").setHeader("operation", "sayHello"));863 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));864 when(applicationContextMock.getBean("customDictionary", DataDictionary.class)).thenReturn(dictionary);865 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());866 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());867 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());868 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {869 @Override870 public void execute() {871 receive(action -> action.endpoint(messageEndpoint)872 .messageType(MessageType.PLAINTEXT)873 .payload("TestMessage")874 .header("operation", "sayHello")875 .dictionary("customDictionary"));876 }877 };878 TestCase test = builder.getTestCase();879 Assert.assertEquals(test.getActionCount(), 1);880 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);881 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));882 Assert.assertEquals(action.getName(), "receive");883 Assert.assertEquals(action.getEndpoint(), messageEndpoint);884 Assert.assertEquals(action.getMessageType(), MessageType.PLAINTEXT.name());885 Assert.assertEquals(action.getDataDictionary(), dictionary);886 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);887 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "TestMessage");888 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));889 }890 @Test891 public void testReceiveBuilderWithSelector() {892 SelectiveConsumer selectiveConsumer = Mockito.mock(SelectiveConsumer.class);893 reset(messageEndpoint, selectiveConsumer, configuration);894 when(messageEndpoint.createConsumer()).thenReturn(selectiveConsumer);895 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);896 when(configuration.getTimeout()).thenReturn(100L);897 when(messageEndpoint.getActor()).thenReturn(null);898 when(selectiveConsumer.receive(eq("operation = 'sayHello'"), any(TestContext.class), anyLong())).thenReturn(899 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")900 .setHeader("operation", "sayHello"));901 final Map<String, String> messageSelector = new HashMap<>();902 messageSelector.put("operation", "sayHello");903 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {904 @Override905 public void execute() {906 receive(action -> action.endpoint(messageEndpoint)907 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")908 .selector(messageSelector));909 }910 };911 TestCase test = builder.getTestCase();912 Assert.assertEquals(test.getActionCount(), 1);913 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);914 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));915 Assert.assertEquals(action.getName(), "receive");916 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());917 Assert.assertEquals(action.getEndpoint(), messageEndpoint);918 Assert.assertEquals(action.getMessageSelectorMap(), messageSelector);919 }920 921 @Test922 public void testReceiveBuilderWithSelectorExpression() {923 SelectiveConsumer selectiveConsumer = Mockito.mock(SelectiveConsumer.class);924 reset(messageEndpoint, selectiveConsumer, configuration);925 when(messageEndpoint.createConsumer()).thenReturn(selectiveConsumer);926 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);927 when(configuration.getTimeout()).thenReturn(100L);928 when(messageEndpoint.getActor()).thenReturn(null);929 when(selectiveConsumer.receive(eq("operation = 'sayHello'"), any(TestContext.class), anyLong())).thenReturn(930 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")931 .setHeader("operation", "sayHello"));932 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {933 @Override934 public void execute() {935 receive(action -> action.endpoint(messageEndpoint)936 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")937 .selector("operation = 'sayHello'"));938 }939 };940 TestCase test = builder.getTestCase();941 Assert.assertEquals(test.getActionCount(), 1);942 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);943 944 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));945 Assert.assertEquals(action.getName(), "receive");946 947 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());948 Assert.assertEquals(action.getEndpoint(), messageEndpoint);949 950 Assert.assertTrue(action.getMessageSelectorMap().isEmpty());951 Assert.assertEquals(action.getMessageSelector(), "operation = 'sayHello'");952 }953 954 @Test955 public void testReceiveBuilderExtractFromPayload() {956 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);957 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);958 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);959 when(configuration.getTimeout()).thenReturn(100L);960 when(messageEndpoint.getActor()).thenReturn(null);961 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(962 new DefaultMessage("<TestRequest><Message lang=\"ENG\">Hello World!</Message></TestRequest>")963 .setHeader("operation", "sayHello"));964 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));965 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());966 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());967 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());968 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {969 @Override970 public void execute() {971 receive(action -> action.endpoint(messageEndpoint)972 .payload("<TestRequest><Message lang=\"ENG\">Hello World!</Message></TestRequest>")973 .extractFromPayload("/TestRequest/Message", "text")974 .extractFromPayload("/TestRequest/Message/@lang", "language"));975 }976 };977 TestContext context = builder.getTestContext();978 Assert.assertNotNull(context.getVariable("text"));979 Assert.assertNotNull(context.getVariable("language"));980 Assert.assertEquals(context.getVariable("text"), "Hello World!");981 Assert.assertEquals(context.getVariable("language"), "ENG");982 TestCase test = builder.getTestCase();983 Assert.assertEquals(test.getActionCount(), 1);984 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);985 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));986 Assert.assertEquals(action.getName(), "receive");987 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());988 Assert.assertEquals(action.getEndpoint(), messageEndpoint);989 Assert.assertEquals(action.getVariableExtractors().size(), 1);990 Assert.assertTrue(action.getVariableExtractors().get(0) instanceof XpathPayloadVariableExtractor);991 Assert.assertTrue(((XpathPayloadVariableExtractor) action.getVariableExtractors().get(0)).getXpathExpressions().containsKey("/TestRequest/Message"));992 Assert.assertTrue(((XpathPayloadVariableExtractor) action.getVariableExtractors().get(0)).getXpathExpressions().containsKey("/TestRequest/Message/@lang"));993 }994 @Test995 public void testReceiveBuilderExtractJsonPathFromPayload() {996 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);997 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);998 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);999 when(configuration.getTimeout()).thenReturn(100L);1000 when(messageEndpoint.getActor()).thenReturn(null);1001 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1002 new DefaultMessage("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1003 .setHeader("operation", "sayHello"));1004 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));1005 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());1006 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());1007 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());1008 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {1009 @Override1010 public void execute() {1011 receive(action -> action.endpoint(messageEndpoint)1012 .messageType(MessageType.JSON)1013 .payload("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1014 .extractFromPayload("$.text", "text")1015 .extractFromPayload("$.toString()", "payload")1016 .extractFromPayload("$.person", "person"));1017 }1018 };1019 TestContext context = builder.getTestContext();1020 Assert.assertNotNull(context.getVariable("text"));1021 Assert.assertNotNull(context.getVariable("person"));1022 Assert.assertNotNull(context.getVariable("payload"));1023 Assert.assertEquals(context.getVariable("text"), "Hello World!");1024 Assert.assertEquals(context.getVariable("payload"), "{\"person\":{\"surname\":\"Doe\",\"name\":\"John\"},\"index\":5,\"text\":\"Hello World!\",\"id\":\"x123456789x\"}");1025 Assert.assertTrue(context.getVariable("person").contains("\"John\""));1026 TestCase test = builder.getTestCase();1027 Assert.assertEquals(test.getActionCount(), 1);1028 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1029 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1030 Assert.assertEquals(action.getName(), "receive");1031 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1032 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1033 Assert.assertEquals(action.getVariableExtractors().size(), 1);1034 Assert.assertTrue(action.getVariableExtractors().get(0) instanceof JsonPathVariableExtractor);1035 Assert.assertTrue(((JsonPathVariableExtractor) action.getVariableExtractors().get(0)).getJsonPathExpressions().containsKey("$.text"));1036 Assert.assertTrue(((JsonPathVariableExtractor) action.getVariableExtractors().get(0)).getJsonPathExpressions().containsKey("$.person"));1037 }1038 1039 @Test1040 public void testReceiveBuilderExtractFromHeader() {1041 reset(messageEndpoint, messageConsumer, configuration);1042 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1043 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1044 when(configuration.getTimeout()).thenReturn(100L);1045 when(messageEndpoint.getActor()).thenReturn(null);1046 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1047 new DefaultMessage("<TestRequest><Message lang=\"ENG\">Hello World!</Message></TestRequest>")1048 .setHeader("operation", "sayHello")1049 .setHeader("requestId", "123456"));1050 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1051 @Override1052 public void execute() {1053 receive(action -> action.endpoint(messageEndpoint)1054 .payload("<TestRequest><Message lang=\"ENG\">Hello World!</Message></TestRequest>")1055 .extractFromHeader("operation", "operationHeader")1056 .extractFromHeader("requestId", "id"));1057 }1058 };1059 TestContext context = builder.getTestContext();1060 Assert.assertNotNull(context.getVariable("operationHeader"));1061 Assert.assertNotNull(context.getVariable("id"));1062 Assert.assertEquals(context.getVariable("operationHeader"), "sayHello");1063 Assert.assertEquals(context.getVariable("id"), "123456");1064 TestCase test = builder.getTestCase();1065 Assert.assertEquals(test.getActionCount(), 1);1066 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1067 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1068 Assert.assertEquals(action.getName(), "receive");1069 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1070 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1071 Assert.assertEquals(action.getVariableExtractors().size(), 1);1072 Assert.assertTrue(action.getVariableExtractors().get(0) instanceof MessageHeaderVariableExtractor);1073 Assert.assertTrue(((MessageHeaderVariableExtractor) action.getVariableExtractors().get(0)).getHeaderMappings().containsKey("operation"));1074 Assert.assertTrue(((MessageHeaderVariableExtractor) action.getVariableExtractors().get(0)).getHeaderMappings().containsKey("requestId"));1075 }1076 1077 @Test1078 public void testReceiveBuilderExtractCombined() {1079 reset(messageEndpoint, messageConsumer, configuration);1080 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1081 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1082 when(configuration.getTimeout()).thenReturn(100L);1083 when(messageEndpoint.getActor()).thenReturn(null);1084 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1085 new DefaultMessage("<TestRequest><Message lang=\"ENG\">Hello World!</Message></TestRequest>")1086 .setHeader("operation", "sayHello")1087 .setHeader("requestId", "123456"));1088 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1089 @Override1090 public void execute() {1091 receive(action -> action.endpoint(messageEndpoint)1092 .payload("<TestRequest><Message lang=\"ENG\">Hello World!</Message></TestRequest>")1093 .extractFromHeader("operation", "operationHeader")1094 .extractFromHeader("requestId", "id")1095 .extractFromPayload("/TestRequest/Message", "text")1096 .extractFromPayload("/TestRequest/Message/@lang", "language"));1097 }1098 };1099 TestContext context = builder.getTestContext();1100 Assert.assertNotNull(context.getVariable("operationHeader"));1101 Assert.assertNotNull(context.getVariable("id"));1102 Assert.assertEquals(context.getVariable("operationHeader"), "sayHello");1103 Assert.assertEquals(context.getVariable("id"), "123456");1104 Assert.assertNotNull(context.getVariable("text"));1105 Assert.assertNotNull(context.getVariable("language"));1106 Assert.assertEquals(context.getVariable("text"), "Hello World!");1107 Assert.assertEquals(context.getVariable("language"), "ENG");1108 TestCase test = builder.getTestCase();1109 Assert.assertEquals(test.getActionCount(), 1);1110 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1111 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1112 Assert.assertEquals(action.getName(), "receive");1113 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1114 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1115 Assert.assertEquals(action.getVariableExtractors().size(), 2);1116 Assert.assertTrue(action.getVariableExtractors().get(0) instanceof MessageHeaderVariableExtractor);1117 Assert.assertTrue(((MessageHeaderVariableExtractor) action.getVariableExtractors().get(0)).getHeaderMappings().containsKey("operation"));1118 Assert.assertTrue(((MessageHeaderVariableExtractor) action.getVariableExtractors().get(0)).getHeaderMappings().containsKey("requestId"));1119 Assert.assertTrue(action.getVariableExtractors().get(1) instanceof XpathPayloadVariableExtractor);1120 Assert.assertTrue(((XpathPayloadVariableExtractor) action.getVariableExtractors().get(1)).getXpathExpressions().containsKey("/TestRequest/Message"));1121 Assert.assertTrue(((XpathPayloadVariableExtractor) action.getVariableExtractors().get(1)).getXpathExpressions().containsKey("/TestRequest/Message/@lang"));1122 }1123 1124 @Test1125 public void testReceiveBuilderWithValidationCallback() {1126 final AbstractValidationCallback callback = Mockito.mock(AbstractValidationCallback.class);1127 reset(callback, messageEndpoint, messageConsumer, configuration);1128 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1129 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1130 when(configuration.getTimeout()).thenReturn(100L);1131 when(messageEndpoint.getActor()).thenReturn(null);1132 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("TestMessage").setHeader("operation", "sayHello"));1133 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1134 @Override1135 public void execute() {1136 receive(action -> action.endpoint(messageEndpoint)1137 .messageType(MessageType.PLAINTEXT)1138 .payload("TestMessage")1139 .header("operation", "sayHello")1140 .validationCallback(callback));1141 }1142 };1143 TestCase test = builder.getTestCase();1144 Assert.assertEquals(test.getActionCount(), 1);1145 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1146 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1147 Assert.assertEquals(action.getName(), "receive");1148 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1149 Assert.assertEquals(action.getMessageType(), MessageType.PLAINTEXT.name());1150 Assert.assertEquals(action.getValidationCallback(), callback);1151 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1152 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getPayloadData(), "TestMessage");1153 Assert.assertTrue(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));1154 verify(callback).setApplicationContext(applicationContext);1155 verify(callback).validate(any(Message.class), any(TestContext.class));1156 }1157 @Test1158 public void testReceiveBuilderWithValidatonScript() {1159 final GroovyJsonMessageValidator validator = new GroovyJsonMessageValidator();1160 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);1161 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1162 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1163 when(configuration.getTimeout()).thenReturn(100L);1164 when(messageEndpoint.getActor()).thenReturn(null);1165 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("{\"message\": \"Hello Citrus!\"}").setHeader("operation", "sayHello"));1166 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));1167 when(applicationContextMock.getBean("groovyMessageValidator", MessageValidator.class)).thenReturn(validator);1168 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());1169 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());1170 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());1171 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {1172 @Override1173 public void execute() {1174 receive(action -> action.endpoint(messageEndpoint)1175 .messageType(MessageType.JSON)1176 .validateScript("assert json.message == 'Hello Citrus!'")1177 .validator("groovyMessageValidator"));1178 }1179 };1180 TestCase test = builder.getTestCase();1181 Assert.assertEquals(test.getActionCount(), 1);1182 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1183 1184 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1185 Assert.assertEquals(action.getName(), "receive");1186 1187 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1188 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1189 Assert.assertEquals(action.getValidators().size(), 1L);1190 Assert.assertEquals(action.getValidators().get(0), validator);1191 Assert.assertEquals(action.getValidationContexts().size(), 4L);1192 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1193 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1194 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1195 Assert.assertEquals(action.getValidationContexts().get(3).getClass(), ScriptValidationContext.class);1196 ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(3);1197 1198 Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);1199 Assert.assertEquals(validationContext.getValidationScript(), "assert json.message == 'Hello Citrus!'");1200 Assert.assertNull(validationContext.getValidationScriptResourcePath());1201 }1202 1203 @Test1204 public void testReceiveBuilderWithValidatonScriptResourcePath() throws IOException {1205 final GroovyJsonMessageValidator validator = new GroovyJsonMessageValidator();1206 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);1207 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1208 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1209 when(configuration.getTimeout()).thenReturn(100L);1210 when(messageEndpoint.getActor()).thenReturn(null);1211 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("{\"message\": \"Hello Citrus!\"}").setHeader("operation", "sayHello"));1212 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));1213 when(applicationContextMock.getBean("groovyMessageValidator", MessageValidator.class)).thenReturn(validator);1214 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());1215 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());1216 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());1217 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {1218 @Override1219 public void execute() {1220 receive(action -> action.endpoint(messageEndpoint)1221 .messageType(MessageType.JSON)1222 .validateScriptResource("classpath:com/consol/citrus/dsl/runner/validation.groovy")1223 .validator("groovyMessageValidator"));1224 }1225 };1226 TestCase test = builder.getTestCase();1227 Assert.assertEquals(test.getActionCount(), 1);1228 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1229 1230 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1231 Assert.assertEquals(action.getName(), "receive");1232 1233 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1234 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1235 Assert.assertEquals(action.getValidators().size(), 1L);1236 Assert.assertEquals(action.getValidators().get(0), validator);1237 Assert.assertEquals(action.getValidationContexts().size(), 4L);1238 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1239 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1240 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1241 Assert.assertEquals(action.getValidationContexts().get(3).getClass(), ScriptValidationContext.class);1242 ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(3);1243 1244 Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);1245 Assert.assertEquals(validationContext.getValidationScript(), "");1246 Assert.assertEquals(validationContext.getValidationScriptResourcePath(), "classpath:com/consol/citrus/dsl/runner/validation.groovy");1247 }1248 @Test1249 public void testReceiveBuilderWithValidatonScriptResource() throws IOException {1250 final GroovyJsonMessageValidator validator = new GroovyJsonMessageValidator();1251 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);1252 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1253 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1254 when(configuration.getTimeout()).thenReturn(100L);1255 when(messageEndpoint.getActor()).thenReturn(null);1256 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("{\"message\": \"Hello Citrus!\"}").setHeader("operation", "sayHello"));1257 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));1258 when(applicationContextMock.getBean("groovyMessageValidator", MessageValidator.class)).thenReturn(validator);1259 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());1260 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());1261 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());1262 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {1263 @Override1264 public void execute() {1265 receive(action -> action.endpoint(messageEndpoint)1266 .messageType(MessageType.JSON)1267 .validateScript(new ClassPathResource("com/consol/citrus/dsl/runner/validation.groovy"))1268 .validator("groovyMessageValidator"));1269 }1270 };1271 TestCase test = builder.getTestCase();1272 Assert.assertEquals(test.getActionCount(), 1);1273 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1274 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1275 Assert.assertEquals(action.getName(), "receive");1276 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1277 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1278 Assert.assertEquals(action.getValidators().size(), 1L);1279 Assert.assertEquals(action.getValidators().get(0), validator);1280 Assert.assertEquals(action.getValidationContexts().size(), 4L);1281 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1282 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1283 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1284 Assert.assertEquals(action.getValidationContexts().get(3).getClass(), ScriptValidationContext.class);1285 ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(3);1286 Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);1287 Assert.assertEquals(validationContext.getValidationScript(), "assert json.message == 'Hello Citrus!'");1288 Assert.assertNull(validationContext.getValidationScriptResourcePath());1289 }1290 1291 @Test1292 public void testReceiveBuilderWithValidatonScriptAndHeader() {1293 final GroovyJsonMessageValidator validator = new GroovyJsonMessageValidator();1294 reset(applicationContextMock, messageEndpoint, messageConsumer, configuration);1295 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1296 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1297 when(configuration.getTimeout()).thenReturn(100L);1298 when(messageEndpoint.getActor()).thenReturn(null);1299 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new DefaultMessage("{\"message\": \"Hello Citrus!\"}").setHeader("operation", "sayHello"));1300 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));1301 when(applicationContextMock.getBean("groovyMessageValidator", MessageValidator.class)).thenReturn(validator);1302 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());1303 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());1304 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());1305 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {1306 @Override1307 public void execute() {1308 receive(action -> action.endpoint(messageEndpoint)1309 .messageType(MessageType.JSON)1310 .validateScript("assert json.message == 'Hello Citrus!'")1311 .validator("groovyMessageValidator")1312 .header("operation", "sayHello"));1313 }1314 };1315 TestCase test = builder.getTestCase();1316 Assert.assertEquals(test.getActionCount(), 1);1317 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1318 1319 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1320 Assert.assertEquals(action.getName(), "receive");1321 1322 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1323 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1324 Assert.assertEquals(action.getValidators().size(), 1L);1325 Assert.assertEquals(action.getValidators().get(0), validator);1326 Assert.assertEquals(action.getValidationContexts().size(), 4L);1327 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1328 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1329 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1330 Assert.assertEquals(action.getValidationContexts().get(3).getClass(), ScriptValidationContext.class);1331 ScriptValidationContext validationContext = (ScriptValidationContext) action.getValidationContexts().get(3);1332 1333 Assert.assertEquals(validationContext.getScriptType(), ScriptTypes.GROOVY);1334 Assert.assertEquals(validationContext.getValidationScript(), "assert json.message == 'Hello Citrus!'");1335 Assert.assertNull(validationContext.getValidationScriptResourcePath());1336 1337 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1338 Assert.assertNull(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData());1339 Assert.assertNull(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadResourcePath());1340 Assert.assertTrue(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getMessageHeaders().containsKey("operation"));1341 }1342 1343 @Test1344 public void testReceiveBuilderWithNamespaceValidation() {1345 reset(messageEndpoint, messageConsumer, configuration);1346 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1347 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1348 when(configuration.getTimeout()).thenReturn(100L);1349 when(messageEndpoint.getActor()).thenReturn(null);1350 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1351 new DefaultMessage("<TestRequest xmlns:pfx=\"http://www.consol.de/schemas/test\"><Message>Hello World!</Message></TestRequest>")1352 .setHeader("operation", "foo"));1353 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1354 @Override1355 public void execute() {1356 receive(action -> action.endpoint(messageEndpoint)1357 .payload("<TestRequest xmlns:pfx=\"http://www.consol.de/schemas/test\"><Message>Hello World!</Message></TestRequest>")1358 .validateNamespace("pfx", "http://www.consol.de/schemas/test"));1359 }1360 };1361 TestCase test = builder.getTestCase();1362 Assert.assertEquals(test.getActionCount(), 1);1363 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1364 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1365 Assert.assertEquals(action.getName(), "receive");1366 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1367 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1368 Assert.assertEquals(action.getValidationContexts().size(), 3);1369 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1370 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1371 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1372 XmlMessageValidationContext validationContext = (XmlMessageValidationContext) action.getValidationContexts().get(1);1373 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1374 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(),1375 "<TestRequest xmlns:pfx=\"http://www.consol.de/schemas/test\"><Message>Hello World!</Message></TestRequest>");1376 Assert.assertEquals(validationContext.getControlNamespaces().get("pfx"), "http://www.consol.de/schemas/test");1377 }1378 @Test1379 public void testReceiveBuilderWithXpathExpressions() {1380 reset(messageEndpoint, messageConsumer, configuration);1381 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1382 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1383 when(configuration.getTimeout()).thenReturn(100L);1384 when(messageEndpoint.getActor()).thenReturn(null);1385 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1386 new DefaultMessage("<TestRequest><Message lang=\"ENG\">Hello World!</Message><Operation>SayHello</Operation></TestRequest>")1387 .setHeader("operation", "sayHello"));1388 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1389 @Override1390 public void execute() {1391 receive(action -> action.endpoint(messageEndpoint)1392 .payload("<TestRequest><Message lang=\"ENG\">Hello World!</Message><Operation>SayHello</Operation></TestRequest>")1393 .validate("TestRequest.Message", "Hello World!")1394 .validate("TestRequest.Operation", "SayHello"));1395 }1396 };1397 TestCase test = builder.getTestCase();1398 Assert.assertEquals(test.getActionCount(), 1);1399 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1400 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1401 Assert.assertEquals(action.getName(), "receive");1402 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1403 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1404 Assert.assertEquals(action.getValidationContexts().size(), 3);1405 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1406 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), JsonMessageValidationContext.class);1407 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), XpathMessageValidationContext.class);1408 XpathMessageValidationContext validationContext = (XpathMessageValidationContext) action.getValidationContexts().get(2);1409 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1410 Assert.assertEquals(validationContext.getXpathExpressions().size(), 2L);1411 Assert.assertEquals(validationContext.getXpathExpressions().get("TestRequest.Message"), "Hello World!");1412 Assert.assertEquals(validationContext.getXpathExpressions().get("TestRequest.Operation"), "SayHello");1413 }1414 @Test1415 public void testReceiveBuilderWithJsonPathExpressions() {1416 reset(messageEndpoint, messageConsumer, configuration);1417 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1418 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1419 when(configuration.getTimeout()).thenReturn(100L);1420 when(messageEndpoint.getActor()).thenReturn(null);1421 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1422 new DefaultMessage("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\",\"active\": true}, \"index\":5, \"id\":\"x123456789x\"}")1423 .setHeader("operation", "sayHello"));1424 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1425 @Override1426 public void execute() {1427 receive(action -> action.endpoint(messageEndpoint)1428 .messageType(MessageType.JSON)1429 .payload("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\",\"active\": true}, \"index\":5, \"id\":\"x123456789x\"}")1430 .validate("$.person.name", "John")1431 .validate("$.person.active", true)1432 .validate("$.id", anyOf(containsString("123456789"), nullValue()))1433 .validate("$.text", "Hello World!")1434 .validate("$.index", 5));1435 }1436 };1437 TestCase test = builder.getTestCase();1438 Assert.assertEquals(test.getActionCount(), 1);1439 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1440 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1441 Assert.assertEquals(action.getName(), "receive");1442 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1443 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1444 Assert.assertEquals(action.getValidationContexts().size(), 4);1445 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1446 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1447 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1448 Assert.assertEquals(action.getValidationContexts().get(3).getClass(), JsonPathMessageValidationContext.class);1449 JsonPathMessageValidationContext validationContext = (JsonPathMessageValidationContext) action.getValidationContexts().get(3);1450 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1451 Assert.assertEquals(validationContext.getJsonPathExpressions().size(), 5L);1452 Assert.assertEquals(validationContext.getJsonPathExpressions().get("$.person.name"), "John");1453 Assert.assertEquals(validationContext.getJsonPathExpressions().get("$.person.active"), true);1454 Assert.assertEquals(validationContext.getJsonPathExpressions().get("$.text"), "Hello World!");1455 Assert.assertEquals(validationContext.getJsonPathExpressions().get("$.index"), 5);1456 Assert.assertEquals(validationContext.getJsonPathExpressions().get("$.id").getClass(), AnyOf.class);1457 }1458 @Test(expectedExceptions = TestCaseFailedException.class)1459 public void testReceiveBuilderWithJsonPathExpressionsFailure() {1460 reset(messageEndpoint, messageConsumer, configuration);1461 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1462 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1463 when(configuration.getTimeout()).thenReturn(100L);1464 when(messageEndpoint.getActor()).thenReturn(null);1465 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1466 new DefaultMessage("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1467 .setHeader("operation", "sayHello"));1468 new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1469 @Override1470 public void execute() {1471 receive(action -> action.endpoint(messageEndpoint)1472 .messageType(MessageType.JSON)1473 .payload("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1474 .validate("$.person.name", "John")1475 .validate("$.text", "Hello Citrus!"));1476 }1477 };1478 }1479 @Test(expectedExceptions = TestCaseFailedException.class)1480 public void testReceiveBuilderWithJsonValidationFailure() {1481 reset(messageEndpoint, messageConsumer, configuration);1482 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1483 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1484 when(configuration.getTimeout()).thenReturn(100L);1485 when(messageEndpoint.getActor()).thenReturn(null);1486 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1487 new DefaultMessage("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1488 .setHeader("operation", "sayHello"));1489 new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1490 @Override1491 public void execute() {1492 receive(action -> action.endpoint(messageEndpoint)1493 .messageType(MessageType.JSON)1494 .payload("{\"text\":\"Hello Citrus!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1495 .validate("$.person.name", "John")1496 .validate("$.text", "Hello World!"));1497 }1498 };1499 }1500 1501 @Test1502 public void testReceiveBuilderWithIgnoreElementsXpath() {1503 reset(messageEndpoint, messageConsumer, configuration);1504 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1505 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1506 when(configuration.getTimeout()).thenReturn(100L);1507 when(messageEndpoint.getActor()).thenReturn(null);1508 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1509 new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>")1510 .setHeader("operation", "sayHello"));1511 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1512 @Override1513 public void execute() {1514 receive(action -> action.endpoint(messageEndpoint)1515 .payload("<TestRequest><Message>?</Message></TestRequest>")1516 .ignore("TestRequest.Message"));1517 }1518 };1519 TestCase test = builder.getTestCase();1520 Assert.assertEquals(test.getActionCount(), 1);1521 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1522 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1523 Assert.assertEquals(action.getName(), "receive");1524 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1525 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1526 Assert.assertEquals(action.getValidationContexts().size(), 3);1527 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1528 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1529 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1530 XmlMessageValidationContext validationContext = (XmlMessageValidationContext) action.getValidationContexts().get(1);1531 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1532 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest><Message>?</Message></TestRequest>");1533 Assert.assertEquals(validationContext.getIgnoreExpressions().size(), 1L);1534 Assert.assertEquals(validationContext.getIgnoreExpressions().iterator().next(), "TestRequest.Message");1535 }1536 @Test1537 public void testReceiveBuilderWithIgnoreElementsJson() {1538 reset(messageEndpoint, messageConsumer, configuration);1539 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1540 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1541 when(configuration.getTimeout()).thenReturn(100L);1542 when(messageEndpoint.getActor()).thenReturn(null);1543 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1544 new DefaultMessage("{\"text\":\"Hello World!\", \"person\":{\"name\":\"John\",\"surname\":\"Doe\"}, \"index\":5, \"id\":\"x123456789x\"}")1545 .setHeader("operation", "sayHello"));1546 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1547 @Override1548 public void execute() {1549 receive(action -> action.endpoint(messageEndpoint)1550 .messageType(MessageType.JSON)1551 .payload("{\"text\":\"?\", \"person\":{\"name\":\"John\",\"surname\":\"?\"}, \"index\":0, \"id\":\"x123456789x\"}")1552 .ignore("$..text")1553 .ignore("$.person.surname")1554 .ignore("$.index"));1555 }1556 };1557 TestCase test = builder.getTestCase();1558 Assert.assertEquals(test.getActionCount(), 1);1559 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1560 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1561 Assert.assertEquals(action.getName(), "receive");1562 Assert.assertEquals(action.getMessageType(), MessageType.JSON.name());1563 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1564 Assert.assertEquals(action.getValidationContexts().size(), 3);1565 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1566 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1567 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1568 JsonMessageValidationContext validationContext = (JsonMessageValidationContext) action.getValidationContexts().get(2);1569 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1570 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getPayloadData(), "{\"text\":\"?\", \"person\":{\"name\":\"John\",\"surname\":\"?\"}, \"index\":0, \"id\":\"x123456789x\"}");1571 Assert.assertEquals(validationContext.getIgnoreExpressions().size(), 3L);1572 Assert.assertTrue(validationContext.getIgnoreExpressions().contains("$..text"));1573 Assert.assertTrue(validationContext.getIgnoreExpressions().contains("$.person.surname"));1574 Assert.assertTrue(validationContext.getIgnoreExpressions().contains("$.index"));1575 }1576 @Test1577 public void testReceiveBuilderWithSchema() throws IOException {1578 XsdSchema schema = applicationContext.getBean("testSchema", XsdSchema.class);1579 XmlValidator validator = Mockito.mock(XmlValidator.class);1580 reset(applicationContextMock, schema, validator, messageEndpoint, messageConsumer, configuration);1581 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1582 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1583 when(configuration.getTimeout()).thenReturn(100L);1584 when(messageEndpoint.getActor()).thenReturn(null);1585 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1586 new DefaultMessage("<TestRequest xmlns=\"http://citrusframework.org/test\"><Message>Hello World!</Message></TestRequest>")1587 .setHeader("operation", "sayHello"));1588 when(applicationContextMock.getBean(TestContext.class)).thenReturn(applicationContext.getBean(TestContext.class));1589 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());1590 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());1591 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());1592 when(schema.createValidator()).thenReturn(validator);1593 when(validator.validate(any(Source.class))).thenReturn(new SAXParseException[] {});1594 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {1595 @Override1596 public void execute() {1597 receive(action -> action.endpoint(messageEndpoint)1598 .payload("<TestRequest xmlns=\"http://citrusframework.org/test\"><Message>Hello World!</Message></TestRequest>")1599 .xsd("testSchema"));1600 }1601 };1602 TestCase test = builder.getTestCase();1603 Assert.assertEquals(test.getActionCount(), 1);1604 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1605 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1606 Assert.assertEquals(action.getName(), "receive");1607 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1608 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1609 Assert.assertEquals(action.getValidationContexts().size(), 3);1610 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1611 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1612 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1613 XmlMessageValidationContext validationContext = (XmlMessageValidationContext) action.getValidationContexts().get(1);1614 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1615 Assert.assertEquals(((PayloadTemplateMessageBuilder) action.getMessageBuilder()).getPayloadData(), "<TestRequest xmlns=\"http://citrusframework.org/test\"><Message>Hello World!</Message></TestRequest>");1616 Assert.assertEquals(validationContext.getSchema(), "testSchema");1617 }1618 1619 @Test1620 public void testReceiveBuilderWithSchemaRepository() throws IOException {1621 XsdSchema schema = applicationContext.getBean("testSchema", XsdSchema.class);1622 reset(schema, messageEndpoint, messageConsumer, configuration);1623 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1624 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1625 when(configuration.getTimeout()).thenReturn(100L);1626 when(messageEndpoint.getActor()).thenReturn(null);1627 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1628 new DefaultMessage("<TestRequest xmlns=\"http://citrusframework.org/test\"><Message>Hello World!</Message></TestRequest>")1629 .setHeader("operation", "sayHello"));1630 when(schema.getTargetNamespace()).thenReturn("http://citrusframework.org/test");1631 when(schema.getSource()).thenReturn(new StringSource("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n" +1632 " xmlns=\"http://citrusframework.org/test\"\n" +1633 " targetNamespace=\"http://citrusframework.org/test\"\n" +1634 " elementFormDefault=\"qualified\"\n" +1635 " attributeFormDefault=\"unqualified\">\n" +1636 " <xs:element name=\"TestRequest\">\n" +1637 " <xs:complexType>\n" +1638 " <xs:sequence>\n" +1639 " <xs:element name=\"Message\" type=\"xs:string\"/>\n" +1640 " </xs:sequence>\n" +1641 " </xs:complexType>\n" +1642 " </xs:element></xs:schema>"));1643 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1644 @Override1645 public void execute() {1646 receive(action -> action.endpoint(messageEndpoint)1647 .payload("<TestRequest xmlns=\"http://citrusframework.org/test\"><Message>Hello World!</Message></TestRequest>")1648 .xsdSchemaRepository("customSchemaRepository"));1649 }1650 };1651 TestCase test = builder.getTestCase();1652 Assert.assertEquals(test.getActionCount(), 1);1653 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1654 1655 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1656 Assert.assertEquals(action.getName(), "receive");1657 1658 Assert.assertEquals(action.getMessageType(), MessageType.XML.name());1659 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1660 Assert.assertEquals(action.getValidationContexts().size(), 3);1661 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1662 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1663 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1664 1665 XmlMessageValidationContext validationContext = (XmlMessageValidationContext) action.getValidationContexts().get(1);1666 1667 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1668 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "<TestRequest xmlns=\"http://citrusframework.org/test\"><Message>Hello World!</Message></TestRequest>");1669 Assert.assertEquals(validationContext.getSchemaRepository(), "customSchemaRepository");1670 }1671 @Test1672 public void testReceiveBuilderWithJsonSchemaRepository() throws IOException {1673 SimpleJsonSchema schema = applicationContext.getBean("jsonTestSchema", SimpleJsonSchema.class);1674 reset(schema, messageEndpoint, messageConsumer, configuration);1675 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1676 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1677 when(configuration.getTimeout()).thenReturn(100L);1678 when(messageEndpoint.getActor()).thenReturn(null);1679 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1680 new DefaultMessage("{}")1681 .setHeader("operation", "sayHello"));1682 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1683 @Override1684 public void execute() {1685 receive(action -> action.endpoint(messageEndpoint)1686 .payload("{}")1687 .jsonSchemaRepository("customJsonSchemaRepository"));1688 }1689 };1690 TestCase test = builder.getTestCase();1691 Assert.assertEquals(test.getActionCount(), 1);1692 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1693 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1694 Assert.assertEquals(action.getName(), "receive");1695 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1696 Assert.assertEquals(action.getValidationContexts().size(), 3);1697 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1698 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1699 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1700 JsonMessageValidationContext validationContext = (JsonMessageValidationContext) action.getValidationContexts().get(2);1701 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1702 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "{}");1703 Assert.assertEquals(validationContext.getSchemaRepository(), "customJsonSchemaRepository");1704 }1705 @Test1706 public void testReceiveBuilderWithJsonSchema() throws IOException {1707 SimpleJsonSchema schema = applicationContext.getBean("jsonTestSchema", SimpleJsonSchema.class);1708 reset(schema, messageEndpoint, messageConsumer, configuration);1709 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1710 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1711 when(configuration.getTimeout()).thenReturn(100L);1712 when(messageEndpoint.getActor()).thenReturn(null);1713 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1714 new DefaultMessage("{}")1715 .setHeader("operation", "sayHello"));1716 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1717 @Override1718 public void execute() {1719 receive(action -> action.endpoint(messageEndpoint)1720 .payload("{}")1721 .jsonSchema("jsonTestSchema"));1722 }1723 };1724 TestCase test = builder.getTestCase();1725 Assert.assertEquals(test.getActionCount(), 1);1726 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1727 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1728 Assert.assertEquals(action.getName(), "receive");1729 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1730 Assert.assertEquals(action.getValidationContexts().size(), 3);1731 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1732 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1733 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1734 JsonMessageValidationContext validationContext = (JsonMessageValidationContext) action.getValidationContexts().get(2);1735 Assert.assertTrue(action.getMessageBuilder() instanceof PayloadTemplateMessageBuilder);1736 Assert.assertEquals(((PayloadTemplateMessageBuilder)action.getMessageBuilder()).getPayloadData(), "{}");1737 Assert.assertEquals(validationContext.getSchema(), "jsonTestSchema");1738 }1739 @Test1740 public void testActivateSchemaValidation() throws Exception {1741 SimpleJsonSchema schema = applicationContext.getBean("jsonTestSchema", SimpleJsonSchema.class);1742 reset(schema, messageEndpoint, messageConsumer, configuration);1743 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1744 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1745 when(configuration.getTimeout()).thenReturn(100L);1746 when(messageEndpoint.getActor()).thenReturn(null);1747 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1748 new DefaultMessage("{}")1749 .setHeader("operation", "sayHello"));1750 JsonSchema jsonSchemaMock = mock(JsonSchema.class);1751 when(jsonSchemaMock.validate(any())).thenReturn(new GraciousProcessingReport(true));1752 when(schema.getSchema()).thenReturn(jsonSchemaMock);1753 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1754 @Override1755 public void execute() {1756 receive(action -> action.endpoint(messageEndpoint)1757 .payload("{}")1758 .schemaValidation(true));1759 }1760 };1761 TestCase test = builder.getTestCase();1762 Assert.assertEquals(test.getActionCount(), 1);1763 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1764 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1765 Assert.assertEquals(action.getName(), "receive");1766 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1767 Assert.assertEquals(action.getValidationContexts().size(), 3);1768 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1769 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);1770 Assert.assertEquals(action.getValidationContexts().get(2).getClass(), JsonMessageValidationContext.class);1771 XmlMessageValidationContext xmlMessageValidationContext =1772 (XmlMessageValidationContext) action.getValidationContexts().get(1);1773 Assert.assertTrue(xmlMessageValidationContext.isSchemaValidationEnabled());1774 JsonMessageValidationContext jsonMessageValidationContext =1775 (JsonMessageValidationContext) action.getValidationContexts().get(2);1776 Assert.assertTrue(jsonMessageValidationContext.isSchemaValidationEnabled());1777 }1778 @Test1779 public void testDeactivateSchemaValidation() throws IOException {1780 reset(messageEndpoint, messageConsumer, configuration);1781 when(messageEndpoint.createConsumer()).thenReturn(messageConsumer);1782 when(messageEndpoint.getEndpointConfiguration()).thenReturn(configuration);1783 when(configuration.getTimeout()).thenReturn(100L);1784 when(messageEndpoint.getActor()).thenReturn(null);1785 when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(1786 new DefaultMessage("{}")1787 .setHeader("operation", "sayHello"));1788 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {1789 @Override1790 public void execute() {1791 receive(action -> action.endpoint(messageEndpoint)1792 .payload("{}")1793 .schemaValidation(false));1794 }1795 };1796 TestCase test = builder.getTestCase();1797 Assert.assertEquals(test.getActionCount(), 1);1798 Assert.assertEquals(test.getActions().get(0).getClass(), ReceiveMessageAction.class);1799 ReceiveMessageAction action = ((ReceiveMessageAction)test.getActions().get(0));1800 Assert.assertEquals(action.getName(), "receive");1801 Assert.assertEquals(action.getEndpoint(), messageEndpoint);1802 Assert.assertEquals(action.getValidationContexts().size(), 3);1803 Assert.assertEquals(action.getValidationContexts().get(0).getClass(), HeaderValidationContext.class);1804 Assert.assertEquals(action.getValidationContexts().get(1).getClass(), XmlMessageValidationContext.class);...

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1com.consol.citrus.dsl.runner.ReceiveMessageTestRunnerTest.testReceiveMessageBuilder(): # Language: markdown2com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilder(): # Language: markdown3com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeout(): # Language: markdown4com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelector(): # Language: markdown5com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelectorAndMessageSelector(): # Language: markdown6com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelectorAndTimeout(): # Language: markdown7com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelectorAndTimeoutAndMessageSelector(): # Language: markdown8com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelectorAndTimeoutAndMessageSelectorAndMessageSelector(): # Language: markdown9com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelectorAndTimeoutAndMessageSelectorAndTimeout(): # Language: markdown10com.consol.citrus.dsl.runner.ReceiveTimeoutTestRunnerTest.testReceiveTimeoutBuilderWithTimeoutAndMessageSelectorAndTimeoutAndMessageSelectorAndTimeoutAndMessageSelector(): # Language:

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1public void testReceiveMessage() {2 execute(new ReceiveMessageTestRunner() {3 public void execute() {4 receive(builder -> builder.endpoint(fooEndpoint)5 .messageType(MessageType.PLAINTEXT)6 .message("Hello Citrus!"));7 }8 });9}10public void testReceiveMessage() {11 execute(new ReceiveMessageTestRunner() {12 public void execute() {13 receive(builder -> builder.endpoint(fooEndpoint)14 .messageType(MessageType.PLAINTEXT)15 .message("Hello Citrus!"));16 }17 });18}19execute(new ReceiveMessageTestRunner() {20 public void execute() {21 name("MyTest");22 author("Christoph Deppisch");23 description("This is my test case");24 receive(builder -> builder.endpoint(fooEndpoint)25 .messageType(MessageType.PLAINTEXT)26 .message("Hello Citrus!"));27 }28});29execute(new ReceiveMessageTestRunner() {30 public void execute() {31 name("MyTest");32 author("Christoph Deppisch");33 description("This is my test case");34 receive(builder -> builder.endpoint(fooEndpoint)35 .messageType(MessageType.PLAINTEXT)36 .message("Hello Citrus!"));37 }38});

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in ReceiveMessageTestRunnerTest

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful