aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java
index 27d69f69f0..24f3259380 100644
--- a/src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java
+++ b/src/scratchpad/testcases/org/apache/poi/hmef/TestBugs.java
@@ -16,40 +16,41 @@
==================================================================== */
package org.apache.poi.hmef;
+import static org.apache.poi.hmef.TestHMEFMessage.openSample;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import org.apache.poi.POIDataSamples;
+import java.io.IOException;
+import java.util.List;
+
import org.apache.poi.hmef.attribute.MAPIAttribute;
import org.apache.poi.hmef.attribute.TNEFAttribute;
import org.apache.poi.hmef.attribute.TNEFProperty;
import org.apache.poi.hsmf.datatypes.MAPIProperty;
import org.apache.poi.util.LittleEndian;
-
import org.junit.Test;
public class TestBugs {
@Test
- public void test52400ReadSimpleTNEF() throws Exception {
- POIDataSamples samples = POIDataSamples.getHMEFInstance();
- String testFile = "bug52400-winmail-simple.dat";
- HMEFMessage tnefDat = new HMEFMessage(samples.openResourceAsStream(testFile));
+ public void test52400ReadSimpleTNEF() throws IOException {
+ HMEFMessage tnefDat = openSample("bug52400-winmail-simple.dat");
MAPIAttribute bodyHtml = tnefDat.getMessageMAPIAttribute(MAPIProperty.BODY_HTML);
+ assertNotNull(bodyHtml);
String bodyStr = new String(bodyHtml.getData(), getEncoding(tnefDat));
assertTrue(bodyStr.contains("This is the message body."));
}
-
+
@Test
- public void test52400ReadAttachedTNEF() throws Exception {
- POIDataSamples samples = POIDataSamples.getHMEFInstance();
- String testFile = "bug52400-winmail-with-attachments.dat";
- HMEFMessage tnefDat = new HMEFMessage(samples.openResourceAsStream(testFile));
+ public void test52400ReadAttachedTNEF() throws IOException {
+ HMEFMessage tnefDat = openSample("bug52400-winmail-with-attachments.dat");
MAPIAttribute bodyHtml = tnefDat.getMessageMAPIAttribute(MAPIProperty.BODY_HTML);
+ assertNotNull(bodyHtml);
String bodyStr = new String(bodyHtml.getData(), getEncoding(tnefDat));
assertTrue(bodyStr.contains("There are also two attachments."));
assertEquals(2, tnefDat.getAttachments().size());
}
-
+
private String getEncoding(HMEFMessage tnefDat) {
TNEFAttribute oemCP = tnefDat.getMessageAttribute(TNEFProperty.ID_OEMCODEPAGE);
MAPIAttribute cpId = tnefDat.getMessageMAPIAttribute(MAPIProperty.INTERNET_CPID);
@@ -66,4 +67,15 @@ public class TestBugs {
default: return "cp"+codePage;
}
}
+
+ @Test
+ public void bug63955() throws IOException {
+ HMEFMessage tnefDat = openSample("bug63955-winmail.dat");
+ List<MAPIAttribute> atts = tnefDat.getMessageMAPIAttributes();
+ assertEquals(96, atts.size());
+ MAPIAttribute bodyHtml = tnefDat.getMessageMAPIAttribute(MAPIProperty.BODY_HTML);
+ assertNotNull(bodyHtml);
+ String bodyStr = new String(bodyHtml.getData(), getEncoding(tnefDat));
+ assertEquals(1697, bodyStr.length());
+ }
}