22
33import org .jetbrains .annotations .NotNull ;
44import org .junit .Test ;
5+ import org .simplejavamail .api .email .CalendarMethod ;
56import org .simplejavamail .api .email .Email ;
67import org .simplejavamail .api .email .EmailAssert ;
78import org .simplejavamail .api .email .Recipient ;
9+ import testutil .SecureTestDataHelper ;
10+ import testutil .SecureTestDataHelper .PasswordsConsumer ;
811
912import java .io .File ;
13+ import java .util .Properties ;
1014
1115import static demo .ResourceFolderHelper .determineResourceFolder ;
1216import static javax .mail .Message .RecipientType .CC ;
1620
1721public class EmailConverterTest {
1822
19- private static final String RESOURCE_FOLDER = determineResourceFolder ("simple-java-mail" ) + "/test/resources/test-messages" ;
23+ private static final String RESOURCES = determineResourceFolder ("simple-java-mail" ) + "/test/resources" ;
24+ private static final String RESOURCE_TEST_MESSAGES = RESOURCES + "/test-messages" ;
2025
2126 @ Test
2227 public void testOutlookBasicConversions () {
2328 final Recipient elias =
new Recipient (
"Elias Laugher" ,
"[email protected] " ,
null );
2429 final Recipient sven =
new Recipient (
"Sven Sielenkemper" ,
"[email protected] " ,
TO );
2530 final Recipient niklas =
new Recipient (
"[email protected] " ,
"[email protected] " ,
CC );
2631
27- @ NotNull Email msg = EmailConverter .outlookMsgToEmail (new File (RESOURCE_FOLDER + "/simple email with TO and CC.msg" ));
32+ @ NotNull Email msg = EmailConverter .outlookMsgToEmail (new File (RESOURCE_TEST_MESSAGES + "/simple email with TO and CC.msg" ));
2833 EmailAssert .assertThat (msg ).hasFromRecipient (elias );
2934 EmailAssert .assertThat (msg ).hasSubject ("Test E-Mail" );
3035 EmailAssert .assertThat (msg ).hasOnlyRecipients (sven , niklas );
@@ -39,7 +44,7 @@ public void testOutlookUnicode() {
3944 final Recipient kalejs =
new Recipient (
"[email protected] " ,
"[email protected] " ,
null );
4045 final Recipient dummy =
new Recipient (
"[email protected] " ,
"[email protected] " ,
TO );
4146
42- @ NotNull Email msg = EmailConverter .outlookMsgToEmail (new File (RESOURCE_FOLDER + "/tst_unicode.msg" ));
47+ @ NotNull Email msg = EmailConverter .outlookMsgToEmail (new File (RESOURCE_TEST_MESSAGES + "/tst_unicode.msg" ));
4348 EmailAssert .assertThat (msg ).hasFromRecipient (kalejs );
4449 EmailAssert .assertThat (msg ).hasSubject ("Testcase" );
4550 EmailAssert .assertThat (msg ).hasOnlyRecipients (dummy );
@@ -65,12 +70,26 @@ public void testOutlookUnicode() {
6570 public void testOutlookUnsentDraft () {
6671 final Recipient time2talk =
new Recipient (
"[email protected] " ,
"[email protected] " ,
TO );
6772
68- @ NotNull Email msg = EmailConverter .outlookMsgToEmail (new File (RESOURCE_FOLDER + "/unsent draft.msg" ));
73+ @ NotNull Email msg = EmailConverter .outlookMsgToEmail (new File (RESOURCE_TEST_MESSAGES + "/unsent draft.msg" ));
6974 EmailAssert .
assertThat (
msg ).
hasFromRecipient (
new Recipient (
null ,
"[email protected] " ,
null ));
7075 EmailAssert .assertThat (msg ).hasSubject ("MSG Test File" );
7176 EmailAssert .assertThat (msg ).hasOnlyRecipients (time2talk );
7277 EmailAssert .assertThat (msg ).hasNoAttachments ();
7378 assertThat (msg .getPlainText ()).isNotEmpty ();
7479 assertThat (normalizeNewlines (msg .getHTMLText ())).isNotEmpty ();
7580 }
81+
82+ @ Test
83+ public void testEmlWithQuotablePrintableCalendarAttachment ()
84+ throws Exception {
85+ SecureTestDataHelper .runTestWithSecureTestData (new PasswordsConsumer () {
86+ @ Override
87+ public void accept (final Properties passwords ) {
88+ File file = new File (RESOURCES + "/secure-testdata/secure-testdata/calendar-quotable-printable-email/qp-calendar-multipart.eml" );
89+ final Email email = EmailConverter .emlToEmail (file );
90+ assertThat (email .getCalendarMethod ()).isEqualTo (CalendarMethod .REQUEST );
91+ assertThat (email .getCalendarText ()).startsWith ("BEGIN:VCALENDAR" );
92+ }
93+ });
94+ }
7695}
0 commit comments