aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
diff options
context:
space:
mode:
authorShawn Laubach <slaubach@apache.org>2003-02-09 21:12:35 +0000
committerShawn Laubach <slaubach@apache.org>2003-02-09 21:12:35 +0000
commitc2a0fd4fe6533e1d5aaf19a24e9e56a5e4d24e1a (patch)
tree6e748cc1dffffb0dc249aee2fed7d2a4cbbc3614 /src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
parent5bbf6e777428bcbdd6e7b9d3c521e6fc99074ddc (diff)
downloadpoi-c2a0fd4fe6533e1d5aaf19a24e9e56a5e4d24e1a.tar.gz
poi-c2a0fd4fe6533e1d5aaf19a24e9e56a5e4d24e1a.zip
Fix for bug #15019. NullPointerException in shiftRows. Added the test case and moved the other test case into the file. Put Toshiaki Kamoshida as an author of the test case. Test failed. Added patch. Test worked.
PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353004 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java83
1 files changed, 0 insertions, 83 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
index 0b39b345e5..8b1908bd0b 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
@@ -237,89 +237,6 @@ public class TestHSSFSheet
assertEquals(cloned.getRow((short)0).getCell((short)0).getStringCellValue(), "clone_test");
}
- /**
- * Tests the shiftRows function. Does three different shifts.
- * After each shift, writes the workbook to file and reads back to
- * check. This ensures that if some changes code that breaks
- * writing or what not, they realize it.
- *
- * Shawn Laubach (slaubach at apache dot org)
- */
- public void testShiftRows() throws Exception
- {
- // Read initial file in
- String filename = System.getProperty( "HSSF.testdata.path" );
- filename = filename + "/SimpleMultiCell.xls";
- FileInputStream fin = new FileInputStream( filename );
- HSSFWorkbook wb = new HSSFWorkbook( fin );
- fin.close();
- HSSFSheet s = wb.getSheetAt( 0 );
-
- // Shift the second row down 1 and write to temp file
- s.shiftRows( 1, 1, 1 );
- File tempFile = File.createTempFile( "shift", "test.xls" );
- FileOutputStream fout = new FileOutputStream( tempFile );
- wb.write( fout );
- fout.close();
-
- // Read from temp file and check the number of cells in each
- // row (in original file each row was unique)
- fin = new FileInputStream( tempFile );
- wb = new HSSFWorkbook( fin );
- fin.close();
- s = wb.getSheetAt( 0 );
-
- assertEquals( s.getRow( 0 ).getPhysicalNumberOfCells(), 1 );
- assertTrue( s.getRow( 1 ) == null || s.getRow( 1 ).getPhysicalNumberOfCells() == 0 );
- assertEquals( s.getRow( 2 ).getPhysicalNumberOfCells(), 2 );
- assertEquals( s.getRow( 3 ).getPhysicalNumberOfCells(), 4 );
- assertEquals( s.getRow( 4 ).getPhysicalNumberOfCells(), 5 );
-
- // Shift rows 1-3 down 3 in the current one. This tests when
- // 1 row is blank. Write to a another temp file
- s.shiftRows( 0, 2, 3 );
- tempFile = File.createTempFile( "shift", "test.xls" );
- fout = new FileOutputStream( tempFile );
- wb.write( fout );
- fout.close();
-
- // Read and ensure things are where they should be
- fin = new FileInputStream( tempFile );
- wb = new HSSFWorkbook( fin );
- fin.close();
- s = wb.getSheetAt( 0 );
- assertTrue( s.getRow( 0 ) == null || s.getRow( 0 ).getPhysicalNumberOfCells() == 0 );
- assertTrue( s.getRow( 1 ) == null || s.getRow( 1 ).getPhysicalNumberOfCells() == 0 );
- assertTrue( s.getRow( 2 ) == null || s.getRow( 2 ).getPhysicalNumberOfCells() == 0 );
- assertEquals( s.getRow( 3 ).getPhysicalNumberOfCells(), 1 );
- assertTrue( s.getRow( 4 ) == null || s.getRow( 4 ).getPhysicalNumberOfCells() == 0 );
- assertEquals( s.getRow( 5 ).getPhysicalNumberOfCells(), 2 );
-
- // Read the first file again
- fin = new FileInputStream( filename );
- wb = new HSSFWorkbook( fin );
- fin.close();
- s = wb.getSheetAt( 0 );
-
- // Shift rows 3 and 4 up and write to temp file
- s.shiftRows( 2, 3, -2 );
- tempFile = File.createTempFile( "shift", "test.xls" );
- fout = new FileOutputStream( tempFile );
- wb.write( fout );
- fout.close();
-
- // Read file and test
- fin = new FileInputStream( tempFile );
- wb = new HSSFWorkbook( fin );
- fin.close();
- s = wb.getSheetAt( 0 );
- assertEquals( s.getRow( 0 ).getPhysicalNumberOfCells(), 3 );
- assertEquals( s.getRow( 1 ).getPhysicalNumberOfCells(), 4 );
- assertTrue( s.getRow( 2 ) == null || s.getRow( 2 ).getPhysicalNumberOfCells() == 0 );
- assertTrue( s.getRow( 3 ) == null || s.getRow( 3 ).getPhysicalNumberOfCells() == 0 );
- assertEquals( s.getRow( 4 ).getPhysicalNumberOfCells(), 5 );
- }
-
public void testZoom()
throws Exception
{