Fix inconsistent whitespace in HSMF test files
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
73aa6c507e
commit
43886b815b
@ -38,26 +38,26 @@ public final class TestBasics extends TestCase {
|
|||||||
private MAPIMessage cyrillic;
|
private MAPIMessage cyrillic;
|
||||||
private MAPIMessage chinese;
|
private MAPIMessage chinese;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this test, load up the blank.msg mapi message.
|
* Initialize this test, load up the blank.msg mapi message.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public TestBasics() throws IOException {
|
public TestBasics() throws IOException {
|
||||||
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
||||||
simple = new MAPIMessage(samples.openResourceAsStream("simple_test_msg.msg"));
|
simple = new MAPIMessage(samples.openResourceAsStream("simple_test_msg.msg"));
|
||||||
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"));
|
noRecipientAddress = new MAPIMessage(samples.openResourceAsStream("no_recipient_address.msg"));
|
||||||
unicode = new MAPIMessage(samples.openResourceAsStream("example_received_unicode.msg"));
|
unicode = new MAPIMessage(samples.openResourceAsStream("example_received_unicode.msg"));
|
||||||
cyrillic = new MAPIMessage(samples.openResourceAsStream("cyrillic_message.msg"));
|
cyrillic = new MAPIMessage(samples.openResourceAsStream("cyrillic_message.msg"));
|
||||||
chinese = new MAPIMessage(samples.openResourceAsStream("chinese-traditional.msg"));
|
chinese = new MAPIMessage(samples.openResourceAsStream("chinese-traditional.msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can we always get the recipient's email?
|
* Can we always get the recipient's email?
|
||||||
*/
|
*/
|
||||||
public void testRecipientEmail() throws Exception {
|
public void testRecipientEmail() throws Exception {
|
||||||
assertEquals("travis@overwrittenstack.com", simple.getRecipientEmailAddress());
|
assertEquals("travis@overwrittenstack.com", simple.getRecipientEmailAddress());
|
||||||
assertEquals("kevin.roast@alfresco.org", quick.getRecipientEmailAddress());
|
assertEquals("kevin.roast@alfresco.org", quick.getRecipientEmailAddress());
|
||||||
assertEquals("nicolas1.23456@free.fr", attachments.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",
|
"debbie.payne@pnl.gov; stuart.rose@pnl.gov; randall.scarberry@pnl.gov; Leigh.Williams@pnl.gov",
|
||||||
outlook30.getRecipientEmailAddress()
|
outlook30.getRecipientEmailAddress()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test subject
|
* Test subject
|
||||||
*/
|
*/
|
||||||
public void testSubject() throws Exception {
|
public void testSubject() throws Exception {
|
||||||
assertEquals("test message", simple.getSubject());
|
assertEquals("test message", simple.getSubject());
|
||||||
assertEquals("Test the content transformer", quick.getSubject());
|
assertEquals("Test the content transformer", quick.getSubject());
|
||||||
assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", outlook30.getSubject());
|
assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", outlook30.getSubject());
|
||||||
assertEquals("test pi\u00e8ce jointe 1", attachments.getSubject());
|
assertEquals("test pi\u00e8ce jointe 1", attachments.getSubject());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test message headers
|
* Test message headers
|
||||||
*/
|
*/
|
||||||
public void testHeaders() throws Exception {
|
public void testHeaders() throws Exception {
|
||||||
// Simple email first
|
// Simple email first
|
||||||
assertEquals(26, simple.getHeaders().length);
|
assertEquals(26, simple.getHeaders().length);
|
||||||
assertTrue(simple.getHeaders()[0].startsWith("Return-path:"));
|
assertTrue(simple.getHeaders()[0].startsWith("Return-path:"));
|
||||||
assertTrue(simple.getHeaders()[1].equals("Envelope-to: travis@overwrittenstack.com"));
|
assertTrue(simple.getHeaders()[1].equals("Envelope-to: travis@overwrittenstack.com"));
|
||||||
assertTrue(simple.getHeaders()[25].startsWith("X-Antivirus-Scanner: Clean"));
|
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()[0].startsWith("Microsoft Mail Internet Headers"));
|
||||||
assertTrue(outlook30.getHeaders()[1].startsWith("x-mimeole:"));
|
assertTrue(outlook30.getHeaders()[1].startsWith("x-mimeole:"));
|
||||||
assertTrue(outlook30.getHeaders()[32].startsWith("\t\"Williams")); // May need better parsing in future
|
assertTrue(outlook30.getHeaders()[32].startsWith("\t\"Williams")); // May need better parsing in future
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test attachments
|
* Test attachments
|
||||||
*/
|
*/
|
||||||
public void testAttachments() throws Exception {
|
public void testAttachments() throws Exception {
|
||||||
assertEquals(0, simple.getAttachmentFiles().length);
|
assertEquals(0, simple.getAttachmentFiles().length);
|
||||||
assertEquals(0, quick.getAttachmentFiles().length);
|
assertEquals(0, quick.getAttachmentFiles().length);
|
||||||
assertEquals(0, outlook30.getAttachmentFiles().length);
|
assertEquals(0, outlook30.getAttachmentFiles().length);
|
||||||
assertEquals(2, attachments.getAttachmentFiles().length);
|
assertEquals(2, attachments.getAttachmentFiles().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test missing chunks.
|
* Test missing chunks.
|
||||||
* Use a file with no HTML body
|
* Use a file with no HTML body
|
||||||
*/
|
*/
|
||||||
public void testMissingChunks() throws Exception {
|
public void testMissingChunks() throws Exception {
|
||||||
assertEquals(false, attachments.isReturnNullOnMissingChunk());
|
assertEquals(false, attachments.isReturnNullOnMissingChunk());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
attachments.getHtmlBody();
|
attachments.getHtmlBody();
|
||||||
fail();
|
fail();
|
||||||
} catch(ChunkNotFoundException e) {
|
} catch(ChunkNotFoundException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
|
|
||||||
attachments.setReturnNullOnMissingChunk(true);
|
attachments.setReturnNullOnMissingChunk(true);
|
||||||
|
|
||||||
assertEquals(null, attachments.getHtmlBody());
|
assertEquals(null, attachments.getHtmlBody());
|
||||||
|
|
||||||
attachments.setReturnNullOnMissingChunk(false);
|
attachments.setReturnNullOnMissingChunk(false);
|
||||||
|
|
||||||
@ -148,13 +148,13 @@ public final class TestBasics extends TestCase {
|
|||||||
} catch(ChunkNotFoundException e) {
|
} catch(ChunkNotFoundException e) {
|
||||||
// Good
|
// Good
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More missing chunk testing, this time for
|
* More missing chunk testing, this time for
|
||||||
* missing recipient email address
|
* missing recipient email address
|
||||||
*/
|
*/
|
||||||
public void testMissingAddressChunk() throws Exception {
|
public void testMissingAddressChunk() throws Exception {
|
||||||
assertEquals(false, noRecipientAddress.isReturnNullOnMissingChunk());
|
assertEquals(false, noRecipientAddress.isReturnNullOnMissingChunk());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -183,17 +183,17 @@ public final class TestBasics extends TestCase {
|
|||||||
assertEquals("New Outlook User", noRecipientAddress.getDisplayTo());
|
assertEquals("New Outlook User", noRecipientAddress.getDisplayTo());
|
||||||
|
|
||||||
noRecipientAddress.setReturnNullOnMissingChunk(false);
|
noRecipientAddress.setReturnNullOnMissingChunk(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the 7 bit detection
|
* Test the 7 bit detection
|
||||||
*/
|
*/
|
||||||
public void test7BitDetection() throws Exception {
|
public void test7BitDetection() throws Exception {
|
||||||
assertEquals(false, unicode.has7BitEncodingStrings());
|
assertEquals(false, unicode.has7BitEncodingStrings());
|
||||||
assertEquals(true, simple.has7BitEncodingStrings());
|
assertEquals(true, simple.has7BitEncodingStrings());
|
||||||
assertEquals(true, chinese.has7BitEncodingStrings());
|
assertEquals(true, chinese.has7BitEncodingStrings());
|
||||||
assertEquals(true, cyrillic.has7BitEncodingStrings());
|
assertEquals(true, cyrillic.has7BitEncodingStrings());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We default to CP1252, but can sometimes do better
|
* We default to CP1252, but can sometimes do better
|
||||||
|
@ -28,99 +28,94 @@ import junit.framework.TestCase;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests to verify that the library can read blank msg files.
|
* Tests to verify that the library can read blank msg files.
|
||||||
*
|
|
||||||
* @author Travis Ferguson
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class TestBlankFileRead extends TestCase {
|
public final class TestBlankFileRead extends TestCase {
|
||||||
private MAPIMessage mapiMessage;
|
private MAPIMessage mapiMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this test, load up the blank.msg mapi message.
|
* Initialize this test, load up the blank.msg mapi message.
|
||||||
*/
|
*/
|
||||||
public TestBlankFileRead() throws IOException {
|
public TestBlankFileRead() throws IOException {
|
||||||
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
||||||
this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("blank.msg"));
|
this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("blank.msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the body of the blank message, we expect "".
|
* Check if we can read the body of the blank message, we expect "".
|
||||||
*/
|
*/
|
||||||
public void testReadBody() {
|
public void testReadBody() {
|
||||||
try {
|
try {
|
||||||
mapiMessage.getTextBody();
|
mapiMessage.getTextBody();
|
||||||
} catch(ChunkNotFoundException exp) {
|
} catch(ChunkNotFoundException exp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
|
TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayCC() throws ChunkNotFoundException {
|
public void testReadDisplayCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayCC();
|
String obtained = mapiMessage.getDisplayCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(expected, obtained);
|
TestCase.assertEquals(expected, obtained);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayTo() throws ChunkNotFoundException {
|
public void testReadDisplayTo() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayTo();
|
String obtained = mapiMessage.getDisplayTo();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(expected, obtained);
|
TestCase.assertEquals(expected, obtained);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the FROM Chunk.
|
* Test to see if we can read the FROM Chunk.
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayFrom() {
|
public void testReadDisplayFrom() {
|
||||||
try {
|
try {
|
||||||
mapiMessage.getDisplayFrom();
|
mapiMessage.getDisplayFrom();
|
||||||
} catch(ChunkNotFoundException exp) {
|
} catch(ChunkNotFoundException exp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
|
TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayBCC();
|
String obtained = mapiMessage.getDisplayBCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(expected, obtained);
|
TestCase.assertEquals(expected, obtained);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*/
|
*/
|
||||||
public void testReadSubject() throws Exception {
|
public void testReadSubject() throws Exception {
|
||||||
String obtained = mapiMessage.getSubject();
|
String obtained = mapiMessage.getSubject();
|
||||||
TestCase.assertEquals("", obtained);
|
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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,58 +36,56 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
|||||||
* ones, for example Submission Dates
|
* ones, for example Submission Dates
|
||||||
*/
|
*/
|
||||||
public final class TestFixedSizedProperties extends POITestCase {
|
public final class TestFixedSizedProperties extends POITestCase {
|
||||||
protected static final String messageSucceeds = "53784_succeeds.msg";
|
protected static final String messageSucceeds = "53784_succeeds.msg";
|
||||||
protected static final String messageFails = "53784_fails.msg";
|
protected static final String messageFails = "53784_fails.msg";
|
||||||
private MAPIMessage mapiMessageSucceeds;
|
private MAPIMessage mapiMessageSucceeds;
|
||||||
private MAPIMessage mapiMessageFails;
|
private MAPIMessage mapiMessageFails;
|
||||||
private POIFSFileSystem fsMessageSucceeds;
|
private POIFSFileSystem fsMessageSucceeds;
|
||||||
private POIFSFileSystem fsMessageFails;
|
private POIFSFileSystem fsMessageFails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this test, load up the messages.
|
* Initialize this test, load up the messages.
|
||||||
*
|
*/
|
||||||
* @throws Exception
|
public TestFixedSizedProperties() throws Exception {
|
||||||
*/
|
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
||||||
public TestFixedSizedProperties() throws Exception {
|
this.mapiMessageSucceeds = new MAPIMessage(
|
||||||
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
samples.openResourceAsStream(messageSucceeds));
|
||||||
this.mapiMessageSucceeds = new MAPIMessage(
|
this.mapiMessageFails = new MAPIMessage(
|
||||||
samples.openResourceAsStream(messageSucceeds));
|
samples.openResourceAsStream(messageFails));
|
||||||
this.mapiMessageFails = new MAPIMessage(
|
this.fsMessageSucceeds = new POIFSFileSystem(new FileInputStream(samples.getFile(messageSucceeds)));
|
||||||
samples.openResourceAsStream(messageFails));
|
this.fsMessageFails = new POIFSFileSystem(new FileInputStream(samples.getFile(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.
|
* 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
|
* TODO Work out why the Fri 22nd vs Monday 25th problem is occurring and fix
|
||||||
*/
|
*/
|
||||||
public void DISABLEDtestReadMessageDateSucceedsWithOutlookTextExtractor() {
|
public void DISABLEDtestReadMessageDateSucceedsWithOutlookTextExtractor() {
|
||||||
OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageSucceeds);
|
OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageSucceeds);
|
||||||
String text = ext.getText();
|
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
|
* TODO Work out why the Thu 21st vs Monday 25th problem is occurring and fix
|
||||||
*/
|
*/
|
||||||
public void DISABLEDtestReadMessageDateFailsWithOutlookTextExtractor() {
|
public void DISABLEDtestReadMessageDateFailsWithOutlookTextExtractor() {
|
||||||
OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageFails);
|
OutlookTextExtactor ext = new OutlookTextExtactor(mapiMessageFails);
|
||||||
String text = ext.getText();
|
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.
|
* Test to see if we can read the Date Chunk with HSMFDump.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void testReadMessageDateSucceedsWithHSMFDump() throws IOException {
|
public void testReadMessageDateSucceedsWithHSMFDump() throws IOException {
|
||||||
PrintStream stream = new PrintStream(new ByteArrayOutputStream());
|
PrintStream stream = new PrintStream(new ByteArrayOutputStream());
|
||||||
HSMFDump dump = new HSMFDump(fsMessageSucceeds);
|
HSMFDump dump = new HSMFDump(fsMessageSucceeds);
|
||||||
dump.dump(stream);
|
dump.dump(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,9 +93,9 @@ public final class TestFixedSizedProperties extends POITestCase {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadMessageDateFailsWithHSMFDump() throws Exception {
|
public void testReadMessageDateFailsWithHSMFDump() throws Exception {
|
||||||
PrintStream stream = new PrintStream(new ByteArrayOutputStream());
|
PrintStream stream = new PrintStream(new ByteArrayOutputStream());
|
||||||
HSMFDump dump = new HSMFDump(fsMessageFails);
|
HSMFDump dump = new HSMFDump(fsMessageFails);
|
||||||
dump.dump(stream);
|
dump.dump(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,117 +29,117 @@ import junit.framework.TestCase;
|
|||||||
* Tests to verify that we can still work on the newer Outlook 3.0 files.
|
* Tests to verify that we can still work on the newer Outlook 3.0 files.
|
||||||
*/
|
*/
|
||||||
public final class TestOutlook30FileRead extends TestCase {
|
public final class TestOutlook30FileRead extends TestCase {
|
||||||
private MAPIMessage mapiMessage;
|
private MAPIMessage mapiMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this test, load up the blank.msg mapi message.
|
* Initialize this test, load up the blank.msg mapi message.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public TestOutlook30FileRead() throws IOException {
|
public TestOutlook30FileRead() throws IOException {
|
||||||
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
||||||
this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("outlook_30_msg.msg"));
|
this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("outlook_30_msg.msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayCC() throws ChunkNotFoundException {
|
public void testReadDisplayCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayCC();
|
String obtained = mapiMessage.getDisplayCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayTo() throws ChunkNotFoundException {
|
public void testReadDisplayTo() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayTo();
|
String obtained = mapiMessage.getDisplayTo();
|
||||||
|
|
||||||
assertTrue(obtained.startsWith("Bohn, Shawn"));
|
assertTrue(obtained.startsWith("Bohn, Shawn"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the From Chunk.
|
* Test to see if we can read the From Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayFrom() throws ChunkNotFoundException {
|
public void testReadDisplayFrom() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayFrom();
|
String obtained = mapiMessage.getDisplayFrom();
|
||||||
String expected = "Cramer, Nick";
|
String expected = "Cramer, Nick";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayBCC();
|
String obtained = mapiMessage.getDisplayBCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the body of the blank message, we expect "".
|
* Check if we can read the body of the blank message, we expect "".
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadBody() throws Exception {
|
public void testReadBody() throws Exception {
|
||||||
String obtained = mapiMessage.getTextBody();
|
String obtained = mapiMessage.getTextBody();
|
||||||
assertTrue(obtained.startsWith("I am shutting down"));
|
assertTrue(obtained.startsWith("I am shutting down"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadSubject() throws Exception {
|
public void testReadSubject() throws Exception {
|
||||||
String obtained = mapiMessage.getSubject();
|
String obtained = mapiMessage.getSubject();
|
||||||
String expected = "IN-SPIRE servers going down for a bit, back up around 8am";
|
String expected = "IN-SPIRE servers going down for a bit, back up around 8am";
|
||||||
|
|
||||||
TestCase.assertEquals(expected, obtained);
|
TestCase.assertEquals(expected, obtained);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadConversationTopic() throws Exception {
|
public void testReadConversationTopic() throws Exception {
|
||||||
String obtained = mapiMessage.getConversationTopic();
|
String obtained = mapiMessage.getConversationTopic();
|
||||||
TestCase.assertEquals("IN-SPIRE servers going down for a bit, back up around 8am", obtained);
|
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 ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadMessageClass() throws Exception {
|
public void testReadMessageClass() throws Exception {
|
||||||
String obtained = mapiMessage.getMessageClass();
|
String obtained = mapiMessage.getMessageClass();
|
||||||
TestCase.assertEquals("IPM.Note", obtained);
|
TestCase.assertEquals("IPM.Note", obtained);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure we can get the HTML and RTF versions
|
* Ensure we can get the HTML and RTF versions
|
||||||
*/
|
*/
|
||||||
public void testReadBodyContents() throws Exception {
|
public void testReadBodyContents() throws Exception {
|
||||||
String html = mapiMessage.getHtmlBody();
|
String html = mapiMessage.getHtmlBody();
|
||||||
String rtf = mapiMessage.getRtfBody();
|
String rtf = mapiMessage.getRtfBody();
|
||||||
assertNotNull(html);
|
assertNotNull(html);
|
||||||
assertNotNull(rtf);
|
assertNotNull(rtf);
|
||||||
|
|
||||||
assertTrue("Wrong text:\n" + html, html.startsWith("<!DOCTYPE"));
|
assertTrue("Wrong text:\n" + html, html.startsWith("<!DOCTYPE"));
|
||||||
assertTrue("Wrong text:\n" + rtf, rtf.startsWith("{\\rtf1"));
|
assertTrue("Wrong text:\n" + rtf, rtf.startsWith("{\\rtf1"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,117 +26,112 @@ import org.apache.poi.POIDataSamples;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests to verify that we can read a simple msg file, that is in plain/text format with no attachments
|
* Tests to verify that we can read a simple msg file, that is in plain/text
|
||||||
* or extra recipents.
|
* format with no attachments or extra recipents.
|
||||||
*
|
|
||||||
* @author Travis Ferguson
|
|
||||||
*/
|
*/
|
||||||
public final class TestSimpleFileRead extends TestCase {
|
public final class TestSimpleFileRead extends TestCase {
|
||||||
private MAPIMessage mapiMessage;
|
private MAPIMessage mapiMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this test, load up the blank.msg mapi message.
|
* Initialize this test, load up the blank.msg mapi message.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public TestSimpleFileRead() throws IOException {
|
public TestSimpleFileRead() throws IOException {
|
||||||
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
||||||
this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("simple_test_msg.msg"));
|
this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("simple_test_msg.msg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayCC() throws ChunkNotFoundException {
|
public void testReadDisplayCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayCC();
|
String obtained = mapiMessage.getDisplayCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayTo() throws ChunkNotFoundException {
|
public void testReadDisplayTo() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayTo();
|
String obtained = mapiMessage.getDisplayTo();
|
||||||
String expected = "travis@overwrittenstack.com";
|
String expected = "travis@overwrittenstack.com";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the From Chunk.
|
* Test to see if we can read the From Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayFrom() throws ChunkNotFoundException {
|
public void testReadDisplayFrom() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayFrom();
|
String obtained = mapiMessage.getDisplayFrom();
|
||||||
String expected = "Travis Ferguson";
|
String expected = "Travis Ferguson";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
* @throws ChunkNotFoundException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayBCC();
|
String obtained = mapiMessage.getDisplayBCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the body of the blank message, we expect "".
|
* Check if we can read the body of the blank message, we expect "".
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadBody() throws Exception {
|
public void testReadBody() throws Exception {
|
||||||
String obtained = mapiMessage.getTextBody();
|
String obtained = mapiMessage.getTextBody();
|
||||||
String expected = "This is a test message.";
|
String expected = "This is a test message.";
|
||||||
|
|
||||||
TestCase.assertEquals(obtained, expected);
|
TestCase.assertEquals(obtained, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testReadSubject() throws Exception {
|
public void testReadSubject() throws Exception {
|
||||||
String obtained = mapiMessage.getSubject();
|
String obtained = mapiMessage.getSubject();
|
||||||
String expected = "test message";
|
String expected = "test message";
|
||||||
|
|
||||||
TestCase.assertEquals(expected, obtained);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user