Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java Thu 
Dec 24 18:42:29 2020
@@ -5,9 +5,9 @@
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
-   
+
    http://www.apache.org/licenses/LICENSE-2.0
-   
+
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,11 +17,12 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -39,7 +40,7 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.VerticalAlignment;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests Spreadsheet CellUtil
@@ -52,30 +53,29 @@ public abstract class BaseTestCellUtil {
     protected BaseTestCellUtil(ITestDataProvider testDataProvider) {
         _testDataProvider = testDataProvider;
     }
-    
+
     @Test
     public void setCellStyleProperty() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s = wb.createSheet();
-        Row r = s.createRow(0);
-        Cell c = r.createCell(0);
-
-        // Add a border should create a new style
-        int styCnt1 = wb.getNumCellStyles();
-        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 
BorderStyle.THIN);
-        int styCnt2 = wb.getNumCellStyles();
-        assertEquals(styCnt1+1, styCnt2);
-
-        // Add same border to another cell, should not create another style
-        c = r.createCell(1);
-        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 
BorderStyle.THIN);
-        int styCnt3 = wb.getNumCellStyles();
-        assertEquals(styCnt2, styCnt3);
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet s = wb.createSheet();
+            Row r = s.createRow(0);
+            Cell c = r.createCell(0);
 
-        wb.close();
+            // Add a border should create a new style
+            int styCnt1 = wb.getNumCellStyles();
+            CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 
BorderStyle.THIN);
+            int styCnt2 = wb.getNumCellStyles();
+            assertEquals(styCnt1 + 1, styCnt2);
+
+            // Add same border to another cell, should not create another style
+            c = r.createCell(1);
+            CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 
BorderStyle.THIN);
+            int styCnt3 = wb.getNumCellStyles();
+            assertEquals(styCnt2, styCnt3);
+        }
     }
-    
-    @Test(expected=RuntimeException.class)
+
+    @Test
     public void setCellStylePropertyWithInvalidValue() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             Sheet s = wb.createSheet();
@@ -83,127 +83,120 @@ public abstract class BaseTestCellUtil {
             Cell c = r.createCell(0);
 
             // An invalid BorderStyle constant
-            CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 42);
+            assertThrows(RuntimeException.class, () -> 
CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 42));
         }
     }
-    
+
     @Test()
     public void setCellStylePropertyBorderWithShortAndEnum() throws 
IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s = wb.createSheet();
-        Row r = s.createRow(0);
-        Cell c = r.createCell(0);
-
-        // A valid BorderStyle constant, as a Short
-        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 
BorderStyle.DASH_DOT.getCode());
-        assertEquals(BorderStyle.DASH_DOT, c.getCellStyle().getBorderBottom());
-        
-        // A valid BorderStyle constant, as an Enum
-        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_TOP, 
BorderStyle.MEDIUM_DASH_DOT);
-        assertEquals(BorderStyle.MEDIUM_DASH_DOT, 
c.getCellStyle().getBorderTop());
-        
-        wb.close();
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet s = wb.createSheet();
+            Row r = s.createRow(0);
+            Cell c = r.createCell(0);
+
+            // A valid BorderStyle constant, as a Short
+            CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 
BorderStyle.DASH_DOT.getCode());
+            assertEquals(BorderStyle.DASH_DOT, 
c.getCellStyle().getBorderBottom());
+
+            // A valid BorderStyle constant, as an Enum
+            CellUtil.setCellStyleProperty(c, CellUtil.BORDER_TOP, 
BorderStyle.MEDIUM_DASH_DOT);
+            assertEquals(BorderStyle.MEDIUM_DASH_DOT, 
c.getCellStyle().getBorderTop());
+        }
     }
 
     @Test
     public void setCellStyleProperties() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s = wb.createSheet();
-        Row r = s.createRow(0);
-        Cell c = r.createCell(0);
-
-        // Add multiple border properties to cell should create a single new 
style
-        int styCnt1 = wb.getNumCellStyles();
-        Map<String, Object> props = new HashMap<>();
-        props.put(CellUtil.BORDER_TOP, BorderStyle.THIN);
-        props.put(CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
-        props.put(CellUtil.BORDER_LEFT, BorderStyle.THIN);
-        props.put(CellUtil.BORDER_RIGHT, BorderStyle.THIN);
-        props.put(CellUtil.ALIGNMENT, HorizontalAlignment.CENTER.getCode()); 
// try it both with a Short (deprecated)
-        props.put(CellUtil.VERTICAL_ALIGNMENT, VerticalAlignment.CENTER); // 
and with an enum
-        CellUtil.setCellStyleProperties(c, props);
-        int styCnt2 = wb.getNumCellStyles();
-        assertEquals("Only one additional style should have been created", 
styCnt1 + 1, styCnt2);
-
-        // Add same border another to same cell, should not create another 
style
-        c = r.createCell(1);
-        CellUtil.setCellStyleProperties(c, props);
-        int styCnt3 = wb.getNumCellStyles();
-        assertEquals("No additional styles should have been created", styCnt2, 
styCnt3);
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet s = wb.createSheet();
+            Row r = s.createRow(0);
+            Cell c = r.createCell(0);
 
-        wb.close();
-        
+            // Add multiple border properties to cell should create a single 
new style
+            int styCnt1 = wb.getNumCellStyles();
+            Map<String, Object> props = new HashMap<>();
+            props.put(CellUtil.BORDER_TOP, BorderStyle.THIN);
+            props.put(CellUtil.BORDER_BOTTOM, BorderStyle.THIN);
+            props.put(CellUtil.BORDER_LEFT, BorderStyle.THIN);
+            props.put(CellUtil.BORDER_RIGHT, BorderStyle.THIN);
+            props.put(CellUtil.ALIGNMENT, 
HorizontalAlignment.CENTER.getCode()); // try it both with a Short (deprecated)
+            props.put(CellUtil.VERTICAL_ALIGNMENT, VerticalAlignment.CENTER); 
// and with an enum
+            CellUtil.setCellStyleProperties(c, props);
+            int styCnt2 = wb.getNumCellStyles();
+            assertEquals(styCnt1 + 1, styCnt2, "Only one additional style 
should have been created");
+
+            // Add same border another to same cell, should not create another 
style
+            c = r.createCell(1);
+            CellUtil.setCellStyleProperties(c, props);
+            int styCnt3 = wb.getNumCellStyles();
+            assertEquals(styCnt2, styCnt3, "No additional styles should have 
been created");
+        }
     }
 
     @Test
     public void getRow() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
-        Row row1 = sh.createRow(0);
-        
-        // Get row that already exists
-        Row r1 = CellUtil.getRow(0, sh);
-        assertNotNull(r1);
-        assertSame("An existing row should not be recreated", row1, r1);
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet sh = wb.createSheet();
+            Row row1 = sh.createRow(0);
 
-        // Get row that does not exist yet
-        assertNotNull(CellUtil.getRow(1, sh));
+            // Get row that already exists
+            Row r1 = CellUtil.getRow(0, sh);
+            assertNotNull(r1);
+            assertSame(row1, r1, "An existing row should not be recreated");
 
-        wb.close();
+            // Get row that does not exist yet
+            assertNotNull(CellUtil.getRow(1, sh));
+        }
     }
 
     @Test
     public void getCell() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
-        Row row = sh.createRow(0);
-        Cell A1 = row.createCell(0);
-
-        // Get cell that already exists
-        Cell a1 = CellUtil.getCell(row, 0);
-        assertNotNull(a1);
-        assertSame("An existing cell should not be recreated", A1, a1);
-
-        // Get cell that does not exist yet
-        assertNotNull(CellUtil.getCell(row, 1));
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet sh = wb.createSheet();
+            Row row = sh.createRow(0);
+            Cell A1 = row.createCell(0);
+
+            // Get cell that already exists
+            Cell a1 = CellUtil.getCell(row, 0);
+            assertNotNull(a1);
+            assertSame(A1, a1, "An existing cell should not be recreated");
 
-        wb.close();
+            // Get cell that does not exist yet
+            assertNotNull(CellUtil.getCell(row, 1));
+        }
     }
 
     @Test
     public void createCell() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
-        Row row = sh.createRow(0);
-
-        CellStyle style = wb.createCellStyle();
-        style.setWrapText(true);
-
-        // calling createCell on a non-existing cell should create a cell and 
set the cell value and style.
-        Cell F1 = CellUtil.createCell(row, 5, "Cell Value", style);
-
-        assertSame(row.getCell(5), F1);
-        assertEquals("Cell Value", F1.getStringCellValue());
-        assertEquals(style, F1.getCellStyle());
-        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call.
-        // HSSFCellStyle wraps an underlying style record, and the underlying
-        // style record is the same between multiple getCellStyle() calls.
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet sh = wb.createSheet();
+            Row row = sh.createRow(0);
 
