PayloadTemplateMessageBuilder extends AbstractMessageContentBuilder { public void setPayloadResourcePath(String payloadResource) { this.payloadResourcePath = payloadResource; }  @Override Object buildMessagePayload(TestContext context, String messageType); void setPayloadData(String payloadData); void setPayloadResourcePath(String payloadResource); String getPayloadResourcePath(); String getPayloadData(); String getPayloadResourceCharset(); void setPayloadResourceCharset(String payloadResourceCharset);  }
@Test public void testMessageBuilderWithPayloadResource() { String textPayloadResource = "classpath:com/consol/citrus/validation/builder/payload-data-resource.txt"; messageBuilder = new PayloadTemplateMessageBuilder(); messageBuilder.setPayloadResourcePath(textPayloadResource); Message resultingMessage = messageBuilder.buildMessageContent(context, CitrusSettings.DEFAULT_MESSAGE_TYPE); assertEquals(resultingMessage.getPayload(), "TestMessageData"); }
@Test public void testMessageBuilderWithPayloadResourceVariableSupport() { messageBuilder = new PayloadTemplateMessageBuilder(); messageBuilder.setPayloadResourcePath(variablePayloadResource); context.setVariable("placeholder", "payload data"); Message resultingMessage = messageBuilder.buildMessageContent(context, CitrusSettings.DEFAULT_MESSAGE_TYPE); assertEquals(resultingMessage.getPayload(), "This payload data contains variables!"); }