]> source.dussan.org Git - poi.git/commitdiff
Try to reproduce bug 52258 and add more checks to integration tests
authorDominik Stadler <centic@apache.org>
Sun, 3 Jan 2016 21:23:09 +0000 (21:23 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 3 Jan 2016 21:23:09 +0000 (21:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1722755 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java
src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java

index 6a53b2e00995fea2a9493820e08bbdeeb8be6bf7..6a84201b457973c1733e8959cf597f7d208eb9d4 100644 (file)
@@ -26,12 +26,14 @@ import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 
-public class HPSFFileHandler extends AbstractFileHandler {
+public class HPSFFileHandler extends POIFSFileHandler {
        @Override
     public void handleFile(InputStream stream) throws Exception {
                HPSFPropertiesOnlyDocument hpsf = new HPSFPropertiesOnlyDocument(new POIFSFileSystem(stream));
                assertNotNull(hpsf.getDocumentSummaryInformation());
                assertNotNull(hpsf.getSummaryInformation());
+               
+               handlePOIDocument(hpsf);
        }
        
        // a test-case to test this locally without executing the full TestAllFiles
index 8c442ca8dec492c119f8841131cc23aa231c7f28..56be0d9eed53a931a7a01a7c38a23a1f31ecba86 100644 (file)
@@ -20,21 +20,45 @@ import static org.junit.Assert.assertNotNull;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.poi.POIDocument;
+import org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.junit.Test;
 
 public class POIFSFileHandler extends AbstractFileHandler {
 
        @Override
     public void handleFile(InputStream stream) throws Exception {
                POIFSFileSystem fs = new POIFSFileSystem(stream);
-               handlePOIFSFileSystem(fs);
-               fs.close();
+               try {
+                   handlePOIFSFileSystem(fs);
+                   handleHPSFProperties(fs);
+               } finally {
+                   fs.close();
+               }
        }
 
-       private void handlePOIFSFileSystem(POIFSFileSystem fs) {
+       private void handleHPSFProperties(POIFSFileSystem fs) throws IOException {
+        HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
+        try {
+            // can be null
+            ext.getDocSummaryInformation();
+            ext.getSummaryInformation();
+            
+            assertNotNull(ext.getDocumentSummaryInformationText());
+            assertNotNull(ext.getSummaryInformationText());
+            assertNotNull(ext.getText());
+        } finally {
+            ext.close();
+        }
+    }
+
+    private void handlePOIFSFileSystem(POIFSFileSystem fs) {
                assertNotNull(fs);
                assertNotNull(fs.getRoot());
        }
@@ -48,4 +72,19 @@ public class POIFSFileHandler extends AbstractFileHandler {
                handlePOIFSFileSystem(fs);
                fs.close();
        }
+       
+    // a test-case to test this locally without executing the full TestAllFiles
+    @Test
+    public void test() throws Exception {
+        File file = new File("test-data/poifs/Notes.ole2");
+
+        InputStream stream = new FileInputStream(file);
+        try {
+            handleFile(stream);
+        } finally {
+            stream.close();
+        }
+        
+        //handleExtracting(file);
+    }
 }
index 0ef39719d4641ec3d590f7b26a651303083315e1..475741f88fc58db827b4dd5d8308f4ea0bb16b18 100644 (file)
@@ -166,4 +166,18 @@ public final class TestHPSFPropertiesExtractor extends TestCase {
         assertNotNull(thumbnail.getThumbnailAsWMF());
         wb.close();
     }
+
+    public void test52258() throws Exception {
+        POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestVisioWithCodepage.vsd"));
+        HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
+        try {
+            assertNotNull(ext.getDocSummaryInformation());
+            assertNotNull(ext.getDocumentSummaryInformationText());
+            assertNotNull(ext.getSummaryInformation());
+            assertNotNull(ext.getSummaryInformationText());
+            assertNotNull(ext.getText());
+        } finally {
+            ext.close();
+        }
+    }
 }