]> source.dussan.org Git - poi.git/commitdiff
Unit test for non-reproducable #58747
authorNick Burch <nick@apache.org>
Thu, 17 Dec 2015 15:05:06 +0000 (15:05 +0000)
committerNick Burch <nick@apache.org>
Thu, 17 Dec 2015 15:05:06 +0000 (15:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1720588 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
test-data/spreadsheet/58747.xlsx [new file with mode: 0644]

index 85613d3e476ed2824e5a47b3f4ce2020ae540db7..b964ced1d62ae9d984fafb3fc58eac3c1566ec47 100644 (file)
@@ -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.<init> 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 (file)
index 0000000..2bfec8a
Binary files /dev/null and b/test-data/spreadsheet/58747.xlsx differ