From: Dominik Stadler Date: Thu, 3 Sep 2015 20:46:04 +0000 (+0000) Subject: Add unit tests to verify that bug 51626 and bug 51451 are fixed X-Git-Tag: REL_3_13_FINAL~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8b12e2e544a80ab4adf851b32299417b83c9344;p=poi.git Add unit tests to verify that bug 51626 and bug 51451 are fixed 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 --- diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 6b4170ddb8..5fccecc681 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -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 index 0000000000..6a5e3ffa9d 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 index 0000000000..a3e4e5b7ed Binary files /dev/null and b/test-data/spreadsheet/51626_contact.xlsx differ