How to use testSendBuilderWithHeaderData method of com.consol.citrus.dsl.design.SendMessageTestDesignerTest class

Best Citrus code snippet using com.consol.citrus.dsl.design.SendMessageTestDesignerTest.testSendBuilderWithHeaderData

Source:SendMessageTestDesignerTest.java Github

copy

Full Screen

...343 Assert.assertEquals(messageBuilder.getMessageHeaders().get("language"), "eng");344 }345 346 @Test347 public void testSendBuilderWithHeaderData() {348 final MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {349 @Override350 public void configure() {351 send(messageEndpoint)352 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")353 .header("<Header><Name>operation</Name><Value>foo</Value></Header>");354 355 send(messageEndpoint)356 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))357 .header("<Header><Name>operation</Name><Value>foo</Value></Header>");358 }359 };360 builder.configure();361 final TestCase test = builder.getTestCase();362 Assert.assertEquals(test.getActionCount(), 2);363 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);364 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendMessageAction.class);365 Assert.assertEquals(test.getActions().get(1).getClass(), DelegatingTestAction.class);366 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(1)).getDelegate().getClass(), SendMessageAction.class);367 368 SendMessageAction action = (SendMessageAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();369 Assert.assertEquals(action.getName(), "send");370 371 Assert.assertEquals(action.getEndpoint(), messageEndpoint);372 Assert.assertEquals(action.getMessageBuilder().getClass(), PayloadTemplateMessageBuilder.class);373 final PayloadTemplateMessageBuilder messageBuilder = (PayloadTemplateMessageBuilder) action.getMessageBuilder();374 Assert.assertEquals(messageBuilder.getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");375 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);376 Assert.assertEquals(messageBuilder.getHeaderData().size(), 1L);377 Assert.assertEquals(messageBuilder.getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo</Value></Header>");378 Assert.assertEquals(messageBuilder.getHeaderResources().size(), 0L);379 action = (SendMessageAction) ((DelegatingTestAction)test.getActions().get(1)).getDelegate();380 Assert.assertEquals(action.getName(), "send");381 Assert.assertEquals(action.getEndpoint(), messageEndpoint);382 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);383 final StaticMessageContentBuilder staticMessageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();384 Assert.assertEquals(staticMessageBuilder.getMessage().getPayload(String.class), "<TestRequest><Message>Hello World!</Message></TestRequest>");385 Assert.assertEquals(staticMessageBuilder.getMessageHeaders().size(), 0L);386 Assert.assertEquals(staticMessageBuilder.getHeaderData().size(), 1L);387 Assert.assertEquals(staticMessageBuilder.getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo</Value></Header>");388 Assert.assertEquals(staticMessageBuilder.getHeaderResources().size(), 0L);389 }390 @Test391 public void testSendBuilderWithMultipleHeaderData() {392 final MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {393 @Override394 public void configure() {395 send(messageEndpoint)396 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")397 .header("<Header><Name>operation</Name><Value>foo1</Value></Header>")398 .header("<Header><Name>operation</Name><Value>foo2</Value></Header>");399 send(messageEndpoint)400 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))401 .header("<Header><Name>operation</Name><Value>foo1</Value></Header>")402 .header("<Header><Name>operation</Name><Value>foo2</Value></Header>");403 }404 };405 builder.configure();406 final TestCase test = builder.getTestCase();407 Assert.assertEquals(test.getActionCount(), 2);408 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);409 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendMessageAction.class);410 Assert.assertEquals(test.getActions().get(1).getClass(), DelegatingTestAction.class);411 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(1)).getDelegate().getClass(), SendMessageAction.class);412 SendMessageAction action = (SendMessageAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();413 Assert.assertEquals(action.getName(), "send");414 Assert.assertEquals(action.getEndpoint(), messageEndpoint);415 Assert.assertEquals(action.getMessageBuilder().getClass(), PayloadTemplateMessageBuilder.class);416 final PayloadTemplateMessageBuilder messageBuilder = (PayloadTemplateMessageBuilder) action.getMessageBuilder();417 Assert.assertEquals(messageBuilder.getPayloadData(), "<TestRequest><Message>Hello World!</Message></TestRequest>");418 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);419 Assert.assertEquals(messageBuilder.getHeaderData().size(), 2L);420 Assert.assertEquals(messageBuilder.getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo1</Value></Header>");421 Assert.assertEquals(messageBuilder.getHeaderData().get(1), "<Header><Name>operation</Name><Value>foo2</Value></Header>");422 Assert.assertEquals(messageBuilder.getHeaderResources().size(), 0L);423 action = (SendMessageAction) ((DelegatingTestAction)test.getActions().get(1)).getDelegate();424 Assert.assertEquals(action.getName(), "send");425 Assert.assertEquals(action.getEndpoint(), messageEndpoint);426 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);427 final StaticMessageContentBuilder staticMessageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();428 Assert.assertEquals(staticMessageBuilder.getMessage().getPayload(String.class), "<TestRequest><Message>Hello World!</Message></TestRequest>");429 Assert.assertEquals(staticMessageBuilder.getMessageHeaders().size(), 0L);430 Assert.assertEquals(staticMessageBuilder.getHeaderData().size(), 2L);431 Assert.assertEquals(staticMessageBuilder.getHeaderData().get(0), "<Header><Name>operation</Name><Value>foo1</Value></Header>");432 Assert.assertEquals(staticMessageBuilder.getHeaderData().get(1), "<Header><Name>operation</Name><Value>foo2</Value></Header>");433 Assert.assertEquals(staticMessageBuilder.getHeaderResources().size(), 0L);434 }435 436 @Test437 public void testSendBuilderWithHeaderDataResource() throws IOException {438 final MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {439 @Override440 public void configure() {441 send(messageEndpoint)442 .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")443 .header(resource);444 445 send(messageEndpoint)446 .message(new DefaultMessage("<TestRequest><Message>Hello World!</Message></TestRequest>"))447 .header(resource);448 }449 };450 451 reset(resource);...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful