aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-10 09:58:02 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-10 09:58:02 +0000
commit2514e4d0ab925a4de8baa4ed4bcdbb90ca2713ab (patch)
treef7fdf0803511a51f89ec8672dad6c2e26a5b3347 /poi-ooxml
parent69b2f313741845d42f8a756db83cc5a9fbd4b8a9 (diff)
downloadpoi-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.java23
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