]> source.dussan.org Git - poi.git/commitdiff
Integration test: Do a few more things with the MapiMessage
authorDominik Stadler <centic@apache.org>
Sun, 22 Mar 2015 21:48:27 +0000 (21:48 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 22 Mar 2015 21:48:27 +0000 (21:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1668485 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java

index 9de8b798c50c91704a78a3d282d3310400861f65..d68504a04caf82e7444f49fa67921ee1942120c7 100644 (file)
@@ -22,6 +22,8 @@ import java.io.FileInputStream;
 import java.io.InputStream;
 
 import org.apache.poi.hsmf.MAPIMessage;
+import org.apache.poi.hsmf.datatypes.AttachmentChunks;
+import org.apache.poi.hsmf.datatypes.DirectoryChunk;
 import org.junit.Test;
 
 public class HSMFFileHandler extends POIFSFileHandler {
@@ -32,6 +34,19 @@ public class HSMFFileHandler extends POIFSFileHandler {
                assertNotNull(mapi.getDisplayBCC());
                assertNotNull(mapi.getMessageDate());
 
+               AttachmentChunks[] attachments = mapi.getAttachmentFiles();
+
+               for(AttachmentChunks attachment : attachments) {
+
+                  DirectoryChunk chunkDirectory = attachment.attachmentDirectory;
+                  if(chunkDirectory != null) {
+                          MAPIMessage attachmentMSG = chunkDirectory.getAsEmbededMessage();
+                          assertNotNull(attachmentMSG);
+                          String body = attachmentMSG.getTextBody();
+                          assertNotNull(body);
+                  }
+               }
+
                /* => Writing isn't yet supported...
                // write out the file
                File file = TempFile.createTempFile("StressTest", ".msg");