From: Andreas Beeker Date: Fri, 18 Mar 2016 23:12:28 +0000 (+0000) Subject: eclipse warning fixes X-Git-Tag: REL_3_15_BETA2~419 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=78d19690c85e2c9b002e9e65d056dbd89e59950a;p=poi.git eclipse warning fixes git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1735706 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java b/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java index bb120861f6..5512aa04fd 100644 --- a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java +++ b/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java @@ -140,6 +140,8 @@ public class CalendarDemo { FileOutputStream out = new FileOutputStream(file); wb.write(out); out.close(); + + wb.close(); } /** diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java index d8baaceda5..48e3fd122d 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java @@ -127,6 +127,8 @@ public class CalendarDemo { FileOutputStream out = new FileOutputStream("calendar-"+year+".xlsx"); wb.write(out); out.close(); + + wb.close(); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java index b876518ef5..36ce03406e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java @@ -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 "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 "5" // Verified with LibreOffice 4.2.8.2 on 2015-12-28 - wb.close(); + wb2.close(); + wb1.close(); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java index 6b6fc81a5a..88caed9936 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java @@ -17,11 +17,22 @@ 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(); } } diff --git a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java index f6326f7792..1686790255 100644 --- a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java +++ b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java @@ -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, diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java index 1b93c22a11..65d6911c22 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java @@ -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", diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java index 9d238c9f93..70ba300b71 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestDataFormat.java @@ -17,30 +17,34 @@ 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 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(); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java index 77806e1af9..7846c256a9 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java @@ -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(); }