From: Avik Sengupta Date: Tue, 16 Jan 2007 09:23:18 +0000 (+0000) Subject: Testcases for bugs. Thanks Yegor X-Git-Tag: REL_3_0_RC1~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=59b21811f377c1158abe3a73a11e634c897ae663;p=poi.git Testcases for bugs. Thanks Yegor git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@496633 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/hssf/data/25183.xls b/src/testcases/org/apache/poi/hssf/data/25183.xls new file mode 100644 index 0000000000..635a649879 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/25183.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/26100.xls b/src/testcases/org/apache/poi/hssf/data/26100.xls new file mode 100644 index 0000000000..802cf89601 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/26100.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/27933.xls b/src/testcases/org/apache/poi/hssf/data/27933.xls new file mode 100644 index 0000000000..79722370b4 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/27933.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/29675.xls b/src/testcases/org/apache/poi/hssf/data/29675.xls new file mode 100644 index 0000000000..a80df1ffb9 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/29675.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/29942.xls b/src/testcases/org/apache/poi/hssf/data/29942.xls new file mode 100644 index 0000000000..9fac290a07 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/29942.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/29982.xls b/src/testcases/org/apache/poi/hssf/data/29982.xls new file mode 100644 index 0000000000..8430ff72b0 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/29982.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/30540.xls b/src/testcases/org/apache/poi/hssf/data/30540.xls new file mode 100644 index 0000000000..bf91e1bb16 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/30540.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/31749.xls b/src/testcases/org/apache/poi/hssf/data/31749.xls new file mode 100644 index 0000000000..6962a09237 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/31749.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/31979.xls b/src/testcases/org/apache/poi/hssf/data/31979.xls new file mode 100644 index 0000000000..a0c743d28a Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/31979.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/35564.xls b/src/testcases/org/apache/poi/hssf/data/35564.xls new file mode 100644 index 0000000000..db18e0187a Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/35564.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/35565.xls b/src/testcases/org/apache/poi/hssf/data/35565.xls new file mode 100644 index 0000000000..ee97f0a365 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/35565.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/37376.xls b/src/testcases/org/apache/poi/hssf/data/37376.xls new file mode 100644 index 0000000000..59176a66e5 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/37376.xls differ diff --git a/src/testcases/org/apache/poi/hssf/data/40285.xls b/src/testcases/org/apache/poi/hssf/data/40285.xls new file mode 100644 index 0000000000..077e1c8341 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/40285.xls differ diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index ad36c5574f..0483871691 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -24,6 +24,7 @@ import org.apache.poi.hssf.util.Region; import org.apache.poi.util.TempFile; import java.io.*; +import java.util.Iterator; @@ -31,6 +32,7 @@ import java.io.*; * Testcases for bugs entered in bugzilla * the Test name contains the bugzilla bug id * @author Avik Sengupta + * @author Yegor Kozlov */ public class TestBugs @@ -537,7 +539,335 @@ extends TestCase { assertTrue("Read book fine!" , true); } - + protected String cwd = System.getProperty("HSSF.testdata.path"); + + /** + * Bug 25183: org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet + */ + public void test25183() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "25183.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 26100: 128-character message in IF statement cell causes HSSFWorkbook open failure + */ + public void test26100() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "26100.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + assertTrue("No Exceptions while reading file", true); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 27933: Unable to use a template (xls) file containing a wmf graphic + */ + public void test27933() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "27933.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 29206: NPE on HSSFSheet.getRow for blank rows + */ + public void test29206() throws Exception { + //the first check with blank workbook + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet(); + + for(int i = 1; i < 400; i++) { + HSSFRow row = sheet.getRow(i); + if(row != null) { + HSSFCell cell = row.getCell((short)0); + } + } + + //now check on an existing xls file + FileInputStream in = new FileInputStream(new File(cwd, "Simple.xls")); + wb = new HSSFWorkbook(in); + in.close(); + + for(int i = 1; i < 400; i++) { + HSSFRow row = sheet.getRow(i); + if(row != null) { + HSSFCell cell = row.getCell((short)0); + } + } + + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 29675: POI 2.5 final corrupts output when starting workbook has a graphic + */ + public void test29675() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "29675.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 29942: Importing Excel files that have been created by Open Office on Linux + */ + public void test29942() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "29942.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + HSSFSheet sheet = wb.getSheetAt(0); + int count = 0; + for (int i = sheet.getFirstRowNum(); i <= sheet.getLastRowNum(); i++) { + HSSFRow row = sheet.getRow(i); + if (row != null) { + HSSFCell cell = row .getCell((short)0); + assertEquals(HSSFCell.CELL_TYPE_STRING, cell.getCellType()); + count++; + } + } + assertEquals(85, count); //should read 85 rows + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 29982: Unable to read spreadsheet when dropdown list cell is selected - + * Unable to construct record instance + */ + public void test29982() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "29982.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 30540: HSSFSheet.setRowBreak throws NullPointerException + */ + public void test30540() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "30540.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + HSSFSheet s = wb.getSheetAt(0); + s.setRowBreak(1); + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 31749: {Need help urgently}[This is critical] workbook.write() corrupts the file......? + */ + public void test31749() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "31749.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + + /** + * Bug 31979: {urgent help needed .....}poi library does not support form objects properly. + */ + public void test31979() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "31979.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + //wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + + } + + /** + * Bug 35564: HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() + * when HSSFWorkbook is created from file + */ + public void test35564() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "35564.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + HSSFSheet sheet = wb.getSheetAt( 0 ); + assertEquals(false, sheet.isGridsPrinted()); + assertEquals(false, sheet.getProtect()); + + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + + } + + /** + * Bug 35565: HSSFCell.java: NullPtrExc in getColumnBreaks() when HSSFWorkbook is created from file + */ + public void test35565() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "35565.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + HSSFSheet sheet = wb.getSheetAt( 0 ); + assertNotNull(sheet); + + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + + } + + /** + * Bug 37376: Cannot open the saved Excel file if checkbox controls exceed certain limit + */ + public void test37376() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "37376.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + assertTrue("No Exceptions while reading file", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + + } + + /** + * Bug 40285: CellIterator Skips First Column + */ + public void test40285() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "40285.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + HSSFSheet sheet = wb.getSheetAt( 0 ); + int rownum = 0; + for (Iterator it = sheet.rowIterator(); it.hasNext(); rownum++) { + HSSFRow row = (HSSFRow)it.next(); + assertEquals(rownum, row.getRowNum()); + int cellNum = 0; + for (Iterator it2 = row.cellIterator(); it2.hasNext(); cellNum++) { + HSSFCell cell = (HSSFCell)it2.next(); + assertEquals(cellNum, cell.getCellNum()); + } + } + } + + /** + * Bug 40296: HSSFCell.setCellFormula throws + * ClassCastException if cell is created using HSSFRow.createCell(short column, int type) + */ + public void test40296() throws Exception { + HSSFWorkbook wb = new HSSFWorkbook(); + + HSSFWorkbook workBook = new HSSFWorkbook(); + HSSFSheet workSheet = workBook.createSheet("Sheet1"); + HSSFCell cell; + HSSFRow row; + + row = workSheet.createRow(0); + cell = row.createCell((short)0, HSSFCell.CELL_TYPE_NUMERIC); + cell.setCellValue(1.0); + cell = row.createCell((short)1, HSSFCell.CELL_TYPE_NUMERIC); + cell.setCellValue(2.0); + cell = row.createCell((short)2, HSSFCell.CELL_TYPE_FORMULA); + cell.setCellFormula("SUM(A1:B1)"); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + } + }