// 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());
@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
@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
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;
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();
+ }
+ }
}