1010import org .simplejavamail .email .EmailPopulatingBuilder ;
1111import org .simplejavamail .email .Recipient ;
1212import org .simplejavamail .util .ConfigLoader ;
13+ import org .simplejavamail .util .TestDataHelper ;
1314import testutil .EmailHelper ;
1415import testutil .testrules .SmtpServerRule ;
1516import testutil .testrules .TestSmtpServer ;
@@ -47,37 +48,37 @@ public void setup() {
4748 @ Test
4849 public void createMailSession_EmptySubjectAndBody ()
4950 throws IOException , MessagingException {
50- assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , true , false ));
51+ assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , true , false ), true );
5152 }
5253
5354 @ Test
5455 public void createMailSession_StandardDummyMailBasicFields ()
5556 throws IOException , MessagingException {
56- assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , true , false ));
57+ assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , true , false ), true );
5758 }
5859
5960 @ Test
6061 public void createMailSession_StandardDummyMail_AllFields ()
6162 throws IOException , MessagingException {
62- assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , false , false ));
63+ assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , false , false ), true );
6364 }
6465
6566 @ Test
6667 public void createMailSession_StandardDummyMail_IncludingCustomHeaders ()
6768 throws IOException , MessagingException {
68- assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , false , true ));
69+ assertSendingEmail (EmailHelper .createDummyEmailBuilder (true , false , true ), true );
6970 }
7071
7172 @ Test
7273 public void createMailSession_StandardDummyMailWithId ()
7374 throws IOException , MessagingException {
74- assertSendingEmail (EmailHelper .createDummyEmailBuilder ("<123@456>" , true , false , false ));
75+ assertSendingEmail (EmailHelper .createDummyEmailBuilder ("<123@456>" , true , false , false ), true );
7576 }
7677
7778 @ Test
7879 public void createMailSession_OutlookMessageTest ()
7980 throws IOException , MessagingException {
80- Email email = assertSendingEmail (readOutlookMessage ("test-messages/HTML mail with replyto and attachment and embedded image.msg" ));
81+ Email email = assertSendingEmail (readOutlookMessage ("test-messages/HTML mail with replyto and attachment and embedded image.msg" ), false );
8182
8283 // Google SMTP overrode this, Outlook recognized it as: Benny Bottema <[email protected] >; on behalf of; lollypop <[email protected] > 8384 EmailAssert .
assertThat (
email ).
hasFromRecipient (
new Recipient (
"lollypop" ,
"[email protected] " ,
null ));
@@ -104,7 +105,7 @@ public void createMailSession_OutlookMessageTest()
104105 assertThat (normalizeText (attachment2 .readAllData ())).isEqualTo ("On the moon!" );
105106 }
106107
107- private Email assertSendingEmail (final EmailPopulatingBuilder originalEmailPopulatingBuilder )
108+ private Email assertSendingEmail (final EmailPopulatingBuilder originalEmailPopulatingBuilder , boolean compensateForDresscodeAttachmentNameOverrideErasure )
108109 throws MessagingException {
109110 Email originalEmail = originalEmailPopulatingBuilder .buildEmail ();
110111 mailer .sendMail (originalEmail );
@@ -124,6 +125,11 @@ private Email assertSendingEmail(final EmailPopulatingBuilder originalEmailPopul
124125 if (originalEmailPopulatingBuilder .getBounceToRecipient () != null ) {
125126 originalEmailPopulatingBuilder .clearBounceTo ();
126127 }
128+
129+ if (compensateForDresscodeAttachmentNameOverrideErasure ) {
130+ TestDataHelper .fixDresscodeAttachment (receivedEmail );
131+ }
132+
127133 assertThat (receivedEmail ).isEqualTo (originalEmailPopulatingBuilder .buildEmail ());
128134 return receivedEmail ;
129135 }
@@ -138,7 +144,7 @@ public void createMailSession_ReplyToMessage()
138144
139145 // send reply to initial mail
140146 Email reply = EmailBuilder
141- .replyingToAll (assertSendingEmail (receivedEmailPopulatingBuilder ))
147+ .replyingToAll (assertSendingEmail (receivedEmailPopulatingBuilder , false ))
142148143149 .withPlainText ("This is the reply" )
144150 .buildEmail ();
@@ -170,7 +176,7 @@ public void createMailSession_ReplyToMessage_NotAll_AndCustomReferences()
170176
171177 // send reply to initial mail
172178 Email reply = EmailBuilder
173- .replyingTo (assertSendingEmail (receivedEmailPopulatingBuilder ))
179+ .replyingTo (assertSendingEmail (receivedEmailPopulatingBuilder , false ))
174180 .withHeader ("References" , "dummy-references" )
175181176182 .withPlainText ("This is the reply" )
0 commit comments