]> source.dussan.org Git - poi.git/commitdiff
IntegrationTest - move excludes to file handler
authorAndreas Beeker <kiwiwings@apache.org>
Tue, 2 May 2017 23:25:45 +0000 (23:25 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Tue, 2 May 2017 23:25:45 +0000 (23:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1793595 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
src/integrationtest/org/apache/poi/TestAllFiles.java
src/integrationtest/org/apache/poi/stress/FileHandler.java
src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java
src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java
src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java
src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java
src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java
src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java
src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java
src/integrationtest/org/apache/poi/stress/OPCFileHandler.java
src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java
src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java
src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java
src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java
src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java

index e61df18ce15a744b1187c57e21d282ccc75e1b03..9a589bbe94047815c608eed3c7b8bbc1210dd75b 100644 (file)
@@ -52,6 +52,7 @@ import org.apache.poi.stress.XSSFBFileHandler;
 import org.apache.poi.stress.XSSFFileHandler;
 import org.apache.poi.stress.XWPFFileHandler;
 import org.apache.tools.ant.DirectoryScanner;
+import org.junit.AssumptionViolatedException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -84,7 +85,6 @@ import org.junit.runners.Parameterized.Parameters;
  */
 @RunWith(Parameterized.class)
 public class TestAllFiles {
-
     private static final File ROOT_DIR = new File("test-data");
 
     static final String[] SCAN_EXCLUDES = new String[] { "**/.svn/**", "lost+found" };
@@ -202,15 +202,15 @@ public class TestAllFiles {
         HANDLERS.put("spreadsheet/test_properties1", new NullFileHandler());
     }
 
-    private static Set<String> unmodifiableHashSet(String... a) {
+    private static final Set<String> unmodifiableHashSet(String... a) {
         return Collections.unmodifiableSet(hashSet(a));
     }
-    private static Set<String> hashSet(String... a) {
+    private static final Set<String> hashSet(String... a) {
         return new HashSet<String>(Arrays.asList(a));
     }
 
     // Old Word Documents where we can at least extract some text
-    private static final Set<String> OLD_FILES = unmodifiableHashSet(
+    private static final Set<String> OLD_FILES_HWPF = unmodifiableHashSet(
         "document/Bug49933.doc",
         "document/Bug51944.doc",
         "document/Word6.doc",
@@ -222,7 +222,9 @@ public class TestAllFiles {
         "document/Bug60942.doc",
         "document/Bug60942b.doc",
         "hpsf/TestMickey.doc",
-        "document/52117.doc"
+        "document/52117.doc",
+        "hpsf/TestInvertedClassID.doc",
+        "hpsf/TestBug52117.doc"
     );
 
     private static final Set<String> EXPECTED_FAILURES = unmodifiableHashSet(
@@ -320,7 +322,7 @@ public class TestAllFiles {
         // OPC handler works / XSSF handler fails
         "spreadsheet/57181.xlsm"
     );
-    
+
     @Parameters(name="{index}: {0} using {1}")
     public static Iterable<Object[]> files() {
         DirectoryScanner scanner = new DirectoryScanner();
@@ -346,7 +348,14 @@ public class TestAllFiles {
                 handler instanceof XWPFFileHandler ||
                 handler instanceof XSLFFileHandler ||
                 handler instanceof XDGFFileHandler) {
-                files.add(new Object[] { file, HANDLERS.get(".ooxml") });
+                files.add(new Object[] { file, new OPCFileHandler() });
+            }
+            
+            if (handler instanceof HSSFFileHandler ||
+                handler instanceof HSLFFileHandler ||
+                handler instanceof HWPFFileHandler ||
+                handler instanceof HDGFFileHandler) {
+                files.add(new Object[] { file, new HPSFFileHandler() });
             }
         }
 
@@ -359,36 +368,37 @@ public class TestAllFiles {
 
     @Parameter(value=1)
     public FileHandler handler;
-
+    
     @Test
     public void testAllFiles() throws Exception {
         System.out.println("Reading " + file + " with " + handler.getClass());
         assertNotNull("Unknown file extension for file: " + file + ": " + getExtension(file), handler);
         File inputFile = new File(ROOT_DIR, file);
 
+        // special cases where docx-handling breaks, but OPCPackage handling works
+        boolean ignoredOPC = (file.endsWith(".docx") || file.endsWith(".xlsx") ||
+                    file.endsWith(".xlsb") || file.endsWith(".pptx")) &&
+                handler instanceof OPCFileHandler;
+        boolean ignoreHPSF = (handler instanceof HPSFFileHandler);
+        
+        
         try {
             InputStream stream = new BufferedInputStream(new FileInputStream(inputFile), 64*1024);
             try {
-                handler.handleFile(stream);
-
+                handler.handleFile(stream, file);
                 assertFalse("Expected to fail for file " + file + " and handler " + handler + ", but did not fail!", 
-                        OLD_FILES.contains(file));
+                    OLD_FILES_HWPF.contains(file) && !ignoreHPSF);
             } finally {
                 stream.close();
             }
 
             handler.handleExtracting(inputFile);
 
-            // special cases where docx-handling breaks, but OPCPackage handling works
-            boolean ignoredOPC = (file.endsWith(".docx") || file.endsWith(".xlsx") ||
-                        file.endsWith(".xlsb") || file.endsWith(".pptx")) &&
-                    handler instanceof OPCFileHandler;
-
             assertFalse("Expected to fail for file " + file + " and handler " + handler + ", but did not fail!", 
-                EXPECTED_FAILURES.contains(file) && !ignoredOPC);
+                EXPECTED_FAILURES.contains(file) && !ignoredOPC && !ignoreHPSF);
         } catch (OldFileFormatException e) {
             // for old word files we should still support extracting text
-            if(OLD_FILES.contains(file)) {
+            if(OLD_FILES_HWPF.contains(file)) {
                 handler.handleExtracting(inputFile);
             } else {
                 // check if we expect failure for this file
@@ -397,6 +407,8 @@ public class TestAllFiles {
                     throw new Exception("While handling " + file, e);
                 }
             }
+        } catch (AssumptionViolatedException e) {
+            // file handler ignored this file
         } catch (Exception e) {
             // check if we expect failure for this file
             if(!EXPECTED_FAILURES.contains(file) && !AbstractFileHandler.EXPECTED_EXTRACTOR_FAILURES.contains(file)) {
@@ -420,7 +432,7 @@ public class TestAllFiles {
 
     private static class NullFileHandler implements FileHandler {
         @Override
-        public void handleFile(InputStream stream) throws Exception {
+        public void handleFile(InputStream stream, String path) throws Exception {
         }
 
         @Override
index c1888e7314c4dde794029f30b63a5fee44310e4b..aef3878afa1227c6984158b9d054111993a1f821 100644 (file)
@@ -32,9 +32,10 @@ public interface FileHandler {
         * Closing is handled by the framework outside this call.
         *
         * @param stream The input stream to read the file from.
+        * @param path the relative path to the file
         * @throws Exception If an error happens in the file-specific handler
         */
-       void handleFile(InputStream stream) throws Exception;
+       void handleFile(InputStream stream, String path) throws Exception;
        
        /**
         * Ensures that extracting text from the given file
index 758a3ad294dea798b728c5ab6c42d2d137dc95ba..a325f0d5ea89c473dd9e46635aa05759ecbec16b 100644 (file)
@@ -33,7 +33,7 @@ import org.junit.Test;
 
 public class HDGFFileHandler extends POIFSFileHandler {
        @Override
-       public void handleFile(InputStream stream) throws IOException {
+       public void handleFile(InputStream stream, String path) throws IOException {
            POIFSFileSystem poifs = new POIFSFileSystem(stream);
                HDGFDiagram diagram = new HDGFDiagram(poifs);
                Stream[] topLevelStreams = diagram.getTopLevelStreams();
@@ -55,11 +55,11 @@ public class HDGFFileHandler extends POIFSFileHandler {
        @Override
     @Test
        public void test() throws Exception {
-               File file = new File("test-data/diagram/44501.vsd");
+        File file = new File("test-data/diagram/44501.vsd");
 
-               InputStream stream = new FileInputStream(file);
+        InputStream stream = new FileInputStream(file);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
index 30e98af59a81d15aff4274fe74e091985e294190..4532ab0503c0f01f9deed7798b91d252fe9deb1b 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Test;
 public class HMEFFileHandler extends AbstractFileHandler {
 
        @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
                HMEFMessage msg = new HMEFMessage(stream);
                
                // list all properties
@@ -50,9 +50,10 @@ public class HMEFFileHandler 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/hmef/quick-winmail.dat");
+           String path = "test-data/hmef/quick-winmail.dat";
+               InputStream stream = new FileInputStream(path);
                try {
-                       handleFile(stream);
+                       handleFile(stream, path);
                } finally {
                        stream.close();
                }
index 093ef0274b281d6af1e28b89c0b52a9344512159..788f9da613bd945f055e1ab30efc4a366a0cbe0d 100644 (file)
@@ -29,24 +29,25 @@ import org.junit.Test;
 
 public class HPBFFileHandler extends POIFSFileHandler {
        @Override
-       public void handleFile(InputStream stream) throws Exception {
+       public void handleFile(InputStream stream, String path) throws Exception {
                HPBFDocument pub = new HPBFDocument(new POIFSFileSystem(stream));
                assertNotNull(pub.getEscherDelayStm());
                assertNotNull(pub.getMainContents());
                assertNotNull(pub.getQuillContents());
                
                // writing is not yet implemented... handlePOIDocument(pub);
+               pub.close();
        }
        
        // a test-case to test this locally without executing the full TestAllFiles
        @Override
     @Test
        public void test() throws Exception {
-               File file = new File("test-data/publisher/SampleBrochure.pub");
+        File file = new File("test-data/publisher/SampleBrochure.pub");
 
-               InputStream stream = new FileInputStream(file);
+        InputStream stream = new FileInputStream(file);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
index b9cff7650d75bf8573ae8d39d2ac0953f9e88c73..fcf0324fe9f2ee63c8fbfc233acbb77da0c1f157 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Test;
 
 public class HSLFFileHandler extends SlideShowHandler {
        @Override
-       public void handleFile(InputStream stream) throws Exception {
+       public void handleFile(InputStream stream, String path) throws Exception {
                HSLFSlideShowImpl slide = new HSLFSlideShowImpl(stream);
                assertNotNull(slide.getCurrentUserAtom());
                assertNotNull(slide.getEmbeddedObjects());
@@ -40,13 +40,13 @@ public class HSLFFileHandler extends SlideShowHandler {
                    assertNotNull("Found a record which was null", record);
                        assertTrue(record.getRecordType() >= 0);
                }
-
+               
                handlePOIDocument(slide);
-
+               
                HSLFSlideShow ss = new HSLFSlideShow(slide);
                handleSlideShow(ss);
        }
-
+       
        @Test
        public void testOne() throws Exception {
                testOneFile(new File("test-data/slideshow/54880_chinese.ppt"));
@@ -81,10 +81,10 @@ public class HSLFFileHandler extends SlideShowHandler {
                //System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
                InputStream stream = new FileInputStream(file);
                try {
-            handleFile(stream);
-        } finally {
-            stream.close();
-        }
+            handleFile(stream, file.getPath());
+               } finally {
+                       stream.close();
+               }
 
                handleExtracting(file);
        }
@@ -93,7 +93,7 @@ public class HSLFFileHandler extends SlideShowHandler {
           System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
           InputStream stream = new FileInputStream(args[0]);
           try {
-                  new HSLFFileHandler().handleFile(stream);
+                  new HSLFFileHandler().handleFile(stream, args[0]);
           } finally {
                   stream.close();
           }
index 1d40e6f4b08b97348e1c8014000ec1d27a338d1e..61d10789cb11a5a701a02a31bbd7ab8fb259c966 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Test;
 
 public class HSMFFileHandler extends POIFSFileHandler {
        @Override
-       public void handleFile(InputStream stream) throws Exception {
+       public void handleFile(InputStream stream, String path) throws Exception {
                MAPIMessage mapi = new MAPIMessage(stream);
                assertNotNull(mapi.getAttachmentFiles());
                assertNotNull(mapi.getDisplayBCC());
@@ -60,6 +60,8 @@ public class HSMFFileHandler extends POIFSFileHandler {
                */
                
                // writing is not yet supported... handlePOIDocument(mapi);
+               
+               mapi.close();
        }
        
 //     private void writeToFile(MAPIMessage mapi, File file)
@@ -76,10 +78,10 @@ public class HSMFFileHandler extends POIFSFileHandler {
        @Override
     @Test
        public void test() throws Exception {
-               File file = new File("test-data/hsmf/logsat.com_signatures_valid.msg");
+        File file = new File("test-data/hsmf/logsat.com_signatures_valid.msg");
         InputStream stream = new FileInputStream(file);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
index 2743738eb15ac89cebbd617123e4c684a244f982..c2928e72c0b8e754329b6a2b5b40ebe27fa711ad 100644 (file)
@@ -32,7 +32,7 @@ import static org.junit.Assert.assertFalse;
 public class HSSFFileHandler extends SpreadsheetHandler {
        private final POIFSFileHandler delegate = new POIFSFileHandler();
        @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
                HSSFWorkbook wb = new HSSFWorkbook(stream);
                handleWorkbook(wb);
                
@@ -100,14 +100,19 @@ public class HSSFFileHandler extends SpreadsheetHandler {
        // a test-case to test this locally without executing the full TestAllFiles
        @Test
        public void test() throws Exception {
-           File file = new File("test-data/spreadsheet/49219.xls");
-               
+        File file = new File("test-data/spreadsheet/49219.xls");
+        
                InputStream stream = new FileInputStream(file);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
-        handleExtracting(file);
        }
+
+       // a test-case to test this locally without executing the full TestAllFiles
+    @Test
+    public void testExtractor() throws Exception {
+        handleExtracting(new File("test-data/spreadsheet/BOOK_in_capitals.xls"));
+    }
 }
\ No newline at end of file
index d762598a4c5aa3704d8d99bd28abfb0b02631879..d4ec360062644ae023407f12149607256d05bf6a 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Test;
 
 public class HWPFFileHandler extends POIFSFileHandler {
        @Override
-       public void handleFile(InputStream stream) throws Exception {
+       public void handleFile(InputStream stream, String path) throws Exception {
                HWPFDocument doc = new HWPFDocument(stream);
                assertNotNull(doc.getBookmarks());
                assertNotNull(doc.getCharacterTable());
@@ -41,11 +41,11 @@ public class HWPFFileHandler extends POIFSFileHandler {
        @Override
     @Test
        public void test() throws Exception {
-               File file = new File("test-data/document/52117.doc");
+        File file = new File("test-data/document/52117.doc");
 
-               InputStream stream = new FileInputStream(file);
+        InputStream stream = new FileInputStream(file);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
index ca019ae51d9cfc03ba0abc74d12f03151e5c7bf9..cd9e93c09242cb3a245323c0d4c499eef8b90a12 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.Test;
 
 public class OPCFileHandler extends AbstractFileHandler {
        @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
         // ignore password protected files
         if (POIXMLDocumentHandler.isEncrypted(stream)) return;
 
@@ -63,11 +63,11 @@ public class OPCFileHandler extends AbstractFileHandler {
        // a test-case to test this locally without executing the full TestAllFiles
        @Test
        public void test() throws Exception {
-               File file = new File("test-data/diagram/test.vsdx");
+        File file = new File("test-data/diagram/test.vsdx");
 
-               InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000);
+        InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
index 56be0d9eed53a931a7a01a7c38a23a1f31ecba86..309949b33f4ff1dcb9036e9ed6eeab62cd94e79f 100644 (file)
@@ -33,7 +33,7 @@ import org.junit.Test;
 public class POIFSFileHandler extends AbstractFileHandler {
 
        @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
                POIFSFileSystem fs = new POIFSFileSystem(stream);
                try {
                    handlePOIFSFileSystem(fs);
@@ -80,7 +80,7 @@ public class POIFSFileHandler extends AbstractFileHandler {
 
         InputStream stream = new FileInputStream(file);
         try {
-            handleFile(stream);
+            handleFile(stream, file.getPath());
         } finally {
             stream.close();
         }
index 9b7d03f8a5798975164f65ea849710ca29777ffe..a9845b6fda482dfed6b4e9040e9cf68f8a457a7d 100644 (file)
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class XDGFFileHandler extends AbstractFileHandler {
     @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
         // ignore password protected files
         if (POIXMLDocumentHandler.isEncrypted(stream)) return;
 
index ce5e0c0408093a62fafec19359ca86ec9108ef78..a45dead45071ededb72fbd7d46732a4ef6f19f86 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.Test;
 
 public class XSLFFileHandler extends SlideShowHandler {
        @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
            XMLSlideShow slide = new XMLSlideShow(stream);
            XSLFSlideShow slideInner = new XSLFSlideShow(slide.getPackage());
                assertNotNull(slideInner.getPresentation());
@@ -69,14 +69,14 @@ public class XSLFFileHandler extends SlideShowHandler {
        @Override
     @Test
        public void test() throws Exception {
-               File file = new File("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx");
-               InputStream stream = new FileInputStream(file);
+        File file = new File("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx");
+        InputStream stream = new FileInputStream(file);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }
 
-        handleExtracting(file);
-   }
-}
+               handleExtracting(file);
+       }
+}
\ No newline at end of file
index 0d71de7e8af45838663a219a32d96a124a3990f3..6bf099f4ac4336255837d90bff1c39097a6f6187 100644 (file)
@@ -37,7 +37,7 @@ public class XSSFBFileHandler extends AbstractFileHandler {
     }
 
     @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         IOUtils.copy(stream, out);
 
@@ -54,7 +54,7 @@ public class XSSFBFileHandler extends AbstractFileHandler {
 
     private void testNotHandledByWorkbookException(OPCPackage pkg) throws IOException {
         try {
-            new XSSFWorkbook(pkg);
+            new XSSFWorkbook(pkg).close();
         } catch (XLSBUnsupportedException e) {
             //this is what we'd expect
             //swallow
index aa47a7267055879bb9cea22b6cb47490317dcb6d..ec325b9551634f10c83a89ceb6bb3264a02a21fa 100644 (file)
 ==================================================================== */
 package org.apache.poi.stress;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.BufferedInputStream;
+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 java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException;
@@ -31,20 +51,9 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.Test;
 import org.xml.sax.SAXException;
 
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-import java.io.*;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Set;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
 public class XSSFFileHandler extends SpreadsheetHandler {
     @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
         // ignore password protected files
         if (POIXMLDocumentHandler.isEncrypted(stream)) return;
 
@@ -52,13 +61,13 @@ public class XSSFFileHandler extends SpreadsheetHandler {
 
         // make sure the potentially large byte-array is freed up quickly again
         {
-               ByteArrayOutputStream out = new ByteArrayOutputStream();
-               IOUtils.copy(stream, out);
-               final byte[] bytes = out.toByteArray();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            IOUtils.copy(stream, out);
+            final byte[] bytes = out.toByteArray();
 
-               checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes)));
+            checkXSSFReader(OPCPackage.open(new ByteArrayInputStream(bytes)));
 
-               wb = new XSSFWorkbook(new ByteArrayInputStream(bytes));
+            wb = new XSSFWorkbook(new ByteArrayInputStream(bytes));
         }
 
         // use the combined handler for HSSF/XSSF
@@ -76,6 +85,8 @@ public class XSSFFileHandler extends SpreadsheetHandler {
 
         // this allows to trigger a heap-dump at this point to see which memory is still allocated
         //HeapDump.dumpHeap("/tmp/poi.hprof", false);
+        
+        wb.close();
     }
 
 
@@ -185,7 +196,7 @@ public class XSSFFileHandler extends SpreadsheetHandler {
 
         InputStream stream = new BufferedInputStream(new FileInputStream(file));
         try {
-            handleFile(stream);
+            handleFile(stream, file.getPath());
         } finally {
             stream.close();
         }
index c097dc9f71cc138c632dbd16825f5b8840fa1086..142e8161091ad4a9a1b70aa14d1d7ae3edf92c23 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Test;
 
 public class XWPFFileHandler extends AbstractFileHandler {
        @Override
-    public void handleFile(InputStream stream) throws Exception {
+    public void handleFile(InputStream stream, String path) throws Exception {
         // ignore password protected files
         if (POIXMLDocumentHandler.isEncrypted(stream)) return;
 
@@ -38,11 +38,11 @@ public class XWPFFileHandler extends AbstractFileHandler {
        // 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/51921-Word-Crash067.docx");
+        File file = new File("test-data/document/51921-Word-Crash067.docx");
 
-               InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000);
+        InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000);
                try {
-                       handleFile(stream);
+                       handleFile(stream, file.getPath());
                } finally {
                        stream.close();
                }