⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testbugs.java

📁 介绍java核心技术的pio编程方法以及基本概念
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * 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);    }    /**     * Test bug 38266: NPE when adding a row break     *     * User's diagnosis:     * 1. Manually (i.e., not using POI) create an Excel Workbook, making sure it     * contains a sheet that doesn't have any row breaks     * 2. Using POI, create a new HSSFWorkbook from the template in step #1     * 3. Try adding a row break (via sheet.setRowBreak()) to the sheet mentioned in step #1     * 4. Get a NullPointerException     */    public void test38266() throws Exception {        String[] files = {"Simple.xls", "SimpleMultiCell.xls", "duprich1.xls"};        for (int i = 0; i < files.length; i++) {            FileInputStream in = new FileInputStream(new File(cwd, files[i]));            HSSFWorkbook wb = new HSSFWorkbook(in);            in.close();            HSSFSheet sheet = wb.getSheetAt( 0 );            int[] breaks = sheet.getRowBreaks();            assertNull(breaks);            //add 3 row breaks            for (int j = 1; j <= 3; j++) {                sheet.setRowBreak(j*20);            }            assertTrue("No Exceptions while adding row breaks in " + files[i], true);        }    }    public void test40738() throws Exception {        FileInputStream in = new FileInputStream(new File(cwd, "SimpleWithAutofilter.xls"));        HSSFWorkbook wb = new HSSFWorkbook(in);        in.close();        //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 44200: Sheet not cloneable when Note added to excel cell     */    public void test44200() throws Exception {        FileInputStream in = new FileInputStream(new File(cwd, "44200.xls"));        HSSFWorkbook wb = new HSSFWorkbook(in);        in.close();        wb.cloneSheet(0);        assertTrue("No Exceptions while cloning sheet", 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 44201: Sheet not cloneable when validation added to excel cell     */    public void test44201() throws Exception {        FileInputStream in = new FileInputStream(new File(cwd, "44201.xls"));        HSSFWorkbook wb = new HSSFWorkbook(in);        in.close();        wb.cloneSheet(0);        assertTrue("No Exceptions while cloning sheet", 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 37684  : Unhandled Continue Record Error     */    public void test37684 () throws Exception {        FileInputStream in = new FileInputStream(new File(cwd, "37684-1.xls"));        HSSFWorkbook wb = new HSSFWorkbook(in);        in.close();        assertTrue("No exceptions while reading workbook", true);        //serialize and read again        ByteArrayOutputStream out = new ByteArrayOutputStream();        wb.write(out);        out.close();        assertTrue("No exceptions while saving workbook", true);        wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));        assertTrue("No exceptions while reading saved stream", true);        in = new FileInputStream(new File(cwd, "37684-2.xls"));        wb = new HSSFWorkbook(in);        in.close();        assertTrue("No exceptions while reading workbook", true);        //serialize and read again        out = new ByteArrayOutputStream();        wb.write(out);        out.close();        assertTrue("No exceptions while saving workbook", true);        wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));        assertTrue("No exceptions while reading saved stream", true);    }    /**     * Bug 41139: Constructing HSSFWorkbook is failed,threw threw ArrayIndexOutOfBoundsException for creating UnknownRecord     */    public void test41139() throws Exception {        FileInputStream in = new FileInputStream(new File(cwd, "41139.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 42618: RecordFormatException reading a file containing	 * 	=CHOOSE(2,A2,A3,A4)	 */    public void test42618() throws Exception {        //Comment the test until we are sure it passes.        // Yegor, January 25, 2008        /*        FileInputStream in = new FileInputStream(new File(cwd, "SimpleWithChoose.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);        */    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -