You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/20 04:21:26 UTC

svn commit: r1749264 - in /poi/trunk/src: ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

Author: onealj
Date: Mon Jun 20 04:21:26 2016
New Revision: 1749264

URL: http://svn.apache.org/viewvc?rev=1749264&view=rev
Log:
whitespace (tabs to 4 spaces)

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java?rev=1749264&r1=1749263&r2=1749264&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java Mon Jun 20 04:21:26 2016
@@ -44,115 +44,115 @@ public final class TestXSSFSheetShiftRow
 
     @Override
     @Test
-	public void testShiftRowBreaks() {
+    public void testShiftRowBreaks() {
         // disabled test from superclass
         // TODO - support shifting of page breaks
     }
 
     @Test
-	public void testBug54524() throws IOException {
+    public void testBug54524() throws IOException {
         XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("54524.xlsx");
         XSSFSheet sheet = workbook.getSheetAt(0);
-		sheet.shiftRows(3, 5, -1);
+        sheet.shiftRows(3, 5, -1);
 
         Cell cell = CellUtil.getCell(sheet.getRow(1), 0);
-		assertEquals(1.0, cell.getNumericCellValue(), 0);
-		cell = CellUtil.getCell(sheet.getRow(2), 0);
-		assertEquals("SUM(A2:A2)", cell.getCellFormula());
-		cell = CellUtil.getCell(sheet.getRow(3), 0);
-		assertEquals("X", cell.getStringCellValue());
-		workbook.close();
-	}
+        assertEquals(1.0, cell.getNumericCellValue(), 0);
+        cell = CellUtil.getCell(sheet.getRow(2), 0);
+        assertEquals("SUM(A2:A2)", cell.getCellFormula());
+        cell = CellUtil.getCell(sheet.getRow(3), 0);
+        assertEquals("X", cell.getStringCellValue());
+        workbook.close();
+    }
+
+    @Test
+    public void testBug53798() throws IOException {
+        // NOTE that for HSSF (.xls) negative shifts combined with positive ones do work as expected  
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx");
+
+        Sheet testSheet    = wb.getSheetAt(0);
+        // 1) corrupted xlsx (unreadable data in the first row of a shifted group) already comes about  
+        // when shifted by less than -1 negative amount (try -2)
+        testSheet.shiftRows(3, 3, -2);
+        
+        Row newRow = null; Cell newCell = null;
+        // 2) attempt to create a new row IN PLACE of a removed row by a negative shift causes corrupted 
+        // xlsx file with  unreadable data in the negative shifted row. 
+        // NOTE it's ok to create any other row.
+        newRow = testSheet.createRow(3);
+        newCell = newRow.createCell(0);
+        newCell.setCellValue("new Cell in row "+newRow.getRowNum());
+        
+        // 3) once a negative shift has been made any attempt to shift another group of rows 
+        // (note: outside of previously negative shifted rows) by a POSITIVE amount causes POI exception: 
+        // org.apache.xmlbeans.impl.values.XmlValueDisconnectedException.
+        // NOTE: another negative shift on another group of rows is successful, provided no new rows in  
+        // place of previously shifted rows were attempted to be created as explained above.
+
+        // -- CHANGE the shift to positive once the behaviour of the above has been tested
+        testSheet.shiftRows(6, 7, 1); 
+        
+        Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
+        wb.close();
+        assertNotNull(read);
+        
+        Sheet readSheet = read.getSheetAt(0);
+        verifyCellContent(readSheet, 0, "0.0");
+        verifyCellContent(readSheet, 1, "3.0");
+        verifyCellContent(readSheet, 2, "2.0");
+        verifyCellContent(readSheet, 3, "new Cell in row 3");
+        verifyCellContent(readSheet, 4, "4.0");
+        verifyCellContent(readSheet, 5, "5.0");
+        verifyCellContent(readSheet, 6, null);
+        verifyCellContent(readSheet, 7, "6.0");
+        verifyCellContent(readSheet, 8, "7.0");
+        read.close();
+    }
 
+    private void verifyCellContent(Sheet readSheet, int row, String expect) {
+        Row readRow = readSheet.getRow(row);
+        if(expect == null) {
+            assertNull(readRow);
+            return;
+        }
+        Cell readCell = readRow.getCell(0);
+        if(readCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+            assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
+        } else {
+            assertEquals(expect, readCell.getStringCellValue());
+        }
+    }
+    
     @Test
-	public void testBug53798() throws IOException {
-		// NOTE that for HSSF (.xls) negative shifts combined with positive ones do work as expected  
-		Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx");
-
-		Sheet testSheet	= wb.getSheetAt(0);
-		// 1) corrupted xlsx (unreadable data in the first row of a shifted group) already comes about  
-		// when shifted by less than -1 negative amount (try -2)
-		testSheet.shiftRows(3, 3, -2);
-		
-		Row newRow = null; Cell newCell = null;
-		// 2) attempt to create a new row IN PLACE of a removed row by a negative shift causes corrupted 
-		// xlsx file with  unreadable data in the negative shifted row. 
-		// NOTE it's ok to create any other row.
-		newRow = testSheet.createRow(3);
-		newCell = newRow.createCell(0);
-		newCell.setCellValue("new Cell in row "+newRow.getRowNum());
-		
-		// 3) once a negative shift has been made any attempt to shift another group of rows 
-		// (note: outside of previously negative shifted rows) by a POSITIVE amount causes POI exception: 
-		// org.apache.xmlbeans.impl.values.XmlValueDisconnectedException.
-		// NOTE: another negative shift on another group of rows is successful, provided no new rows in  
-		// place of previously shifted rows were attempted to be created as explained above.
-
-		// -- CHANGE the shift to positive once the behaviour of the above has been tested
-		testSheet.shiftRows(6, 7, 1); 
-		
-		Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
-		wb.close();
-		assertNotNull(read);
-		
-		Sheet readSheet = read.getSheetAt(0);
-		verifyCellContent(readSheet, 0, "0.0");
-		verifyCellContent(readSheet, 1, "3.0");
-		verifyCellContent(readSheet, 2, "2.0");
-		verifyCellContent(readSheet, 3, "new Cell in row 3");
-		verifyCellContent(readSheet, 4, "4.0");
-		verifyCellContent(readSheet, 5, "5.0");
-		verifyCellContent(readSheet, 6, null);
-		verifyCellContent(readSheet, 7, "6.0");
-		verifyCellContent(readSheet, 8, "7.0");
-		read.close();
-	}
-
-	private void verifyCellContent(Sheet readSheet, int row, String expect) {
-		Row readRow = readSheet.getRow(row);
-		if(expect == null) {
-			assertNull(readRow);
-			return;
-		}
-		Cell readCell = readRow.getCell(0);
-		if(readCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
-			assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
-		} else {
-			assertEquals(expect, readCell.getStringCellValue());
-		}
-	}
-	
-	@Test
-	public void testBug53798a() throws IOException {
-		Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx");
+    public void testBug53798a() throws IOException {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx");
 
-		Sheet testSheet	= wb.getSheetAt(0);
-		testSheet.shiftRows(3, 3, -1);
+        Sheet testSheet    = wb.getSheetAt(0);
+        testSheet.shiftRows(3, 3, -1);
         for (Row r : testSheet) {
-        	r.getRowNum();
+            r.getRowNum();
         }
-		testSheet.shiftRows(6, 6, 1);
-		
-		Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
-		wb.close();
-		assertNotNull(read);
-		
-		Sheet readSheet = read.getSheetAt(0);
-		verifyCellContent(readSheet, 0, "0.0");
-		verifyCellContent(readSheet, 1, "1.0");
-		verifyCellContent(readSheet, 2, "3.0");
-		verifyCellContent(readSheet, 3, null);
-		verifyCellContent(readSheet, 4, "4.0");
-		verifyCellContent(readSheet, 5, "5.0");
-		verifyCellContent(readSheet, 6, null);
-		verifyCellContent(readSheet, 7, "6.0");
-		verifyCellContent(readSheet, 8, "8.0");
-		read.close();
-	}
-	
-	@Test
-	public void testBug56017() throws IOException {
-	    Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56017.xlsx");
+        testSheet.shiftRows(6, 6, 1);
+        
+        Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
+        wb.close();
+        assertNotNull(read);
+        
+        Sheet readSheet = read.getSheetAt(0);
+        verifyCellContent(readSheet, 0, "0.0");
+        verifyCellContent(readSheet, 1, "1.0");
+        verifyCellContent(readSheet, 2, "3.0");
+        verifyCellContent(readSheet, 3, null);
+        verifyCellContent(readSheet, 4, "4.0");
+        verifyCellContent(readSheet, 5, "5.0");
+        verifyCellContent(readSheet, 6, null);
+        verifyCellContent(readSheet, 7, "6.0");
+        verifyCellContent(readSheet, 8, "8.0");
+        read.close();
+    }
+    
+    @Test
+    public void testBug56017() throws IOException {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56017.xlsx");
 
         Sheet sheet = wb.getSheetAt(0);
 
@@ -189,11 +189,11 @@ public final class TestXSSFSheetShiftRow
         assertEquals("Amdocs", comment.getAuthor());
         assertEquals("Amdocs:\ntest\n", comment.getString().getString());
         wbBack.close();
-	}
+    }
 
-	@Test
+    @Test
     public void test57171() throws IOException {
-	    Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
         assertEquals(5, wb.getActiveSheetIndex());
         removeAllSheetsBut(5, wb); // 5 is the active / selected sheet
         assertEquals(0, wb.getActiveSheetIndex());
@@ -208,7 +208,7 @@ public final class TestXSSFSheetShiftRow
         wbRead.close();
     }
 
-	@Test
+    @Test
     public void test57163() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
         assertEquals(5, wb.getActiveSheetIndex());
@@ -218,7 +218,7 @@ public final class TestXSSFSheetShiftRow
         wb.close();
     }
 
