]> source.dussan.org Git - poi.git/commitdiff
[bug-66365] add test for XSSFExcelExtractor
authorPJ Fanning <fanningpj@apache.org>
Mon, 28 Nov 2022 14:23:16 +0000 (14:23 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 28 Nov 2022 14:23:16 +0000 (14:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1905574 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java

index a00e232e290bdff47811b5ec943b9e60945d63f1..b4f6fe09a0bc262d91d62a830cb95e7f42ab05de 100644 (file)
@@ -202,15 +202,6 @@ class TestExtractorFactory {
         assertTrue(ex.getMessage().contains("Invalid header signature; read 0x3D20726F68747541, expected 0xE11AB1A1E011CFD0"));
     }
 
-    private void testExtractor(final POITextExtractor ext, final String testcase, final String extrClass, final Integer minLength) {
-        assertEquals(extrClass, ext.getClass().getSimpleName(), "invalid extractor for " + testcase);
-        final String actual = ext.getText();
-        if (minLength == -1) {
-            assertContains(actual.toLowerCase(Locale.ROOT), "test");
-        } else {
-            assertTrue(actual.length() > minLength, "extracted content too short for " + testcase);
-        }
-    }
     @Test
     void testPackageInvalid() {
         // Text
@@ -440,6 +431,15 @@ class TestExtractorFactory {
         assertThrows(IllegalStateException.class, () -> ExtractorFactory.getEmbeddedDocsTextExtractors(null));
     }
 
+    @Test
+    void test66365() throws Exception {
+        try (POITextExtractor extractor = ex("66365.xlsx")) {
+            String text = extractor.getText();
+            assertContains(text, "Alice\tAlice");
+            assertContains(text, "Bob\tBob");
+        }
+    }
+
     // This bug is currently open. This test will fail with "expected error not thrown" when the bug has been fixed.
     // When this happens, change this from @Test(expected=...) to @Test
     // bug 45565: text within TextBoxes is extracted by ExcelExtractor and WordExtractor
@@ -454,6 +454,16 @@ class TestExtractorFactory {
         }
     }
 
+    private void testExtractor(final POITextExtractor ext, final String testcase, final String extrClass, final Integer minLength) {
+        assertEquals(extrClass, ext.getClass().getSimpleName(), "invalid extractor for " + testcase);
+        final String actual = ext.getText();
+        if (minLength == -1) {
+            assertContains(actual.toLowerCase(Locale.ROOT), "test");
+        } else {
+            assertTrue(actual.length() > minLength, "extracted content too short for " + testcase);
+        }
+    }
+
     private static POITextExtractor ex(String filename) throws IOException {
         return createExtractor(ssTests.getFile(filename));
     }