]> source.dussan.org Git - poi.git/commitdiff
Fix inconsistent whitespace in HSMF test files
authorNick Burch <nick@apache.org>
Wed, 26 Jun 2013 15:28:25 +0000 (15:28 +0000)
committerNick Burch <nick@apache.org>
Wed, 26 Jun 2013 15:28:25 +0000 (15:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496969 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java
src/scratchpad/testcases/org/apache/poi/hsmf/TestBlankFileRead.java
src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java
src/scratchpad/testcases/org/apache/poi/hsmf/TestOutlook30FileRead.java
src/scratchpad/testcases/org/apache/poi/hsmf/TestSimpleFileRead.java

index 4567b12c6d657739aa9c97123a1f4c9ac2b4be7b..c250c0e412b93190fcf4be5104a5d11807293977 100644 (file)
@@ -38,26 +38,26 @@ public final class TestBasics extends TestCase {
    private MAPIMessage cyrillic;
    private MAPIMessage chinese;
 
-       /**
-        * 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"));
-      noRecipientAddress = new MAPIMessage(samples.openResourceAsStream("no_recipient_address.msg"));
-      unicode = new MAPIMessage(samples.openResourceAsStream("example_received_unicode.msg"));
-      cyrillic = new MAPIMessage(samples.openResourceAsStream("cyrillic_message.msg"));
-      chinese = new MAPIMessage(samples.openResourceAsStream("chinese-traditional.msg"));
-       }
-       
-       /**
-        * Can we always get the recipient's email?
-        */
-       public void testRecipientEmail() throws Exception {
+   /**
+    * 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"));
+       noRecipientAddress = new MAPIMessage(samples.openResourceAsStream("no_recipient_address.msg"));
+       unicode = new MAPIMessage(samples.openResourceAsStream("example_received_unicode.msg"));
+       cyrillic = new MAPIMessage(samples.openResourceAsStream("cyrillic_message.msg"));
+       chinese = new MAPIMessage(samples.openResourceAsStream("chinese-traditional.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("nicolas1.23456@free.fr", attachments.getRecipientEmailAddress());
@@ -71,25 +71,25 @@ public final class TestBasics extends TestCase {
                "debbie.payne@pnl.gov; stuart.rose@pnl.gov; randall.scarberry@pnl.gov; Leigh.Williams@pnl.gov", 
             outlook30.getRecipientEmailAddress()
       );
-       }
-       
-       /**
-        * Test subject
-        */
-       public void testSubject() throws Exception {
+   }
+
+   /**
+    * 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 message headers
-        */
-       public void testHeaders() throws Exception {
-          // Simple email first
-          assertEquals(26, simple.getHeaders().length);
-          assertTrue(simple.getHeaders()[0].startsWith("Return-path:"));
+   }
+
+   /**
+    * Test message headers
+    */
+   public void testHeaders() throws Exception {
+      // Simple email first
+      assertEquals(26, simple.getHeaders().length);
+      assertTrue(simple.getHeaders()[0].startsWith("Return-path:"));
       assertTrue(simple.getHeaders()[1].equals("Envelope-to: travis@overwrittenstack.com"));
       assertTrue(simple.getHeaders()[25].startsWith("X-Antivirus-Scanner: Clean"));
       
@@ -110,35 +110,35 @@ public final class TestBasics extends TestCase {
       assertTrue(outlook30.getHeaders()[0].startsWith("Microsoft Mail Internet Headers"));
       assertTrue(outlook30.getHeaders()[1].startsWith("x-mimeole:"));
       assertTrue(outlook30.getHeaders()[32].startsWith("\t\"Williams")); // May need better parsing in future
-       }
-       
-       /**
-        * Test attachments
-        */
-       public void testAttachments() throws Exception {
+   }
+
+   /**
+    * 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);
-       }
-       
-       /**
-        * Test missing chunks.
-        * Use a file with no HTML body
-        */
-       public void testMissingChunks() throws Exception {
-          assertEquals(false, attachments.isReturnNullOnMissingChunk());
-
-          try {
-             attachments.getHtmlBody();
-             fail();
-          } catch(ChunkNotFoundException e) {
-             // Good
-          }
-          
-          attachments.setReturnNullOnMissingChunk(true);
-          
-          assertEquals(null, attachments.getHtmlBody());
+   }
+
+   /**
+    * Test missing chunks.
+    * Use a file with no HTML body
+    */
+   public void testMissingChunks() throws Exception {
+      assertEquals(false, attachments.isReturnNullOnMissingChunk());
+
+      try {
+          attachments.getHtmlBody();
+          fail();
+      } catch(ChunkNotFoundException e) {
+          // Good
+      }
+
+      attachments.setReturnNullOnMissingChunk(true);
+
+      assertEquals(null, attachments.getHtmlBody());
           
       attachments.setReturnNullOnMissingChunk(false);
       
@@ -148,13 +148,13 @@ public final class TestBasics extends TestCase {
       } catch(ChunkNotFoundException e) {
          // Good
       }
-       }
-       
-       /**
-        * More missing chunk testing, this time for
-        *  missing recipient email address
-        */
-       public void testMissingAddressChunk() throws Exception {
+   }
+
+   /**
+    * More missing chunk testing, this time for
+    *  missing recipient email address
+    */
+   public void testMissingAddressChunk() throws Exception {
       assertEquals(false, noRecipientAddress.isReturnNullOnMissingChunk());
 
       try {
@@ -183,17 +183,17 @@ public final class TestBasics extends TestCase {
       assertEquals("New Outlook User", noRecipientAddress.getDisplayTo());
       
       noRecipientAddress.setReturnNullOnMissingChunk(false);
-       }
-       
-       /**
-        * Test the 7 bit detection
-        */
-       public void test7BitDetection() throws Exception {
-          assertEquals(false, unicode.has7BitEncodingStrings());
+   }
+
+   /**
+    * Test the 7 bit detection
+    */
+   public void test7BitDetection() throws Exception {
+      assertEquals(false, unicode.has7BitEncodingStrings());
       assertEquals(true, simple.has7BitEncodingStrings());
       assertEquals(true, chinese.has7BitEncodingStrings());
       assertEquals(true, cyrillic.has7BitEncodingStrings());
-       }
+   }
        
    /**
     * We default to CP1252, but can sometimes do better
index 430c1b8e7ac78039bfd2501646c63c5a7b913d82..79fe7ebd9b55029f570b6fd5e372095e497cb58b 100644 (file)
@@ -28,99 +28,94 @@ import junit.framework.TestCase;
 
 /**
  * Tests to verify that the library can read blank msg files.
- *
- * @author Travis Ferguson
- *
  */
 public final class TestBlankFileRead extends TestCase {
-       private MAPIMessage mapiMessage;
+    private MAPIMessage mapiMessage;
 
-       /**
-        * Initialize this test, load up the blank.msg mapi message.
-        */
-       public TestBlankFileRead() throws IOException {
+    /**
+     * Initialize this test, load up the blank.msg mapi message.
+     */
+    public TestBlankFileRead() throws IOException {
         POIDataSamples samples = POIDataSamples.getHSMFInstance();
-               this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("blank.msg"));
-       }
-
-       /**
-        * Check if we can read the body of the blank message, we expect "".
-        */
-       public void testReadBody() {
-               try {
-                       mapiMessage.getTextBody();
-               } catch(ChunkNotFoundException exp) {
-                       return;
-               }
-
-               TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
-       }
-
-
-       /**
-        * Test to see if we can read the CC Chunk.
-        */
-       public void testReadDisplayCC() throws ChunkNotFoundException {
-               String obtained = mapiMessage.getDisplayCC();
-               String expected = "";
-
-               TestCase.assertEquals(expected, obtained);
-       }
-
-       /**
-        * Test to see if we can read the CC Chunk.
-        */
-       public void testReadDisplayTo() throws ChunkNotFoundException {
-               String obtained = mapiMessage.getDisplayTo();
-               String expected = "";
-
-               TestCase.assertEquals(expected, obtained);
-       }
-
-       /**
-        * Test to see if we can read the FROM Chunk.
-        */
-       public void testReadDisplayFrom() {
-               try {
-                       mapiMessage.getDisplayFrom();
-               } catch(ChunkNotFoundException exp) {
-                       return;
-               }
-
-               TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
-       }
-
-       /**
-        * Test to see if we can read the CC Chunk.
-        */
-       public void testReadDisplayBCC() throws ChunkNotFoundException {
-               String obtained = mapiMessage.getDisplayBCC();
-               String expected = "";
-
-               TestCase.assertEquals(expected, obtained);
-       }
-
-
-       /**
-        * Check if we can read the subject line of the blank message, we expect ""
-        */
-       public void testReadSubject() throws Exception {
-               String obtained = mapiMessage.getSubject();
-               TestCase.assertEquals("", obtained);
-       }
-
-
-       /**
-        * Check if we can read the subject line of the blank message, we expect ""
-        */
-       public void testReadConversationTopic() {
-               try {
-                       mapiMessage.getConversationTopic();
-               } catch(ChunkNotFoundException exp) {
-                       return;
-               }
-               TestCase.fail("We shouldn't have a ConversationTopic node on the blank.msg file.");
-       }
-
-
+        this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("blank.msg"));
+    }
+
+    /**
+     * Check if we can read the body of the blank message, we expect "".
+     */
+    public void testReadBody() {
+        try {
+            mapiMessage.getTextBody();
+        } catch(ChunkNotFoundException exp) {
+            return;
+        }
+
+        TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
+    }
+
+
+    /**
+     * Test to see if we can read the CC Chunk.
+     */
+    public void testReadDisplayCC() throws ChunkNotFoundException {
+        String obtained = mapiMessage.getDisplayCC();
+        String expected = "";
+
+        TestCase.assertEquals(expected, obtained);
+    }
+
+    /**
+     * Test to see if we can read the CC Chunk.
+     */
+    public void testReadDisplayTo() throws ChunkNotFoundException {
+        String obtained = mapiMessage.getDisplayTo();
+        String expected = "";
+
+        TestCase.assertEquals(expected, obtained);
+    }
+
+    /**
+     * Test to see if we can read the FROM Chunk.
+     */
+    public void testReadDisplayFrom() {
+        try {
+            mapiMessage.getDisplayFrom();
+        } catch(ChunkNotFoundException exp) {
+            return;
+        }
+
+        TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
+    }
+
+    /**
+     * Test to see if we can read the CC Chunk.
+     */
+    public void testReadDisplayBCC() throws ChunkNotFoundException {
+        String obtained = mapiMessage.getDisplayBCC();
+        String expected = "";
+
+        TestCase.assertEquals(expected, obtained);
+    }
+
+
+    /**
+     * Check if we can read the subject line of the blank message, we expect ""
+     */
+    public void testReadSubject() throws Exception {
+        String obtained = mapiMessage.getSubject();
+        TestCase.assertEquals("", obtained);
+    }
+
+
+    /**
+     * Check if we can read the subject line of the blank message, we expect ""
+     */
+    public void testReadConversationTopic() {
+        try {
+            mapiMessage.getConversationTopic();
+        } catch(ChunkNotFoundException exp) {
+            return;
+        }
+        TestCase.fail("We shouldn't have a ConversationTopic node on the blank.msg file.");
+    }
 }
index 49a04793cfcc304393784ece685b00a8c977236d..1809b6f5741e34cd3acc1aae41e1302a329398d4 100644 (file)
@@ -36,70 +36,68 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  *  ones, for example Submission Dates
  */
 public final class TestFixedSizedProperties extends POITestCase {
-       protected static final String messageSucceeds = "53784_succeeds.msg";
-       protected static final String messageFails = "53784_fails.msg";
-       private MAPIMessage mapiMessageSucceeds;
-       private MAPIMessage mapiMessageFails;
-       private POIFSFileSystem fsMessageSucceeds;
-       private POIFSFileSystem fsMessageFails; 
+   protected static final String messageSucceeds = "53784_succeeds.msg";
+   protected static final String messageFails = "53784_fails.msg";
+   private MAPIMessage mapiMessageSucceeds;
+   private MAPIMessage mapiMessageFails;
+   private POIFSFileSystem fsMessageSucceeds;
+   private POIFSFileSystem fsMessageFails;     
 
-       /**
-        * Initialize this test, load up the messages.
-        * 
-        * @throws Exception
-        */
-       public TestFixedSizedProperties() throws Exception {
-               POIDataSamples samples = POIDataSamples.getHSMFInstance();
-               this.mapiMessageSucceeds = new MAPIMessage(
-                               samples.openResourceAsStream(messageSucceeds));
-               this.mapiMessageFails = new MAPIMessage(
-                               samples.openResourceAsStream(messageFails));            
-               this.fsMessageSucceeds = new POIFSFileSystem(new FileInputStream(samples.getFile(messageSucceeds)));
-               this.fsMessageFails = new POIFSFileSystem(new FileInputStream(samples.getFile(messageFails)));
-       }
+   /**
+    * Initialize this test, load up the messages.
+    */
+   public TestFixedSizedProperties() throws Exception {
+       POIDataSamples samples = POIDataSamples.getHSMFInstance();
+      this.mapiMessageSucceeds = new MAPIMessage(
+                samples.openResourceAsStream(messageSucceeds));
+      this.mapiMessageFails = new MAPIMessage(
+                samples.openResourceAsStream(messageFails));           
+      this.fsMessageSucceeds = new POIFSFileSystem(new FileInputStream(samples.getFile(messageSucceeds)));
+      this.fsMessageFails = new POIFSFileSystem(new FileInputStream(samples.getFile(messageFails)));
+   }
 
-       /**
-        * Test to see if we can read the Date Chunk with OutlookTextExtractor.
-        * TODO Work out why the Fri 22nd vs Monday 25th problem is occurring and fix
-        */
-       public void DISABLEDtestReadMessageDateSucceedsWithOutlookTextExtractor() {
-               OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageSucceeds);
-               String text = ext.getText();
+   /**
+    * Test to see if we can read the Date Chunk with OutlookTextExtractor.
+    * TODO Work out why the Fri 22nd vs Monday 25th problem is occurring and fix
+    */
+   public void DISABLEDtestReadMessageDateSucceedsWithOutlookTextExtractor() {
+      OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageSucceeds);
+      String text = ext.getText();
 
-               assertContains(text, "Date: Fri, 22 Jun 2012 21:32:54\n");
-       }
+      assertContains(text, "Date: Fri, 22 Jun 2012 21:32:54\n");
+   }
 
-       /**
-        * Test to see if we can read the Date Chunk with OutlookTextExtractor.
+   /**
+    * Test to see if we can read the Date Chunk with OutlookTextExtractor.
     * TODO Work out why the Thu 21st vs Monday 25th problem is occurring and fix
-        */
-       public void DISABLEDtestReadMessageDateFailsWithOutlookTextExtractor() {
-               OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageFails);
-               String text = ext.getText();
+    */
+   public void DISABLEDtestReadMessageDateFailsWithOutlookTextExtractor() {
+      OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageFails);
+      String text = ext.getText();
+
+      assertContains(text, "Date: Thu, 21 Jun 2012 17:14:04\n");
+   }
 
-               assertContains(text, "Date: Thu, 21 Jun 2012 17:14:04\n");
-       }
-       
    /**
     * Test to see if we can read the Date Chunk with HSMFDump.
     * @throws IOException 
     */
    public void testReadMessageDateSucceedsWithHSMFDump() throws IOException {
-      PrintStream stream = new PrintStream(new ByteArrayOutputStream());
-      HSMFDump dump = new HSMFDump(fsMessageSucceeds);
-      dump.dump(stream);
+       PrintStream stream = new PrintStream(new ByteArrayOutputStream());
+       HSMFDump dump = new HSMFDump(fsMessageSucceeds);
+       dump.dump(stream);
    }   
