]> source.dussan.org Git - poi.git/commitdiff
Add unit tests to verify that bug 51626 and bug 51451 are fixed
authorDominik Stadler <centic@apache.org>
Thu, 3 Sep 2015 20:46:04 +0000 (20:46 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 3 Sep 2015 20:46:04 +0000 (20:46 +0000)
Conflicts:
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1701132 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/51626.xlsx [new file with mode: 0644]
test-data/spreadsheet/51626_contact.xlsx [new file with mode: 0644]

index 6b4170ddb83febf7ee1c6720cbe250f5a9714bf3..5fccecc68173c196a807bd52701021ddba85f4cf 100644 (file)
@@ -29,9 +29,10 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.List;
@@ -66,6 +67,7 @@ import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.Comment;
 import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.DataFormat;
 import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.usermodel.Drawing;
@@ -2571,4 +2573,47 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
             }
         }
     }
+
+    @Test
+    public void test51626() throws Exception {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51626.xlsx");
+        assertNotNull(wb);
+        wb.close();
+        
+        InputStream stream = HSSFTestDataSamples.openSampleFileStream("51626.xlsx");
+        wb = WorkbookFactory.create(stream);
+        stream.close();
+        wb.close();
+        
+        wb = XSSFTestDataSamples.openSampleWorkbook("51626_contact.xlsx");
+        assertNotNull(wb);
+        wb.close();
+        
+        stream = HSSFTestDataSamples.openSampleFileStream("51626_contact.xlsx");
+        wb = WorkbookFactory.create(stream);
+        stream.close();
+        wb.close();
+    }
+    
+    @Test
+    public void test51451() throws IOException {
+        Workbook wb = new XSSFWorkbook();
+        Sheet sh = wb.createSheet();
+        
+        Row row = sh.createRow(0);
+        Cell cell = row.createCell(0);
+        cell.setCellValue(239827342);
+        
+        CellStyle style = wb.createCellStyle();
+        //style.setHidden(false);
+        DataFormat excelFormat = wb.createDataFormat();
+        style.setDataFormat(excelFormat.getFormat("#,##0"));
+        sh.setDefaultColumnStyle(0, style);
+
+//        FileOutputStream out = new FileOutputStream("/tmp/51451.xlsx");
+//        wb.write(out);
+//        out.close();
+        
+        wb.close();
+    }
 }
diff --git a/test-data/spreadsheet/51626.xlsx b/test-data/spreadsheet/51626.xlsx
new file mode 100644 (file)
index 0000000..6a5e3ff
Binary files /dev/null and b/test-data/spreadsheet/51626.xlsx differ
diff --git a/test-data/spreadsheet/51626_contact.xlsx b/test-data/spreadsheet/51626_contact.xlsx
new file mode 100644 (file)
index 0000000..a3e4e5b
Binary files /dev/null and b/test-data/spreadsheet/51626_contact.xlsx differ