-	@Test
+    @Test
     public void testSetSheetOrderAndAdjustActiveSheet() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
         
@@ -268,7 +268,7 @@ public final class TestXSSFSheetShiftRow
         wb.close();
     }   
 
-	@Test
+    @Test
     public void testRemoveSheetAndAdjustActiveSheet() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
         
@@ -312,7 +312,7 @@ public final class TestXSSFSheetShiftRow
         wb.close();
     }
 
-	@Test
+    @Test
     public void test57165() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
         assertEquals(5, wb.getActiveSheetIndex());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java?rev=1749264&r1=1749263&r2=1749264&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java Mon Jun 20 04:21:26 2016
@@ -123,7 +123,7 @@ public abstract class BaseTestSheetShift
     @Test
     public final void testShiftRow() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s	= wb.createSheet();
+        Sheet s = wb.createSheet();
         s.createRow(0).createCell(0).setCellValue("TEST1");
         s.createRow(3).createCell(0).setCellValue("TEST2");
         s.shiftRows(0,4,1);
@@ -136,7 +136,7 @@ public abstract class BaseTestSheetShift
     @Test
     public final void testActiveCell() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s	= wb.createSheet();
+        Sheet s = wb.createSheet();
 
         s.createRow(0).createCell(0).setCellValue("TEST1");
         s.createRow(3).createCell(0).setCellValue("TEST2");