-       
+
    /**
     * Test to see if we can read the Date Chunk with HSMFDump.
     * @throws Exception 
     */
    public void testReadMessageDateFailsWithHSMFDump() throws Exception {
-      PrintStream stream = new PrintStream(new ByteArrayOutputStream());
-      HSMFDump dump = new HSMFDump(fsMessageFails);
-      dump.dump(stream);
+       PrintStream stream = new PrintStream(new ByteArrayOutputStream());
+       HSMFDump dump = new HSMFDump(fsMessageFails);
+       dump.dump(stream);
    }
-       
+
    /**
     * TODO Work out why the Fri 22nd vs Monday 25th problem is occurring and fix
     */
index 435f9bcf0973c329eccf08d8e7be478e548fbb67..a791874ced3e228147a1e9d318a1d1c3b80427b4 100644 (file)
@@ -29,117 +29,117 @@ import junit.framework.TestCase;
  * Tests to verify that we can still work on the newer Outlook 3.0 files.
  */
 public final class TestOutlook30FileRead extends TestCase {
-private MAPIMessage mapiMessage;
+    private MAPIMessage mapiMessage;
 
-       /**
-        * Initialize this test, load up the blank.msg mapi message.
-        * @throws Exception
-        */
-       public TestOutlook30FileRead() throws IOException {
+    /**
+     * Initialize this test, load up the blank.msg mapi message.
+     * @throws Exception
+     */
+    public TestOutlook30FileRead() throws IOException {
         POIDataSamples samples = POIDataSamples.getHSMFInstance();
-               this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("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);
-       }
-   
-   /**
-    * Ensure we can get the HTML and RTF versions
-    */
-   public void testReadBodyContents() throws Exception {
-      String html = mapiMessage.getHtmlBody();
-      String rtf = mapiMessage.getRtfBody();
-      assertNotNull(html);
-      assertNotNull(rtf);
-      
-      assertTrue("Wrong text:\n" + html, html.startsWith("<!DOCTYPE"));
-      assertTrue("Wrong text:\n" + rtf,  rtf.startsWith("{\\rtf1"));
-   }
+        this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("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);
+    }
+
+    /**
+     * Ensure we can get the HTML and RTF versions
+     */
+    public void testReadBodyContents() throws Exception {
+        String html = mapiMessage.getHtmlBody();
+        String rtf = mapiMessage.getRtfBody();
+        assertNotNull(html);
+        assertNotNull(rtf);
+
+        assertTrue("Wrong text:\n" + html, html.startsWith("<!DOCTYPE"));
+        assertTrue("Wrong text:\n" + rtf,  rtf.startsWith("{\\rtf1"));
+    }
 }
index 3f261f4d8fe3d4d163cd49add5ce1f5ca839f7a2..318031015cfb6a81c3256245dc9d5e427de53ca1 100644 (file)
@@ -26,117 +26,112 @@ import org.apache.poi.POIDataSamples;
 import junit.framework.TestCase;
 
 /**
- * Tests to verify that we can read a simple msg file, that is in plain/text format with no attachments
- * or extra recipents.
- *
- * @author Travis Ferguson
+ * Tests to verify that we can read a simple msg file, that is in plain/text
+ *  format with no attachments or extra recipents.
  */
 public final class TestSimpleFileRead extends TestCase {
-private MAPIMessage mapiMessage;
+    private MAPIMessage mapiMessage;
 
-       /**
-        * Initialize this test, load up the blank.msg mapi message.
-        * @throws Exception
-        */
-       public TestSimpleFileRead() throws IOException {
+    /**
+     * Initialize this test, load up the blank.msg mapi message.
+     * @throws Exception
+     */
+    public TestSimpleFileRead() throws IOException {
         POIDataSamples samples = POIDataSamples.getHSMFInstance();
-               this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("simple_test_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();
-               String expected = "travis@overwrittenstack.com";
-
-               TestCase.assertEquals(obtained, expected);
-       }
-
-       /**
-        * Test to see if we can read the From Chunk.
-        * @throws ChunkNotFoundException
-        *
-        */
-       public void testReadDisplayFrom() throws ChunkNotFoundException {
-               String obtained = mapiMessage.getDisplayFrom();
-               String expected = "Travis Ferguson";
-
-               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();
-               String expected = "This is a test message.";
-
-               TestCase.assertEquals(obtained, expected);
-       }
-
-       /**
-        * 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 = "test message";
-
-               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("test message", 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);
-       }
-
-
-
+        this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("simple_test_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();
+        String expected = "travis@overwrittenstack.com";
+
+        TestCase.assertEquals(obtained, expected);
+    }
+
+    /**
+     * Test to see if we can read the From Chunk.
+     * @throws ChunkNotFoundException
+     *
+     */
+    public void testReadDisplayFrom() throws ChunkNotFoundException {
+        String obtained = mapiMessage.getDisplayFrom();
+        String expected = "Travis Ferguson";
+
+        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();
+        String expected = "This is a test message.";
+
+        TestCase.assertEquals(obtained, expected);
+    }
+
+    /**
+     * 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 = "test message";
+
+        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("test message", 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);
+    }
 }