From e95fc069293db1fd4988053c6cc078af1287612c Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 17 Oct 2018 14:20:02 +0000 Subject: [PATCH] Failing unit test for bug #62831 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1844115 13f79535-47bb-0310-9956-ffa450edef68 --- .classpath | 2 +- .../apache/poi/ss/TestWorkbookFactory.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.classpath b/.classpath index fc3394904a..89d75f475b 100644 --- a/.classpath +++ b/.classpath @@ -36,7 +36,7 @@ - + diff --git a/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java b/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java index ade80688d0..e3c631c1da 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java +++ b/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java @@ -39,6 +39,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory; +import org.junit.Ignore; import org.junit.Test; public final class TestWorkbookFactory { @@ -387,4 +388,34 @@ public final class TestWorkbookFactory { } } + /** + * See Bugzilla bug #62831 - #WorkbookFactory.create(File) needs + * to work for sub-classes of File too, eg JFileChooser + */ + @Test + @Ignore + public void testFileSubclass() throws Exception { + Workbook wb; + + File normalXLS = HSSFTestDataSamples.getSampleFile(xls); + File normalXLSX = HSSFTestDataSamples.getSampleFile(xlsx); + File altXLS = new TestFile(normalXLS.getAbsolutePath()); + File altXLSX = new TestFile(normalXLSX.getAbsolutePath()); + assertTrue(altXLS.exists()); + assertTrue(altXLSX.exists()); + + wb = WorkbookFactory.create(altXLS); + assertNotNull(wb); + assertTrue(wb instanceof HSSFWorkbook); + + wb = WorkbookFactory.create(altXLSX); + assertNotNull(wb); + assertTrue(wb instanceof XSSFWorkbook); + } + + private static class TestFile extends File { + public TestFile(String file) { + super(file); + } + } } -- 2.39.5