]> source.dussan.org Git - poi.git/commitdiff
Add reproducer for Bug 57165, no fix yet, though...
authorDominik Stadler <centic@apache.org>
Mon, 22 Dec 2014 09:10:01 +0000 (09:10 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 22 Dec 2014 09:10:01 +0000 (09:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647265 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java

index 96f42f554cabd6e1f5115cca82462711455a9cc3..5b31ccd6bf6dd0f3f2f4fad3516e5bfe452a0864 100644 (file)
@@ -32,6 +32,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.SXSSFITestDataProvider;\r
 import org.apache.poi.xssf.XSSFTestDataSamples;\r
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;\r
+import org.junit.Test;\r
 \r
 /**\r
  * @author centic\r
@@ -134,4 +135,36 @@ public final class TestUnfixedBugs extends TestCase {
             }\r
         }\r
     }\r
+\r
+    \r
+    @Test\r
+    public void test57165() throws IOException {\r
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");\r
+        try {\r
+            removeAllSheetsBut(3, wb);\r
+            wb.cloneSheet(0); // Throws exception here\r
+            wb.setSheetName(1, "New Sheet");\r
+            //saveWorkbook(wb, fileName);\r
+            \r
+            XSSFWorkbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);\r
+            try {\r
+                \r
+            } finally {\r
+                wbBack.close();\r
+            }\r
+        } finally {\r
+            wb.close();\r
+        }\r
+    }\r
+\r
+    private static void removeAllSheetsBut(int sheetIndex, Workbook wb)\r
+    {\r
+        int sheetNb = wb.getNumberOfSheets();\r
+        // Move this sheet at the first position\r
+        wb.setSheetOrder(wb.getSheetName(sheetIndex), 0);\r
+        for (int sn = sheetNb - 1; sn > 0; sn--)\r
+        {\r
+            wb.removeSheetAt(sn);\r
+        }\r
+    }\r
 }\r