]> source.dussan.org Git - poi.git/commitdiff
Add test-document to verify that bug 51921 is fixed already
authorDominik Stadler <centic@apache.org>
Sun, 22 Mar 2015 21:47:19 +0000 (21:47 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 22 Mar 2015 21:47:19 +0000 (21:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1668482 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java
src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java
src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
test-data/document/51921-Word-Crash067.doc [new file with mode: 0644]
test-data/document/51921-Word-Crash067.docx [new file with mode: 0644]

index 31ad8bc12399c1d25d4655e3a2b7ecd23d5e42fc..a41b6ebadf44be02f285e5f25bc9a4241600b902 100644 (file)
@@ -18,10 +18,12 @@ package org.apache.poi.stress;
 
 import static org.junit.Assert.assertNotNull;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
 import org.apache.poi.hpbf.HPBFDocument;
+import org.apache.poi.hpbf.extractor.PublisherTextExtractor;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 
@@ -39,11 +41,28 @@ public class HPBFFileHandler extends POIFSFileHandler {
        // a test-case to test this locally without executing the full TestAllFiles
        @Test
        public void test() throws Exception {
-               InputStream stream = new FileInputStream("test-data/publisher/SampleBrochure.pub");
+               File file = new File("test-data/publisher/SampleBrochure.pub");
+
+               InputStream stream = new FileInputStream(file);
                try {
                        handleFile(stream);
                } finally {
                        stream.close();
                }
+               
+               handleExtracting(file);
+               
+               stream = new FileInputStream(file);
+               try {
+                       PublisherTextExtractor extractor = new PublisherTextExtractor(stream);
+                       try {
+                               assertNotNull(extractor.getText());
+                       } finally {
+                               extractor.close();
+                       }
+               } finally {
+                       stream.close();
+               }
        }
+       
 }
index 5f24337fbb722a33c150e6723a3a122c6f16e5fb..3a223674cdd43a887a07189fdcaaf5021f264edd 100644 (file)
@@ -68,7 +68,7 @@ public class HWPFFileHandler extends POIFSFileHandler {
        // a test-case to test this locally without executing the full TestAllFiles
        @Test
        public void test() throws Exception {
-               File file = new File("test-data/document/47304.doc");
+               File file = new File("test-data/document/51921-Word-Crash067.doc");
 
                InputStream stream = new FileInputStream(file);
                try {
@@ -91,4 +91,4 @@ public class HWPFFileHandler extends POIFSFileHandler {
                        stream.close();
                }
        }
-}
\ No newline at end of file
+}
index 47c18d8aa051f0da9712acfe701e8b88dbb25e94..c097dc9f71cc138c632dbd16825f5b8840fa1086 100644 (file)
 ==================================================================== */
 package org.apache.poi.stress;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.io.PushbackInputStream;
 
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.junit.Test;
@@ -36,12 +38,16 @@ public class XWPFFileHandler extends AbstractFileHandler {
        // a test-case to test this locally without executing the full TestAllFiles
        @Test
        public void test() throws Exception {
-               InputStream stream = new FileInputStream("test-data/document/footnotes.docx");
+               File file = new File("test-data/document/51921-Word-Crash067.docx");
+
+               InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000);
                try {
                        handleFile(stream);
                } finally {
                        stream.close();
                }
+               
+               handleExtracting(file);
        }
        
 }
\ No newline at end of file
diff --git a/test-data/document/51921-Word-Crash067.doc b/test-data/document/51921-Word-Crash067.doc
new file mode 100644 (file)
index 0000000..dc8bfff
Binary files /dev/null and b/test-data/document/51921-Word-Crash067.doc differ
diff --git a/test-data/document/51921-Word-Crash067.docx b/test-data/document/51921-Word-Crash067.docx
new file mode 100644 (file)
index 0000000..12c27c8
Binary files /dev/null and b/test-data/document/51921-Word-Crash067.docx differ