poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r954476 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java test-data/hsmf/no_recipient_address.msg
Date Mon, 14 Jun 2010 13:47:22 GMT
Author: nick
Date: Mon Jun 14 13:47:22 2010
New Revision: 954476

URL: http://svn.apache.org/viewvc?rev=954476&view=rev
Log:
Better handling of Outlook messages in HSMF when there's no recipient email address

Added:
    poi/trunk/test-data/hsmf/no_recipient_address.msg   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=954476&r1=954475&r2=954476&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Jun 14 13:47:22 2010
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-beta2" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">Better handling of Outlook messages
in HSMF when there's no recipient email address</action>
            <action dev="POI-DEVELOPERS" type="fix">When formatting numbers with DataFormatter,
handle brackets following colours</action>
         </release>
         <release version="3.7-beta1" date="2010-06-16">

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java?rev=954476&r1=954475&r2=954476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java Mon Jun 14 13:47:22
2010
@@ -239,7 +239,11 @@ public class MAPIMessage extends POIDocu
          if(email != null) {
             emails[i] = email;
          } else {
-            throw new ChunkNotFoundException("No email address holding chunks found for the
" + (i+1) + "th recipient");
+            if(returnNullOnMissingChunk) {
+               emails[i] = null;
+            } else {
+               throw new ChunkNotFoundException("No email address holding chunks found for
the " + (i+1) + "th recipient");
+            }
          }
       }
 
@@ -393,6 +397,7 @@ public class MAPIMessage extends POIDocu
       boolean first = true;
 
       for(String s : l) {
+         if(s == null) continue;
          if(first) {
             first = false;
          } else {

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java?rev=954476&r1=954475&r2=954476&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java Mon Jun 14 13:47:22
2010
@@ -33,6 +33,7 @@ public final class TestBasics extends Te
    private MAPIMessage quick;
    private MAPIMessage outlook30;
    private MAPIMessage attachments;
+   private MAPIMessage noRecipientAddress;
 
 	/**
 	 * Initialize this test, load up the blank.msg mapi message.
@@ -44,6 +45,7 @@ public final class TestBasics extends Te
       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"));
 	}
 	
 	/**
@@ -140,4 +142,39 @@ public final class TestBasics extends Te
          // Good
       }
 	}
+	
+	/**
+	 * More missing chunk testing, this time for
+	 *  missing recipient email address
+	 */
+	public void testMissingAddressChunk() throws Exception {
+      assertEquals(false, noRecipientAddress.isReturnNullOnMissingChunk());
+
+      try {
+         noRecipientAddress.getRecipientEmailAddress();
+         fail();
+      } catch(ChunkNotFoundException e) {
+         // Good
+      }
+      try {
+         noRecipientAddress.getRecipientEmailAddressList();
+         fail();
+      } catch(ChunkNotFoundException e) {
+         // Good
+      }
+      
+      noRecipientAddress.setReturnNullOnMissingChunk(true);
+      
+      noRecipientAddress.getRecipientEmailAddress();
+      noRecipientAddress.getRecipientEmailAddressList();
+      assertEquals("", noRecipientAddress.getRecipientEmailAddress());
+      assertEquals(1, noRecipientAddress.getRecipientEmailAddressList().length);
+      assertEquals(null, noRecipientAddress.getRecipientEmailAddressList()[0]);
+      
+      // Check a few other bits too
+      assertEquals("Microsoft Outlook 2003 Team", noRecipientAddress.getDisplayFrom());
+      assertEquals("New Outlook User", noRecipientAddress.getDisplayTo());
+      
+      noRecipientAddress.setReturnNullOnMissingChunk(false);
+	}
 }

Added: poi/trunk/test-data/hsmf/no_recipient_address.msg
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/hsmf/no_recipient_address.msg?rev=954476&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/hsmf/no_recipient_address.msg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message