Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

WiserAssertions.withContentContains fails with nested multipart parts #1

Closed
jonjo-manywho opened this issue Jan 25, 2016 · 4 comments
Closed
Milestone

Comments

@jonjo-manywho
Copy link

Hi,

I've noticed that when a message contains nested multipart parts, the getMimeMessageBody method fails to convert the message to a String correctly, and the assertion ends up looking at a value of javax.mail.internet.MimeMultipart@2eada095.

The plain message content and how it's generated is as follows:

// I'm using org.codemonkey.simplejavamail:simple-java-mail:2.5 for this bit

final Email email = new Email();
email.addRecipient("Jonjo McKay", "[email protected]", Message.RecipientType.TO);
email.setFromAddress("ManyWho", "[email protected]");
email.setSubject("New activity");
email.setText("Hi Jonjo McKay,\n" +
        "\n" +
        "A new message was just posted in a stream you follow on ManyWho. The message was:\n" +
        "\n" +
        "Lance Drake Mandrell: \"This is a test message\"\n" +
        "\n" +
        "Join the flow at https://flow.manywho.com to read the stream and reply.\n" +
        "\n" +
        "ManyWho Email Bot");

mailer.sendMail(email);
Received: from trevor (localhost.localdomain [127.0.0.1])
        by trevor
        with SMTP (SubEthaSMTP 3.1.7) id IJTVO8YF
        for [email protected];
        Mon, 25 Jan 2016 11:15:36 +0000 (GMT)
Date: Mon, 25 Jan 2016 11:15:36 +0000 (GMT)
From: ManyWho <[email protected]>
To: Jonjo McKay <[email protected]>
Message-ID: <62259848.3.1453720536622@trevor>
Subject: New activity
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_0_836429443.1453720536568"

------=_Part_0_836429443.1453720536568
Content-Type: multipart/related; 
    boundary="----=_Part_1_543941625.1453720536595"

------=_Part_1_543941625.1453720536595
Content-Type: multipart/alternative; 
    boundary="----=_Part_2_417869968.1453720536595"

------=_Part_2_417869968.1453720536595
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Hi Jonjo McKay,

A new message was just posted in a stream you follow on ManyWho. The message was:

Lance Drake Mandrell: "This is a test message"

Join the flow at https://flow.manywho.com to read the stream and reply.

ManyWho Email Bot
------=_Part_2_417869968.1453720536595--

------=_Part_1_543941625.1453720536595--

------=_Part_0_836429443.1453720536568--
@kemitix
Copy link
Owner

kemitix commented Jan 25, 2016

I've created a draft test to try and catch this. I'm not familiar with simple-java-mail though; I'm getting an error:

org.codemonkey.simplejavamail.MailException: Generic error: Invalid protocol: null
    at net.kemitix.wiser.assertions.Issue1Test.shouldParseNestedMultiPartEmails(Issue1Test.java:32)
Caused by: javax.mail.NoSuchProviderException: Invalid protocol: null
    at net.kemitix.wiser.assertions.Issue1Test.shouldParseNestedMultiPartEmails(Issue1Test.java:32)

Could you have a look at the branch issue-1-nested-multipart-mails and send a pull request to complete the failing test? (Or even a fix if you feel inclined)

@jonjo-manywho
Copy link
Author

Sure, I'll fork and send a pull request!

jonjo-manywho pushed a commit to jonjo-manywho/wiser-assertions that referenced this issue Jan 25, 2016
kemitix added a commit that referenced this issue Jan 25, 2016
Issue #1: Add support for nested multipart messages
kemitix added a commit that referenced this issue Jan 25, 2016
Issue #1: Add support for nested multipart messages
@kemitix kemitix added this to the 0.3.0 milestone Jan 25, 2016
kemitix added a commit that referenced this issue Jan 25, 2016
Add support for nested multi-part emails [jonjo-manywho] [#1]

Signed-off-by: Paul Campbell <[email protected]>
kemitix added a commit that referenced this issue Jan 25, 2016
Add support for nested multi-part emails [jonjo-manywho] [#1]

Signed-off-by: Paul Campbell <[email protected]>
@kemitix
Copy link
Owner

kemitix commented Jan 25, 2016

Thanks for the PR. Fixed in 0.3.0 which is on it's way to the public repos now.

@kemitix kemitix closed this as completed Jan 25, 2016
@jonjo-manywho
Copy link
Author

Awesome! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants