Best Citrus code snippet using com.consol.citrus.actions.ReceiveMessageAction.ReceiveMessageAction
Source:ReceiveMessageActionTest.java
...35import com.consol.citrus.validation.xml.DomXmlMessageValidator;36/**37 * @author Christoph Deppisch38 */39public class ReceiveMessageActionTest extends AbstractBaseTest {40 private MessageReceiver messageReceiver = EasyMock.createMock(MessageReceiver.class);41 42 private DomXmlMessageValidator validator = new DomXmlMessageValidator();43 44 @Test45 @SuppressWarnings("unchecked")46 public void testReceiveMessageWithMessagePayloadData() {47 ReceiveMessageAction receiveAction = new ReceiveMessageAction();48 receiveAction.setMessageReceiver(messageReceiver);49 50 receiveAction.setValidator(validator);51 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");52 53 Map<String, Object> headers = new HashMap<String, Object>();54 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")55 .copyHeaders(headers)56 .build();57 58 reset(messageReceiver);59 expect(messageReceiver.receive()).andReturn(controlMessage).once();60 replay(messageReceiver);61 62 receiveAction.execute(context);63 64 verify(messageReceiver);65 }66 67 @Test68 @SuppressWarnings("unchecked")69 public void testReceiveMessageWithMessagePayloadResource() {70 ReceiveMessageAction receiveAction = new ReceiveMessageAction();71 receiveAction.setMessageReceiver(messageReceiver);72 73 receiveAction.setValidator(validator);74 receiveAction.setMessageResource(new ClassPathResource("test-request-payload.xml", ReceiveMessageActionTest.class));75 76 Map<String, Object> headers = new HashMap<String, Object>();77 final Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")78 .copyHeaders(headers)79 .build();80 81 reset(messageReceiver);82 expect(messageReceiver.receive()).andReturn(controlMessage).once();83 replay(messageReceiver);84 85 receiveAction.execute(context);86 87 verify(messageReceiver);88 }89 90 @Test91 @SuppressWarnings("unchecked")92 public void testReceiveMessageWithMessagePayloadScriptData() {93 ReceiveMessageAction receiveAction = new ReceiveMessageAction();94 receiveAction.setMessageReceiver(messageReceiver);95 receiveAction.setValidator(validator);96 StringBuilder sb = new StringBuilder();97 sb.append("xml.TestRequest(){\n");98 sb.append("Message('Hello World!')\n");99 sb.append("}");100 receiveAction.setScriptData(sb.toString());101 102 Map<String, Object> headers = new HashMap<String, Object>();103 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")104 .copyHeaders(headers)105 .build();106 107 reset(messageReceiver);108 expect(messageReceiver.receive()).andReturn(controlMessage).once();109 replay(messageReceiver);110 111 receiveAction.execute(context);112 113 verify(messageReceiver);114 }115 116 @Test117 @SuppressWarnings("unchecked")118 public void testReceiveMessageWithMessagePayloadScriptResource() {119 ReceiveMessageAction receiveAction = new ReceiveMessageAction();120 receiveAction.setMessageReceiver(messageReceiver);121 receiveAction.setValidator(validator);122 receiveAction.setScriptResource(new ClassPathResource("test-request-payload.groovy", ReceiveMessageActionTest.class));123 124 Map<String, Object> headers = new HashMap<String, Object>();125 final Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")126 .copyHeaders(headers)127 .build();128 129 reset(messageReceiver);130 expect(messageReceiver.receive()).andReturn(controlMessage).once();131 replay(messageReceiver);132 133 receiveAction.execute(context);134 135 verify(messageReceiver);136 }137 138 @Test139 @SuppressWarnings("unchecked")140 public void testReceiveMessageWithMessagePayloadDataVariablesSupport() {141 ReceiveMessageAction receiveAction = new ReceiveMessageAction();142 receiveAction.setMessageReceiver(messageReceiver);143 receiveAction.setValidator(validator);144 receiveAction.setMessageData("<TestRequest><Message>${myText}</Message></TestRequest>");145 146 context.setVariable("myText", "Hello World!");147 148 Map<String, Object> headers = new HashMap<String, Object>();149 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")150 .copyHeaders(headers)151 .build();152 153 reset(messageReceiver);154 expect(messageReceiver.receive()).andReturn(controlMessage).once();155 replay(messageReceiver);156 157 receiveAction.execute(context);158 159 verify(messageReceiver);160 }161 162 @Test163 @SuppressWarnings("unchecked")164 public void testReceiveMessageWithMessagePayloadResourceVariablesSupport() {165 ReceiveMessageAction receiveAction = new ReceiveMessageAction();166 receiveAction.setMessageReceiver(messageReceiver);167 receiveAction.setValidator(validator);168 receiveAction.setMessageResource(new ClassPathResource("test-request-payload-with-variables.xml", ReceiveMessageActionTest.class));169 170 context.setVariable("myText", "Hello World!");171 172 Map<String, Object> headers = new HashMap<String, Object>();173 final Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")174 .copyHeaders(headers)175 .build();176 177 reset(messageReceiver);178 expect(messageReceiver.receive()).andReturn(controlMessage).once();179 replay(messageReceiver);180 181 receiveAction.execute(context);182 183 verify(messageReceiver);184 }185 186 @Test187 @SuppressWarnings("unchecked")188 public void testReceiveMessageWithMessagePayloadResourceFunctionsSupport() {189 ReceiveMessageAction receiveAction = new ReceiveMessageAction();190 receiveAction.setMessageReceiver(messageReceiver);191 receiveAction.setValidator(validator);192 receiveAction.setMessageResource(new ClassPathResource("test-request-payload-with-functions.xml", ReceiveMessageActionTest.class));193 194 Map<String, Object> headers = new HashMap<String, Object>();195 final Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")196 .copyHeaders(headers)197 .build();198 199 reset(messageReceiver);200 expect(messageReceiver.receive()).andReturn(controlMessage).once();201 replay(messageReceiver);202 203 receiveAction.execute(context);204 205 verify(messageReceiver);206 }207 208 @Test209 @SuppressWarnings("unchecked")210 public void testReceiveMessageOverwriteMessageElementsXPath() {211 ReceiveMessageAction receiveAction = new ReceiveMessageAction();212 receiveAction.setMessageReceiver(messageReceiver);213 receiveAction.setValidator(validator);214 receiveAction.setMessageData("<TestRequest><Message>?</Message></TestRequest>");215 216 Map<String, String> overwriteElements = new HashMap<String, String>();217 overwriteElements.put("/TestRequest/Message", "Hello World!");218 receiveAction.setMessageElements(overwriteElements);219 220 Map<String, Object> headers = new HashMap<String, Object>();221 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")222 .copyHeaders(headers)223 .build();224 225 reset(messageReceiver);226 expect(messageReceiver.receive()).andReturn(controlMessage).once();227 replay(messageReceiver);228 229 receiveAction.execute(context);230 231 verify(messageReceiver);232 }233 234 @Test235 @SuppressWarnings("unchecked")236 public void testReceiveMessageOverwriteMessageElementsDotNotation() {237 ReceiveMessageAction receiveAction = new ReceiveMessageAction();238 receiveAction.setMessageReceiver(messageReceiver);239 receiveAction.setValidator(validator);240 receiveAction.setMessageData("<TestRequest><Message>?</Message></TestRequest>");241 242 Map<String, String> overwriteElements = new HashMap<String, String>();243 overwriteElements.put("TestRequest.Message", "Hello World!");244 receiveAction.setMessageElements(overwriteElements);245 246 Map<String, Object> headers = new HashMap<String, Object>();247 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")248 .copyHeaders(headers)249 .build();250 251 reset(messageReceiver);252 expect(messageReceiver.receive()).andReturn(controlMessage).once();253 replay(messageReceiver);254 255 receiveAction.execute(context);256 257 verify(messageReceiver);258 }259 260 @Test261 @SuppressWarnings("unchecked")262 public void testReceiveMessageOverwriteMessageElementsXPathWithNamespaces() {263 ReceiveMessageAction receiveAction = new ReceiveMessageAction();264 receiveAction.setMessageReceiver(messageReceiver);265 receiveAction.setValidator(validator);266 receiveAction.setSchemaValidation(false);267 268 receiveAction.setMessageData("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +269 "<ns0:Message>?</ns0:Message></ns0:TestRequest>");270 271 Map<String, String> overwriteElements = new HashMap<String, String>();272 overwriteElements.put("/ns0:TestRequest/ns0:Message", "Hello World!");273 receiveAction.setMessageElements(overwriteElements);274 275 Map<String, Object> headers = new HashMap<String, Object>();276 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +277 "<ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>")278 .copyHeaders(headers)279 .build();280 281 reset(messageReceiver);282 expect(messageReceiver.receive()).andReturn(controlMessage).once();283 replay(messageReceiver);284 285 receiveAction.execute(context);286 287 verify(messageReceiver);288 }289 290 @Test291 @SuppressWarnings("unchecked")292 public void testReceiveMessageOverwriteMessageElementsXPathWithNestedNamespaces() {293 ReceiveMessageAction receiveAction = new ReceiveMessageAction();294 receiveAction.setMessageReceiver(messageReceiver);295 receiveAction.setValidator(validator);296 receiveAction.setSchemaValidation(false);297 298 receiveAction.setMessageData("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +299 "<ns1:Message xmlns:ns1=\"http://citrusframework.org/unittest/message\">?</ns1:Message></ns0:TestRequest>");300 301 Map<String, String> overwriteElements = new HashMap<String, String>();302 overwriteElements.put("/ns0:TestRequest/ns1:Message", "Hello World!");303 receiveAction.setMessageElements(overwriteElements);304 305 Map<String, Object> headers = new HashMap<String, Object>();306 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +307 "<ns1:Message xmlns:ns1=\"http://citrusframework.org/unittest/message\">Hello World!</ns1:Message></ns0:TestRequest>")308 .copyHeaders(headers)309 .build();310 311 reset(messageReceiver);312 expect(messageReceiver.receive()).andReturn(controlMessage).once();313 replay(messageReceiver);314 315 receiveAction.execute(context);316 317 verify(messageReceiver);318 }319 320 @Test321 @SuppressWarnings("unchecked")322 public void testReceiveMessageOverwriteMessageElementsXPathWithDefaultNamespaces() {323 ReceiveMessageAction receiveAction = new ReceiveMessageAction();324 receiveAction.setMessageReceiver(messageReceiver);325 receiveAction.setValidator(validator);326 receiveAction.setSchemaValidation(false);327 328 receiveAction.setMessageData("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +329 "<Message>?</Message></TestRequest>");330 331 Map<String, String> overwriteElements = new HashMap<String, String>();332 overwriteElements.put("/:TestRequest/:Message", "Hello World!");333 receiveAction.setMessageElements(overwriteElements);334 335 Map<String, Object> headers = new HashMap<String, Object>();336 Message controlMessage = MessageBuilder.withPayload("<TestRequest xmlns=\"http://citrusframework.org/unittest\"><Message>Hello World!</Message></TestRequest>")337 .copyHeaders(headers)338 .build();339 340 reset(messageReceiver);341 expect(messageReceiver.receive()).andReturn(controlMessage).once();342 replay(messageReceiver);343 344 receiveAction.execute(context);345 346 verify(messageReceiver);347 }348 349 @Test350 @SuppressWarnings("unchecked")351 public void testReceiveMessageWithMessageHeaders() {352 ReceiveMessageAction receiveAction = new ReceiveMessageAction();353 receiveAction.setMessageReceiver(messageReceiver);354 receiveAction.setValidator(validator);355 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");356 validator.setFunctionRegistry(context.getFunctionRegistry());357 358 Map<String, Object> headers = new HashMap<String, Object>();359 headers.put("Operation", "sayHello");360 receiveAction.setControlMessageHeaders(headers);361 362 Map<String, Object> controlHeaders = new HashMap<String, Object>();363 controlHeaders.put("Operation", "sayHello");364 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")365 .copyHeaders(controlHeaders)366 .build();367 368 reset(messageReceiver);369 expect(messageReceiver.receive()).andReturn(controlMessage).once();370 replay(messageReceiver);371 372 receiveAction.execute(context);373 374 verify(messageReceiver);375 }376 377 @Test378 @SuppressWarnings("unchecked")379 public void testReceiveMessageWithMessageHeadersVariablesSupport() {380 ReceiveMessageAction receiveAction = new ReceiveMessageAction();381 receiveAction.setMessageReceiver(messageReceiver);382 receiveAction.setValidator(validator);383 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");384 validator.setFunctionRegistry(context.getFunctionRegistry());385 386 context.setVariable("myOperation", "sayHello");387 388 Map<String, Object> headers = new HashMap<String, Object>();389 headers.put("Operation", "${myOperation}");390 receiveAction.setControlMessageHeaders(headers);391 392 Map<String, Object> controlHeaders = new HashMap<String, Object>();393 controlHeaders.put("Operation", "sayHello");394 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")395 .copyHeaders(controlHeaders)396 .build();397 398 reset(messageReceiver);399 expect(messageReceiver.receive()).andReturn(controlMessage).once();400 replay(messageReceiver);401 402 receiveAction.execute(context);403 404 verify(messageReceiver);405 }406 407 @Test408 @SuppressWarnings("unchecked")409 public void testReceiveMessageWithUnknownVariablesInMessageHeaders() {410 ReceiveMessageAction receiveAction = new ReceiveMessageAction();411 receiveAction.setMessageReceiver(messageReceiver);412 receiveAction.setValidator(validator);413 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");414 validator.setFunctionRegistry(context.getFunctionRegistry());415 416 Map<String, Object> headers = new HashMap<String, Object>();417 headers.put("Operation", "${myOperation}");418 receiveAction.setControlMessageHeaders(headers);419 420 Map<String, Object> controlHeaders = new HashMap<String, Object>();421 controlHeaders.put("Operation", "sayHello");422 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")423 .copyHeaders(controlHeaders)424 .build();425 426 reset(messageReceiver);427 expect(messageReceiver.receive()).andReturn(controlMessage).once();428 replay(messageReceiver);429 430 try {431 receiveAction.execute(context);432 } catch(CitrusRuntimeException e) {433 Assert.assertEquals(e.getMessage(), "Unknown variable '${myOperation}'");434 return;435 }436 437 verify(messageReceiver);438 }439 440 @Test441 @SuppressWarnings("unchecked")442 public void testReceiveMessageWithUnknownVariableInMessagePayload() {443 ReceiveMessageAction receiveAction = new ReceiveMessageAction();444 receiveAction.setMessageReceiver(messageReceiver);445 receiveAction.setValidator(validator);446 receiveAction.setMessageData("<TestRequest><Message>${myText}</Message></TestRequest>");447 448 Map<String, Object> headers = new HashMap<String, Object>();449 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")450 .copyHeaders(headers)451 .build();452 453 reset(messageReceiver);454 expect(messageReceiver.receive()).andReturn(controlMessage).once();455 replay(messageReceiver);456 457 try {458 receiveAction.execute(context);459 } catch(CitrusRuntimeException e) {460 Assert.assertEquals(e.getMessage(), "Unknown variable 'myText'");461 return;462 }463 464 verify(messageReceiver);465 }466 467 @Test468 @SuppressWarnings("unchecked")469 public void testReceiveMessageWithExtractVariablesFromHeaders() {470 ReceiveMessageAction receiveAction = new ReceiveMessageAction();471 receiveAction.setMessageReceiver(messageReceiver);472 receiveAction.setValidator(validator);473 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");474 validator.setFunctionRegistry(context.getFunctionRegistry());475 476 Map<String, String> headers = new HashMap<String, String>();477 headers.put("Operation", "myOperation");478 receiveAction.setExtractHeaderValues(headers);479 480 Map<String, Object> controlHeaders = new HashMap<String, Object>();481 controlHeaders.put("Operation", "sayHello");482 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")483 .copyHeaders(controlHeaders)484 .build();485 486 reset(messageReceiver);487 expect(messageReceiver.receive()).andReturn(controlMessage).once();488 replay(messageReceiver);489 490 receiveAction.execute(context);491 492 Assert.assertNotNull(context.getVariable("myOperation"));493 Assert.assertEquals(context.getVariable("myOperation"), "sayHello");494 495 verify(messageReceiver);496 }497 498 @Test499 @SuppressWarnings("unchecked")500 public void testReceiveMessageWithValidateMessageElementsFromMessageXPath() {501 ReceiveMessageAction receiveAction = new ReceiveMessageAction();502 receiveAction.setMessageReceiver(messageReceiver);503 receiveAction.setValidator(validator);504 validator.setFunctionRegistry(context.getFunctionRegistry());505 506 Map<String, String> messageElements = new HashMap<String, String>();507 messageElements.put("/TestRequest/Message", "Hello World!");508 receiveAction.setPathValidationExpressions(messageElements);509 510 Map<String, Object> controlHeaders = new HashMap<String, Object>();511 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")512 .copyHeaders(controlHeaders)513 .build();514 515 reset(messageReceiver);516 expect(messageReceiver.receive()).andReturn(controlMessage).once();517 replay(messageReceiver);518 519 receiveAction.execute(context);520 521 verify(messageReceiver);522 }523 524 @Test525 @SuppressWarnings("unchecked")526 public void testReceiveMessageWithValidateMessageElementsXPathDefaultNamespaceSupport() {527 ReceiveMessageAction receiveAction = new ReceiveMessageAction();528 receiveAction.setMessageReceiver(messageReceiver);529 receiveAction.setValidator(validator);530 receiveAction.setSchemaValidation(false);531 validator.setFunctionRegistry(context.getFunctionRegistry());532 533 Map<String, String> messageElements = new HashMap<String, String>();534 messageElements.put("/:TestRequest/:Message", "Hello World!");535 receiveAction.setPathValidationExpressions(messageElements);536 537 Map<String, Object> controlHeaders = new HashMap<String, Object>();538 Message controlMessage = MessageBuilder.withPayload("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +539 "<Message>Hello World!</Message></TestRequest>")540 .copyHeaders(controlHeaders)541 .build();542 543 reset(messageReceiver);544 expect(messageReceiver.receive()).andReturn(controlMessage).once();545 replay(messageReceiver);546 547 receiveAction.execute(context);548 549 verify(messageReceiver);550 }551 552 @Test553 @SuppressWarnings("unchecked")554 public void testReceiveMessageWithValidateMessageElementsXPathNamespaceSupport() {555 ReceiveMessageAction receiveAction = new ReceiveMessageAction();556 receiveAction.setMessageReceiver(messageReceiver);557 receiveAction.setValidator(validator);558 receiveAction.setSchemaValidation(false);559 validator.setFunctionRegistry(context.getFunctionRegistry());560 561 Map<String, String> messageElements = new HashMap<String, String>();562 messageElements.put("/ns0:TestRequest/ns0:Message", "Hello World!");563 receiveAction.setPathValidationExpressions(messageElements);564 565 Map<String, Object> controlHeaders = new HashMap<String, Object>();566 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +567 "<ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>")568 .copyHeaders(controlHeaders)569 .build();570 571 reset(messageReceiver);572 expect(messageReceiver.receive()).andReturn(controlMessage).once();573 replay(messageReceiver);574 575 receiveAction.execute(context);576 577 verify(messageReceiver);578 }579 580 @Test581 @SuppressWarnings("unchecked")582 public void testReceiveMessageWithValidateMessageElementsXPathNestedNamespaceSupport() {583 ReceiveMessageAction receiveAction = new ReceiveMessageAction();584 receiveAction.setMessageReceiver(messageReceiver);585 receiveAction.setValidator(validator);586 receiveAction.setSchemaValidation(false);587 validator.setFunctionRegistry(context.getFunctionRegistry());588 589 Map<String, String> messageElements = new HashMap<String, String>();590 messageElements.put("/ns0:TestRequest/ns1:Message", "Hello World!");591 receiveAction.setPathValidationExpressions(messageElements);592 593 Map<String, Object> controlHeaders = new HashMap<String, Object>();594 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +595 "<ns1:Message xmlns:ns1=\"http://citrusframework.org/unittest/message\">Hello World!</ns1:Message></ns0:TestRequest>")596 .copyHeaders(controlHeaders)597 .build();598 599 reset(messageReceiver);600 expect(messageReceiver.receive()).andReturn(controlMessage).once();601 replay(messageReceiver);602 603 receiveAction.execute(context);604 605 verify(messageReceiver);606 }607 608 @Test609 @SuppressWarnings("unchecked")610 public void testReceiveMessageWithValidateMessageElementsXPathNamespaceBindings() {611 ReceiveMessageAction receiveAction = new ReceiveMessageAction();612 receiveAction.setMessageReceiver(messageReceiver);613 receiveAction.setValidator(validator);614 receiveAction.setSchemaValidation(false);615 validator.setFunctionRegistry(context.getFunctionRegistry());616 617 Map<String, String> messageElements = new HashMap<String, String>();618 messageElements.put("/pfx:TestRequest/pfx:Message", "Hello World!");619 receiveAction.setPathValidationExpressions(messageElements);620 621 Map<String, String> namespaces = new HashMap<String, String>();622 namespaces.put("pfx", "http://citrusframework.org/unittest");623 receiveAction.setNamespaces(namespaces);624 625 Map<String, Object> controlHeaders = new HashMap<String, Object>();626 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +627 "<ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>")628 .copyHeaders(controlHeaders)629 .build();630 631 reset(messageReceiver);632 expect(messageReceiver.receive()).andReturn(controlMessage).once();633 replay(messageReceiver);634 635 receiveAction.execute(context);636 637 verify(messageReceiver);638 }639 640 @Test641 @SuppressWarnings("unchecked")642 public void testReceiveMessageWithExtractVariablesFromMessageXPath() {643 ReceiveMessageAction receiveAction = new ReceiveMessageAction();644 receiveAction.setMessageReceiver(messageReceiver);645 receiveAction.setValidator(validator);646 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");647 validator.setFunctionRegistry(context.getFunctionRegistry());648 649 Map<String, String> extractMessageElements = new HashMap<String, String>();650 extractMessageElements.put("/TestRequest/Message", "messageVar");651 receiveAction.setExtractMessageElements(extractMessageElements);652 653 Map<String, Object> controlHeaders = new HashMap<String, Object>();654 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")655 .copyHeaders(controlHeaders)656 .build();657 658 reset(messageReceiver);659 expect(messageReceiver.receive()).andReturn(controlMessage).once();660 replay(messageReceiver);661 662 receiveAction.execute(context);663 664 Assert.assertNotNull(context.getVariable("messageVar"));665 Assert.assertEquals(context.getVariable("messageVar"), "Hello World!");666 667 verify(messageReceiver);668 }669 670 @Test671 @SuppressWarnings("unchecked")672 public void testReceiveMessageWithExtractVariablesFromMessageXPathDefaultNamespaceSupport() {673 ReceiveMessageAction receiveAction = new ReceiveMessageAction();674 receiveAction.setMessageReceiver(messageReceiver);675 receiveAction.setValidator(validator);676 receiveAction.setSchemaValidation(false);677 receiveAction.setMessageData("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +678 "<Message>Hello World!</Message></TestRequest>");679 validator.setFunctionRegistry(context.getFunctionRegistry());680 681 Map<String, String> extractMessageElements = new HashMap<String, String>();682 extractMessageElements.put("/:TestRequest/:Message", "messageVar");683 receiveAction.setExtractMessageElements(extractMessageElements);684 685 Map<String, Object> controlHeaders = new HashMap<String, Object>();686 Message controlMessage = MessageBuilder.withPayload("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +687 "<Message>Hello World!</Message></TestRequest>")688 .copyHeaders(controlHeaders)689 .build();690 691 reset(messageReceiver);692 expect(messageReceiver.receive()).andReturn(controlMessage).once();693 replay(messageReceiver);694 695 receiveAction.execute(context);696 697 Assert.assertNotNull(context.getVariable("messageVar"));698 Assert.assertEquals(context.getVariable("messageVar"), "Hello World!");699 700 verify(messageReceiver);701 }702 703 @Test704 @SuppressWarnings("unchecked")705 public void testReceiveMessageWithExtractVariablesFromMessageXPathNamespaceSupport() {706 ReceiveMessageAction receiveAction = new ReceiveMessageAction();707 receiveAction.setMessageReceiver(messageReceiver);708 receiveAction.setValidator(validator);709 receiveAction.setSchemaValidation(false);710 receiveAction.setMessageData("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +711 "<Message>Hello World!</Message></TestRequest>");712 validator.setFunctionRegistry(context.getFunctionRegistry());713 714 Map<String, String> extractMessageElements = new HashMap<String, String>();715 extractMessageElements.put("/ns0:TestRequest/ns0:Message", "messageVar");716 receiveAction.setExtractMessageElements(extractMessageElements);717 718 Map<String, Object> controlHeaders = new HashMap<String, Object>();719 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +720 "<ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>")721 .copyHeaders(controlHeaders)722 .build();723 724 reset(messageReceiver);725 expect(messageReceiver.receive()).andReturn(controlMessage).once();726 replay(messageReceiver);727 728 receiveAction.execute(context);729 730 Assert.assertNotNull(context.getVariable("messageVar"));731 Assert.assertEquals(context.getVariable("messageVar"), "Hello World!");732 733 verify(messageReceiver);734 }735 736 @Test737 @SuppressWarnings("unchecked")738 public void testReceiveMessageWithExtractVariablesFromMessageXPathNestedNamespaceSupport() {739 ReceiveMessageAction receiveAction = new ReceiveMessageAction();740 receiveAction.setMessageReceiver(messageReceiver);741 receiveAction.setValidator(validator);742 receiveAction.setSchemaValidation(false);743 receiveAction.setMessageData("<TestRequest xmlns=\"http://citrusframework.org/unittest\" xmlns:ns1=\"http://citrusframework.org/unittest/message\">" +744 "<ns1:Message>Hello World!</ns1:Message></TestRequest>");745 validator.setFunctionRegistry(context.getFunctionRegistry());746 747 Map<String, String> extractMessageElements = new HashMap<String, String>();748 extractMessageElements.put("/ns0:TestRequest/ns1:Message", "messageVar");749 receiveAction.setExtractMessageElements(extractMessageElements);750 751 Map<String, Object> controlHeaders = new HashMap<String, Object>();752 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +753 "<ns1:Message xmlns:ns1=\"http://citrusframework.org/unittest/message\">Hello World!</ns1:Message></ns0:TestRequest>")754 .copyHeaders(controlHeaders)755 .build();756 757 reset(messageReceiver);758 expect(messageReceiver.receive()).andReturn(controlMessage).once();759 replay(messageReceiver);760 761 receiveAction.execute(context);762 763 Assert.assertNotNull(context.getVariable("messageVar"));764 Assert.assertEquals(context.getVariable("messageVar"), "Hello World!");765 766 verify(messageReceiver);767 }768 769 @Test770 @SuppressWarnings("unchecked")771 public void testReceiveMessageWithExtractVariablesFromMessageXPathNamespaceBindings() {772 ReceiveMessageAction receiveAction = new ReceiveMessageAction();773 receiveAction.setMessageReceiver(messageReceiver);774 receiveAction.setValidator(validator);775 receiveAction.setSchemaValidation(false);776 receiveAction.setMessageData("<TestRequest xmlns=\"http://citrusframework.org/unittest\">" +777 "<Message>Hello World!</Message></TestRequest>");778 validator.setFunctionRegistry(context.getFunctionRegistry());779 780 Map<String, String> extractMessageElements = new HashMap<String, String>();781 extractMessageElements.put("/pfx:TestRequest/pfx:Message", "messageVar");782 receiveAction.setExtractMessageElements(extractMessageElements);783 784 Map<String, String> namespaces = new HashMap<String, String>();785 namespaces.put("pfx", "http://citrusframework.org/unittest");786 receiveAction.setNamespaces(namespaces);787 788 Map<String, Object> controlHeaders = new HashMap<String, Object>();789 Message controlMessage = MessageBuilder.withPayload("<ns0:TestRequest xmlns:ns0=\"http://citrusframework.org/unittest\">" +790 "<ns0:Message>Hello World!</ns0:Message></ns0:TestRequest>")791 .copyHeaders(controlHeaders)792 .build();793 794 reset(messageReceiver);795 expect(messageReceiver.receive()).andReturn(controlMessage).once();796 replay(messageReceiver);797 798 receiveAction.execute(context);799 800 Assert.assertNotNull(context.getVariable("messageVar"));801 Assert.assertEquals(context.getVariable("messageVar"), "Hello World!");802 803 verify(messageReceiver);804 }805 806 @Test807 @SuppressWarnings("unchecked")808 public void testReceiveMessageWithTimeout() {809 ReceiveMessageAction receiveAction = new ReceiveMessageAction();810 receiveAction.setMessageReceiver(messageReceiver);811 receiveAction.setValidator(validator);812 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");813 814 receiveAction.setReceiveTimeout(5000L);815 816 Map<String, Object> headers = new HashMap<String, Object>();817 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")818 .copyHeaders(headers)819 .build();820 821 reset(messageReceiver);822 expect(messageReceiver.receive(5000L)).andReturn(controlMessage).once();823 replay(messageReceiver);824 825 receiveAction.execute(context);826 827 verify(messageReceiver);828 }829 830 @Test831 @SuppressWarnings("unchecked")832 public void testReceiveSelectedWithMessageSelectorString() {833 ReceiveMessageAction receiveAction = new ReceiveMessageAction();834 receiveAction.setMessageReceiver(messageReceiver);835 receiveAction.setValidator(validator);836 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");837 838 String messageSelectorString = "Operation = 'sayHello'";839 receiveAction.setMessageSelectorString(messageSelectorString);840 841 Map<String, Object> headers = new HashMap<String, Object>();842 headers.put("Operation", "sayHello");843 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")844 .copyHeaders(headers)845 .build();846 847 reset(messageReceiver);848 expect(messageReceiver.receiveSelected(messageSelectorString)).andReturn(controlMessage).once();849 replay(messageReceiver);850 851 receiveAction.execute(context);852 853 verify(messageReceiver);854 }855 856 @Test857 @SuppressWarnings("unchecked")858 public void testReceiveSelectedWithMessageSelectorStringAndTimeout() {859 ReceiveMessageAction receiveAction = new ReceiveMessageAction();860 receiveAction.setMessageReceiver(messageReceiver);861 receiveAction.setValidator(validator);862 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");863 864 receiveAction.setReceiveTimeout(5000L);865 866 String messageSelectorString = "Operation = 'sayHello'";867 receiveAction.setMessageSelectorString(messageSelectorString);868 869 Map<String, Object> headers = new HashMap<String, Object>();870 headers.put("Operation", "sayHello");871 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")872 .copyHeaders(headers)873 .build();874 875 reset(messageReceiver);876 expect(messageReceiver.receiveSelected(messageSelectorString, 5000L)).andReturn(controlMessage).once();877 replay(messageReceiver);878 879 receiveAction.execute(context);880 881 verify(messageReceiver);882 }883 884 @Test885 @SuppressWarnings("unchecked")886 public void testReceiveSelectedWithMessageSelectorMap() {887 ReceiveMessageAction receiveAction = new ReceiveMessageAction();888 receiveAction.setMessageReceiver(messageReceiver);889 receiveAction.setValidator(validator);890 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");891 892 Map<String, String> messageSelector = new HashMap<String, String>();893 messageSelector.put("Operation", "sayHello");894 receiveAction.setMessageSelector(messageSelector);895 896 Map<String, Object> headers = new HashMap<String, Object>();897 headers.put("Operation", "sayHello");898 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")899 .copyHeaders(headers)900 .build();901 902 reset(messageReceiver);903 expect(messageReceiver.receiveSelected("Operation = 'sayHello'")).andReturn(controlMessage).once();904 replay(messageReceiver);905 906 receiveAction.execute(context);907 908 verify(messageReceiver);909 }910 911 @Test912 @SuppressWarnings("unchecked")913 public void testReceiveSelectedWithMessageSelectorMapAndTimeout() {914 ReceiveMessageAction receiveAction = new ReceiveMessageAction();915 receiveAction.setMessageReceiver(messageReceiver);916 receiveAction.setValidator(validator);917 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");918 919 receiveAction.setReceiveTimeout(5000L);920 921 Map<String, String> messageSelector = new HashMap<String, String>();922 messageSelector.put("Operation", "sayHello");923 receiveAction.setMessageSelector(messageSelector);924 925 Map<String, Object> headers = new HashMap<String, Object>();926 headers.put("Operation", "sayHello");927 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")928 .copyHeaders(headers)929 .build();930 931 reset(messageReceiver);932 expect(messageReceiver.receiveSelected("Operation = 'sayHello'", 5000L)).andReturn(controlMessage).once();933 replay(messageReceiver);934 935 receiveAction.execute(context);936 937 verify(messageReceiver);938 }939 940 @Test941 public void testMessageTimeout() {942 ReceiveMessageAction receiveAction = new ReceiveMessageAction();943 receiveAction.setMessageReceiver(messageReceiver);944 945 receiveAction.setValidator(validator);946 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");947 948 reset(messageReceiver);949 expect(messageReceiver.receive()).andReturn(null).once();950 replay(messageReceiver);951 952 try {953 receiveAction.execute(context);954 } catch(CitrusRuntimeException e) {955 Assert.assertEquals(e.getMessage(), "Received message is null!");956 verify(messageReceiver);957 return;958 }959 960 Assert.fail("Missing " + CitrusRuntimeException.class + " for receiving no message");961 }962 963 @Test964 @SuppressWarnings("unchecked")965 public void testReceiveEmptyMessagePayloadAsExpected() {966 ReceiveMessageAction receiveAction = new ReceiveMessageAction();967 receiveAction.setMessageReceiver(messageReceiver);968 receiveAction.setValidator(validator);969 receiveAction.setMessageData("");970 971 Map<String, Object> headers = new HashMap<String, Object>();972 Message controlMessage = MessageBuilder.withPayload("")973 .copyHeaders(headers)974 .build();975 976 reset(messageReceiver);977 expect(messageReceiver.receive()).andReturn(controlMessage).once();978 replay(messageReceiver);979 980 receiveAction.execute(context);981 982 verify(messageReceiver);983 }984 985 @Test986 @SuppressWarnings("unchecked")987 public void testReceiveEmptyMessagePayloadUnexpected() {988 ReceiveMessageAction receiveAction = new ReceiveMessageAction();989 receiveAction.setMessageReceiver(messageReceiver);990 receiveAction.setValidator(validator);991 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");992 993 Map<String, Object> headers = new HashMap<String, Object>();994 Message controlMessage = MessageBuilder.withPayload("")995 .copyHeaders(headers)996 .build();997 998 reset(messageReceiver);999 expect(messageReceiver.receive()).andReturn(controlMessage).once();1000 replay(messageReceiver);1001 1002 try {1003 receiveAction.execute(context);1004 } catch(CitrusRuntimeException e) {1005 Assert.assertEquals(e.getMessage(), "Validation error: Received message body is empty");1006 verify(messageReceiver);1007 return;1008 }1009 1010 Assert.fail("Missing " + CitrusRuntimeException.class + " for receiving unexpected empty message payload");1011 }1012 1013 @Test1014 @SuppressWarnings("unchecked")1015 public void testReceiveMessageWithValidationScript() {1016 ReceiveMessageAction receiveAction = new ReceiveMessageAction();1017 receiveAction.setMessageReceiver(messageReceiver);1018 receiveAction.setValidator(validator);1019 receiveAction.setValidationScript("assert root.Message.name() == 'Message'\n" + "assert root.Message.text() == 'Hello World!'");1020 1021 Map<String, Object> headers = new HashMap<String, Object>();1022 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")1023 .copyHeaders(headers)1024 .build();1025 1026 reset(messageReceiver);1027 expect(messageReceiver.receive()).andReturn(controlMessage).once();1028 replay(messageReceiver);1029 1030 receiveAction.execute(context);1031 1032 verify(messageReceiver);1033 }1034 1035 @Test1036 @SuppressWarnings("unchecked")1037 public void testReceiveMessageWithValidationScriptResource() {1038 ReceiveMessageAction receiveAction = new ReceiveMessageAction();1039 receiveAction.setMessageReceiver(messageReceiver);1040 receiveAction.setValidator(validator);1041 receiveAction.setValidationScriptResource(new ClassPathResource("test-validation-script.groovy", ReceiveMessageActionTest.class));1042 1043 Map<String, Object> headers = new HashMap<String, Object>();1044 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")1045 .copyHeaders(headers)1046 .build();1047 1048 reset(messageReceiver);1049 expect(messageReceiver.receive()).andReturn(controlMessage).once();1050 replay(messageReceiver);1051 1052 receiveAction.execute(context);1053 1054 verify(messageReceiver);1055 }1056 1057 @Test1058 @SuppressWarnings("unchecked")1059 public void testInjectedMessageValidators() {1060 ReceiveMessageAction receiveAction = new ReceiveMessageAction();1061 receiveAction.setMessageReceiver(messageReceiver);1062 1063 receiveAction.setMessageData("<TestRequest><Message>Hello World!</Message></TestRequest>");1064 1065 Map<String, Object> headers = new HashMap<String, Object>();1066 Message controlMessage = MessageBuilder.withPayload("<TestRequest><Message>Hello World!</Message></TestRequest>")1067 .copyHeaders(headers)1068 .build();1069 1070 reset(messageReceiver);1071 expect(messageReceiver.receive()).andReturn(controlMessage).times(2);1072 replay(messageReceiver);1073 1074 receiveAction.execute(context);...
Source:ReceiveMessageActionConverter.java
...14 * limitations under the License.15 */16package com.consol.citrus.admin.converter.action;17import com.consol.citrus.Citrus;18import com.consol.citrus.actions.ReceiveMessageAction;19import com.consol.citrus.admin.model.Property;20import com.consol.citrus.admin.model.TestActionModel;21import com.consol.citrus.config.xml.PayloadElementParser;22import com.consol.citrus.message.MessageType;23import com.consol.citrus.model.testcase.core.*;24import com.consol.citrus.util.TypeConversionUtils;25import com.consol.citrus.validation.builder.*;26import org.springframework.stereotype.Component;27import org.springframework.util.StringUtils;28import java.util.Map;29import java.util.Optional;30import java.util.stream.Collectors;31import java.util.stream.Stream;32/**33 * @author Christoph Deppisch34 */35@Component36public class ReceiveMessageActionConverter extends AbstractTestActionConverter<ReceiveModel, ReceiveMessageAction> {37 /**38 * Default constructor using action type reference.39 */40 public ReceiveMessageActionConverter() {41 super("receive");42 }43 @Override44 public TestActionModel convert(ReceiveModel model) {45 TestActionModel action = super.convert(model);46 if (model.getMessage() != null) {47 action.add(new Property<>("message.name", "message.name", "MessageName", model.getMessage().getName(), false));48 action.add(new Property<>("message.type", "message.type", "MessageType", Optional.ofNullable(model.getMessage().getType()).orElse(Citrus.DEFAULT_MESSAGE_TYPE).toLowerCase(), true)49 .options(Stream.of(MessageType.values()).map(MessageType::name).map(String::toLowerCase).collect(Collectors.toList())));50 } else {51 action.add(new Property<>("message.name", "message.name", "MessageName", null, false));52 action.add(new Property<>("message.type", "message.type", "MessageType", Citrus.DEFAULT_MESSAGE_TYPE.toLowerCase(), true)53 .options(Stream.of(MessageType.values()).map(MessageType::name).map(String::toLowerCase).collect(Collectors.toList())));54 }55 return action;56 }57 @Override58 protected Map<String, String> getDisplayNameMappings() {59 Map<String, String> mappings = super.getDisplayNameMappings();60 mappings.put("header", "Headers");61 return mappings;62 }63 @Override64 protected <V> V resolvePropertyExpression(V value) {65 if (value instanceof ReceiveModel.Message) {66 ReceiveModel.Message message = (ReceiveModel.Message) value;67 if (StringUtils.hasText(message.getData())) {68 return (V) message.getData().trim();69 }70 if (message.getPayload()!= null) {71 return (V) PayloadElementParser.parseMessagePayload(message.getPayload().getAnies().get(0));72 }73 if (message.getResource() != null &&74 StringUtils.hasText(message.getResource().getFile())) {75 return (V) message.getResource().getFile();76 }77 if (message.getBuilder() != null) {78 return (V) message.getBuilder().getValue().trim();79 }80 return (V) "";81 }82 if (value instanceof ReceiveModel.Header) {83 return (V) ((ReceiveModel.Header) value).getElements().stream().map(header -> header.getName() + "=" + header.getValue()).collect(Collectors.joining(","));84 }85 if (value instanceof ReceiveModel.Selector) {86 ReceiveModel.Selector selector = (ReceiveModel.Selector) value;87 if (StringUtils.hasText(selector.getSelectorValue())) {88 return (V) selector.getSelectorValue().trim();89 } else {90 return (V) selector.getElements().stream().map(header -> header.getName() + "=" + header.getValue()).collect(Collectors.joining(","));91 }92 }93 return super.resolvePropertyExpression(value);94 }95 @Override96 public ReceiveModel convertModel(ReceiveMessageAction model) {97 ReceiveModel action = new ObjectFactory().createReceiveModel();98 if (model.getActor() != null) {99 action.setActor(model.getActor().getName());100 } else if (model.getEndpoint() != null && model.getEndpoint().getActor() != null) {101 action.setActor(model.getEndpoint().getActor().getName());102 }103 action.setDescription(model.getDescription());104 action.setEndpoint(model.getEndpoint() != null ? model.getEndpoint().getName() : model.getEndpointUri());105 ReceiveModel.Message message = new ReceiveModel.Message();106 if (model.getMessageBuilder() instanceof PayloadTemplateMessageBuilder) {107 PayloadTemplateMessageBuilder messageBuilder = (PayloadTemplateMessageBuilder) model.getMessageBuilder();108 message.setName(messageBuilder.getMessageName());109 message.setData(messageBuilder.getPayloadData());110 if (StringUtils.hasText(messageBuilder.getPayloadResourcePath())) {111 ReceiveModel.Message.Resource messageResource = new ReceiveModel.Message.Resource();112 messageResource.setFile(messageBuilder.getPayloadResourcePath());113 messageResource.setCharset(messageBuilder.getPayloadResourceCharset());114 message.setResource(messageResource);115 }116 }117 if (model.getMessageBuilder() instanceof StaticMessageContentBuilder) {118 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) model.getMessageBuilder();119 message.setName(messageBuilder.getMessageName());120 message.setData(messageBuilder.getMessage().getPayload(String.class));121 }122 if (model.getMessageBuilder() instanceof AbstractMessageContentBuilder) {123 ReceiveModel.Header header = new ReceiveModel.Header();124 ((AbstractMessageContentBuilder) model.getMessageBuilder()).getMessageHeaders().forEach((key, value) -> {125 ReceiveModel.Header.Element headerElement = new ReceiveModel.Header.Element();126 headerElement.setName(key);127 headerElement.setValue(TypeConversionUtils.convertIfNecessary(value, String.class));128 header.getElements().add(headerElement);129 });130 header.getDatas().addAll(((AbstractMessageContentBuilder) model.getMessageBuilder()).getHeaderData());131 (((AbstractMessageContentBuilder) model.getMessageBuilder()).getHeaderResources()).forEach(resource -> {132 ReceiveModel.Header.Resource headerResource = new ReceiveModel.Header.Resource();133 headerResource.setFile(resource);134 header.getResources().add(headerResource);135 });136 action.setHeader(header);137 }138 action.setMessage(message);139 return action;140 }141 @Override142 public Class<ReceiveModel> getSourceModelClass() {143 return ReceiveModel.class;144 }145 @Override146 public Class<ReceiveMessageAction> getActionModelClass() {147 return ReceiveMessageAction.class;148 }149}...
Source:ReceiveResponseActionConverter.java
...14 * limitations under the License.15 */16package com.consol.citrus.admin.converter.action.http;17import com.consol.citrus.Citrus;18import com.consol.citrus.actions.ReceiveMessageAction;19import com.consol.citrus.admin.converter.action.AbstractTestActionConverter;20import com.consol.citrus.admin.model.Property;21import com.consol.citrus.admin.model.TestActionModel;22import com.consol.citrus.config.xml.PayloadElementParser;23import com.consol.citrus.message.MessageType;24import com.consol.citrus.model.testcase.http.*;25import org.springframework.http.HttpStatus;26import org.springframework.stereotype.Component;27import org.springframework.util.StringUtils;28import java.util.Map;29import java.util.Optional;30import java.util.stream.Collectors;31import java.util.stream.Stream;32/**33 * @author Christoph Deppisch34 */35@Component36public class ReceiveResponseActionConverter extends AbstractTestActionConverter<ReceiveResponseModel, ReceiveMessageAction> {37 /**38 * Default constructor using action type reference.39 */40 public ReceiveResponseActionConverter() {41 super("http-client:receive");42 }43 @Override44 public TestActionModel convert(ReceiveResponseModel model) {45 TestActionModel action = super.convert(model);46 ResponseHeadersType headers = model.getHeaders();47 if (headers != null) {48 action.add(new Property<>("status", "status", "Status", model.getHeaders().getStatus(), true)49 .options(Stream.of(HttpStatus.values()).map(HttpStatus::toString).collect(Collectors.toList())));50 action.add(new Property<>("reason", "reason", "Reason", model.getHeaders().getReasonPhrase(), false)51 .options(Stream.of(HttpStatus.values()).map(HttpStatus::getReasonPhrase).collect(Collectors.toList())));52 action.add(new Property<>("version", "version", "Version", Optional.ofNullable(model.getHeaders().getVersion()).orElse("HTTP/1.1"), false));53 }54 if (model.getBody() != null) {55 action.add(new Property<>("message.name", "message.name", "MessageName", model.getBody().getName(), false));56 action.add(new Property<>("message.type", "message.type", "MessageType", Optional.ofNullable(model.getBody().getType()).orElse(Citrus.DEFAULT_MESSAGE_TYPE).toLowerCase(), true)57 .options(Stream.of(MessageType.values()).map(MessageType::name).map(String::toLowerCase).collect(Collectors.toList())));58 } else {59 action.add(new Property<>("message.name", "message.name", "MessageName", null, false));60 action.add(new Property<>("message.type", "message.type", "MessageType", Citrus.DEFAULT_MESSAGE_TYPE.toLowerCase(), true)61 .options(Stream.of(MessageType.values()).map(MessageType::name).map(String::toLowerCase).collect(Collectors.toList())));62 }63 return action;64 }65 @Override66 protected Map<String, String> getFieldNameMappings() {67 Map<String, String> mappings = super.getFieldNameMappings();68 mappings.put("client", "endpoint");69 mappings.put("uri", "endpointUri");70 return mappings;71 }72 @Override73 protected <V> V resolvePropertyExpression(V value) {74 if (value instanceof ReceiveResponseModel.Body) {75 ReceiveResponseModel.Body body = (ReceiveResponseModel.Body) value;76 if (body != null) {77 if (StringUtils.hasText(body.getData())) {78 return (V) body.getData().trim();79 } else if (body.getPayload() != null) {80 return (V) PayloadElementParser.parseMessagePayload(body.getPayload().getAnies().get(0));81 } else if (body.getResource() != null &&82 StringUtils.hasText(body.getResource().getFile())) {83 return (V) body.getResource().getFile();84 } else {85 return null;86 }87 }88 }89 if (value instanceof ResponseHeadersType) {90 return (V) ((ResponseHeadersType) value).getHeaders().stream().map(header -> header.getName() + "=" + header.getValue()).collect(Collectors.joining(","));91 }92 return super.resolvePropertyExpression(value);93 }94 @Override95 public ReceiveResponseModel convertModel(ReceiveMessageAction model) {96 ReceiveResponseModel action = new ObjectFactory().createReceiveResponseModel();97 if (model.getActor() != null) {98 action.setActor(model.getActor().getName());99 } else if (model.getEndpoint() != null && model.getEndpoint().getActor() != null) {100 action.setActor(model.getEndpoint().getActor().getName());101 }102 action.setClient(model.getEndpoint() != null ? model.getEndpoint().getName() : model.getEndpointUri());103 ClientRequestType request = new ClientRequestType();104 request.setDescription(model.getDescription());105 return action;106 }107 @Override108 public Class<ReceiveResponseModel> getSourceModelClass() {109 return ReceiveResponseModel.class;110 }111 @Override112 public Class<ReceiveMessageAction> getActionModelClass() {113 return ReceiveMessageAction.class;114 }115}...
ReceiveMessageAction
Using AI Code Generation
1import com.consol.citrus.actions.ReceiveMessageAction;2import com.consol.citrus.dsl.builder.ReceiveMessageBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;5import com.consol.citrus.message.MessageType;6import org.springframework.http.HttpStatus;7import org.testng.annotations.Test;8public class ReceiveMessageActionTest extends TestNGCitrusTestDesigner{9public void ReceiveMessageActionTest(){10TestRunner runner = this.createTestRunner();11ReceiveMessageAction receiveMessageAction = new ReceiveMessageAction();12receiveMessageAction.execute(runner);13}14}
ReceiveMessageAction
Using AI Code Generation
1import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;2import com.consol.citrus.message.MessageType;3import org.testng.annotations.Test;4public class 4 extends TestNGCitrusTestDesigner {5public void 4() {6variable("var1", "value1");7variable("var2", "value2");8variable("var3", "value3");9variable("var4", "value4");10variable("var5", "value5");11variable("var6", "value6");12variable("var7", "value7");13variable("var8", "value8");14variable("var9", "value9");15variable("var10", "value10");16variable("var11", "value11");17variable("var12", "value12");18variable("var13", "value13");19variable("var14", "value14");20variable("var15", "value15");21variable("var16", "value16");22variable("var17", "value17");23variable("var18", "value18");24variable("var19", "value19");25variable("var20", "value20");26variable("var21", "value21");27variable("var22", "value22");28variable("var23", "value23");29variable("var24", "value24");30variable("var25", "value25");31variable("var26", "value26");32variable("var27", "value27");33variable("var28", "value28");34variable("var29", "value29");35variable("var30", "value30");36variable("var31", "value31");37variable("var32", "value32");38variable("var33", "value33");39variable("var34", "value34");40variable("var35", "value35");41variable("var36", "value36");42variable("var37", "value37");43variable("var38", "value38");44variable("var39", "value39");45variable("var40", "value40");46variable("var41", "value41");47variable("var42", "value42");48variable("var43", "value43");49variable("var44", "value44");50variable("var45", "value45");51variable("var46", "value46");52variable("var47", "value47");53variable("var48", "value48");54variable("var49", "value49");55variable("var50
ReceiveMessageAction
Using AI Code Generation
1import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;2import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.runner.TestRunnerSupport;5import com.consol.citrus.exceptions.CitrusRuntimeException;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.validation.xml.XmlMessageValidationContext;8public class ReceiveMessageActionBuilderTest {9public static void main(String[] args) {10TestRunner runner = new TestRunnerSupport();11ReceiveMessageActionBuilder receiveBuilder = runner.receive();12receiveBuilder.endpoint("myEndpoint");13receiveBuilder.message("<TestRequest><Message>Hello World!</Message></TestRequest>");14receiveBuilder.validationContext(new XmlMessageValidationContext());15receiveBuilder.validationContextPath("xsd:mySchema.xsd");16receiveBuilder.messageType(MessageType.XML);17receiveBuilder.timeout(5000L);18receiveBuilder.selector("operation = 'foo'");19receiveBuilder.selector("operation = 'foo' AND bar = 'baz'");20receiveBuilder.selector("operation = 'foo' OR bar = 'baz'");21receiveBuilder.selector("operation = 'foo' AND (bar = 'baz' OR bar = 'qux')");22receiveBuilder.selector("operation = 'foo' AND (bar = 'baz' OR bar = 'qux') AND (foo = 'bar' OR foo = 'baz')");23ReceiveTimeoutBuilder timeoutBuilder = receiveBuilder.timeout(5000L);24timeoutBuilder.selector("operation = 'foo'");25timeoutBuilder.selector("operation = 'foo' AND bar = 'baz'");26timeoutBuilder.selector("operation = 'foo' OR bar = 'baz'");27timeoutBuilder.selector("operation = 'foo' AND (bar = 'baz' OR bar = 'qux')");28timeoutBuilder.selector("operation = 'foo' AND (bar = 'baz' OR bar = 'qux') AND (foo = 'bar' OR foo = 'baz')");29receiveBuilder.build();30}31}32import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;33import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder;34import com.consol.citrus.dsl.runner.TestRunner;35import com.consol.citrus.dsl.runner.TestRunnerSupport;36import com.consol
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.actions;2import java.util.HashMap;3import java.util.Map;4import org.testng.annotations.Test;5import com.consol.citrus.annotations.CitrusTest;6import com.consol.citrus.testng.CitrusParameters;7import com.consol.citrus.testng.TestNGCitrusSupport;8import com.consol.citrus.ws.actions.ReceiveMessageAction;9import com.consol.citrus.ws.message.SoapMessage;10public class ReceiveMessageActionTest extends TestNGCitrusSupport {11 @CitrusParameters({"name"})12 public void receiveMessageActionTest() {13 ReceiveMessageAction.Builder receiveMessageActionBuilder1 = new ReceiveMessageAction.Builder();14 receiveMessageActionBuilder1.endpoint("myEndpoint");15 receiveMessageActionBuilder1.message(new SoapMessage());16 receiveMessageActionBuilder1.messageType("SOAP");17 receiveMessageActionBuilder1.timeout(5000L);18 receiveMessageActionBuilder1.validationCallback(new SoapMessageValidationCallback());19 receiveMessageActionBuilder1.validationContext(new SoapValidationContext());20 receiveMessageActionBuilder1.validationMatcher(new SoapMessageValidationMatcher());21 receiveMessageActionBuilder1.validationScript(new SoapMessageValidationScript());22 receiveMessageActionBuilder1.validationScriptEngine("Groovy");23 receiveMessageActionBuilder1.validationScriptResourcePath("classpath:com/consol/citrus/ws/validation/script.groovy");24 receiveMessageActionBuilder1.validationScriptVariables(new HashMap<String, Object>());25 receiveMessageActionBuilder1.validationScriptVariable("foo", "bar");26 receiveMessageActionBuilder1.validationScriptVariable("foo", "bar", "com.consol.citrus");27 receiveMessageActionBuilder1.validationScriptVariable("foo", "bar", "com.consol.citrus", "groovy");28 receiveMessageActionBuilder1.validationScriptVariables(new HashMap<String, Object>());29 receiveMessageActionBuilder1.validationScriptVariables(new HashMap<String, Object>(), "com.consol.citrus");30 receiveMessageActionBuilder1.validationScriptVariables(new HashMap<String, Object>(), "com.consol.citrus", "groovy");31 receiveMessageActionBuilder1.validationScriptVariables("foo=bar");32 receiveMessageActionBuilder1.validationScriptVariables("foo=bar", "com.consol.citrus");33 receiveMessageActionBuilder1.validationScriptVariables("foo=bar", "com.consol.citrus", "
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.dsl.testng;2import com.consol.citrus.actions.ReceiveMessageAction;3import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;4import com.consol.citrus.dsl.builder.SendMessageActionBuilder;5import com.consol.citrus.dsl.runner.TestRunner;6import com.consol.citrus.testng.AbstractTestNGCitrusTest;7import org.springframework.http.HttpStatus;8import org.springframework.http.MediaType;9import org.testng.annotations.Test;10public class ReceiveMessageActionTest extends AbstractTestNGCitrusTest {11 public void receiveMessageAction() {12 run(new SendMessageActionBuilder()13 .endpoint("httpServerRequestEndpoint")14 .message("Hello World!")15 .contentType(MediaType.TEXT_PLAIN_VALUE)16 );17 run(new ReceiveMessageActionBuilder()18 .endpoint("httpServerResponseEndpoint")19 .messageType(ReceiveMessageAction.MessageType.PLAINTEXT)20 .message("Hello World!")21 .status(HttpStatus.OK)22 .contentType(MediaType.TEXT_PLAIN_VALUE)23 );24 }25}26package com.consol.citrus.dsl.testng;27import com.consol.citrus.actions.ReceiveMessageAction;28import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;29import com.consol.citrus.dsl.builder.SendMessageActionBuilder;30import com.consol.citrus.dsl.runner.TestRunner;31import com.consol.citrus.testng.AbstractTestNGCitrusTest;32import org.springframework.http.HttpStatus;33import org.springframework.http.MediaType;34import org.testng.annotations.Test;35public class ReceiveMessageActionTest extends AbstractTestNGCitrusTest {36 public void receiveMessageAction() {37 run(new SendMessageActionBuilder()38 .endpoint("httpServerRequestEndpoint")39 .message("Hello World!")40 .contentType(MediaType.TEXT_PLAIN_VALUE)41 );42 run(new ReceiveMessageActionBuilder()43 .endpoint("httpServerResponseEndpoint")44 .messageType(ReceiveMessageAction.MessageType.PLAINTEXT)45 .message("Hello World!")46 .status(HttpStatus.OK)47 .contentType(MediaType.TEXT_PLAIN_VALUE)48 );49 }50}
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.actions;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class ReceiveMessageAction extends TestNGCitrusTestDesigner {5public void receiveMessageAction() {6receive("helloWorldClient")7.payload("Hello Citrus!");8}9}10package com.consol.citrus.actions;11import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;12import org.testng.annotations.Test;13public class ReceiveMessageAction extends TestNGCitrusTestDesigner {14public void receiveMessageAction() {15receive("helloWorldClient")16.payload("Hello Citrus!")17.validationCallback((message, context) -> {18assertTrue(message.getPayload(String.class).contains("Hello Citrus!"));19});20}21}22package com.consol.citrus.actions;23import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;24import org.testng.annotations.Test;25public class ReceiveMessageAction extends TestNGCitrusTestDesigner {26public void receiveMessageAction() {27receive("helloWorldClient")28.payload("Hello Citrus!")29.validationScript(new ClassPathResource("myValidationScript.js"));30}31}32package com.consol.citrus.actions;33import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;34import org.testng.annotations.Test;35public class ReceiveMessageAction extends TestNGCitrusTestDesigner {36public void receiveMessageAction() {37receive("helloWorldClient")38.payload("Hello Citrus!")39.validationScript(new ClassPathResource("myValidationScript.js"))40.timeout(10000L);41}42}43package com.consol.citrus.actions;44import com.consol.citrus
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.dsl.design;2import com.consol.citrus.*;3import com.consol.citrus.dsl.builder.ReceiveMessageBuilder;4import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder;5import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilderImpl;6import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilderSupport;7import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilderSupportImpl;8import com.consol.citrus.endpoint.Endpoint;9import com.consol.citrus.message.MessageType;10import com.consol.citrus.message.builder.ObjectMappingPayloadBuilder;11import com.consol.citrus.message.builder.PayloadTemplateMessageBuilder;12import com.consol.citrus.message.builder.StaticMessageContentBuilder;13import com.consol.citrus.validation.builder.*;14import com.consol.citrus.validation.json.JsonTextMessageBuilder;15import com.consol.citrus.validation.json.JsonValidationContext;16import com.consol.citrus.validation.script.GroovyScriptMessageBuilder;17import com.consol.citrus.validation.script.GroovyScriptValidationContext;18import com.consol.citrus.validation.script.ScriptValidationContext;19import com.consol.citrus.validation.xml.DomXmlMessageBuilder;20import com.consol.citrus.validation.xml.XpathMessageBuilder;21import com.consol.citrus.validation.xml.XpathPayloadVariableExtractor;22import com.consol.citrus.validation.xml.XmlMessageValidationContext;23import com.consol.citrus.validation.xml.XmlValidationContext;24import com.consol.citrus.variable.MessageHeaderVariableExtractor;25import com.consol.citrus.variable.MessagePayloadVariableExtractor;26import com.consol.citrus.variable.MessageVariableExtractor;27import com.consol.citrus.variable.dictionary.DataDictionary;28import org.springframework.beans.factory.annotation.Autowired;29import org.springframework.core.io.Resource;30import org.springframework.util.StringUtils;31import org.w3c.dom.Document;32import org.xml.sax.InputSource;33import javax.xml.transform.Source;34import javax.xml.transform.stream.StreamSource;35import javax.xml.validation.Schema;36import java.util.*;37import java.util.function.Consumer;38import static com.consol.citrus.dsl.support.BuilderSupport.*;39import static com.consol.citrus.validation.script.ScriptValidationContext.Builder.*;40import static com.consol.citrus.validation.xml.XmlValidationContext.Builder.*;41import static com.consol.citrus.validation.json.JsonValidationContext.Builder.*;42import static com.consol.citrus.validation.script.ScriptValidationContext.Builder.*;43import static com.consol.cit
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.design.TestDesigner;3import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;4import com.consol.citrus.dsl.design.TestDesignerBeforeTestSupport;5import com.consol.citrus.dsl.design.TestDesignerAfterTestSupport;6import com.consol.citrus.dsl.design.TestDesignerAfterSuiteSupport;7import com.consol.citrus.dsl.design.TestDesignerSequenceBeforeSuiteSupport;8import com.consol.citrus.dsl.design.TestDesignerSequenceBeforeTestSupport;9import com.consol.citrus.dsl.design.TestDesignerSequenceAfterTestSupport;10import com.consol.citrus.dsl.design.TestDesignerSequenceAfterSuiteSupport;11import com.consol.citrus.dsl.design.TestDesignerParallelBeforeSuiteSupport;12import com.consol.citrus.dsl.design.TestDesignerParallelBeforeTestSupport;13import com.consol.citrus.dsl.design.TestDesignerParallelAfterTestSupport;14import com.consol.citrus.dsl.design.TestDesignerParallelAfterSuiteSupport;15import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;16import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder;17import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutBuilderSupport;18import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutConditionBuilderSupport;19import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutMessageBuilderSupport;20import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutMessageSelectorBuilderSupport;21import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationCallbackBuilderSupport;22import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport;23import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport;24import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport.ReceiveTimeoutValidationScriptBuilderDataSupport;25import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport.ReceiveTimeoutValidationScriptBuilderDataSupport.ReceiveTimeoutValidationScriptBuilderValidationSupport;26import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport.ReceiveTimeoutValidationScriptBuilderDataSupport.ReceiveTimeoutValidationScriptBuilderValidationSupport.ReceiveTimeoutValidationScriptBuilderValidationContextSupport;27import com.consol
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;4import com.consol.citrus.message.MessageType;5import org.junit.Test;6public class ReceiveMessageActionTest extends JUnit4CitrusTestDesigner {7 public void receiveMessageAction() {8 variable("message", "Hello Citrus!");9 variable("messageType", "TEXT");10 receive("myQueue")11 .messageType(MessageType.valueOf(variable("messageType")))12 .message(variable("message"));13 }14}15package com.consol.citrus.samples;16import com.consol.citrus.annotations.CitrusTest;17import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;18import com.consol.citrus.message.MessageType;19import org.junit.Test;20public class ReceiveMessageActionTest extends JUnit4CitrusTestDesigner {21 public void receiveMessageAction() {22 variable("message", "Hello Citrus!");23 variable("messageType", "TEXT");24 receive("myQueue")25 .messageType(MessageType.valueOf(variable("messageType")))26 .message(variable("message"));27 }28}29package com.consol.citrus.samples;30import com.consol.citrus.annotations.CitrusTest;31import com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner;32import com.consol.citrus.message.MessageType;33import org.junit.Test;34public class ReceiveMessageActionTest extends JUnit4CitrusTestDesigner {35 public void receiveMessageAction() {36 variable("message", "Hello Citrus!");37 variable("messageType", "TEXT");38 receive("myQueue")39 .messageType(MessageType.valueOf(variable("messageType")))40 .message(variable("message"));41 }42}
ReceiveMessageAction
Using AI Code Generation
1public class 4 extends TestNGCitrusTestDesigner {2 private JmsEndpoint jmsEndpoint;3 private JmsEndpoint jmsEndpoint2;4 private JmsEndpoint jmsEndpoint3;5 private JmsEndpoint jmsEndpoint4;6 private JmsEndpoint jmsEndpoint5;7 private JmsEndpoint jmsEndpoint6;8 private JmsEndpoint jmsEndpoint7;9 private JmsEndpoint jmsEndpoint8;10 private JmsEndpoint jmsEndpoint9;11 private JmsEndpoint jmsEndpoint10;12 private JmsEndpoint jmsEndpoint11;13 private JmsEndpoint jmsEndpoint12;14 private JmsEndpoint jmsEndpoint13;15 private JmsEndpoint jmsEndpoint14;16 private JmsEndpoint jmsEndpoint15;17 private JmsEndpoint jmsEndpoint16;18 private JmsEndpoint jmsEndpoint17;19 private JmsEndpoint jmsEndpoint18;20 private JmsEndpoint jmsEndpoint19;21 private JmsEndpoint jmsEndpoint20;22 private JmsEndpoint jmsEndpoint21;23 private JmsEndpoint jmsEndpoint22;24 private JmsEndpoint jmsEndpoint23;25 private JmsEndpoint jmsEndpoint24;26 private JmsEndpoint jmsEndpoint25;27 private JmsEndpoint jmsEndpoint26;28 private JmsEndpoint jmsEndpoint27;29 private JmsEndpoint jmsEndpoint28;30 private JmsEndpoint jmsEndpoint29;31 private JmsEndpoint jmsEndpoint30;32 private JmsEndpoint jmsEndpoint31;33 private JmsEndpoint jmsEndpoint32;34 private JmsEndpoint jmsEndpoint33;35 private JmsEndpoint jmsEndpoint34;36import com.consol.citrus.validation.script.ScriptValidationContext;37import com.consol.citrus.validation.xml.DomXmlMessageBuilder;38import com.consol.citrus.validation.xml.XpathMessageBuilder;39import com.consol.citrus.validation.xml.XpathPayloadVariableExtractor;40import com.consol.citrus.validation.xml.XmlMessageValidationContext;41import com.consol.citrus.validation.xml.XmlValidationContext;42import com.consol.citrus.variable.MessageHeaderVariableExtractor;43import com.consol.citrus.variable.MessagePayloadVariableExtractor;44import com.consol.citrus.variable.MessageVariableExtractor;45import com.consol.citrus.variable.dictionary.DataDictionary;46import org.springframework.beans.factory.annotation.Autowired;47import org.springframework.core.io.Resource;48import org.springframework.util.StringUtils;49import org.w3c.dom.Document;50import org.xml.sax.InputSource;51import javax.xml.transform.Source;52import javax.xml.transform.stream.StreamSource;53import javax.xml.validation.Schema;54import java.util.*;55import java.util.function.Consumer;56import static com.consol.citrus.dsl.support.BuilderSupport.*;57import static com.consol.citrus.validation.script.ScriptValidationContext.Builder.*;58import static com.consol.citrus.validation.xml.XmlValidationContext.Builder.*;59import static com.consol.citrus.validation.json.JsonValidationContext.Builder.*;60import static com.consol.citrus.validation.script.ScriptValidationContext.Builder.*;61import static com.consol.cit
ReceiveMessageAction
Using AI Code Generation
1package com.consol.citrus.dsl.design;2import com.consol.citrus.dsl.design.TestDesigner;3import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;4import com.consol.citrus.dsl.design.TestDesignerBeforeTestSupport;5import com.consol.citrus.dsl.design.TestDesignerAfterTestSupport;6import com.consol.citrus.dsl.design.TestDesignerAfterSuiteSupport;7import com.consol.citrus.dsl.design.TestDesignerSequenceBeforeSuiteSupport;8import com.consol.citrus.dsl.design.TestDesignerSequenceBeforeTestSupport;9import com.consol.citrus.dsl.design.TestDesignerSequenceAfterTestSupport;10import com.consol.citrus.dsl.design.TestDesignerSequenceAfterSuiteSupport;11import com.consol.citrus.dsl.design.TestDesignerParallelBeforeSuiteSupport;12import com.consol.citrus.dsl.design.TestDesignerParallelBeforeTestSupport;13import com.consol.citrus.dsl.design.TestDesignerParallelAfterTestSupport;14import com.consol.citrus.dsl.design.TestDesignerParallelAfterSuiteSupport;15import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;16import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder;17import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutBuilderSupport;18import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutConditionBuilderSupport;19import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutMessageBuilderSupport;20import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutMessageSelectorBuilderSupport;21import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationCallbackBuilderSupport;22import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport;23import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport;24import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport.ReceiveTimeoutValidationScriptBuilderDataSupport;25import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport.ReceiveTimeoutValidationScriptBuilderDataSupport.ReceiveTimeoutValidationScriptBuilderValidationSupport;26import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutValidationScriptBuilderSupport.ReceiveTimeoutValidationScriptBuilderVariablesSupport.ReceiveTimeoutValidationScriptBuilderDataSupport.ReceiveTimeoutValidationScriptBuilderValidationSupport.ReceiveTimeoutValidationScriptBuilderValidationContextSupport;27import com.consol
ReceiveMessageAction
Using AI Code Generation
1public class 4 extends TestNGCitrusTestDesigner {2 private JmsEndpoint jmsEndpoint;3 private JmsEndpoint jmsEndpoint2;4 private JmsEndpoint jmsEndpoint3;5 private JmsEndpoint jmsEndpoint4;6 private JmsEndpoint jmsEndpoint5;7 private JmsEndpoint jmsEndpoint6;8 private JmsEndpoint jmsEndpoint7;9 private JmsEndpoint jmsEndpoint8;10 private JmsEndpoint jmsEndpoint9;11 private JmsEndpoint jmsEndpoint10;12 private JmsEndpoint jmsEndpoint11;13 private JmsEndpoint jmsEndpoint12;14 private JmsEndpoint jmsEndpoint13;15 private JmsEndpoint jmsEndpoint14;16 private JmsEndpoint jmsEndpoint15;17 private JmsEndpoint jmsEndpoint16;18 private JmsEndpoint jmsEndpoint17;19 private JmsEndpoint jmsEndpoint18;20 private JmsEndpoint jmsEndpoint19;21 private JmsEndpoint jmsEndpoint20;22 private JmsEndpoint jmsEndpoint21;23 private JmsEndpoint jmsEndpoint22;24 private JmsEndpoint jmsEndpoint23;25 private JmsEndpoint jmsEndpoint24;26 private JmsEndpoint jmsEndpoint25;27 private JmsEndpoint jmsEndpoint26;28 private JmsEndpoint jmsEndpoint27;29 private JmsEndpoint jmsEndpoint28;30 private JmsEndpoint jmsEndpoint29;31 private JmsEndpoint jmsEndpoint30;32 private JmsEndpoint jmsEndpoint31;33 private JmsEndpoint jmsEndpoint32;34 private JmsEndpoint jmsEndpoint33;35 private JmsEndpoint jmsEndpoint34;
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!