diff --git a/MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParserTest.java b/MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParserTest.java index 3423c16a..34e61fbe 100644 --- a/MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParserTest.java +++ b/MSGViewer/src/test/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParserTest.java @@ -1,12 +1,17 @@ package net.sourceforge.MSGViewer.factory.mbox; import com.auxilii.msgparser.Message; +import com.auxilii.msgparser.attachment.Attachment; +import com.auxilii.msgparser.attachment.FileAttachment; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import java.net.URI; import java.nio.file.Path; +import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertTrue; class JavaMailParserTest { @@ -20,4 +25,18 @@ void should_parse_charset(String resource, String expected) throws Exception { String bodyText = message.getBodyText(); assertTrue(bodyText.contains(expected)); } + + @Test + void should_throw() throws Exception { + URI uri = JavaMailParserTest.class.getResource("/unnamed-attachment.eml").toURI(); + Path file = Path.of(uri); + JavaMailParser sut = new JavaMailParser(file); + Message message = sut.parse(); + List attachments = message.getAttachments(); + assertThat(attachments) + .element(0) + .isInstanceOf(FileAttachment.class) + .extracting(attachment -> ((FileAttachment) attachment).getLongFilename()) + .isEqualTo("unknown"); + } } diff --git a/MSGViewer/src/test/resources/unnamed-attachment.eml b/MSGViewer/src/test/resources/unnamed-attachment.eml new file mode 100644 index 00000000..f2463d37 --- /dev/null +++ b/MSGViewer/src/test/resources/unnamed-attachment.eml @@ -0,0 +1,86 @@ +Content-Transfer-Encoding: quoted-printable +To: bar +From: Foo +Subject: test +Content-Type: image/gif +Content-Disposition: inline +Content-Transfer-Encoding: base64 + +R0lGODlhVQBVAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N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