diff options
author | Nick Burch <nick@apache.org> | 2010-06-02 15:24:11 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2010-06-02 15:24:11 +0000 |
commit | a007df3ef926501b6f6e8bff3553ed4f00fbfb10 (patch) | |
tree | 465fdf5f664dd3db648514d501d6ada4211fea65 /src/scratchpad/testcases | |
parent | fe3cb0b4e35b515b3767a4b291a2198b9efbf232 (diff) | |
download | poi-a007df3ef926501b6f6e8bff3553ed4f00fbfb10.tar.gz poi-a007df3ef926501b6f6e8bff3553ed4f00fbfb10.zip |
List attachment names in the output of OutlookTextExtractor (to get attachment contents, use ExtractorFactory as normal)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@950595 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases')
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java b/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java index 2a00b37fe4..b18a9eb26c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java @@ -26,6 +26,9 @@ import java.util.GregorianCalendar; import junit.framework.TestCase; import org.apache.poi.POIDataSamples; +import org.apache.poi.POITextExtractor; +import org.apache.poi.extractor.ExtractorFactory; +import org.apache.poi.extractor.TestExtractorFactory; import org.apache.poi.hsmf.MAPIMessage; import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -59,6 +62,7 @@ public final class TestOutlookTextExtractor extends TestCase { assertContains(text, "To: Kevin Roast <kevin.roast@alfresco.org>\n"); assertEquals(-1, text.indexOf("CC:")); assertEquals(-1, text.indexOf("BCC:")); + assertEquals(-1, text.indexOf("Attachment:")); assertContains(text, "Subject: Test the content transformer\n"); Calendar cal = new GregorianCalendar(2007, 5, 14, 9, 42, 55); SimpleDateFormat f = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss"); @@ -171,4 +175,31 @@ public final class TestOutlookTextExtractor extends TestCase { assertContains(text, "The quick brown fox jumps over the lazy dog"); } } + + /** + * See also {@link TestExtractorFactory#testEmbeded()} + */ + public void testWithAttachments() throws Exception { + POIFSFileSystem simple = new POIFSFileSystem( + new FileInputStream(samples.getFile("attachment_test_msg.msg")) + ); + MAPIMessage msg = new MAPIMessage(simple); + OutlookTextExtactor ext = new OutlookTextExtactor(msg); + + // Check the normal bits + String text = ext.getText(); + + assertContains(text, "From: Nicolas1"); + assertContains(text, "To: 'nicolas1.23456@free.fr'"); + assertEquals(-1, text.indexOf("CC:")); + assertEquals(-1, text.indexOf("BCC:")); + assertContains(text, "Subject: test"); + assertEquals(-1, text.indexOf("Date:")); + assertContains(text, "Attachment: test-unicode.doc\n"); + assertContains(text, "Attachment: pj1.txt\n"); + assertContains(text, "contenu"); + + // Embeded bits are checked in + // TestExtractorFactory + } } |