-        // calling createCell on an existing cell should return the existing 
cell and modify the cell value and style.
-        Cell f1 = CellUtil.createCell(row, 5, "Overwritten cell value", null);
-        assertSame(row.getCell(5), f1);
-        assertSame(F1, f1);
-        assertEquals("Overwritten cell value", f1.getStringCellValue());
-        assertEquals("Overwritten cell value", F1.getStringCellValue());
-        assertEquals("cell style should be unchanged with createCell(..., 
null)", style, f1.getCellStyle());
-        assertEquals("cell style should be unchanged with createCell(..., 
null)", style, F1.getCellStyle());
-
-        // test createCell(row, column, value) (no CellStyle)
-        f1 = CellUtil.createCell(row, 5, "Overwritten cell with default 
style");
-        assertSame(F1, f1);
+            CellStyle style = wb.createCellStyle();
+            style.setWrapText(true);
 
-        wb.close();
+            // calling createCell on a non-existing cell should create a cell 
and set the cell value and style.
+            Cell F1 = CellUtil.createCell(row, 5, "Cell Value", style);
 
+            assertSame(row.getCell(5), F1);
+            assertEquals("Cell Value", F1.getStringCellValue());
+            assertEquals(style, F1.getCellStyle());
+            // should be assertSame, but a new HSSFCellStyle is returned for 
each getCellStyle() call.
+            // HSSFCellStyle wraps an underlying style record, and the 
underlying
+            // style record is the same between multiple getCellStyle() calls.
+
+            // calling createCell on an existing cell should return the 
existing cell and modify the cell value and style.
+            Cell f1 = CellUtil.createCell(row, 5, "Overwritten cell value", 
null);
+            assertSame(row.getCell(5), f1);
+            assertSame(F1, f1);
+            assertEquals("Overwritten cell value", f1.getStringCellValue());
+            assertEquals("Overwritten cell value", F1.getStringCellValue());
+            assertEquals(style, f1.getCellStyle(), "cell style should be 
unchanged with createCell(..., null)");
+            assertEquals(style, F1.getCellStyle(), "cell style should be 
unchanged with createCell(..., null)");
+
+            // test createCell(row, column, value) (no CellStyle)
+            f1 = CellUtil.createCell(row, 5, "Overwritten cell with default 
style");
+            assertSame(F1, f1);
+        }
     }
 
     /**
@@ -221,7 +214,7 @@ public abstract class BaseTestCellUtil {
 
         // Assumptions
         assertEquals(A1.getCellStyle(), B1.getCellStyle());
-        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call. 
+        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call.
         // HSSFCellStyle wraps an underlying style record, and the underlying
         // style record is the same between multiple getCellStyle() calls.
         assertEquals(HorizontalAlignment.GENERAL, 
A1.getCellStyle().getAlignment());
@@ -238,7 +231,7 @@ public abstract class BaseTestCellUtil {
 
         wb.close();
     }
-    
+
     @Test
     public void setAlignmentEnum() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
@@ -249,7 +242,7 @@ public abstract class BaseTestCellUtil {
 
         // Assumptions
         assertEquals(A1.getCellStyle(), B1.getCellStyle());
-        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call. 
+        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call.
         // HSSFCellStyle wraps an underlying style record, and the underlying
         // style record is the same between multiple getCellStyle() calls.
         assertEquals(HorizontalAlignment.GENERAL, 
A1.getCellStyle().getAlignment());
@@ -266,94 +259,83 @@ public abstract class BaseTestCellUtil {
 
         wb.close();
     }
-    
+
     @Test
     public void setVerticalAlignmentEnum() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
-        Row row = sh.createRow(0);
-        Cell A1 = row.createCell(0);
-        Cell B1 = row.createCell(1);
-
-        // Assumptions
-        assertEquals(A1.getCellStyle(), B1.getCellStyle());
-        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call. 
-        // HSSFCellStyle wraps an underlying style record, and the underlying
-        // style record is the same between multiple getCellStyle() calls.
-        assertEquals(VerticalAlignment.BOTTOM, 
A1.getCellStyle().getVerticalAlignment());
-        assertEquals(VerticalAlignment.BOTTOM, 
B1.getCellStyle().getVerticalAlignment());
-
-        // get/set alignment modifies the cell's style
-        CellUtil.setVerticalAlignment(A1, VerticalAlignment.TOP);
-        assertEquals(VerticalAlignment.TOP, 
A1.getCellStyle().getVerticalAlignment());
-
-        // get/set alignment doesn't affect the style of cells with
-        // the same style prior to modifying the style
-        assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
-        assertEquals(VerticalAlignment.BOTTOM, 
B1.getCellStyle().getVerticalAlignment());
-
-        wb.close();
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet sh = wb.createSheet();
+            Row row = sh.createRow(0);
+            Cell A1 = row.createCell(0);
+            Cell B1 = row.createCell(1);
+
+            // Assumptions
+            assertEquals(A1.getCellStyle(), B1.getCellStyle());
+            // should be assertSame, but a new HSSFCellStyle is returned for 
each getCellStyle() call.
+            // HSSFCellStyle wraps an underlying style record, and the 
underlying
+            // style record is the same between multiple getCellStyle() calls.
+            assertEquals(VerticalAlignment.BOTTOM, 
A1.getCellStyle().getVerticalAlignment());
+            assertEquals(VerticalAlignment.BOTTOM, 
B1.getCellStyle().getVerticalAlignment());
+
+            // get/set alignment modifies the cell's style
+            CellUtil.setVerticalAlignment(A1, VerticalAlignment.TOP);
+            assertEquals(VerticalAlignment.TOP, 
A1.getCellStyle().getVerticalAlignment());
+
+            // get/set alignment doesn't affect the style of cells with
+            // the same style prior to modifying the style
+            assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
+            assertEquals(VerticalAlignment.BOTTOM, 
B1.getCellStyle().getVerticalAlignment());
+        }
     }
 
     @Test
     public void setFont() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
-        Row row = sh.createRow(0);
-        Cell A1 = row.createCell(0);
-        Cell B1 = row.createCell(1);
-        final int defaultFontIndex = 0;
-        Font font = wb.createFont();
-        font.setItalic(true);
-        final int customFontIndex = font.getIndex();
-
-        // Assumptions
-        assertNotEquals(defaultFontIndex, customFontIndex);
-        assertEquals(A1.getCellStyle(), B1.getCellStyle());
-        // should be assertSame, but a new HSSFCellStyle is returned for each 
getCellStyle() call. 
-        // HSSFCellStyle wraps an underlying style record, and the underlying
-        // style record is the same between multiple getCellStyle() calls.
-        assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndex());
-        assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
-
-        // get/set alignment modifies the cell's style
-        CellUtil.setFont(A1, font);
-        assertEquals(customFontIndex, A1.getCellStyle().getFontIndex());
-
-        // get/set alignment doesn't affect the style of cells with
-        // the same style prior to modifying the style
-        assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
-        assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
-
-        wb.close();
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet sh = wb.createSheet();
+            Row row = sh.createRow(0);
+            Cell A1 = row.createCell(0);
+            Cell B1 = row.createCell(1);
+            final int defaultFontIndex = 0;
+            Font font = wb.createFont();
+            font.setItalic(true);
+            final int customFontIndex = font.getIndex();
+
+            // Assumptions
+            assertNotEquals(defaultFontIndex, customFontIndex);
+            assertEquals(A1.getCellStyle(), B1.getCellStyle());
+            // should be assertSame, but a new HSSFCellStyle is returned for 
each getCellStyle() call.
+            // HSSFCellStyle wraps an underlying style record, and the 
underlying
+            // style record is the same between multiple getCellStyle() calls.
+            assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndex());
+            assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
+
+            // get/set alignment modifies the cell's style
+            CellUtil.setFont(A1, font);
+            assertEquals(customFontIndex, A1.getCellStyle().getFontIndex());
+
+            // get/set alignment doesn't affect the style of cells with
+            // the same style prior to modifying the style
+            assertNotEquals(A1.getCellStyle(), B1.getCellStyle());
+            assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex());
+        }
     }
 
     @Test
     public void setFontFromDifferentWorkbook() throws IOException {
-        Workbook wb1 = _testDataProvider.createWorkbook();
-        Workbook wb2 = _testDataProvider.createWorkbook();
-        Font font1 = wb1.createFont();
-        Font font2 = wb2.createFont();
-        // do something to make font1 and font2 different
-        // so they are not same or equal.
-        font1.setItalic(true);
-        Cell A1 = wb1.createSheet().createRow(0).createCell(0);
-        
-        // okay
-        CellUtil.setFont(A1, font1);
-
-        // font belongs to different workbook
-        try {
-            CellUtil.setFont(A1, font2);
-            fail("setFont not allowed if font belongs to a different 
workbook");
-        } catch (final IllegalArgumentException e) {
-            // one specific message is expected
-            if (!e.getMessage().startsWith("Font does not belong to this 
workbook")) {
-                throw e;
-            }
-        } finally {
-            wb1.close();
-            wb2.close();
+        try (Workbook wb1 = _testDataProvider.createWorkbook();
+            Workbook wb2 = _testDataProvider.createWorkbook()) {
+            Font font1 = wb1.createFont();
+            Font font2 = wb2.createFont();
+            // do something to make font1 and font2 different
+            // so they are not same or equal.
+            font1.setItalic(true);
+            Cell A1 = wb1.createSheet().createRow(0).createCell(0);
+
+            // okay
+            CellUtil.setFont(A1, font1);
+
+            // font belongs to different workbook
+            IllegalArgumentException e = 
assertThrows(IllegalArgumentException.class, () -> CellUtil.setFont(A1, font2));
+            assertTrue(e.getMessage().startsWith("Font does not belong to this 
workbook"));
         }
     }
 
@@ -363,20 +345,19 @@ public abstract class BaseTestCellUtil {
      */
     @Test
     public void setFillForegroundColorBeforeFillBackgroundColorEnum() throws 
IOException {
-        Workbook wb1 = _testDataProvider.createWorkbook();
-        Cell A1 = wb1.createSheet().createRow(0).createCell(0);
-        Map<String, Object> properties = new HashMap<>();
-        properties.put(CellUtil.FILL_PATTERN, FillPatternType.BRICKS);
-        properties.put(CellUtil.FILL_FOREGROUND_COLOR, 
IndexedColors.BLUE.index);
-        properties.put(CellUtil.FILL_BACKGROUND_COLOR, 
IndexedColors.RED.index);
-        
-        CellUtil.setCellStyleProperties(A1, properties);
-        CellStyle style = A1.getCellStyle();
-        assertEquals("fill pattern", FillPatternType.BRICKS, 
style.getFillPattern());
-        assertEquals("fill foreground color", IndexedColors.BLUE, 
IndexedColors.fromInt(style.getFillForegroundColor()));
-        assertEquals("fill background color", IndexedColors.RED, 
IndexedColors.fromInt(style.getFillBackgroundColor()));
-
-        wb1.close();
+        try (Workbook wb1 = _testDataProvider.createWorkbook()) {
+            Cell A1 = wb1.createSheet().createRow(0).createCell(0);
+            Map<String, Object> properties = new HashMap<>();
+            properties.put(CellUtil.FILL_PATTERN, FillPatternType.BRICKS);
+            properties.put(CellUtil.FILL_FOREGROUND_COLOR, 
IndexedColors.BLUE.index);
+            properties.put(CellUtil.FILL_BACKGROUND_COLOR, 
IndexedColors.RED.index);
+
+            CellUtil.setCellStyleProperties(A1, properties);
+            CellStyle style = A1.getCellStyle();
+            assertEquals(FillPatternType.BRICKS, style.getFillPattern(), "fill 
pattern");
+            assertEquals(IndexedColors.BLUE, 
IndexedColors.fromInt(style.getFillForegroundColor()), "fill foreground color");
+            assertEquals(IndexedColors.RED, 
IndexedColors.fromInt(style.getFillBackgroundColor()), "fill background color");
+        }
     }
 
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestAreaReference.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestAreaReference.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestAreaReference.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestAreaReference.java Thu 
Dec 24 18:42:29 2020
@@ -16,20 +16,19 @@
 ==================================================================== */
 package org.apache.poi.ss.util;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.SpreadsheetVersion;
-
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for {@link AreaReference} handling of max rows.
- * 
+ *
  * @author David North
  */
 public class TestAreaReference {
@@ -63,7 +62,7 @@ public class TestAreaReference {
         assertEquals(0, oldStyle.getFirstCell().getRow());
         assertEquals(SpreadsheetVersion.EXCEL97.getLastColumnIndex(), 
oldStyle.getLastCell().getCol());
         assertEquals(1, oldStyle.getLastCell().getRow());
-        
+
         AreaReference newStyle = 
AreaReference.getWholeRow(SpreadsheetVersion.EXCEL2007, "1", "2");
         assertEquals(0, newStyle.getFirstCell().getCol());
         assertEquals(0, newStyle.getFirstCell().getRow());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellAddress.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellAddress.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellAddress.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellAddress.java Thu Dec 
24 18:42:29 2020
@@ -17,14 +17,15 @@
 
 package org.apache.poi.ss.util;
 
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 import java.util.Arrays;
 
+import org.junit.jupiter.api.Test;
+
 /**
  * Tests that the common CellAddress works as we need it to.
  */
@@ -57,7 +58,7 @@ public final class TestCellAddress {
         assertEquals(new CellReference(6, 4), new CellReference(6, 4));
         assertNotEquals(new CellReference(4, 6), new CellReference(6, 4));
     }
-    
+
     @SuppressWarnings("EqualsWithItself")
     @Test
     public void testCompareTo() {
@@ -65,27 +66,27 @@ public final class TestCellAddress {
         final CellAddress A2 = new CellAddress(1, 0);
         final CellAddress B1 = new CellAddress(0, 1);
         final CellAddress B2 = new CellAddress(1, 1);
-        
+
         assertEquals(0,  A1.compareTo(A1));
         assertEquals(-1, A1.compareTo(B1));
         assertEquals(-1, A1.compareTo(A2));
         assertEquals(-1, A1.compareTo(B2));
-        
+
         assertEquals(1,  B1.compareTo(A1));
         assertEquals(0,  B1.compareTo(B1));
         assertEquals(-1, B1.compareTo(A2));
         assertEquals(-1, B1.compareTo(B2));
-        
+
         assertEquals(1,  A2.compareTo(A1));
         assertEquals(1,  A2.compareTo(B1));
         assertEquals(0,  A2.compareTo(A2));
         assertEquals(-1, A2.compareTo(B2));
-        
+
         assertEquals(1,  B2.compareTo(A1));
         assertEquals(1,  B2.compareTo(B1));
         assertEquals(1,  B2.compareTo(A2));
         assertEquals(0,  B2.compareTo(B2));
-        
+
         CellAddress[] sorted = {A1, B1, A2, B2};
         CellAddress[] unsorted = {B1, B2, A1, A2};
         assumeTrue(!Arrays.equals(sorted, unsorted));
@@ -98,7 +99,7 @@ public final class TestCellAddress {
         final CellAddress addr = new CellAddress(6, 4);
         assertEquals(6, addr.getRow());
     }
-    
+
     @Test
     public void testGetColumn() {
         final CellAddress addr = new CellAddress(6, 4);

Modified: 
poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeAddress.java 
Thu Dec 24 18:42:29 2020
@@ -17,12 +17,13 @@ limitations under the License.
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -31,7 +32,7 @@ import java.util.NoSuchElementException;
 
 import org.apache.poi.hssf.record.TestcaseRecordInputStream;
 import org.apache.poi.util.LittleEndianOutputStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestCellRangeAddress {
     static final byte[] data = new byte[] {
@@ -53,13 +54,9 @@ public final class TestCellRangeAddress
 
     @Test
     public void testLoadInvalid() {
-        try {
-            new CellRangeAddress(
-                TestcaseRecordInputStream.create(0x000, new byte[] { 
(byte)0x02 }));
-            fail();
-        } catch (RuntimeException e) {
-            assertTrue("Had: " + e, e.getMessage().contains("Ran out of 
data"));
-        }
+        RuntimeException e = assertThrows(RuntimeException.class, () ->
+            new CellRangeAddress(TestcaseRecordInputStream.create(0x000, new 
byte[]{(byte) 0x02})));
+        assertTrue(e.getMessage().contains("Ran out of data"));
     }
 
     @Test
@@ -74,7 +71,7 @@ public final class TestCellRangeAddress
             recordBytes = baos.toByteArray();
             assertEquals(recordBytes.length, data.length);
             for (int i = 0; i < data.length; i++) {
-                assertEquals("At offset " + i, 0, recordBytes[i]);
+                assertEquals(0, recordBytes[i], "At offset " + i);
             }
 
             // Now set the flags
@@ -90,26 +87,16 @@ public final class TestCellRangeAddress
 
             assertEquals(recordBytes.length, data.length);
             for (int i = 0; i < data.length; i++) {
-                assertEquals("At offset " + i, data[i], recordBytes[i]);
+                assertEquals(data[i], recordBytes[i], "At offset " + i);
             }
         }
     }
-    
+
     @Test
-    public void testCreateIllegal() throws IOException {
+    public void testCreateIllegal() {
         // for some combinations we expected exceptions
-        try {
-            new CellRangeAddress(1, 0, 0, 0);
-            fail("Expect to catch an exception");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
-        try {
-            new CellRangeAddress(0, 0, 1, 0);
-            fail("Expect to catch an exception");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> new 
CellRangeAddress(1, 0, 0, 0));
+        assertThrows(IllegalArgumentException.class, () -> new 
CellRangeAddress(0, 0, 1, 0));
     }
 
     @Test
@@ -120,14 +107,14 @@ public final class TestCellRangeAddress
     }
 
     @Test
-    public void testGetEncodedSize() throws IOException {
+    public void testGetEncodedSize() {
         assertEquals(2*CellRangeAddress.ENCODED_SIZE, 
CellRangeAddress.getEncodedSize(2));
     }
 
     @Test
-    public void testFormatAsString() throws IOException {
+    public void testFormatAsString() {
         CellRangeAddress ref = new CellRangeAddress(1, 2, 3, 4);
-        
+
         assertEquals("D2:E3", ref.formatAsString());
         assertEquals("D2:E3", 
CellRangeAddress.valueOf(ref.formatAsString()).formatAsString());
 
@@ -142,11 +129,11 @@ public final class TestCellRangeAddress
         assertEquals("D2:E3", ref.formatAsString(null, false));
         assertEquals("D2:E3", 
CellRangeAddress.valueOf(ref.formatAsString()).formatAsString(null, false));
         assertEquals("D2:E3", 
CellRangeAddress.valueOf(ref.formatAsString(null, false)).formatAsString(null, 
false));
-        
+
         assertEquals("$D$2:$E$3", ref.formatAsString(null, true));
         assertEquals("$D$2:$E$3", 
CellRangeAddress.valueOf(ref.formatAsString()).formatAsString(null, true));
         assertEquals("$D$2:$E$3", 
CellRangeAddress.valueOf(ref.formatAsString(null, true)).formatAsString(null, 
true));
-        
+
         ref = new CellRangeAddress(-1, -1, 3, 4);
         assertEquals("D:E", ref.formatAsString());
         assertEquals("sheet1!$D:$E", 
CellRangeAddress.valueOf(ref.formatAsString()).formatAsString("sheet1", true));
@@ -178,117 +165,107 @@ public final class TestCellRangeAddress
         ref = new CellRangeAddress(-1, -1, -1, -1);
         assertEquals(":", ref.formatAsString());
     }
-    
+
     @Test
     public void testEquals() {
         final CellRangeAddress ref1 = new CellRangeAddress(1, 2, 3, 4);
         final CellRangeAddress ref2 = new CellRangeAddress(1, 2, 3, 4);
         assertEquals(ref1, ref2);
-        
+
         // Invert first/last row, but refer to same area
         ref2.setFirstRow(2);
         ref2.setLastRow(1);
         assertEquals(ref1, ref2);
-        
+
         // Invert first/last column, but refer to same area
         ref2.setFirstColumn(4);
         ref2.setLastColumn(3);
         assertEquals(ref1, ref2);
-        
+
         // Refer to a different area
         assertNotEquals(ref1, new CellRangeAddress(3, 4, 1, 2));
     }
-    
+
     @Test
     public void testGetMinMaxRow() {
         final CellRangeAddress ref = new CellRangeAddress(1, 2, 3, 4);
         assertEquals(1, ref.getMinRow());
         assertEquals(2, ref.getMaxRow());
-        
+
         ref.setFirstRow(10);
         //now ref is CellRangeAddress(10, 2, 3, 4)
         assertEquals(2, ref.getMinRow());
         assertEquals(10, ref.getMaxRow());
     }
-    
+
     @Test
     public void testGetMinMaxColumn() {
         final CellRangeAddress ref = new CellRangeAddress(1, 2, 3, 4);
         assertEquals(3, ref.getMinColumn());
         assertEquals(4, ref.getMaxColumn());
-        
+
         ref.setFirstColumn(10);
         //now ref is CellRangeAddress(1, 2, 10, 4)
         assertEquals(4, ref.getMinColumn());
         assertEquals(10, ref.getMaxColumn());
     }
-    
+
     @Test
     public void testIntersects() {
         final CellRangeAddress baseRegion = new CellRangeAddress(0, 1, 0, 1);
-        
+
         final CellRangeAddress duplicateRegion = new CellRangeAddress(0, 1, 0, 
1);
         assertIntersects(baseRegion, duplicateRegion);
-        
+
         final CellRangeAddress partiallyOverlappingRegion = new 
CellRangeAddress(1, 2, 1, 2);
         assertIntersects(baseRegion, partiallyOverlappingRegion);
-        
+
         final CellRangeAddress subsetRegion = new CellRangeAddress(0, 1, 0, 0);
         assertIntersects(baseRegion, subsetRegion);
-    
+
         final CellRangeAddress supersetRegion = new CellRangeAddress(0, 2, 0, 
2);
         assertIntersects(baseRegion, supersetRegion);
-        
+
         final CellRangeAddress disjointRegion = new CellRangeAddress(10, 11, 
10, 11);
         assertNotIntersects(baseRegion, disjointRegion);
     }
-    
+
     @Test
     public void containsRow() {
         final CellRangeAddress region = new CellRangeAddress(10, 12, 3, 5);
-        
+
         assertFalse(region.containsRow(9));
         assertTrue(region.containsRow(10));
         assertTrue(region.containsRow(11));
         assertTrue(region.containsRow(12));
         assertFalse(region.containsRow(13));
     }
-    
+
     @Test
     public void containsColumn() {
         final CellRangeAddress region = new CellRangeAddress(10, 12, 3, 5);
-        
+
         assertFalse(region.containsColumn(2));
         assertTrue(region.containsColumn(3));
         assertTrue(region.containsColumn(4));
         assertTrue(region.containsColumn(5));
         assertFalse(region.containsColumn(6));
     }
-    
+
     @Test
     public void iterator() {
         final CellRangeAddress A1_B2 = new CellRangeAddress(0, 1, 0, 1);
-        
+
         // the cell address iterator iterates in row major order
         final Iterator<CellAddress> iter = A1_B2.iterator();
-        assertEquals("A1", new CellAddress(0, 0), iter.next());
-        assertEquals("B1", new CellAddress(0, 1), iter.next());
-        assertEquals("A2", new CellAddress(1, 0), iter.next());
-        assertEquals("B2", new CellAddress(1, 1), iter.next());
+        assertEquals(new CellAddress(0, 0), iter.next(), "A1");
+        assertEquals(new CellAddress(0, 1), iter.next(), "B1");
+        assertEquals(new CellAddress(1, 0), iter.next(), "A2");
+        assertEquals(new CellAddress(1, 1), iter.next(), "B2");
         assertFalse(iter.hasNext());
-        try {
-            iter.next();
-            fail("Expected NoSuchElementException");
-        } catch (final NoSuchElementException e) {
-            //expected
-        }
-        try {
-            iter.remove();
-            fail("Expected UnsupportedOperationException");
-        } catch (final UnsupportedOperationException e) {
-            //expected
-        }
-        
+        assertThrows(NoSuchElementException.class, iter::next);
+        assertThrows(UnsupportedOperationException.class, iter::remove);
+
         // for each interface
         int count = 0;
         for (final CellAddress addr : A1_B2) {
@@ -297,7 +274,7 @@ public final class TestCellRangeAddress
         }
         assertEquals(4, count);
     }
-    
+
     private static void assertIntersects(CellRangeAddress regionA, 
CellRangeAddress regionB) {
         if (!(regionA.intersects(regionB) && regionB.intersects(regionA))) {
             final String A = regionA.formatAsString();

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellRangeUtil.java Thu 
Dec 24 18:42:29 2020
@@ -17,13 +17,14 @@
 
 package org.apache.poi.ss.util;
 
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
-import java.util.HashSet;
+
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests CellRangeUtil.
@@ -31,7 +32,7 @@ import java.util.HashSet;
  * @see org.apache.poi.ss.util.CellRangeUtil
  */
 public final class TestCellRangeUtil {
-    
+
     private static final CellRangeAddress A1 = new CellRangeAddress(0, 0, 0, 
0);
     private static final CellRangeAddress B1 = new CellRangeAddress(0, 0, 1, 
1);
     private static final CellRangeAddress A2 = new CellRangeAddress(1, 1, 0, 
0);
@@ -39,7 +40,7 @@ public final class TestCellRangeUtil {
     private static final CellRangeAddress A1_B2 = new CellRangeAddress(0, 1, 
0, 1);
     private static final CellRangeAddress A1_B1 = new CellRangeAddress(0, 0, 
0, 1);
     private static final CellRangeAddress A1_A2 = new CellRangeAddress(0, 1, 
0, 0);
-    
+
     @Test
     public void testMergeCellRanges() {
         // Note that the order of the output array elements does not matter
@@ -56,7 +57,7 @@ public final class TestCellRangeUtil {
         // Partially mergeable: multiple possible merges
         //    A B
         //  1 x x   A1,A2,B1 --> A1:B1,A2 or A1:A2,B1
-        //  2 x 
+        //  2 x
         assertCellRangesEqual(asArray(A1_B1, A2), merge(A1, B1, A2));
         assertCellRangesEqual(asArray(A1_A2, B1), merge(A2, A1, B1));
         assertCellRangesEqual(asArray(A1_B1, A2), merge(B1, A2, A1));

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellReference.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellReference.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellReference.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestCellReference.java Thu 
Dec 24 18:42:29 2020
@@ -17,24 +17,24 @@
 
 package org.apache.poi.ss.util;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.SpreadsheetVersion;
-
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests that the common CellReference works as we need it to.
@@ -288,7 +288,7 @@ public final class TestCellReference {
         confirmCrInRange(false, "XFD", "1048577", v2007);
         confirmCrInRange(false, "XFE", "1048576", v2007);
 
-        assertFalse("Identified bug 47312a", 
CellReference.cellReferenceIsWithinRange("B", "0", v97));
+        assertFalse(CellReference.cellReferenceIsWithinRange("B", "0", v97), 
"Identified bug 47312a");
 
         confirmCrInRange(false, "A", "0", v97);
         confirmCrInRange(false, "A", "0", v2007);
@@ -296,35 +296,17 @@ public final class TestCellReference {
 
     @Test
     public void testInvalidReference() {
-        try {
-            new CellReference("Sheet1!#REF!");
-            fail("Shouldn't be able to create a #REF! refence");
-        } catch(IllegalArgumentException expected) {
-            // expected here
-        }
-
-        try {
-            new CellReference("'MySheetName'!#REF!");
-            fail("Shouldn't be able to create a #REF! refence");
-        } catch(IllegalArgumentException expected) {
-            // expected here
-        }
-
-        try {
-            new CellReference("#REF!");
-            fail("Shouldn't be able to create a #REF! refence");
-        } catch(IllegalArgumentException expected) {
-            // expected here
+        for (String s : new String[]{"Sheet1!#REF!", "'MySheetName'!#REF!", 
"#REF!"}) {
+            assertThrows(IllegalArgumentException.class, () -> new 
CellReference(s),
+                "Shouldn't be able to create a #REF! "+s);
         }
     }
 
-    private static void confirmCrInRange(boolean expResult, String colStr, 
String rowStr,
-            SpreadsheetVersion sv) {
-        if (expResult == CellReference.cellReferenceIsWithinRange(colStr, 
rowStr, sv)) {
-            return;
-        }
-        fail("expected (c='" + colStr + "', r='" + rowStr + "' to be "
-                + (expResult ? "within" : "out of") + " bounds for version " + 
sv.name());
+    private static void confirmCrInRange(boolean expResult, String colStr, 
String rowStr, SpreadsheetVersion sv) {
+        assertEquals(expResult, 
CellReference.cellReferenceIsWithinRange(colStr, rowStr, sv),
+            "expected (c='" + colStr + "', r='" + rowStr + "' to be "
+            + (expResult ? "within" : "out of") + " bounds for version " + 
sv.name()
+        );
     }
 
     @Test
@@ -338,12 +320,9 @@ public final class TestCellReference {
         assertEquals(0, CellReference.convertColStringToIndex("$A"));
         assertEquals(1, CellReference.convertColStringToIndex("$B"));
 
-        try {
-            CellReference.convertColStringToIndex("A$");
-            fail("Should throw exception here");
-        } catch (IllegalArgumentException expected) {
-            assertTrue(expected.getMessage().contains("A$"));
-        }
+        IllegalArgumentException e = 
assertThrows(IllegalArgumentException.class,
+            () -> CellReference.convertColStringToIndex("A$"));
+        assertTrue(e.getMessage().contains("A$"));
     }
 
     @Test
@@ -368,10 +347,10 @@ public final class TestCellReference {
         assertEquals("HOME", ref.getSheetName());
         assertEquals(168, ref.getRow());
         assertEquals(-1, ref.getCol());
-        assertTrue("row absolute", ref.isRowAbsolute());
+        assertTrue(ref.isRowAbsolute(), "row absolute");
         //assertFalse("column absolute/relative is undefined", 
ref.isColAbsolute());
     }
-    
+
     @Test
     public void getSheetName() {
         assertNull(new CellReference("A5").getSheetName());
@@ -381,39 +360,38 @@ public final class TestCellReference {
         assertEquals("Sheet1", new CellReference("Sheet1!A5").getSheetName());
         assertEquals("Sheet 1", new CellReference("'Sheet 
1'!A5").getSheetName());
     }
-    
+
     @Test
     public void testToString() {
         CellReference ref = new CellReference("'Sheet 1'!A5");
         assertEquals("org.apache.poi.ss.util.CellReference ['Sheet 1'!A5]", 
ref.toString());
     }
-    
+
     @Test
     public void testEqualsAndHashCode() {
         CellReference ref1 = new CellReference("'Sheet 1'!A5");
         CellReference ref2 = new CellReference("Sheet 1", 4, 0, false, false);
-        assertEquals("equals", ref1, ref2);
-        assertEquals("hash code", ref1.hashCode(), ref2.hashCode());
+        assertEquals(ref1, ref2);
+        assertEquals(ref1.hashCode(), ref2.hashCode());
 
         //noinspection ObjectEqualsNull
-        assertNotEquals("null", null, ref1);
-        assertNotEquals("3D vs 2D", ref1, new CellReference("A5"));
-        assertNotEquals("type", ref1, 0L);
+        assertNotEquals(null, ref1);
+        assertNotEquals(ref1, new CellReference("A5"));
     }
 
     @Test
     public void isRowWithinRange() {
         SpreadsheetVersion ss = SpreadsheetVersion.EXCEL2007;
-        assertFalse("1 before first row", CellReference.isRowWithinRange("0", 
ss));
-        assertTrue("first row", CellReference.isRowWithinRange("1", ss));
-        assertTrue("last row", CellReference.isRowWithinRange("1048576", ss));
-        assertFalse("1 beyond last row", 
CellReference.isRowWithinRange("1048577", ss));
+        assertFalse(CellReference.isRowWithinRange("0", ss), "1 before first 
row");
+        assertTrue(CellReference.isRowWithinRange("1", ss), "first row");
+        assertTrue(CellReference.isRowWithinRange("1048576", ss), "last row");
+        assertFalse(CellReference.isRowWithinRange("1048577", ss), "1 beyond 
last row");
 
         // int versions of above, using 0-based indices
-        assertFalse("1 before first row", CellReference.isRowWithinRange(-1, 
ss));
-        assertTrue("first row", CellReference.isRowWithinRange(0, ss));
-        assertTrue("last row", CellReference.isRowWithinRange(1048575, ss));
-        assertFalse("1 beyond last row", 
CellReference.isRowWithinRange(1048576, ss));
+        assertFalse(CellReference.isRowWithinRange(-1, ss), "1 before first 
row");
+        assertTrue(CellReference.isRowWithinRange(0, ss), "first row");
+        assertTrue(CellReference.isRowWithinRange(1048575, ss), "last row");
+        assertFalse(CellReference.isRowWithinRange(1048576, ss), "1 beyond 
last row");
     }
 
     @Test
@@ -421,63 +399,59 @@ public final class TestCellReference {
         String rowNum = "4000000000";
         assertFalse(CellReference.isRowWithinRange(rowNum, 
SpreadsheetVersion.EXCEL2007));
     }
-    
-    @Test(expected=NumberFormatException.class)
+
+    @Test
     public void isRowWithinRangeNonInteger_Alpha() {
         String rowNum = "NotANumber";
-        CellReference.isRowWithinRange(rowNum, SpreadsheetVersion.EXCEL2007);
+        assertThrows(NumberFormatException.class, () -> 
CellReference.isRowWithinRange(rowNum, SpreadsheetVersion.EXCEL2007));
     }
 
     @Test
     public void isColWithinRange() {
         SpreadsheetVersion ss = SpreadsheetVersion.EXCEL2007;
-        assertTrue("(empty)", CellReference.isColumnWithinRange("", ss));
-        assertTrue("first column (A)", CellReference.isColumnWithinRange("A", 
ss));
-        assertTrue("last column (XFD)", 
CellReference.isColumnWithinRange("XFD", ss));
-        assertFalse("1 beyond last column (XFE)", 
CellReference.isColumnWithinRange("XFE", ss));
+        assertTrue(CellReference.isColumnWithinRange("", ss), "(empty)");
+        assertTrue(CellReference.isColumnWithinRange("A", ss), "first column 
(A)");
+        assertTrue(CellReference.isColumnWithinRange("XFD", ss), "last column 
(XFD)");
+        assertFalse(CellReference.isColumnWithinRange("XFE", ss), "1 beyond 
last column (XFE)");
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test
     public void unquotedSheetName() {
-        new CellReference("'Sheet 1!A5");
+        assertThrows(IllegalArgumentException.class, () -> new 
CellReference("'Sheet 1!A5"));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void mismatchedQuotesSheetName() {
-        new CellReference("Sheet 1!A5");
+        assertThrows(IllegalArgumentException.class, () -> new 
CellReference("Sheet 1!A5"));
     }
-    
+
     @Test
     public void escapedSheetName() {
         String escapedName = "'Don''t Touch'!A5";
         String unescapedName = "'Don't Touch'!A5";
         new CellReference(escapedName);
-        try {
-            new CellReference(unescapedName);
-            fail("Sheet names containing apostrophe's must be escaped via a 
repeated apostrophe");
-        } catch (IllegalArgumentException e) {
-            assertTrue(e.getMessage().startsWith("Bad sheet name quote 
escaping: "));
-        }
+        IllegalArgumentException e = 
assertThrows(IllegalArgumentException.class, () -> new 
CellReference(unescapedName));
+        assertTrue(e.getMessage().startsWith("Bad sheet name quote escaping: 
"));
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test
     public void negativeRow() {
-        new CellReference("sheet", -2, 0, false, false);
+        assertThrows(IllegalArgumentException.class, () -> new 
CellReference("sheet", -2, 0, false, false));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void negativeColumn() {
-        new CellReference("sheet", 0, -2, false, false);
+        assertThrows(IllegalArgumentException.class, () -> new 
CellReference("sheet", 0, -2, false, false));
     }
-    
-    @Test(expected=IllegalArgumentException.class)
+
+    @Test
     public void classifyEmptyStringCellReference() {
-        CellReference.classifyCellReference("", SpreadsheetVersion.EXCEL2007);
+        assertThrows(IllegalArgumentException.class, () -> 
CellReference.classifyCellReference("", SpreadsheetVersion.EXCEL2007));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void classifyInvalidFirstCharCellReference() {
-        CellReference.classifyCellReference("!A5", 
SpreadsheetVersion.EXCEL2007);
+        assertThrows(IllegalArgumentException.class, () -> 
CellReference.classifyCellReference("!A5", SpreadsheetVersion.EXCEL2007));
     }
 
     @Test

Modified: 
poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java 
Thu Dec 24 18:42:29 2020
@@ -19,10 +19,10 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -46,7 +46,7 @@ import org.apache.poi.ss.usermodel.Sheet
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.util.LocaleID;
 import org.apache.poi.util.TempFile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestDateFormatConverter {
     private void outputLocaleDataFormats( Date date, boolean dates, boolean 
times, int style, String styleName ) throws Exception {
@@ -181,20 +181,20 @@ public final class TestDateFormatConvert
                 final String partTag = langTag.substring(0, idx);
 
                 Locale loc = Locale.forLanguageTag(partTag);
-                assertNotNull("Invalid language tag: "+partTag, loc);
+                assertNotNull(loc, "Invalid language tag: "+partTag);
 
                 if (excludeList.contains(partTag)) {
                     continue;
                 }
 
                 String prefix = DateFormatConverter.getPrefixForLocale(loc);
-                assertNotNull("Prefix not found - language tag: "+partTag, 
prefix);
-                assertNotEquals("Prefix not found - language tag: 
"+partTag,"", prefix);
+                assertNotNull(prefix, "Prefix not found - language tag: 
"+partTag);
+                assertNotEquals("", prefix, "Prefix not found - language tag: 
"+partTag);
                 Matcher m = p.matcher(prefix);
-                assertTrue("Invalid prefix: "+prefix, m.matches());
+                assertTrue(m.matches(), "Invalid prefix: "+prefix);
 
                 LocaleID partLid = LocaleID.lookupByLanguageTag(partTag);
-                assertNotNull("LocaleID not found for part: "+partTag, 
partLid);
+                assertNotNull(partLid, "LocaleID not found for part: 
"+partTag);
                 assertEquals(partLid.getLcid(), Integer.parseInt(m.group(1), 
16));
             }
         }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateParser.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateParser.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateParser.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestDateParser.java Thu Dec 
24 18:42:29 2020
@@ -17,63 +17,50 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.Calendar;
 
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.EvaluationException;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 public class TestDateParser {
-    @Test
-    public void testFailWhenNoDate() {
-        try {
-            DateParser.parseDate("potato");
-            fail("Shouldn't parse potato!");
-        } catch (EvaluationException e) {
-            assertEquals(ErrorEval.VALUE_INVALID, e.getErrorEval());
-        }
-    }
-
-    @Test
-    public void testFailWhenLooksLikeDateButItIsnt() {
-        try {
-            DateParser.parseDate("potato/cucumber/banana");
-            fail("Shouldn't parse this thing!");
-        } catch (EvaluationException e) {
-            assertEquals(ErrorEval.VALUE_INVALID, e.getErrorEval());
-        }
-    }
-
-    @Test
-    public void testFailWhenIsInvalidDate() {
-        try {
-            DateParser.parseDate("13/13/13");
-            fail("Shouldn't parse this thing!");
-        } catch (EvaluationException e) {
-            assertEquals(ErrorEval.VALUE_INVALID, e.getErrorEval());
-        }
+    @ParameterizedTest
+    @ValueSource(strings = {
+        // no date
+        "potato",
+        // fail when looks like date but it isnt
+        "potato/cucumber/banana",
+        // fail when is invalid date
+        "13/13/13"
+    })
+    public void testFailWhenInvalidDate(String invalidDate) {
+        EvaluationException e = assertThrows(EvaluationException.class,
+            () -> DateParser.parseDate(invalidDate), "Shouldn't parse " + 
invalidDate);
+        assertEquals(ErrorEval.VALUE_INVALID, e.getErrorEval());
     }
 
     @Test
     public void testShouldParseValidDate() throws EvaluationException {
         Calendar expDate = LocaleUtil.getLocaleCalendar(1984, 
Calendar.OCTOBER, 20);
         Calendar actDate = DateParser.parseDate("1984/10/20");
-        assertEquals("Had: " + expDate.getTime() + " and " + actDate.getTime() 
+ "/" + 
-                expDate.getTimeInMillis() + "ms and " + 
actDate.getTimeInMillis() + "ms", 
-                expDate, actDate);
+        assertEquals(expDate, actDate,
+            "Had: " + expDate.getTime() + " and " + actDate.getTime() + "/" +
+            expDate.getTimeInMillis() + "ms and " + actDate.getTimeInMillis() 
+ "ms");
     }
 
     @Test
     public void testShouldIgnoreTimestamp() throws EvaluationException {
         Calendar expDate = LocaleUtil.getLocaleCalendar(1984, 
Calendar.OCTOBER, 20);
         Calendar actDate = DateParser.parseDate("1984/10/20 12:34:56");
-        assertEquals("Had: " + expDate.getTime() + " and " + actDate.getTime() 
+ "/" + 
-                expDate.getTimeInMillis() + "ms and " + 
actDate.getTimeInMillis() + "ms", 
-                expDate, actDate);
+        assertEquals(expDate, actDate,
+            "Had: " + expDate.getTime() + " and " + actDate.getTime() + "/" +
+            expDate.getTimeInMillis() + "ms and " + actDate.getTimeInMillis() 
+ "ms");
     }
 
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestExpandedDouble.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestExpandedDouble.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestExpandedDouble.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestExpandedDouble.java Thu 
Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.math.BigInteger;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link ExpandedDouble}
@@ -34,7 +34,7 @@ public final class TestExpandedDouble {
        @Test
        public void testNegative() {
                ExpandedDouble hd = new ExpandedDouble(0xC010000000000000L);
-               assertNotEquals("identified bug - sign bit not masked out of 
exponent", -2046, hd.getBinaryExponent());
+               assertNotEquals(-2046, hd.getBinaryExponent(), "identified bug 
- sign bit not masked out of exponent");
                assertEquals(2, hd.getBinaryExponent());
                BigInteger frac = hd.getSignificand();
                assertEquals(64, frac.bitLength());
@@ -44,7 +44,7 @@ public final class TestExpandedDouble {
        @Test
        public void testSubnormal() {
                ExpandedDouble hd = new ExpandedDouble(0x0000000000000001L);
-               assertNotEquals("identified bug - subnormal numbers not decoded 
properly", -1023, hd.getBinaryExponent());
+               assertNotEquals(-1023, hd.getBinaryExponent(), "identified bug 
- subnormal numbers not decoded properly");
                assertEquals(-1086, hd.getBinaryExponent());
                BigInteger frac = hd.getSignificand();
                assertEquals(64, frac.bitLength());
@@ -91,7 +91,7 @@ public final class TestExpandedDouble {
                checkNormaliseBaseTenResult(ed1, nd2);
 
                ExpandedDouble ed3 = nd2.normaliseBaseTwo();
-               assertEquals("bin exp mismatch", ed3.getBinaryExponent(), 
ed1.getBinaryExponent());
+               assertEquals(ed3.getBinaryExponent(), ed1.getBinaryExponent(), 
"bin exp mismatch");
 
                BigInteger diff = 
ed3.getSignificand().subtract(ed1.getSignificand()).abs();
                if (diff.signum() == 0) {
@@ -127,6 +127,6 @@ public final class TestExpandedDouble {
                }
                BigInteger diff = subDigsB.subtract(subDigsO).abs();
                // 100/32768 ~= 0.003
-               assertTrue("minor mistake", diff.intValue() <= 100);
+               assertTrue(diff.intValue() <= 100, "minor mistake");
        }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java Thu 
Dec 24 18:42:29 2020
@@ -17,13 +17,14 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.apache.poi.ss.util.NumberComparisonExamples.ComparisonExample;
 import org.apache.poi.util.HexDump;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
 /**
  * Tests for {@link NumberComparer}
  */
@@ -42,7 +43,7 @@ public final class TestNumberComparer {
                        success &= confirm(i, ce.getNegB(), ce.getNegA(), 
+ce.getExpectedResult());
                }
 
-               assertTrue("One or more cases failed.  See stderr", success);
+               assertTrue(success, "One or more cases failed.  See stderr");
        }
 
     @Test
@@ -68,7 +69,6 @@ public final class TestNumberComparer {
        public void testSpecificExampleA() {
                double a = 0.06-0.01;
                double b = 0.05;
-               //noinspection ConstantConditions
         assertNotEquals(a, b, 0.0);
                assertEquals(0, NumberComparer.compare(a, b));
        }
@@ -80,7 +80,6 @@ public final class TestNumberComparer {
        public void testSpecificExampleB() {
                double a = 1+1.0028-0.9973;
                double b = 1.0055;
-               //noinspection ConstantConditions
         assertNotEquals(a, b, 0.0);
                assertEquals(0, NumberComparer.compare(a, b));
        }

Modified: 
poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberToTextConverter.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberToTextConverter.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- 
poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberToTextConverter.java 
(original)
+++ 
poi/trunk/src/testcases/org/apache/poi/ss/util/TestNumberToTextConverter.java 
Thu Dec 24 18:42:29 2020
@@ -17,14 +17,14 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 import org.apache.poi.hssf.record.FormulaRecord;
 import org.apache.poi.ss.formula.constant.ConstantValueParser;
 import org.apache.poi.ss.formula.ptg.NumberPtg;
 import org.apache.poi.ss.util.NumberToTextConversionExamples.ExampleConversion;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link NumberToTextConverter}

Modified: 
poi/trunk/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestPropertyTemplate.java 
Thu Dec 24 18:42:29 2020
@@ -17,8 +17,8 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 
 import java.io.IOException;
 
@@ -31,7 +31,7 @@ import org.apache.poi.ss.usermodel.Index
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests Spreadsheet PropertyTemplate
@@ -799,12 +799,12 @@ public final class TestPropertyTemplate
             }
         }
     }
-    
+
     @Test
     public void drawBordersWithColors() throws IOException {
         CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
         PropertyTemplate pt = new PropertyTemplate();
-        
+
         pt.drawBorders(a1c3, BorderStyle.MEDIUM, IndexedColors.RED.getIndex(), 
BorderExtent.ALL);
         for (int i = 0; i <= 2; i++) {
             for (int j = 0; j <= 2; j++) {
@@ -855,10 +855,10 @@ public final class TestPropertyTemplate
         PropertyTemplate pt = new PropertyTemplate();
         Workbook wb = new HSSFWorkbook();
         Sheet sheet = wb.createSheet();
-        
+
         pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), 
BorderExtent.ALL);
         pt.applyBorders(sheet);
-        
+
         for (Row row: sheet) {
             for (Cell cell: row) {
                 CellStyle cs = cell.getCellStyle();
@@ -872,10 +872,10 @@ public final class TestPropertyTemplate
                 assertEquals(IndexedColors.RED.getIndex(), 
cs.getRightBorderColor());
             }
         }
-        
+
         pt.drawBorders(b2, BorderStyle.NONE, BorderExtent.ALL);
         pt.applyBorders(sheet);
-        
+
         for (Row row: sheet) {
             for (Cell cell: row) {
                 CellStyle cs = cell.getCellStyle();
@@ -905,10 +905,10 @@ public final class TestPropertyTemplate
                 }
             }
         }
-        
+
         wb.close();
     }
-    
+
     @Test
     public void clonePropertyTemplate() throws IOException {
         CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2);
@@ -922,14 +922,14 @@ public final class TestPropertyTemplate
                 assertEquals(4, pt2.getNumBorderColors(i, j));
             }
         }
-        
+
         CellRangeAddress b2 = new CellRangeAddress(1,1,1,1);
         pt2.drawBorders(b2, BorderStyle.THIN, BorderExtent.ALL);
-        
+
         Workbook wb = new HSSFWorkbook();
         Sheet sheet = wb.createSheet();
         pt.applyBorders(sheet);
-        
+
         for (Row row : sheet) {
             for (Cell cell : row) {
                 CellStyle cs = cell.getCellStyle();
@@ -943,7 +943,7 @@ public final class TestPropertyTemplate
                 assertEquals(IndexedColors.RED.getIndex(), 
cs.getRightBorderColor());
             }
         }
-        
+
         wb.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestRegionUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestRegionUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestRegionUtil.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestRegionUtil.java Thu Dec 
24 18:42:29 2020
@@ -17,7 +17,7 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.BorderStyle;
@@ -27,9 +27,9 @@ import org.apache.poi.ss.usermodel.Index
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import java.io.IOException;
 
@@ -44,18 +44,18 @@ public final class TestRegionUtil {
     private static final int DEFAULT_COLOR = 0;
     private Workbook wb;
     private Sheet sheet;
-    
-    @Before
+
+    @BeforeEach
     public void setUp() {
         wb = new HSSFWorkbook();
         sheet = wb.createSheet();
     }
-    
-    @After
+
+    @AfterEach
     public void tearDown() throws IOException {
         wb.close();
     }
-    
+
     private CellStyle getCellStyle(int rowIndex, int columnIndex) {
         Row row = sheet.getRow(rowIndex);
         if (row == null) row = sheet.createRow(rowIndex);
@@ -63,7 +63,7 @@ public final class TestRegionUtil {
         if (cell == null) cell = row.createCell(columnIndex);
         return cell.getCellStyle();
     }
-    
+
     @Test
     public void setBorderTop() {
         assertEquals(NONE, getCellStyle(0, 0).getBorderTop());
@@ -104,7 +104,7 @@ public final class TestRegionUtil {
         assertEquals(THIN, getCellStyle(1, 0).getBorderLeft());
         assertEquals(THIN, getCellStyle(2, 0).getBorderLeft());
     }
-    
+
     @Test
     public void setTopBorderColor() {
         assertEquals(DEFAULT_COLOR, getCellStyle(0, 0).getTopBorderColor());
@@ -145,7 +145,7 @@ public final class TestRegionUtil {
         assertEquals(RED, getCellStyle(1, 0).getLeftBorderColor());
         assertEquals(RED, getCellStyle(2, 0).getLeftBorderColor());
     }
-    
+
     @Test
     public void bordersCanBeAddedToNonExistantCells() {
         RegionUtil.setBorderTop(THIN, A1C3, sheet);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java Thu 
Dec 24 18:42:29 2020
@@ -17,9 +17,9 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.io.IOException;
 import java.util.Date;
@@ -30,7 +30,7 @@ import org.apache.poi.ss.usermodel.CellT
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests SheetBuilder.

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetUtil.java Thu Dec 
24 18:42:29 2020
@@ -5,9 +5,9 @@
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
-   
+
    http://www.apache.org/licenses/LICENSE-2.0
-   
+
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,13 +22,14 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import java.io.IOException;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Tests SheetUtil.
@@ -38,122 +39,128 @@ import static org.junit.Assert.assertTru
 public final class TestSheetUtil {
     @Test
     public void testCellWithMerges() throws Exception {
-        Workbook wb = new HSSFWorkbook();
-        Sheet s = wb.createSheet();
-        
-        // Create some test data
-        Row r2 = s.createRow(1);
-        r2.createCell(0).setCellValue(10);
-        r2.createCell(1).setCellValue(11);
-        Row r3 = s.createRow(2);
-        r3.createCell(0).setCellValue(20);
-        r3.createCell(1).setCellValue(21);
-
-        assertEquals(0, s.addMergedRegion(new CellRangeAddress(2, 3, 0, 0)));
-        assertEquals(1, s.addMergedRegion(new CellRangeAddress(2, 2, 1, 4)));
-        
-        // With a cell that isn't defined, we'll get null
-        assertNull(SheetUtil.getCellWithMerges(s, 0, 0));
-        
-        // With a cell that's not in a merged region, we'll get that
-        assertEquals(10.0, SheetUtil.getCellWithMerges(s, 1, 
0).getNumericCellValue(), 0.01);
-        assertEquals(11.0, SheetUtil.getCellWithMerges(s, 1, 
1).getNumericCellValue(), 0.01);
-        
-        // With a cell that's the primary one of a merged region, we get that 
cell
-        assertEquals(20.0, SheetUtil.getCellWithMerges(s, 2, 
0).getNumericCellValue(), 0.01);
-        assertEquals(21., SheetUtil.getCellWithMerges(s, 2, 
1).getNumericCellValue(), 0.01);
-        
-        // With a cell elsewhere in the merged region, get top-left
-        assertEquals(20.0, SheetUtil.getCellWithMerges(s, 3, 
0).getNumericCellValue(), 0.01);
-        assertEquals(21.0, SheetUtil.getCellWithMerges(s, 2, 
2).getNumericCellValue(), 0.01);
-        assertEquals(21.0, SheetUtil.getCellWithMerges(s, 2, 
3).getNumericCellValue(), 0.01);
-        assertEquals(21.0, SheetUtil.getCellWithMerges(s, 2, 
4).getNumericCellValue(), 0.01);
-        
-        wb.close();
+        try (Workbook wb = new HSSFWorkbook()) {
+            Sheet s = wb.createSheet();
+
+            // Create some test data
+            Row r2 = s.createRow(1);
+            r2.createCell(0).setCellValue(10);
+            r2.createCell(1).setCellValue(11);
+            Row r3 = s.createRow(2);
+            r3.createCell(0).setCellValue(20);
+            r3.createCell(1).setCellValue(21);
+
+            assertEquals(0, s.addMergedRegion(new CellRangeAddress(2, 3, 0, 
0)));
+            assertEquals(1, s.addMergedRegion(new CellRangeAddress(2, 2, 1, 
4)));
+
+            // With a cell that isn't defined, we'll get null
+            assertNull(SheetUtil.getCellWithMerges(s, 0, 0));
+
+            // With a cell that's not in a merged region, we'll get that
+            Cell cell = SheetUtil.getCellWithMerges(s, 1, 0);
+            assertNotNull(cell);
+            assertEquals(10.0, cell.getNumericCellValue(), 0.01);
+            cell = SheetUtil.getCellWithMerges(s, 1, 1);
+            assertNotNull(cell);
+            assertEquals(11.0, cell.getNumericCellValue(), 0.01);
+
+            // With a cell that's the primary one of a merged region, we get 
that cell
+            cell = SheetUtil.getCellWithMerges(s, 2, 0);
+            assertNotNull(cell);
+            assertEquals(20.0, cell.getNumericCellValue(), 0.01);
+            cell = SheetUtil.getCellWithMerges(s, 2, 1);
+            assertNotNull(cell);
+            assertEquals(21., cell.getNumericCellValue(), 0.01);
+
+            // With a cell elsewhere in the merged region, get top-left
+            cell = SheetUtil.getCellWithMerges(s, 3, 0);
+            assertNotNull(cell);
+            assertEquals(20.0, cell.getNumericCellValue(), 0.01);
+            cell = SheetUtil.getCellWithMerges(s, 2, 2);
+            assertNotNull(cell);
+            assertEquals(21.0, cell.getNumericCellValue(), 0.01);
+            cell = SheetUtil.getCellWithMerges(s, 2, 3);
+            assertNotNull(cell);
+            assertEquals(21.0, cell.getNumericCellValue(), 0.01);
+            assertNotNull(cell);
+            cell = SheetUtil.getCellWithMerges(s, 2, 4);
+            assertNotNull(cell);
+            assertEquals(21.0, cell.getNumericCellValue(), 0.01);
+        }
     }
 
     @Test
     public void testCanComputeWidthHSSF() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        
-        // cannot check on result because on some machines we get back false 
here!
-        SheetUtil.canComputeColumnWidth(wb.getFontAt(0));
-
-        wb.close();        
+        try (Workbook wb = new HSSFWorkbook()) {
+            // cannot check on result because on some machines we get back 
false here!
+            SheetUtil.canComputeColumnWidth(wb.getFontAt(0));
+        }
     }
 
     @Test
     public void testGetCellWidthEmpty() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("sheet");
-        Row row = sheet.createRow(0);
-        Cell cell = row.createCell(0);
-        
-        // no contents: cell.setCellValue("sometext");
-        
-        assertEquals(-1.0, SheetUtil.getCellWidth(cell, 1, null, true), 0.01);
-        
-        wb.close();
+        try (Workbook wb = new HSSFWorkbook()) {
+            Sheet sheet = wb.createSheet("sheet");
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+
+            // no contents: cell.setCellValue("sometext");
+            assertEquals(-1.0, SheetUtil.getCellWidth(cell, 1, null, true), 
0.01);
+        }
     }
 
     @Test
     public void testGetCellWidthString() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("sheet");
-        Row row = sheet.createRow(0);
-        Cell cell = row.createCell(0);
-        
-        cell.setCellValue("sometext");
-        
-        assertTrue(SheetUtil.getCellWidth(cell, 1, null, true) > 0);
-        
-        wb.close();
+        try (Workbook wb = new HSSFWorkbook()) {
+            Sheet sheet = wb.createSheet("sheet");
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+
+            cell.setCellValue("sometext");
+
+            assertTrue(SheetUtil.getCellWidth(cell, 1, null, true) > 0);
+        }
     }
 
     @Test
     public void testGetCellWidthNumber() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("sheet");
-        Row row = sheet.createRow(0);
-        Cell cell = row.createCell(0);
-        
-        cell.setCellValue(88.234);
-        
-        assertTrue(SheetUtil.getCellWidth(cell, 1, null, true) > 0);
-        
-        wb.close();
+        try (Workbook wb = new HSSFWorkbook()) {
+            Sheet sheet = wb.createSheet("sheet");
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+
+            cell.setCellValue(88.234);
+
+            assertTrue(SheetUtil.getCellWidth(cell, 1, null, true) > 0);
+        }
     }
 
     @Test
     public void testGetCellWidthBoolean() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("sheet");
-        Row row = sheet.createRow(0);
-        Cell cell = row.createCell(0);
-        
-        cell.setCellValue(false);
-        
-        assertTrue(SheetUtil.getCellWidth(cell, 1, null, false) > 0);
-        
-        wb.close();
+        try (Workbook wb = new HSSFWorkbook()) {
+            Sheet sheet = wb.createSheet("sheet");
+            Row row = sheet.createRow(0);
+            Cell cell = row.createCell(0);
+
+            cell.setCellValue(false);
+
+            assertTrue(SheetUtil.getCellWidth(cell, 1, null, false) > 0);
+        }
     }
 
     @Test
     public void testGetColumnWidthString() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        Sheet sheet = wb.createSheet("sheet");
-        Row row = sheet.createRow(0);
-        sheet.createRow(1);
-        sheet.createRow(2);
-        Cell cell = row.createCell(0);
-        
-        cell.setCellValue("sometext");
-        
-        assertTrue("Having some width for rows with actual cells", 
-                SheetUtil.getColumnWidth(sheet, 0, true) > 0);
-        assertEquals("Not having any widht for rows with all empty cells", 
-                -1.0, SheetUtil.getColumnWidth(sheet, 0, true, 1, 2), 0.01);
-        
-        wb.close();
+        try (Workbook wb = new HSSFWorkbook()) {
+            Sheet sheet = wb.createSheet("sheet");
+            Row row = sheet.createRow(0);
+            sheet.createRow(1);
+            sheet.createRow(2);
+            Cell cell = row.createCell(0);
+
+            cell.setCellValue("sometext");
+
+            assertTrue(SheetUtil.getColumnWidth(sheet, 0, true) > 0, "Having 
some width for rows with actual cells");
+            assertEquals(-1.0, SheetUtil.getColumnWidth(sheet, 0, true, 1, 2), 
0.01, "Not having any widht for rows with all empty cells");
+        }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/TestWorkbookUtil.java Thu 
Dec 24 18:42:29 2020
@@ -17,9 +17,9 @@
 
 package org.apache.poi.ss.util;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests WorkbookUtil.

Modified: 
poi/trunk/src/testcases/org/apache/poi/ss/util/cellwalk/TestCellWalk.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/cellwalk/TestCellWalk.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/cellwalk/TestCellWalk.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/cellwalk/TestCellWalk.java 
Thu Dec 24 18:42:29 2020
@@ -16,7 +16,7 @@
    ==================================================================== */
 package org.apache.poi.ss.util.cellwalk;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Date;
 
@@ -25,7 +25,7 @@ import org.apache.poi.ss.usermodel.Sheet
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.SheetBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestCellWalk {
 

Modified: poi/trunk/src/testcases/org/apache/poi/util/MemoryLeakVerifier.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/util/MemoryLeakVerifier.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/util/MemoryLeakVerifier.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/util/MemoryLeakVerifier.java Thu Dec 
24 18:42:29 2020
@@ -17,12 +17,12 @@
 
 package org.apache.poi.util;
 
+import static org.junit.jupiter.api.Assertions.assertNull;
+
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.junit.Assert.assertNull;
-
 /**
  * A simple utility class that can verify that objects have been successfully 
garbage collected.
  *
@@ -100,7 +100,6 @@ public class MemoryLeakVerifier {
                        Thread.sleep(GC_SLEEP_TIME);
            }
 
-           assertNull("Object should not exist after " + MAX_GC_ITERATIONS + " 
collections, but still had: " + ref.get(),
-                       ref.get());
+           assertNull(ref.get(), "Object should not exist after " + 
MAX_GC_ITERATIONS + " collections, but still had: " + ref.get());
        }
 }



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

Reply via email to