From: Nick Burch Date: Thu, 17 Dec 2015 15:05:06 +0000 (+0000) Subject: Unit test for non-reproducable #58747 X-Git-Tag: REL_3_14_FINAL~177 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35470f6386606dae8b8e194f0199660a95d8de8d;p=poi.git Unit test for non-reproducable #58747 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1720588 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java index 85613d3e47..b964ced1d6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java @@ -27,6 +27,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.util.IOUtils; import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.model.CommentsTable; +import org.apache.poi.xssf.model.StylesTable; import org.apache.poi.xssf.usermodel.XSSFRichTextString; import org.apache.poi.xssf.usermodel.XSSFShape; import org.apache.poi.xssf.usermodel.XSSFSimpleShape; @@ -196,4 +197,22 @@ public final class TestXSSFReader extends TestCase { assertTrue(text.indexOf("Line 3") > -1); } + + /** + * NPE from XSSFReader$SheetIterator. on XLSX files generated by + * the openpyxl library + */ + public void test58747() throws Exception { + OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("58747.xlsx"); + ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(pkg); + XSSFReader reader = new XSSFReader(pkg); + StylesTable styles = reader.getStylesTable(); + + XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) reader.getSheetsData(); + assertEquals(true, iter.hasNext()); + iter.next(); + + assertEquals(false, iter.hasNext()); + assertEquals("Orders", iter.getSheetName()); + } } diff --git a/test-data/spreadsheet/58747.xlsx b/test-data/spreadsheet/58747.xlsx new file mode 100644 index 0000000000..2bfec8a554 Binary files /dev/null and b/test-data/spreadsheet/58747.xlsx differ