001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hsmf.model;
019:
020: import java.io.IOException;
021:
022: import org.apache.poi.hsmf.MAPIMessage;
023: import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
024:
025: import junit.framework.TestCase;
026:
027: /**
028: * Tests to verify that we can read a simple msg file, that is in plain/text format with no attachments
029: * or extra recipents.
030: *
031: * @author Travis Ferguson
032: */
033: public class TestSimpleFileRead extends TestCase {
034: private MAPIMessage mapiMessage;
035:
036: /**
037: * Initialize this test, load up the blank.msg mapi message.
038: * @throws Exception
039: */
040: public TestSimpleFileRead() throws IOException {
041: String dirname = System.getProperty("HSMF.testdata.path");
042: this .mapiMessage = new MAPIMessage(dirname
043: + "/simple_test_msg.msg");
044: }
045:
046: /**
047: * Test to see if we can read the CC Chunk.
048: * @throws ChunkNotFoundException
049: *
050: */
051: public void testReadDisplayCC() throws ChunkNotFoundException {
052: String obtained = mapiMessage.getDisplayCC();
053: String expected = "";
054:
055: TestCase.assertEquals(obtained, expected);
056: }
057:
058: /**
059: * Test to see if we can read the CC Chunk.
060: * @throws ChunkNotFoundException
061: *
062: */
063: public void testReadDisplayTo() throws ChunkNotFoundException {
064: String obtained = mapiMessage.getDisplayTo();
065: String expected = "travis@overwrittenstack.com";
066:
067: TestCase.assertEquals(obtained, expected);
068: }
069:
070: /**
071: * Test to see if we can read the From Chunk.
072: * @throws ChunkNotFoundException
073: *
074: */
075: public void testReadDisplayFrom() throws ChunkNotFoundException {
076: String obtained = mapiMessage.getDisplayFrom();
077: String expected = "Travis Ferguson";
078:
079: TestCase.assertEquals(obtained, expected);
080: }
081:
082: /**
083: * Test to see if we can read the CC Chunk.
084: * @throws ChunkNotFoundException
085: *
086: */
087: public void testReadDisplayBCC() throws ChunkNotFoundException {
088: String obtained = mapiMessage.getDisplayBCC();
089: String expected = "";
090:
091: TestCase.assertEquals(obtained, expected);
092: }
093:
094: /**
095: * Check if we can read the body of the blank message, we expect "".
096: *
097: * @throws Exception
098: */
099: public void testReadBody() throws Exception {
100: String obtained = mapiMessage.getTextBody();
101: String expected = "This is a test message.";
102:
103: TestCase.assertEquals(obtained, expected);
104: }
105:
106: /**
107: * Check if we can read the subject line of the blank message, we expect ""
108: *
109: * @throws Exception
110: */
111: public void testReadSubject() throws Exception {
112: String obtained = mapiMessage.getSubject();
113: String expected = "test message";
114:
115: TestCase.assertEquals(expected, obtained);
116: }
117:
118: /**
119: * Check if we can read the subject line of the blank message, we expect ""
120: *
121: * @throws Exception
122: */
123: public void testReadConversationTopic() throws Exception {
124: String obtained = mapiMessage.getConversationTopic();
125: TestCase.assertEquals("test message", obtained);
126: }
127:
128: /**
129: * Check if we can read the subject line of the blank message, we expect ""
130: *
131: * @throws Exception
132: */
133: public void testReadMessageClass() throws Exception {
134: String obtained = mapiMessage.getMessageClass();
135: TestCase.assertEquals("IPM.Note", obtained);
136: }
137:
138: }
|