Author: yegor
Date: Mon Apr 16 03:49:47 2007
New Revision: 529197

URL: http://svn.apache.org/viewvc?view=rev&rev=529197
Log:
testcases for bugs 38266 and 40738

Added:
    
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithAutofilter.xls
   (with props)
    
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithImages.xls   
(with props)
Modified:
    jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Added: 
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithAutofilter.xls
URL: 
http://svn.apache.org/viewvc/jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithAutofilter.xls?view=auto&rev=529197
==============================================================================
Binary file - no diff available.

Propchange: 
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithAutofilter.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithImages.xls
URL: 
http://svn.apache.org/viewvc/jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithImages.xls?view=auto&rev=529197
==============================================================================
Binary file - no diff available.

Propchange: 
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithImages.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: 
jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: 
http://svn.apache.org/viewvc/jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?view=diff&rev=529197&r1=529196&r2=529197
==============================================================================
--- jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java 
(original)
+++ jakarta/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java 
Mon Apr 16 03:49:47 2007
@@ -868,8 +868,52 @@
         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);
+
+    }
+
+    
 }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to