diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-11-28 14:23:16 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-11-28 14:23:16 +0000 |
commit | 4b911496ebce2cf1729ed33a10dbb459b3704fb6 (patch) | |
tree | b82d84c69a37f7eb5f2701fa0ef2ee06ec530b15 /poi-ooxml | |
parent | c8f4cbd20b3d2670274a4d035a729c7fadf75837 (diff) | |
download | poi-4b911496ebce2cf1729ed33a10dbb459b3704fb6.tar.gz poi-4b911496ebce2cf1729ed33a10dbb459b3704fb6.zip |
[bug-66365] add test for XSSFExcelExtractor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1905574 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java b/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java index a00e232e29..b4f6fe09a0 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java +++ b/poi-ooxml/src/test/java/org/apache/poi/extractor/ooxml/TestExtractorFactory.java @@ -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)); } |