aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-09-15 21:57:21 +0000
committerNick Burch <nick@apache.org>2008-09-15 21:57:21 +0000
commitf6e96990ba42022bb67f315484c29d8aaece05ca (patch)
tree47d03a4f97191371fbd6f6e9bd88df5fb4b3e21a /src/scratchpad/testcases
parentfebcf92fec50f2ebff906510643f97ee7a8a8e72 (diff)
downloadpoi-f6e96990ba42022bb67f315484c29d8aaece05ca.tar.gz
poi-f6e96990ba42022bb67f315484c29d8aaece05ca.zip
Merged revisions 695649 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk ........ r695649 | nick | 2008-09-15 22:51:14 +0100 (Mon, 15 Sep 2008) | 1 line Fix inspired by bug #45804 - Update HSMF to handle Outlook 3.0 msg files, which have a different string chunk type ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@695651 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/AllTests.java1
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/data/outlook_30_msg.msgbin0 -> 97280 bytes
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java31
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java135
4 files changed, 154 insertions, 13 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/AllTests.java b/src/scratchpad/testcases/org/apache/poi/hsmf/AllTests.java
index 18a622c32b..e117ab89ee 100644
--- a/src/scratchpad/testcases/org/apache/poi/hsmf/AllTests.java
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/AllTests.java
@@ -33,6 +33,7 @@ public class AllTests
TestSuite suite = new TestSuite();
suite.addTestSuite(org.apache.poi.hsmf.model.TestBlankFileRead.class);
suite.addTestSuite(org.apache.poi.hsmf.model.TestSimpleFileRead.class);
+ suite.addTestSuite(org.apache.poi.hsmf.model.TestOutlook30FileRead.class);
suite.addTestSuite(org.apache.poi.hsmf.model.TestChunkData.class);
return suite;
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/data/outlook_30_msg.msg b/src/scratchpad/testcases/org/apache/poi/hsmf/data/outlook_30_msg.msg
new file mode 100644
index 0000000000..0a585699a2
--- /dev/null
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/data/outlook_30_msg.msg
Binary files differ
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java b/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java
index dc4b531294..8f5dd47773 100644
--- a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestChunkData.java
@@ -31,42 +31,47 @@ import junit.framework.TestCase;
*
*/
public class TestChunkData extends TestCase {
+ private Chunks chunks = Chunks.getInstance(false);
+
public void testChunkCreate() {
- StringChunk chunk = new StringChunk(0x0200);
+ StringChunk chunk = new StringChunk(0x0200, false);
TestCase.assertEquals("__substg1.0_0200001E", chunk.getEntryName());
/* test the lower and upper limits of the chunk ids */
- chunk = new StringChunk(0x0000);
+ chunk = new StringChunk(0x0000, false);
TestCase.assertEquals("__substg1.0_0000001E", chunk.getEntryName());
- chunk = new StringChunk(0xFFFF);
+ chunk = new StringChunk(0xFFFF, false);
TestCase.assertEquals("__substg1.0_FFFF001E", chunk.getEntryName());
+
+ chunk = new StringChunk(0xFFFF, true);
+ TestCase.assertEquals("__substg1.0_FFFF001F", chunk.getEntryName());
}
public void testTextBodyChunk() {
- StringChunk chunk = new StringChunk(0x1000);
- TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().textBodyChunk.getEntryName());
+ StringChunk chunk = new StringChunk(0x1000, false);
+ TestCase.assertEquals(chunk.getEntryName(), chunks.textBodyChunk.getEntryName());
}
public void testDisplayToChunk() {
- StringChunk chunk = new StringChunk(0x0E04);
- TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().displayToChunk.getEntryName());
+ StringChunk chunk = new StringChunk(0x0E04, false);
+ TestCase.assertEquals(chunk.getEntryName(), chunks.displayToChunk.getEntryName());
}
public void testDisplayCCChunk() {
- StringChunk chunk = new StringChunk(0x0E03);
- TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().displayCCChunk.getEntryName());
+ StringChunk chunk = new StringChunk(0x0E03, false);
+ TestCase.assertEquals(chunk.getEntryName(), chunks.displayCCChunk.getEntryName());
}
public void testDisplayBCCChunk() {
- StringChunk chunk = new StringChunk(0x0E02);
- TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().displayBCCChunk.getEntryName());
+ StringChunk chunk = new StringChunk(0x0E02, false);
+ TestCase.assertEquals(chunk.getEntryName(), chunks.displayBCCChunk.getEntryName());
}
public void testSubjectChunk() {
- Chunk chunk = new StringChunk(0x0037);
- TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().subjectChunk.getEntryName());
+ Chunk chunk = new StringChunk(0x0037, false);
+ TestCase.assertEquals(chunk.getEntryName(), chunks.subjectChunk.getEntryName());
}
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java b/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java
new file mode 100644
index 0000000000..7e94405e08
--- /dev/null
+++ b/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestOutlook30FileRead.java
@@ -0,0 +1,135 @@
+/* ====================================================================
+ 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.model;
+
+import java.io.IOException;
+
+import org.apache.poi.hsmf.MAPIMessage;
+import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests to verify that we can still work on the newer Outlook 3.0 files.
+ */
+public class TestOutlook30FileRead extends TestCase {
+private MAPIMessage mapiMessage;
+
+ /**
+ * Initialize this test, load up the blank.msg mapi message.
+ * @throws Exception
+ */
+ public TestOutlook30FileRead() throws IOException {
+ String dirname = System.getProperty("HSMF.testdata.path");
+ this.mapiMessage = new MAPIMessage(dirname + "/outlook_30_msg.msg");
+ }
+
+ /**
+ * Test to see if we can read the CC Chunk.
+ * @throws ChunkNotFoundException
+ *
+ */
+ public void testReadDisplayCC() throws ChunkNotFoundException {
+ String obtained = mapiMessage.getDisplayCC();
+ String expected = "";
+
+ TestCase.assertEquals(obtained, expected);
+ }
+
+ /**
+ * Test to see if we can read the CC Chunk.
+ * @throws ChunkNotFoundException
+ *
+ */
+ public void testReadDisplayTo() throws ChunkNotFoundException {
+ String obtained = mapiMessage.getDisplayTo();
+
+ assertTrue(obtained.startsWith("Bohn, Shawn"));
+ }
+
+ /**
+ * Test to see if we can read the From Chunk.
+ * @throws ChunkNotFoundException
+ *
+ */
+ public void testReadDisplayFrom() throws ChunkNotFoundException {
+ String obtained = mapiMessage.getDisplayFrom();
+ String expected = "Cramer, Nick";
+
+ TestCase.assertEquals(obtained, expected);
+ }
+
+ /**
+ * Test to see if we can read the CC Chunk.
+ * @throws ChunkNotFoundException
+ *
+ */
+ public void testReadDisplayBCC() throws ChunkNotFoundException {
+ String obtained = mapiMessage.getDisplayBCC();
+ String expected = "";
+
+ TestCase.assertEquals(obtained, expected);
+ }
+
+
+ /**
+ * Check if we can read the body of the blank message, we expect "".
+ *
+ * @throws Exception
+ */
+ public void testReadBody() throws Exception {
+ String obtained = mapiMessage.getTextBody();
+ assertTrue(obtained.startsWith("I am shutting down"));
+ }
+
+ /**
+ * Check if we can read the subject line of the blank message, we expect ""
+ *
+ * @throws Exception
+ */
+ public void testReadSubject() throws Exception {
+ String obtained = mapiMessage.getSubject();
+ String expected = "IN-SPIRE servers going down for a bit, back up around 8am";
+
+ TestCase.assertEquals(expected, obtained);
+ }
+
+ /**
+ * Check if we can read the subject line of the blank message, we expect ""
+ *
+ * @throws Exception
+ */
+ public void testReadConversationTopic() throws Exception {
+ String obtained = mapiMessage.getConversationTopic();
+ TestCase.assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", obtained);
+ }
+
+
+ /**
+ * Check if we can read the subject line of the blank message, we expect ""
+ *
+ * @throws Exception
+ */
+ public void testReadMessageClass() throws Exception {
+ String obtained = mapiMessage.getMessageClass();
+ TestCase.assertEquals("IPM.Note", obtained);
+ }
+
+
+
+}