]> source.dussan.org Git - poi.git/commitdiff
eclipse warning fixes
authorAndreas Beeker <kiwiwings@apache.org>
Fri, 18 Mar 2016 23:12:28 +0000 (23:12 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Fri, 18 Mar 2016 23:12:28 +0000 (23:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1735706 13f79535-47bb-0310-9956-ffa450edef68

src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java
src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java
src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java

index bb120861f6ddcf4875c1da428a921f9580802ca8..5512aa04fd6ef5937445a24baab37028702e4ead 100644 (file)
@@ -140,6 +140,8 @@ public class CalendarDemo {
         FileOutputStream out = new FileOutputStream(file);
         wb.write(out);
         out.close();
+        
+        wb.close();
     }
 
     /**
index d8baaceda5f466e3b3f899e4497fe0e87554a09a..48e3fd122d5d306c008eebe1833bab1a7e4a3c98 100644 (file)
@@ -127,6 +127,8 @@ public class CalendarDemo {
         FileOutputStream out = new FileOutputStream("calendar-"+year+".xlsx");
         wb.write(out);
         out.close();
+        
+        wb.close();
     }
 
     /**
index b876518ef536761907cb0a543297b76da9ccc94d..36ce03406e4c6e8677a6480165921912b48a03e5 100644 (file)
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.junit.Assert.*;
+
 import java.io.IOException;
 
 import org.apache.poi.ss.usermodel.BaseTestDataFormat;
@@ -26,6 +28,7 @@ import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.DataFormat;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Test;
 
 /**
  * Tests for {@link XSSFDataFormat}
@@ -39,7 +42,8 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
     /**
      * [Bug 49928] formatCellValue returns incorrect value for \u00a3 formatted cells
      */
-    public void test49928() {
+       @Test
+    public void test49928() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49928.xlsx");
         doTest49928Core(wb);
         
@@ -57,26 +61,31 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
         short customFmtIdx = dataFormat.getFormat(customFmt);
         assertTrue(customFmtIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX);
         assertEquals(customFmt, dataFormat.getFormat(customFmtIdx));
+        
+        wb.close();
     }
     
     /**
      * [Bug 58532] Handle formats that go numnum, numK, numM etc 
      */
-    public void test58532() {
+       @Test
+    public void test58532() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("FormatKM.xlsx");
         doTest58532Core(wb);
+        wb.close();
     }
     
     /**
      * [Bug 58778] Built-in number formats can be overridden with XSSFDataFormat.putFormat(int id, String fmt)
      */
+       @Test
     public void test58778() throws IOException {
-        XSSFWorkbook wb = new XSSFWorkbook();
-        Cell cell = wb.createSheet("bug58778").createRow(0).createCell(0);
+        XSSFWorkbook wb1 = new XSSFWorkbook();
+        Cell cell = wb1.createSheet("bug58778").createRow(0).createCell(0);
         cell.setCellValue(5.25);
-        CellStyle style = wb.createCellStyle();
+        CellStyle style = wb1.createCellStyle();
         
-        XSSFDataFormat dataFormat = wb.createDataFormat();
+        XSSFDataFormat dataFormat = wb1.createDataFormat();
         
         short poundFmtIdx = 6;
         dataFormat.putFormat(poundFmtIdx, poundFmt);
@@ -84,9 +93,9 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
         cell.setCellStyle(style);
         // Cell should appear as "<poundsymbol>5"
         
-        wb = XSSFTestDataSamples.writeOutCloseAndReadBack(wb);
-        cell = wb.getSheet("bug58778").getRow(0).getCell(0);
-        assertEquals(5.25, cell.getNumericCellValue());
+        XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutCloseAndReadBack(wb1);
+        cell = wb2.getSheet("bug58778").getRow(0).getCell(0);
+        assertEquals(5.25, cell.getNumericCellValue(), 0);
         
         style = cell.getCellStyle();
         assertEquals(poundFmt, style.getDataFormatString());
@@ -94,6 +103,7 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
         
         // manually check the file to make sure the cell is rendered as "<poundsymbol>5"
         // Verified with LibreOffice 4.2.8.2 on 2015-12-28
-        wb.close();
+        wb2.close();
+        wb1.close();
     }
 }
index 6b6fc81a5a2114ded9be9a079994a5850fc5ffe6..88caed993640ecf661302d62696796b13ab5153d 100644 (file)
 
 package org.apache.poi.hssf.usermodel;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestDataFormat;
+import org.apache.poi.ss.usermodel.BuiltinFormats;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
+import org.junit.Test;
 
 /**
  * Tests for {@link HSSFDataFormat}
@@ -36,7 +47,8 @@ public final class TestHSSFDataFormat extends BaseTestDataFormat {
     /**
      * [Bug 49928] formatCellValue returns incorrect value for \u00a3 formatted cells
      */
-    public void test49928(){
+    @Test
+    public void test49928() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49928.xls");
         doTest49928Core(wb);
 
@@ -49,20 +61,25 @@ public final class TestHSSFDataFormat extends BaseTestDataFormat {
         short customFmtIdx = dataFormat.getFormat("\u00a3##.00[Yellow]");
         assertTrue(customFmtIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX );
         assertEquals("\u00a3##.00[Yellow]", dataFormat.getFormat(customFmtIdx));
+        
+        wb.close();
     }
 
     /**
      * [Bug 58532] Handle formats that go numnum, numK, numM etc 
      */
-    public void test58532() {
+    @Test
+    public void test58532() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("FormatKM.xls");
         doTest58532Core(wb);
+        wb.close();
     }
 
     /**
      * Bug 51378: getDataFormatString method call crashes when reading the test file
      */
-    public void test51378(){
+    @Test
+    public void test51378() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("12561-1.xls");
         for (int i = 0; i < wb.getNumberOfSheets(); i++) {
             HSSFSheet sheet = wb.getSheetAt(i);
@@ -77,6 +94,7 @@ public final class TestHSSFDataFormat extends BaseTestDataFormat {
                 }
             }
         }
+        wb.close();
     }
 
 }
