From: Andreas Beeker Date: Tue, 2 May 2017 23:25:45 +0000 (+0000) Subject: IntegrationTest - move excludes to file handler X-Git-Tag: REL_3_17_BETA1~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3388787d2cee72b0e1679ec42fa555dc7b77c978;p=poi.git IntegrationTest - move excludes to file handler git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1793595 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index e61df18ce1..9a589bbe94 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -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 unmodifiableHashSet(String... a) { + private static final Set unmodifiableHashSet(String... a) { return Collections.unmodifiableSet(hashSet(a)); } - private static Set hashSet(String... a) { + private static final Set hashSet(String... a) { return new HashSet(Arrays.asList(a)); } // Old Word Documents where we can at least extract some text - private static final Set OLD_FILES = unmodifiableHashSet( + private static final Set 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 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 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 diff --git a/src/integrationtest/org/apache/poi/stress/FileHandler.java b/src/integrationtest/org/apache/poi/stress/FileHandler.java index c1888e7314..aef3878afa 100644 --- a/src/integrationtest/org/apache/poi/stress/FileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/FileHandler.java @@ -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 diff --git a/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java index 758a3ad294..a325f0d5ea 100644 --- a/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java index 30e98af59a..4532ab0503 100644 --- a/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HMEFFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java index 093ef0274b..788f9da613 100644 --- a/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPBFFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java index b9cff7650d..fcf0324fe9 100644 --- a/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSLFFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java index 1d40e6f4b0..61d10789cb 100644 --- a/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSMFFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java index 2743738eb1..c2928e72c0 100644 --- a/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HSSFFileHandler.java @@ -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 diff --git a/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java index d762598a4c..d4ec360062 100644 --- a/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HWPFFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java b/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java index ca019ae51d..cd9e93c092 100644 --- a/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/OPCFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java b/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java index 56be0d9eed..309949b33f 100644 --- a/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/POIFSFileHandler.java @@ -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(); } diff --git a/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java index 9b7d03f8a5..a9845b6fda 100644 --- a/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XDGFFileHandler.java @@ -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; diff --git a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java index ce5e0c0408..a45dead450 100644 --- a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java @@ -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 diff --git a/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java index 0d71de7e8a..6bf099f4ac 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFBFileHandler.java @@ -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 diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index aa47a72670..ec325b9551 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -16,6 +16,26 @@ ==================================================================== */ 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(); } diff --git a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java index c097dc9f71..142e816109 100644 --- a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java @@ -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(); }