@@ -150,7 +150,7 @@ public abstract class BaseTestSheetShift
     @Test
     public void testShiftRowBreaks() throws IOException { // TODO - enable XSSF test
         Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s	= wb.createSheet();
+        Sheet s = wb.createSheet();
         Row row = s.createRow(4);
         row.createCell(0).setCellValue("test");
         s.setRowBreak(4);
@@ -228,13 +228,13 @@ public abstract class BaseTestSheetShift
         // TODO: it seems HSSFSheet does not correctly remove comments from rows that are overwritten
         // by shifting rows...
         if(!(wb2 instanceof HSSFWorkbook)) {
-        	assertEquals(2, sheet.getLastRowNum());
-        	
-        	// Verify comments are in the position expected
-        	assertNull("Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()),
-        			sheet.getCellComment(new CellAddress(0,0)));
-        	assertNotNull(sheet.getCellComment(new CellAddress(1,0)));
-        	assertNotNull(sheet.getCellComment(new CellAddress(2,0)));
+            assertEquals(2, sheet.getLastRowNum());
+            
+            // Verify comments are in the position expected
+            assertNull("Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()),
+                    sheet.getCellComment(new CellAddress(0,0)));
+            assertNotNull(sheet.getCellComment(new CellAddress(1,0)));
+            assertNotNull(sheet.getCellComment(new CellAddress(2,0)));
         }
 
         comment1 = sheet.getCellComment(new CellAddress(1,0)).getString().getString();
@@ -293,7 +293,7 @@ public abstract class BaseTestSheetShift
     @Test
     public final void testShiftWithMergedRegions() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sheet	= wb.createSheet();
+        Sheet sheet = wb.createSheet();
         Row row = sheet.createRow(0);
         row.createCell(0).setCellValue(1.1);
         row.createCell(1).setCellValue(2.2);
@@ -481,7 +481,7 @@ public abstract class BaseTestSheetShift
     }
 
     @Test
-	public void testBug55280() throws IOException {
+    public void testBug55280() throws IOException {
         Workbook w = _testDataProvider.createWorkbook();
         Sheet s = w.createSheet();
         for (int row = 0; row < 5000; ++row)
@@ -489,7 +489,7 @@ public abstract class BaseTestSheetShift
 
         s.shiftRows(0, 4999, 1);        // takes a long time...
         w.close();
-	}
+    }
 
     @Test
     public void test47169() throws IOException {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org