citrus
citrus copied to clipboard
Mailserver schema requires attachment if attachments is present, but SimpleJavaMail always generates empty collection "attachments"
Citrus Version 3.4.0
Expected behavior Accept empty collection as "no attachment"
Actual behavior Error: Failed to marshal object - the content of element attachment is not complete
Caused by: com.consol.citrus.exceptions.CitrusRuntimeException: Failed to marshal object graph
at com.consol.citrus.mail.model.MailMarshaller.marshal(MailMarshaller.java:120)
at com.consol.citrus.mail.message.MailMessage.getPayload(MailMessage.java:290)
at com.consol.citrus.util.MessageUtils.hasXmlPayload(MessageUtils.java:44)
at com.consol.citrus.validation.xml.DomXmlMessageValidator.supportsMessageType(DomXmlMessageValidator.java:596)
at com.consol.citrus.validation.xml.XpathMessageValidator.supportsMessageType(XpathMessageValidator.java:161)
at com.consol.citrus.validation.MessageValidatorRegistry.findMessageValidators(MessageValidatorRegistry.java:72)
at com.consol.citrus.actions.ReceiveMessageAction.validateMessage(ReceiveMessageAction.java:263)
at com.consol.citrus.actions.ReceiveMessageAction.doExecute(ReceiveMessageAction.java:168)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:59)
at com.consol.citrus.DefaultTestCase.executeAction(DefaultTestCase.java:136)
... 35 more
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; cvc-complex-type.2.4.b: The content of element 'attachment' is not complete. One of '{"http://www.citrusframework.org/schema/mail/message":attachments, "http://www.citrusframework.org/schema/mail/message":fileName}' is expected.]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:226)
at com.consol.citrus.xml.Jaxb2Marshaller.marshal(Jaxb2Marshaller.java:105)
at com.consol.citrus.mail.model.MailMarshaller.marshal(MailMarshaller.java:118)
... 44 more
Test case sample Java: (SimpleJavaMail) ...
Email email = EmailBuilder.startingBlank()
.to(toColl)
.withSubject("subject")
.withPlainText("text")
.withHTMLText("html")
.buildEmail();
... Citrus:
@Test
@CitrusTest
public void test() {
...
receive(receiveMessageBuilder -> receiveMessageBuilder
.endpoint(mailServer)
.message(MailMessage.request()
.from("[email protected]")
.to("[email protected]")
.cc("")
.bcc("")
.subject("ToDo report")
.body("Hello, world!", "text/plain; charset=us-ascii"))
.header(CitrusMailMessageHeaders.MAIL_SUBJECT, "ToDo report"));