]> source.dussan.org Git - poi.git/commitdiff
add an ignored test for bug 58804
authorDominik Stadler <centic@apache.org>
Mon, 25 Jan 2016 20:21:30 +0000 (20:21 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 25 Jan 2016 20:21:30 +0000 (20:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1726681 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
test-data/document/58804.doc [new file with mode: 0644]
test-data/document/58804_1.doc [new file with mode: 0644]

index 3aebf1401f6925b49c39daa5e639e5c300a23364..fbd466e983744294b5e6b766e00f71a3ead7c5e4 100644 (file)
@@ -18,14 +18,14 @@ package org.apache.poi.hwpf.usermodel;
 
 import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hwpf.HWPFDocument;
@@ -37,6 +37,7 @@ import org.apache.poi.hwpf.extractor.Word6Extractor;
 import org.apache.poi.hwpf.extractor.WordExtractor;
 import org.apache.poi.hwpf.model.FieldsDocumentPart;
 import org.apache.poi.hwpf.model.FileInformationBlock;
+import org.apache.poi.hwpf.model.PicturesTable;
 import org.apache.poi.hwpf.model.PlexOfField;
 import org.apache.poi.hwpf.model.SubdocumentType;
 import org.apache.poi.hwpf.model.io.HWPFOutputStream;
@@ -45,6 +46,8 @@ import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 
+import junit.framework.TestCase;
+
 /**
  * Test different problems reported in Apache Bugzilla
  * 
@@ -183,6 +186,7 @@ public class TestBugs extends TestCase
      * Bug 44331 - HWPFDocument.write destroys fields
      * @throws IOException 
      */
+    @SuppressWarnings("deprecation")
     public void test44431() throws IOException
     {
         HWPFDocument doc1 = HWPFTestDataSamples.openSampleFile("Bug44431.doc");
@@ -306,6 +310,7 @@ public class TestBugs extends TestCase
      * 
      * @throws IOException
      */
+    @SuppressWarnings("deprecation")
     public void test47286() throws IOException
     {
         HWPFDocument doc1 = HWPFTestDataSamples.openSampleFile("Bug47286.doc");
index 72b692e882ad042ec1750fc351e542487b42b7bf..d1d340433cbee708e0127ae1d5f9c7829684759c 100644 (file)
@@ -21,12 +21,15 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.FileOutputStream;
+import java.io.OutputStream;
 import java.util.List;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFTestDataSamples;
 import org.apache.poi.hwpf.model.PicturesTable;
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -357,4 +360,42 @@ public final class TestPictures {
 
         assertEquals("This is the alternative text for the picture.", picture.getDescription());
     }
+    
+    @Ignore("This bug is not fixed yet")
+    @Test
+    public void test58804_1() throws Exception {
+        HWPFDocument docA = HWPFTestDataSamples.openSampleFile("58804_1.doc");
+        
+        expectImages(docA, 1);
+
+        HWPFDocument docB = HWPFTestDataSamples.writeOutAndReadBack(docA);
+        
+        OutputStream out = new FileOutputStream("/tmp/58804_1_out.doc");
+        try {
+            docB.write(out);
+        } finally {
+            out.close();
+        }
+
+        expectImages(docB, 1);
+    }
+
+    @Ignore("This bug is not fixed yet")
+    @Test
+    public void test58804() throws Exception {
+        HWPFDocument docA = HWPFTestDataSamples.openSampleFile("58804.doc");
+        
+        expectImages(docA, 7);
+
+        HWPFDocument docB = HWPFTestDataSamples.writeOutAndReadBack(docA);
+
+        expectImages(docB, 7);
+    }
+
+    private void expectImages(HWPFDocument docA, int expectedCount) {
+        assertNotNull(docA.getPicturesTable());
+        PicturesTable picA = docA.getPicturesTable();
+        List<Picture> picturesA = picA.getAllPictures();
+        assertEquals(expectedCount, picturesA.size());
+    }
 }
diff --git a/test-data/document/58804.doc b/test-data/document/58804.doc
new file mode 100644 (file)
index 0000000..6461273
Binary files /dev/null and b/test-data/document/58804.doc differ
diff --git a/test-data/document/58804_1.doc b/test-data/document/58804_1.doc
new file mode 100644 (file)
index 0000000..c792079
Binary files /dev/null and b/test-data/document/58804_1.doc differ