index f6326f779234afb9e16ffb2cccfd3be00b393b0d..1686790255ff9d04f9e8092acfbfb8ed1fcdffeb 100644 (file)
@@ -34,6 +34,7 @@ import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 public class BaseTestSlideShowFactory {
     private static final POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
 
+    @SuppressWarnings("resource")
     protected static void testFactoryFromFile(String file) throws Exception {
         SlideShow<?,?> ss;
         // from file
@@ -42,6 +43,7 @@ public class BaseTestSlideShowFactory {
         assertCloseDoesNotModifyFile(file, ss);
     }
 
+    @SuppressWarnings("resource")
     protected static void testFactoryFromStream(String file) throws Exception {
         SlideShow<?,?> ss;
         // from stream
@@ -50,6 +52,7 @@ public class BaseTestSlideShowFactory {
         assertCloseDoesNotModifyFile(file, ss);
     }
 
+    @SuppressWarnings("resource")
     protected static void testFactoryFromNative(String file) throws Exception {
         SlideShow<?,?> ss;
         // from NPOIFS
@@ -70,6 +73,7 @@ public class BaseTestSlideShowFactory {
         }
     }
 
+    @SuppressWarnings("resource")
     protected static void testFactoryFromProtectedFile(String protectedFile, String password) throws Exception {
         SlideShow<?,?> ss;
         // from protected file 
@@ -78,6 +82,7 @@ public class BaseTestSlideShowFactory {
         assertCloseDoesNotModifyFile(protectedFile, ss);
     }
 
+    @SuppressWarnings("resource")
     protected static void testFactoryFromProtectedStream(String protectedFile, String password) throws Exception {
         SlideShow<?,?> ss;
         // from protected stream
@@ -86,6 +91,7 @@ public class BaseTestSlideShowFactory {
         assertCloseDoesNotModifyFile(protectedFile, ss);
     }
 
+    @SuppressWarnings("resource")
     protected static void testFactoryFromProtectedNative(String protectedFile, String password) throws Exception {
         SlideShow<?,?> ss;
         // Encryption layer is a BIFF8 binary format that can be read by NPOIFSFileSystem,
index 1b93c22a11104fafe80f39250c4e918edb708639..65d6911c22484086169bf661c05b393dc0d56c4d 100644 (file)
@@ -28,6 +28,7 @@ import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.util.Units;
 import org.junit.Test;
 
@@ -47,11 +48,11 @@ public abstract class BaseTestCellComment {
     public final void find() throws IOException {
         Workbook book = _testDataProvider.createWorkbook();
         Sheet sheet = book.createSheet();
-        assertNull(sheet.getCellComment(0, 0));
+        assertNull(sheet.getCellComment(new CellAddress(0, 0)));
 
         Row row = sheet.createRow(0);
         Cell cell = row.createCell(0);
-        assertNull(sheet.getCellComment(0, 0));
+        assertNull(sheet.getCellComment(new CellAddress(0, 0)));
         assertNull(cell.getCellComment());
         book.close();
     }
@@ -68,12 +69,12 @@ public abstract class BaseTestCellComment {
         CreationHelper factory = wb1.getCreationHelper();
 
         Sheet sheet = wb1.createSheet();
-        assertNull(sheet.getCellComment(cellRow, cellColumn));
+        assertNull(sheet.getCellComment(new CellAddress(cellRow, cellColumn)));
 
         Cell cell = sheet.createRow(cellRow).createCell(cellColumn);
         cell.setCellValue(factory.createRichTextString(cellText));
         assertNull(cell.getCellComment());
-        assertNull(sheet.getCellComment(cellRow, cellColumn));
+        assertNull(sheet.getCellComment(new CellAddress(cellRow, cellColumn)));
 
         Drawing patr = sheet.createDrawingPatriarch();
         ClientAnchor anchor = factory.createClientAnchor();
@@ -90,7 +91,7 @@ public abstract class BaseTestCellComment {
         comment.setAuthor(commentAuthor);
         cell.setCellComment(comment);
         assertNotNull(cell.getCellComment());
-        assertNotNull(sheet.getCellComment(cellRow, cellColumn));
+        assertNotNull(sheet.getCellComment(new CellAddress(cellRow, cellColumn)));
 
         //verify our settings
         assertEquals(commentAuthor, comment.getAuthor());
@@ -152,7 +153,7 @@ public abstract class BaseTestCellComment {
             cell = row.getCell(0);
             comment = cell.getCellComment();
             assertNull("Cells in the first column are not commented", comment);
-            assertNull(sheet.getCellComment(rownum, 0));
+            assertNull(sheet.getCellComment(new CellAddress(rownum, 0)));
         }
 
         for (int rownum = 0; rownum < 3; rownum++) {
@@ -160,7 +161,7 @@ public abstract class BaseTestCellComment {
             cell = row.getCell(1);
             comment = cell.getCellComment();
             assertNotNull("Cells in the second column have comments", comment);
-            assertNotNull("Cells in the second column have comments", sheet.getCellComment(rownum, 1));
+            assertNotNull("Cells in the second column have comments", sheet.getCellComment(new CellAddress(rownum, 1)));
 
             assertEquals("Yegor Kozlov", comment.getAuthor());
             assertFalse("cells in the second column have not empyy notes",
index 9d238c9f93cbc1e00795bca9e0f959417deba22b..70ba300b7147624f248c4246c91c7a5907148543 100644 (file)
 
 package org.apache.poi.ss.usermodel;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
 import org.apache.poi.ss.ITestDataProvider;
+import org.junit.Test;
 
 /**
  * Tests of implementation of {@link DataFormat}
  *
  */
-public abstract class BaseTestDataFormat extends TestCase {
+public abstract class BaseTestDataFormat {
 
     private final ITestDataProvider _testDataProvider;
 
     protected BaseTestDataFormat(ITestDataProvider testDataProvider) {
         _testDataProvider = testDataProvider;
     }
-    
+
     public void assertNotBuiltInFormat(String customFmt) {
         //check it is not in built-in formats
         assertEquals(-1, BuiltinFormats.getBuiltinFormat(customFmt));
     }
 
-    public final void testBuiltinFormats() {
+    @Test
+    public final void testBuiltinFormats() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
 
         DataFormat df = wb.createDataFormat();
@@ -66,13 +70,16 @@ public abstract class BaseTestDataFormat extends TestCase {
         assertTrue(customIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX);
         //read and verify the string representation
         assertEquals(customFmt, df.getFormat((short)customIdx));
+
+        wb.close();
     }
-    
+
     /**
      * [Bug 49928] formatCellValue returns incorrect value for \u00a3 formatted cells
      */
-    public abstract void test49928();
-    protected final String poundFmt = "\"\u00a3\"#,##0;[Red]\\-\"\u00a3\"#,##0";
+    @Test
+    public abstract void test49928() throws IOException;
+    protected final static String poundFmt = "\"\u00a3\"#,##0;[Red]\\-\"\u00a3\"#,##0";
     public void doTest49928Core(Workbook wb){
         DataFormatter df = new DataFormatter();
 
@@ -80,8 +87,7 @@ public abstract class BaseTestDataFormat extends TestCase {
         Cell cell = sheet.getRow(0).getCell(0);
         CellStyle style = cell.getCellStyle();
 
-        String poundFmt = "\"\u00a3\"#,##0;[Red]\\-\"\u00a3\"#,##0";
-        // not expected normally, id of a custom format should be greater 
+        // not expected normally, id of a custom format should be greater
         // than BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX
         short  poundFmtIdx = 6;
 
@@ -94,16 +100,17 @@ public abstract class BaseTestDataFormat extends TestCase {
         assertEquals(poundFmtIdx, dataFormat.getFormat(poundFmt));
         assertEquals(poundFmt, dataFormat.getFormat(poundFmtIdx));
     }
-    
+
+    @Test
     public void testReadbackFormat() throws IOException {
         readbackFormat("built-in format", "0.00");
         readbackFormat("overridden built-in format", poundFmt);
-        
+
         String customFormat = "#0.00 AM/PM";
         assertNotBuiltInFormat(customFormat);
         readbackFormat("custom format", customFormat);
     }
-    
+
     private void readbackFormat(String msg, String fmt) throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         try {
@@ -115,118 +122,124 @@ public abstract class BaseTestDataFormat extends TestCase {
             wb.close();
         }
     }
-    
-    public abstract void test58532();
+
+    @Test
+    public abstract void test58532() throws IOException;
     public void doTest58532Core(Workbook wb) {
         Sheet s = wb.getSheetAt(0);
         DataFormatter fmt = new DataFormatter();
         FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
-        
+
         // Column A is the raw values
         // Column B is the ##/#K/#M values
         // Column C is strings of what they should look like
         // Column D is the #.##/#.#K/#.#M values
         // Column E is strings of what they should look like
-        
+
         String formatKMWhole = "[>999999]#,,\"M\";[>999]#,\"K\";#";
         String formatKM3dp = "[>999999]#.000,,\"M\";[>999]#.000,\"K\";#.000";
-        
+
         // Check the formats are as expected
         Row headers = s.getRow(0);
         assertNotNull(headers);
         assertEquals(formatKMWhole, headers.getCell(1).getStringCellValue());
         assertEquals(formatKM3dp, headers.getCell(3).getStringCellValue());
-        
+
         Row r2 = s.getRow(1);
         assertNotNull(r2);
         assertEquals(formatKMWhole, r2.getCell(1).getCellStyle().getDataFormatString());
         assertEquals(formatKM3dp, r2.getCell(3).getCellStyle().getDataFormatString());
-        
+
         // For all of the contents rows, check that DataFormatter is able
         //  to format the cells to the same value as the one next to it
         for (int rn=1; rn<s.getLastRowNum(); rn++) {
             Row r = s.getRow(rn);
             if (r == null) break;
-            
+
             double value = r.getCell(0).getNumericCellValue();
-            
+
             String expWhole = r.getCell(2).getStringCellValue();
             String exp3dp   = r.getCell(4).getStringCellValue();
-            
+
             assertEquals("Wrong formatting of " + value + " for row " + rn,
                          expWhole, fmt.formatCellValue(r.getCell(1), eval));
             assertEquals("Wrong formatting of " + value + " for row " + rn,
                          exp3dp, fmt.formatCellValue(r.getCell(3), eval));
         }
     }
-    
+
     /**
-     * Localised accountancy formats
+     * Localized accountancy formats
      */
-    public final void test58536() {
+    @Test
+    public final void test58536() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         DataFormatter formatter = new DataFormatter();
         DataFormat fmt = wb.createDataFormat();
         Sheet sheet = wb.createSheet();
         Row r = sheet.createRow(0);
-        
+
         char pound = '\u00A3';
         String formatUK  = "_-[$"+pound+"-809]* #,##0_-;\\-[$"+pound+"-809]* #,##0_-;_-[$"+pound+"-809]* \"-\"??_-;_-@_-";
-        
+
         CellStyle cs = wb.createCellStyle();
         cs.setDataFormat(fmt.getFormat(formatUK));
-        
+
         Cell pve = r.createCell(0);
         pve.setCellValue(12345);
         pve.setCellStyle(cs);
-        
+
         Cell nve = r.createCell(1);
         nve.setCellValue(-12345);
         nve.setCellStyle(cs);
-        
+
         Cell zero = r.createCell(2);
         zero.setCellValue(0);
         zero.setCellStyle(cs);
-        
-        assertEquals(pound+"   12,345", formatter.formatCellValue(pve)); 
+
+        assertEquals(pound+"   12,345", formatter.formatCellValue(pve));
         assertEquals("-"+pound+"   12,345", formatter.formatCellValue(nve));
         // TODO Fix this to not have an extra 0 at the end
-        //assertEquals(pound+"   -  ", formatter.formatCellValue(zero)); 
+        //assertEquals(pound+"   -  ", formatter.formatCellValue(zero));
+        
+        wb.close();
     }
-    
+
     /**
      * Using a single quote (') instead of a comma (,) as
-     *  a number separator, eg 1000 -> 1'000 
+     *  a number separator, eg 1000 -> 1'000
      */
-    public final void test55265() {
+    @Test
+    public final void test55265() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
         DataFormatter formatter = new DataFormatter();
         DataFormat fmt = wb.createDataFormat();
         Sheet sheet = wb.createSheet();
         Row r = sheet.createRow(0);
-        
+
         CellStyle cs = wb.createCellStyle();
         cs.setDataFormat(fmt.getFormat("#'##0"));
-        
+
         Cell zero = r.createCell(0);
         zero.setCellValue(0);
         zero.setCellStyle(cs);
-        
+
         Cell sml = r.createCell(1);
         sml.setCellValue(12);
         sml.setCellStyle(cs);
-        
+
         Cell med = r.createCell(2);
         med.setCellValue(1234);
         med.setCellStyle(cs);
-        
+
         Cell lge = r.createCell(3);
         lge.setCellValue(12345678);
         lge.setCellStyle(cs);
-        
-        assertEquals("0", formatter.formatCellValue(zero)); 
-        assertEquals("12", formatter.formatCellValue(sml)); 
-        assertEquals("1'234", formatter.formatCellValue(med)); 
-        assertEquals("12'345'678", formatter.formatCellValue(lge)); 
+
+        assertEquals("0", formatter.formatCellValue(zero));
+        assertEquals("12", formatter.formatCellValue(sml));
+        assertEquals("1'234", formatter.formatCellValue(med));
+        assertEquals("12'345'678", formatter.formatCellValue(lge));
+        wb.close();
     }
 }
index 77806e1af945af9f98c86c7ef86e0c82498e341e..7846c256a93faab4997022e8fb7d0625b5085b66 100644 (file)
@@ -168,16 +168,16 @@ public abstract class BaseTestSheetShiftRows {
         assertEquals(3, sheet.getLastRowNum());
 
         // Verify comments are in the position expected
-        assertNotNull(sheet.getCellComment(0,0));
-        assertNull(sheet.getCellComment(1,0));
-        assertNotNull(sheet.getCellComment(2,0));
-        assertNotNull(sheet.getCellComment(3,0));
+        assertNotNull(sheet.getCellComment(new CellAddress(0,0)));
+        assertNull(sheet.getCellComment(new CellAddress(1,0)));
+        assertNotNull(sheet.getCellComment(new CellAddress(2,0)));
+        assertNotNull(sheet.getCellComment(new CellAddress(3,0)));
 
-        String comment1 = sheet.getCellComment(0,0).getString().getString();
+        String comment1 = sheet.getCellComment(new CellAddress(0,0)).getString().getString();
         assertEquals(comment1,"comment top row1 (index0)\n");
-        String comment3 = sheet.getCellComment(2,0).getString().getString();
+        String comment3 = sheet.getCellComment(new CellAddress(2,0)).getString().getString();
         assertEquals(comment3,"comment top row3 (index2)\n");
-        String comment4 = sheet.getCellComment(3,0).getString().getString();
+        String comment4 = sheet.getCellComment(new CellAddress(3,0)).getString().getString();
         assertEquals(comment4,"comment top row4 (index3)\n");
 
         //Workbook wbBack = _testDataProvider.writeOutAndReadBack(wb);
@@ -187,17 +187,17 @@ public abstract class BaseTestSheetShiftRows {
 
         // Test that comments were shifted as expected
         assertEquals(4, sheet.getLastRowNum());
-        assertNotNull(sheet.getCellComment(0,0));
-        assertNull(sheet.getCellComment(1,0));
-        assertNull(sheet.getCellComment(2,0));
-        assertNotNull(sheet.getCellComment(3,0));
-        assertNotNull(sheet.getCellComment(4,0));
+        assertNotNull(sheet.getCellComment(new CellAddress(0,0)));
+        assertNull(sheet.getCellComment(new CellAddress(1,0)));
+        assertNull(sheet.getCellComment(new CellAddress(2,0)));
+        assertNotNull(sheet.getCellComment(new CellAddress(3,0)));
+        assertNotNull(sheet.getCellComment(new CellAddress(4,0)));
 
-        String comment1_shifted = sheet.getCellComment(0,0).getString().getString();
+        String comment1_shifted = sheet.getCellComment(new CellAddress(0,0)).getString().getString();
         assertEquals(comment1,comment1_shifted);
-        String comment3_shifted = sheet.getCellComment(3,0).getString().getString();
+        String comment3_shifted = sheet.getCellComment(new CellAddress(3,0)).getString().getString();
         assertEquals(comment3,comment3_shifted);
-        String comment4_shifted = sheet.getCellComment(4,0).getString().getString();
+        String comment4_shifted = sheet.getCellComment(new CellAddress(4,0)).getString().getString();
         assertEquals(comment4,comment4_shifted);
 
         // Write out and read back in again
@@ -209,17 +209,17 @@ public abstract class BaseTestSheetShiftRows {
         assertEquals(4, sheet.getLastRowNum());
 
         // Verify comments are in the position expected after the shift
-        assertNotNull(sheet.getCellComment(0,0));
-        assertNull(sheet.getCellComment(1,0));
-        assertNull(sheet.getCellComment(2,0));
-        assertNotNull(sheet.getCellComment(3,0));
-        assertNotNull(sheet.getCellComment(4,0));
+        assertNotNull(sheet.getCellComment(new CellAddress(0,0)));
+        assertNull(sheet.getCellComment(new CellAddress(1,0)));
+        assertNull(sheet.getCellComment(new CellAddress(2,0)));
+        assertNotNull(sheet.getCellComment(new CellAddress(3,0)));
+        assertNotNull(sheet.getCellComment(new CellAddress(4,0)));
 
-        comment1_shifted = sheet.getCellComment(0,0).getString().getString();
+        comment1_shifted = sheet.getCellComment(new CellAddress(0,0)).getString().getString();
         assertEquals(comment1,comment1_shifted);
-        comment3_shifted = sheet.getCellComment(3,0).getString().getString();
+        comment3_shifted = sheet.getCellComment(new CellAddress(3,0)).getString().getString();
         assertEquals(comment3,comment3_shifted);
-        comment4_shifted = sheet.getCellComment(4,0).getString().getString();
+        comment4_shifted = sheet.getCellComment(new CellAddress(4,0)).getString().getString();
         assertEquals(comment4,comment4_shifted);
 
         // Shifting back up again, now two rows
@@ -231,15 +231,15 @@ public abstract class BaseTestSheetShiftRows {
                assertEquals(2, sheet.getLastRowNum());
                
                // Verify comments are in the position expected
-               assertNull("Had: " + (sheet.getCellComment(0,0) == null ? "null" : sheet.getCellComment(0,0).getString()),
-                               sheet.getCellComment(0,0));
-               assertNotNull(sheet.getCellComment(1,0));
-               assertNotNull(sheet.getCellComment(2,0));
+               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(1,0).getString().getString();
+        comment1 = sheet.getCellComment(new CellAddress(1,0)).getString().getString();
         assertEquals(comment1,"comment top row3 (index2)\n");
-        String comment2 = sheet.getCellComment(2,0).getString().getString();
+        String comment2 = sheet.getCellComment(new CellAddress(2,0)).getString().getString();
         assertEquals(comment2,"comment top row4 (index3)\n");
         
         wb2.close();
@@ -342,6 +342,7 @@ public abstract class BaseTestSheetShiftRows {
         expectedMergedRegions.add(C4_D8);
         
         assertEquals(expectedMergedRegions, sheet.getMergedRegions());
+        wb.close();
     }