diff options
author | Nick Burch <nick@apache.org> | 2010-01-08 14:26:27 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2010-01-08 14:26:27 +0000 |
commit | ed6bc2b09d3ce469306029c8179dac296c04b8cd (patch) | |
tree | c27b911ff0572fca0b99e49db9e92c8134362e79 /src/scratchpad/testcases | |
parent | 4aedf8cb5e652577adb7ead1839613909b234deb (diff) | |
download | poi-ed6bc2b09d3ce469306029c8179dac296c04b8cd.tar.gz poi-ed6bc2b09d3ce469306029c8179dac296c04b8cd.zip |
More work on the recipient related chunks, including a helper method to do best-effort finding of the recipients email address
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@897213 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases')
3 files changed, 99 insertions, 10 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java b/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java index 260b658fce..80660aa05a 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/AllHSMFTests.java @@ -24,19 +24,19 @@ import org.apache.poi.hsmf.datatypes.*; import org.apache.poi.hsmf.parsers.*; public final class AllHSMFTests { + public static Test suite() { + TestSuite suite = new TestSuite(AllHSMFTests.class.getName()); + suite.addTestSuite(TestBasics.class); + suite.addTestSuite(TestBlankFileRead.class); + suite.addTestSuite(TestSimpleFileRead.class); + suite.addTestSuite(TestOutlook30FileRead.class); + suite.addTestSuite(TestFileWithAttachmentsRead.class); - public static Test suite() { - TestSuite suite = new TestSuite(AllHSMFTests.class.getName()); - suite.addTestSuite(TestBlankFileRead.class); - suite.addTestSuite(TestSimpleFileRead.class); - suite.addTestSuite(TestOutlook30FileRead.class); - suite.addTestSuite(TestFileWithAttachmentsRead.class); - suite.addTestSuite(TestChunkData.class); suite.addTestSuite(TestTypes.class); suite.addTestSuite(TestPOIFSChunkParser.class); - - return suite; - } + + return suite; + } } diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java b/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java new file mode 100644 index 0000000000..793d9ade0a --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java @@ -0,0 +1,77 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.hsmf; + +import java.io.IOException; + +import junit.framework.TestCase; + +import org.apache.poi.POIDataSamples; + +/** + * Tests to verify that we can perform basic opperations on + * a range of files + */ +public final class TestBasics extends TestCase { + private MAPIMessage simple; + private MAPIMessage quick; + private MAPIMessage outlook30; + private MAPIMessage attachments; + + /** + * Initialize this test, load up the blank.msg mapi message. + * @throws Exception + */ + public TestBasics() throws IOException { + POIDataSamples samples = POIDataSamples.getHSMFInstance(); + simple = new MAPIMessage(samples.openResourceAsStream("simple_test_msg.msg")); + quick = new MAPIMessage(samples.openResourceAsStream("quick.msg")); + outlook30 = new MAPIMessage(samples.openResourceAsStream("outlook_30_msg.msg")); + attachments = new MAPIMessage(samples.openResourceAsStream("attachment_test_msg.msg")); + } + + /** + * Can we always get the recipient's email? + */ + public void testRecipientEmail() throws Exception { + assertEquals("travis@overwrittenstack.com", simple.getRecipientEmailAddress()); + assertEquals("kevin.roast@alfresco.org", quick.getRecipientEmailAddress()); + assertEquals("randall.scarberry@pnl.gov", outlook30.getRecipientEmailAddress()); + assertEquals("nicolas1.23456@free.fr", attachments.getRecipientEmailAddress()); + } + + /** + * Test subject + */ + public void testSubject() throws Exception { + assertEquals("test message", simple.getSubject()); + assertEquals("Test the content transformer", quick.getSubject()); + assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", outlook30.getSubject()); + assertEquals("test pi\u00e8ce jointe 1", attachments.getSubject()); + } + + /** + * Test attachments + */ + public void testAttachments() throws Exception { + assertEquals(0, simple.getAttachmentFiles().length); + assertEquals(0, quick.getAttachmentFiles().length); + assertEquals(0, outlook30.getAttachmentFiles().length); + assertEquals(2, attachments.getAttachmentFiles().length); + } +} diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java b/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java index c86b586bec..5df734f1f2 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java @@ -105,6 +105,18 @@ public final class TestPOIFSChunkParser extends TestCase { assertNotNull(msg.getRecipientDetailsChunks()); assertEquals("kevin.roast@alfresco.org", msg.getRecipientDetailsChunks().recipientEmailChunk.getValue()); + + + // Try both SMTP and EX files for recipient + assertEquals("EX", msg.getRecipientDetailsChunks().deliveryTypeChunk.getValue()); + assertEquals("kevin.roast@alfresco.org", msg.getRecipientDetailsChunks().recipientEmailChunk.getValue()); + + msg = new MAPIMessage(new POIFSFileSystem( + new FileInputStream(samples.getFile("simple_test_msg.msg")) + )); + assertEquals("SMTP", msg.getRecipientDetailsChunks().deliveryTypeChunk.getValue()); + assertEquals(null, msg.getRecipientDetailsChunks().recipientEmailChunk); + assertEquals("travis@overwrittenstack.com", msg.getRecipientDetailsChunks().recipientNameChunk.getValue()); } public void testFindsNameId() throws IOException { |