diff --git a/poi-integration/src/test/java/org/apache/poi/stress/HSSFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/HSSFFileHandler.java index 9ee54b4790..1e0348cac5 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/HSSFFileHandler.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/HSSFFileHandler.java @@ -107,7 +107,7 @@ class HSSFFileHandler extends SpreadsheetHandler { // a test-case to test this locally without executing the full TestAllFiles @Test void test() throws Exception { - File file = new File("test-data/spreadsheet/49219.xls"); + File file = new File("../test-data/spreadsheet/59074.xls"); try (InputStream stream = new FileInputStream(file)) { handleFile(stream, file.getPath()); @@ -122,6 +122,6 @@ class HSSFFileHandler extends SpreadsheetHandler { @Test @SuppressWarnings("java:S2699") void testExtractor() throws Exception { - handleExtracting(new File("test-data/spreadsheet/BOOK_in_capitals.xls")); + handleExtracting(new File("../test-data/spreadsheet/59074.xls")); } } \ No newline at end of file diff --git a/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java b/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java index e6a55f88ff..d5ef5142e7 100644 --- a/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java +++ b/poi/src/main/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java @@ -316,7 +316,38 @@ public class OldExcelExtractor implements POITextExtractor { @Override public POITextExtractor getMetadataTextExtractor() { - return null; + return new POITextExtractor() { + + @Override + public String getText() { + return ""; + } + + @Override + public POITextExtractor getMetadataTextExtractor() { + throw new IllegalStateException("You already have the Metadata Text Extractor, not recursing!"); + } + + @Override + public void setCloseFilesystem(boolean doCloseFilesystem) { + + } + + @Override + public boolean isCloseFilesystem() { + return toClose != null; + } + + @Override + public Closeable getFilesystem() { + return toClose; + } + + @Override + public Object getDocument() { + return ris; + } + }; } @Override diff --git a/poi/src/test/java/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/poi/src/test/java/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java index 3fb037c93e..7dbabe14b1 100644 --- a/poi/src/test/java/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java +++ b/poi/src/test/java/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java @@ -35,6 +35,7 @@ import java.security.Permission; import org.apache.poi.EmptyFileException; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.POIDataSamples; +import org.apache.poi.extractor.POITextExtractor; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.poifs.filesystem.OfficeXmlFileException; import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -378,4 +379,24 @@ final class TestOldExcelExtractor { this.status = status; } } + + @Test + void testMetaData() throws IOException { + try (OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls")) { + POITextExtractor metaData = extractor.getMetadataTextExtractor(); + assertNotNull(metaData); + + assertThrows(IllegalStateException.class, metaData::getMetadataTextExtractor); + assertEquals("", metaData.getText()); + assertNotNull(metaData.getDocument()); + assertTrue(metaData.isCloseFilesystem()); + assertNotNull(metaData.getFilesystem()); + + // the setter is a NOP + metaData.setCloseFilesystem(false); + assertTrue(metaData.isCloseFilesystem()); + + metaData.close(); + } + } } diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls index b613a89751..c773b819d5 100644 Binary files a/test-data/spreadsheet/stress.xls and b/test-data/spreadsheet/stress.xls differ