diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-10-10 09:58:02 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-10-10 09:58:02 +0000 |
commit | 2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab (patch) | |
tree | f7fdf0803511a51f89ec8672dad6c2e26a5b3347 /poi-ooxml | |
parent | 69b2f313741845d42f8a756db83cc5a9fbd4b8a9 (diff) | |
download | poi-2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab.tar.gz poi-2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab.zip |
[bug-65452] fix issue where WorkbookFactory.create(File, ...) returns null if file type not recognised
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894097 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index ae0770f555..e65c92e48e 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3623,4 +3623,25 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { } } } -} + + @Test + void testBug65452() throws IOException { + File file = XSSFTestDataSamples.getSampleFile("workbook.xml"); + try (FileInputStream fis = new FileInputStream(file)) { + try { + Workbook wb = WorkbookFactory.create(fis); + if (wb != null) wb.close(); + fail("WorkbookFactory.create should have failed"); + } catch (IOException ie) { + assertEquals("Can't open workbook - unsupported file type: XML", ie.getMessage()); + } + } + try { + Workbook wb = WorkbookFactory.create(file); + if (wb != null) wb.close(); + fail("WorkbookFactory.create should have failed"); + } catch (IOException ie) { + assertEquals("Can't open workbook - unsupported file type: XML", ie.getMessage()); + } + } +}
\ No newline at end of file |