Sfoglia il codice sorgente

Better handling of Outlook messages in HSMF when there's no recipient email address

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@954476 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_7_BETA1^2
Nick Burch 14 anni fa
parent
commit
64cfb8b399

+ 1
- 0
src/documentation/content/xdocs/status.xml Vedi File



<changes> <changes>
<release version="3.7-beta2" date="2010-??-??"> <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> <action dev="POI-DEVELOPERS" type="fix">When formatting numbers with DataFormatter, handle brackets following colours</action>
</release> </release>
<release version="3.7-beta1" date="2010-06-16"> <release version="3.7-beta1" date="2010-06-16">

+ 6
- 1
src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java Vedi File

if(email != null) { if(email != null) {
emails[i] = email; emails[i] = email;
} else { } 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");
}
} }
} }


boolean first = true; boolean first = true;


for(String s : l) { for(String s : l) {
if(s == null) continue;
if(first) { if(first) {
first = false; first = false;
} else { } else {

+ 37
- 0
src/scratchpad/testcases/org/apache/poi/hsmf/TestBasics.java Vedi File

private MAPIMessage quick; private MAPIMessage quick;
private MAPIMessage outlook30; private MAPIMessage outlook30;
private MAPIMessage attachments; private MAPIMessage attachments;
private MAPIMessage noRecipientAddress;


/** /**
* Initialize this test, load up the blank.msg mapi message. * Initialize this test, load up the blank.msg mapi message.
quick = new MAPIMessage(samples.openResourceAsStream("quick.msg")); quick = new MAPIMessage(samples.openResourceAsStream("quick.msg"));
outlook30 = new MAPIMessage(samples.openResourceAsStream("outlook_30_msg.msg")); outlook30 = new MAPIMessage(samples.openResourceAsStream("outlook_30_msg.msg"));
attachments = new MAPIMessage(samples.openResourceAsStream("attachment_test_msg.msg")); attachments = new MAPIMessage(samples.openResourceAsStream("attachment_test_msg.msg"));
noRecipientAddress = new MAPIMessage(samples.openResourceAsStream("no_recipient_address.msg"));
} }
/** /**
// Good // 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);
}
} }

BIN
test-data/hsmf/no_recipient_address.msg Vedi File


Loading…
Annulla
Salva