|
1 | 1 | package org.simplejavamail.mailer; |
2 | 2 |
|
3 | 3 | import org.junit.Before; |
4 | | -import org.junit.Ignore; |
5 | 4 | import org.junit.Rule; |
6 | 5 | import org.junit.Test; |
7 | 6 | import org.simplejavamail.email.AttachmentResource; |
|
22 | 21 | import static javax.mail.Message.RecipientType.TO; |
23 | 22 | import static org.assertj.core.api.Assertions.assertThat; |
24 | 23 | import static org.simplejavamail.converter.EmailConverter.mimeMessageToEmail; |
25 | | -import static org.simplejavamail.internal.util.MiscUtil.valueNullOrEmpty; |
26 | 24 | import static testutil.EmailHelper.normalizeText; |
27 | 25 | import static testutil.EmailHelper.readOutlookMessage; |
28 | 26 |
|
@@ -67,7 +65,6 @@ public void createMailSession_StandardDummyMail_IncludingCustomHeaders() |
67 | 65 | } |
68 | 66 |
|
69 | 67 | @Test |
70 | | - @Ignore("Unfortunately, Wiser doesn't seem to get the ID back, but I confirmed with gmail that the (correct) ID should be there") |
71 | 68 | public void createMailSession_StandardDummyMailWithId() |
72 | 69 | throws IOException, MessagingException { |
73 | 70 | assertSendingEmail(EmailHelper.createDummyEmail("<123@456>", true, false, false)); |
@@ -107,14 +104,17 @@ private Email assertSendingEmail(final Email originalEmail) |
107 | 104 | throws MessagingException { |
108 | 105 | mailer.sendMail(originalEmail); |
109 | 106 | MimeMessage receivedMimeMessage = smtpServerRule.getOnlyMessage(); |
110 | | - if (!valueNullOrEmpty(originalEmail.getId())) { |
111 | | - assertThat(receivedMimeMessage.getMessageID()).isEqualTo(originalEmail.getId()); |
112 | | - } |
| 107 | + assertThat(receivedMimeMessage.getMessageID()).isEqualTo(originalEmail.getId()); |
| 108 | + |
113 | 109 | Email receivedEmail = mimeMessageToEmail(receivedMimeMessage); |
114 | 110 | // hack: it seems Wiser automatically defaults replyTo address to the From address if left empty |
115 | 111 | if (originalEmail.getReplyToRecipient() == null) { |
116 | 112 | originalEmail.setReplyToAddress(originalEmail.getFromRecipient()); |
117 | 113 | } |
| 114 | + // received email will always have an id, so let's make sure we're able to compare to the original email object |
| 115 | + if (originalEmail.getHeaders().get("Message-ID") == null) { |
| 116 | + originalEmail.addHeader("Message-ID", originalEmail.getId()); |
| 117 | + } |
118 | 118 | assertThat(receivedEmail).isEqualTo(originalEmail); |
119 | 119 | return receivedEmail; |
120 | 120 | } |
|
0 commit comments