Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailserver schema requires attachment if attachments is present, but SimpleJavaMail always generates empty collection "attachments" #1120

Open
klauswr opened this issue Feb 6, 2024 · 0 comments

Comments

@klauswr
Copy link

klauswr commented Feb 6, 2024

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("todo-report@example.org")
                    .to("users@example.org")
                    .cc("")
                    .bcc("")
                    .subject("ToDo report")
                    .body("Hello, world!", "text/plain; charset=us-ascii"))
                .header(CitrusMailMessageHeaders.MAIL_SUBJECT, "ToDo report"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant