You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2020/12/24 18:42:38 UTC

svn commit: r1884783 [10/40] - in /poi: site/src/documentation/content/xdocs/ trunk/ trunk/sonar/ trunk/sonar/integration-test/ trunk/sonar/ooxml/ trunk/src/excelant/poi-ant-contrib/ trunk/src/excelant/testcases/org/apache/poi/ss/excelant/ trunk/src/ex...

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java Thu Dec 24 18:42:29 2020
@@ -17,14 +17,15 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
+import java.util.stream.Stream;
 
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.functions.BaseTestNumeric;
@@ -38,14 +39,11 @@ import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
-@RunWith(Parameterized.class)
 public final class TestMatrixFormulasFromXMLSpreadsheet {
 
     private static final POILogger LOG = POILogFactory.getLogger(TestMatrixFormulasFromXMLSpreadsheet.class);
@@ -96,21 +94,15 @@ public final class TestMatrixFormulasFro
 
     }
 
-    /* Parameters for test case */
-    @Parameter(0)
-    public String targetFunctionName;
-    @Parameter(1)
-    public int formulasRowIdx;
 
-    @AfterClass
+    @AfterAll
     public static void closeResource() throws Exception {
         LocaleUtil.setUserLocale(userLocale);
         workbook.close();
     }
 
     /* generating parameter instances */
-    @Parameters(name="{0}")
-    public static Collection<Object[]> data() throws Exception {
+    public static Stream<Arguments> data() throws Exception {
         // Function "Text" uses custom-formats which are locale specific
         // can't set the locale on a per-testrun execution, as some settings have been
         // already set, when we would try to change the locale by then
@@ -121,11 +113,11 @@ public final class TestMatrixFormulasFro
         sheet = workbook.getSheetAt(0);
         evaluator = new XSSFFormulaEvaluator(workbook);
 
-        List<Object[]> data = new ArrayList<Object[]>();
+        List<Arguments> data = new ArrayList<>();
 
         processFunctionGroup(data, Navigator.START_OPERATORS_ROW_INDEX, null);
 
-        return data;
+        return data.stream();
     }
 
     /**
@@ -133,25 +125,27 @@ public final class TestMatrixFormulasFro
      * @param testFocusFunctionName name of a single function/operator to test alone.
      * Typically pass <code>null</code> to test all functions
      */
-    private static void processFunctionGroup(List<Object[]> data, int startRowIndex, String testFocusFunctionName) {
+    private static void processFunctionGroup(List<Arguments> data, int startRowIndex, String testFocusFunctionName) {
         for (int rowIndex = startRowIndex; true; rowIndex += Navigator.ROW_OFF_NEXT_OP) {
             Row r = sheet.getRow(rowIndex);
             String targetFunctionName = getTargetFunctionName(r);
-            assertNotNull("Test spreadsheet cell empty on row ("
-                    + (rowIndex) + "). Expected function name or '"
-                    + Navigator.END_OF_TESTS + "'", targetFunctionName);
+            assertNotNull(targetFunctionName,
+                "Test spreadsheet cell empty on row ("
+                + (rowIndex) + "). Expected function name or '"
+                + Navigator.END_OF_TESTS + "'");
             if(targetFunctionName.equals(Navigator.END_OF_TESTS)) {
                 // found end of functions list
                 break;
             }
             if(testFocusFunctionName == null || targetFunctionName.equalsIgnoreCase(testFocusFunctionName)) {
-                data.add(new Object[]{targetFunctionName, rowIndex});
+                data.add(Arguments.of(targetFunctionName, rowIndex));
             }
         }
     }
 
-    @Test
-    public void processFunctionRow() {
+    @ParameterizedTest
+    @MethodSource("data")
+    public void processFunctionRow(String targetFunctionName, int formulasRowIdx) {
 
        int endColNum = Navigator.START_RESULT_COL_INDEX + Navigator.COL_OFF_EXPECTED_RESULT;
 
@@ -176,31 +170,31 @@ public final class TestMatrixFormulasFro
                String msg = String.format(Locale.ROOT, "Function '%s': Formula: %s @ %d:%d"
                        , targetFunctionName, c.getCellFormula(), rowNum, colNum);
 
-               assertNotNull(msg + " - Bad setup data expected value is null", expValue);
-               assertNotNull(msg + " - actual value was null", actValue);
+               assertNotNull(expValue, msg + " - Bad setup data expected value is null");
+               assertNotNull(actValue, msg + " - actual value was null");
 
                final CellType cellType = expValue.getCellType();
                switch (cellType) {
                    case BLANK:
-                       assertEquals(msg, CellType.BLANK, actValue.getCellType());
+                       assertEquals(CellType.BLANK, actValue.getCellType(), msg);
                        break;
                    case BOOLEAN:
-                       assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
-                       assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
+                       assertEquals(CellType.BOOLEAN, actValue.getCellType(), msg);
+                       assertEquals(expValue.getBooleanCellValue(), actValue.getBooleanValue(), msg);
                        break;
                    case ERROR:
-                       assertEquals(msg, CellType.ERROR, actValue.getCellType());
-                       assertEquals(msg, ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()));
+                       assertEquals(CellType.ERROR, actValue.getCellType(), msg);
+                       assertEquals(ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()), msg);
                        break;
                    case FORMULA: // will never be used, since we will call method after formula evaluation
                        fail("Cannot expect formula as result of formula evaluation: " + msg);
                    case NUMERIC:
-                       assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
-                       BaseTestNumeric.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR);
+                       assertEquals(CellType.NUMERIC, actValue.getCellType(), msg);
+                       BaseTestNumeric.assertDouble(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR);
                        break;
                    case STRING:
-                       assertEquals(msg, CellType.STRING, actValue.getCellType());
-                       assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
+                       assertEquals(CellType.STRING, actValue.getCellType(), msg);
+                       assertEquals(expValue.getRichStringCellValue().getString(), actValue.getStringValue(), msg);
                        break;
                    default:
                        fail("Unexpected cell type: " + cellType);
@@ -223,15 +217,11 @@ public final class TestMatrixFormulasFro
             LOG.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", can't figure out function name");
             return null;
         }
-        if(cell.getCellType() == CellType.BLANK) {
-            return null;
-        }
-        if(cell.getCellType() == CellType.STRING) {
-            return cell.getRichStringCellValue().getString();
-        }
 
-        fail("Bad cell type for 'function name' column: ("
-                + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
-        return null;
+        CellType ct = cell.getCellType();
+        assertTrue(ct == CellType.BLANK || ct == CellType.STRING,
+            "Bad cell type for 'function name' column: (" + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
+
+        return (ct == CellType.STRING) ? cell.getRichStringCellValue().getString() : null;
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java Thu Dec 24 18:42:29 2020
@@ -17,12 +17,12 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.formula.BaseTestMissingWorkbook;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 
 /**
  * XSSF Specific version of the Missing Workbooks test
@@ -33,7 +33,7 @@ public final class TestMissingWorkbookOn
     }
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() {
         mainWorkbook = XSSFTestDataSamples.openSampleWorkbook(MAIN_WORKBOOK_FILENAME);
         sourceWorkbook = HSSFTestDataSamples.openSampleWorkbook(SOURCE_WORKBOOK_FILENAME);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java Thu Dec 24 18:42:29 2020
@@ -17,16 +17,16 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeNotNull;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
+import java.util.stream.Stream;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.openxml4j.opc.OPCPackage;
@@ -40,17 +40,14 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
 /**
  * Tests formulas for multi sheet reference (i.e. SUM(Sheet1:Sheet5!A1))
  */
-@RunWith(Parameterized.class)
 public final class TestMultiSheetFormulaEvaluatorOnXSSF {
     private static final POILogger logger = POILogFactory.getLogger(TestMultiSheetFormulaEvaluatorOnXSSF.class);
 
@@ -98,29 +95,22 @@ public final class TestMultiSheetFormula
 		String TEST_SHEET_NAME = "test";
 	}
 
-    @Parameter(value = 0)
-	public String targetTestName;
-	@Parameter(value = 1)
-    public String targetFunctionName;
-    @Parameter(value = 2)
-    public int formulasRowIdx;
 
-    @AfterClass
+    @AfterAll
     public static void closeResource() throws Exception {
         workbook.close();
     }
 
-    @Parameters(name="{0}")
-    public static Collection<Object[]> data() throws Exception {
+    public static Stream<Arguments> data() throws Exception {
         workbook = new XSSFWorkbook( OPCPackage.open(HSSFTestDataSamples.getSampleFile(SS.FILENAME), PackageAccess.READ) );
         sheet = workbook.getSheet( SS.TEST_SHEET_NAME );
         evaluator = new XSSFFormulaEvaluator(workbook);
 
-        List<Object[]> data = new ArrayList<>();
+        List<Arguments> data = new ArrayList<>();
 
         processFunctionGroup(data, SS.START_FUNCTIONS_ROW_INDEX, null);
 
-        return data;
+        return data.stream();
     }
 
     /**
@@ -128,7 +118,7 @@ public final class TestMultiSheetFormula
      * @param testFocusFunctionName name of a single function/operator to test alone.
      * Typically pass <code>null</code> to test all functions
      */
-    private static void processFunctionGroup(List<Object[]> data, int startRowIndex, String testFocusFunctionName) {
+    private static void processFunctionGroup(List<Arguments> data, int startRowIndex, String testFocusFunctionName) {
         for (int rowIndex = startRowIndex; true; rowIndex++) {
             Row r = sheet.getRow(rowIndex);
 
@@ -136,9 +126,10 @@ public final class TestMultiSheetFormula
             if(r == null) continue;
 
             String targetFunctionName = getTargetFunctionName(r);
-            assertNotNull("Test spreadsheet cell empty on row ("
+            assertNotNull(targetFunctionName,
+				"Test spreadsheet cell empty on row ("
                 + (rowIndex+1) + "). Expected function name or '"
-                + SS.FUNCTION_NAMES_END_SENTINEL + "'", targetFunctionName);
+                + SS.FUNCTION_NAMES_END_SENTINEL + "'");
 
             if(targetFunctionName.equals(SS.FUNCTION_NAMES_END_SENTINEL)) {
                 // found end of functions list
@@ -150,31 +141,29 @@ public final class TestMultiSheetFormula
 
                 // expected results are on the row below
                 Cell expectedValueCell = r.getCell(SS.COLUMN_INDEX_EXPECTED_VALUE);
-                assertNotNull("Missing expected values cell for function '"
+                assertNotNull(expectedValueCell,
+					"Missing expected values cell for function '"
                     + targetFunctionName + ", test" + targetTestName + " (row " +
-                    rowIndex + 1 + ")", expectedValueCell);
+                    rowIndex + 1 + ")");
 
-                data.add(new Object[]{targetTestName, targetFunctionName, rowIndex});
+                data.add(Arguments.of(targetTestName, targetFunctionName, rowIndex));
             }
         }
     }
 
-    /**
-    *
-    * @return a constant from the local Result class denoting whether there were any evaluation
-    * cases, and whether they all succeeded.
-    */
-    @Test
-    public void processFunctionRow() {
+    @ParameterizedTest
+	@MethodSource("data")
+    public void processFunctionRow(String targetTestName, String targetFunctionName, int formulasRowIdx) {
         Row r = sheet.getRow(formulasRowIdx);
 
         Cell expValue = r.getCell(SS.COLUMN_INDEX_EXPECTED_VALUE);
-        assertNotNull("Missing expected values cell for function '"
+        assertNotNull(expValue,
+			"Missing expected values cell for function '"
             + targetFunctionName + ", test" + targetTestName + " (row " +
-            formulasRowIdx + 1 + ")", expValue);
+            formulasRowIdx + 1 + ")");
 
         Cell c = r.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE);
-        assumeNotNull(c);
+        assumeTrue(c != null);
         assumeTrue(c.getCellType() == CellType.FORMULA);
 
         CellValue actValue = evaluator.evaluate(c);
@@ -182,19 +171,19 @@ public final class TestMultiSheetFormula
         String msg = String.format(Locale.ROOT, "Function '%s': Test: '%s': Formula: %s @ %d:%d",
             targetFunctionName, targetTestName, c.getCellFormula(), formulasRowIdx, SS.COLUMN_INDEX_ACTUAL_VALUE);
 
-        assertNotNull(msg + " - actual value was null", actValue);
+        assertNotNull(actValue, msg + " - actual value was null");
 
         final CellType expectedCellType = expValue.getCellType();
         switch (expectedCellType) {
             case BLANK:
-                assertEquals(msg, CellType.BLANK, actValue.getCellType());
+                assertEquals(CellType.BLANK, actValue.getCellType(), msg);
                 break;
             case BOOLEAN:
-                assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
-                assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
+                assertEquals(CellType.BOOLEAN, actValue.getCellType(), msg);
+                assertEquals(expValue.getBooleanCellValue(), actValue.getBooleanValue(), msg);
                 break;
             case ERROR:
-                assertEquals(msg, CellType.ERROR, actValue.getCellType());
+                assertEquals(CellType.ERROR, actValue.getCellType(), msg);
 //              if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
 //                  assertEquals(msg, expected.getErrorCellValue(), actual.getErrorValue());
 //              }
@@ -202,15 +191,15 @@ public final class TestMultiSheetFormula
             case FORMULA: // will never be used, since we will call method after formula evaluation
                 fail("Cannot expect formula as result of formula evaluation: " + msg);
             case NUMERIC:
-                assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
-				BaseTestNumeric.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR);
+                assertEquals(CellType.NUMERIC, actValue.getCellType(), msg);
+				BaseTestNumeric.assertDouble(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR);
 //              double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue());
 //              double pctExpected = Math.abs(0.00001*expected.getNumericCellValue());
 //              assertTrue(msg, delta <= pctExpected);
                 break;
             case STRING:
-                assertEquals(msg, CellType.STRING, actValue.getCellType());
-                assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
+                assertEquals(CellType.STRING, actValue.getCellType(), msg);
+                assertEquals(expValue.getRichStringCellValue().getString(), actValue.getStringValue(), msg);
                 break;
             default:
                 fail("Unexpected cell type: " + expectedCellType);
@@ -230,17 +219,14 @@ public final class TestMultiSheetFormula
             logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
 			return null;
 		}
-		if(cell.getCellType() == CellType.BLANK) {
-			return null;
-		}
-		if(cell.getCellType() == CellType.STRING) {
-			return cell.getRichStringCellValue().getString();
-		}
 
-		fail("Bad cell type for 'function name' column: ("
-			+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
-		return "";
+		CellType ct = cell.getCellType();
+		assertTrue(ct == CellType.BLANK || ct == CellType.STRING,
+			"Bad cell type for 'function name' column: (" + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
+
+		return (ct == CellType.STRING) ? cell.getRichStringCellValue().getString() : null;
 	}
+
 	/**
 	 * @return <code>null</code> if cell is missing, empty or blank
 	 */
@@ -254,16 +240,10 @@ public final class TestMultiSheetFormula
 		    logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name");
 			return null;
 		}
-		if(cell.getCellType() == CellType.BLANK) {
-			return null;
-		}
-		if(cell.getCellType() == CellType.STRING) {
-			return cell.getRichStringCellValue().getString();
-		}
+		CellType ct = cell.getCellType();
+		assertTrue(ct == CellType.BLANK || ct == CellType.STRING,
+			"Bad cell type for 'test name' column: (" + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
 
-		fail("Bad cell type for 'test name' column: ("
-			+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
-		return "";
+		return (ct == CellType.STRING) ? cell.getRichStringCellValue().getString() : null;
 	}
-
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java Thu Dec 24 18:42:29 2020
@@ -17,11 +17,12 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.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.File;
 import java.io.FileOutputStream;
@@ -42,8 +43,8 @@ import org.apache.poi.xssf.streaming.SXS
 import org.apache.poi.xssf.streaming.SXSSFRow;
 import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
 
 public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
@@ -52,11 +53,16 @@ public final class TestSXSSFBugs extends
     }
 
     // override some tests which do not work for SXSSF
-    @Override @Ignore("cloneSheet() not implemented") @Test public void bug18800() { /* cloneSheet() not implemented */ }
-    @Override @Ignore("cloneSheet() not implemented") @Test public void bug22720() { /* cloneSheet() not implemented */ }
-    @Override @Ignore("Evaluation is not fully supported") @Test public void bug47815() { /* Evaluation is not supported */ }
-    @Override @Ignore("Evaluation is not fully supported") @Test public void bug46729_testMaxFunctionArguments() { /* Evaluation is not supported */ }
-    @Override @Ignore("Reading data is not supported") @Test public void bug57798() { /* Reading data is not supported */ }
+    @Override @Disabled("cloneSheet() not implemented") @Test
+    public void bug18800() { /* cloneSheet() not implemented */ }
+    @Override @Disabled("cloneSheet() not implemented") @Test
+    public void bug22720() { /* cloneSheet() not implemented */ }
+    @Override @Disabled("Evaluation is not fully supported") @Test
+    public void bug47815() { /* Evaluation is not supported */ }
+    @Override @Disabled("Evaluation is not fully supported") @Test
+    public void bug46729_testMaxFunctionArguments() { /* Evaluation is not supported */ }
+    @Override @Disabled("Reading data is not supported") @Test
+    public void bug57798() { /* Reading data is not supported */ }
 
     /**
      * Setting repeating rows and columns shouldn't break
@@ -122,10 +128,8 @@ public final class TestSXSSFBugs extends
 
         // does not work
         try (SXSSFWorkbook wb = new SXSSFWorkbook()) {
-            writeWorkbook(wb, SXSSFITestDataProvider.instance);
-            fail("Should catch exception here");
-        } catch (RuntimeException e) {
-            // this is not implemented yet
+            assertThrows(RuntimeException.class, () -> writeWorkbook(wb, SXSSFITestDataProvider.instance),
+                "this is not implemented yet");
         }
     }
 
@@ -173,7 +177,7 @@ public final class TestSXSSFBugs extends
     }
 
     @Test
-    @Ignore("takes too long for the normal test run")
+    @Disabled("takes too long for the normal test run")
     public void test62872() throws Exception {
         final int COLUMN_COUNT = 300;
         final int ROW_COUNT = 600000;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestTableStyles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestTableStyles.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestTableStyles.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestTableStyles.java Thu Dec 24 18:42:29 2020
@@ -17,10 +17,10 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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;
 
 import org.apache.poi.ss.usermodel.DifferentialStyleProvider;
 import org.apache.poi.ss.usermodel.FontFormatting;
@@ -30,7 +30,7 @@ import org.apache.poi.ss.usermodel.Table
 import org.apache.poi.ss.usermodel.TableStyleInfo;
 import org.apache.poi.ss.usermodel.TableStyleType;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test built-in table styles
@@ -43,37 +43,35 @@ public class TestTableStyles {
     @Test
     public void testBuiltinStyleInit() {
         TableStyle style = XSSFBuiltinTableStyle.TableStyleMedium2.getStyle();
-        assertNotNull("no style found for Medium2", style);
-        assertNull("Should not have style info for blankRow", style.getStyle(TableStyleType.blankRow));
+        assertNotNull(style, "no style found for Medium2");
+        assertNull(style.getStyle(TableStyleType.blankRow), "Should not have style info for blankRow");
         DifferentialStyleProvider headerRow = style.getStyle(TableStyleType.headerRow);
-        assertNotNull("no header row style", headerRow);
+        assertNotNull(headerRow, "no header row style");
         FontFormatting font = headerRow.getFontFormatting();
-        assertNotNull("No header row font formatting", font);
-        assertTrue("header row not bold", font.isBold());
+        assertNotNull(font, "No header row font formatting");
+        assertTrue(font.isBold(), "header row not bold");
         PatternFormatting fill = headerRow.getPatternFormatting();
-        assertNotNull("No header fill", fill);
-        assertEquals("wrong header fill", 4, ((XSSFColor) fill.getFillBackgroundColorColor()).getTheme());
+        assertNotNull(fill, "No header fill");
+        assertEquals(4, ((XSSFColor) fill.getFillBackgroundColorColor()).getTheme(), "wrong header fill");
     }
 
     @Test
     public void testCustomStyle() throws Exception {
-        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("tableStyle.xlsx");
-        
-        Table table = wb.getTable("Table1");
-        assertNotNull("missing table", table);
-        
-        TableStyleInfo style = table.getStyle();
-        assertNotNull("Missing table style info", style);
-        assertNotNull("Missing table style", style.getStyle());
-        assertEquals("Wrong name", "TestTableStyle", style.getName());
-        assertEquals("Wrong name", "TestTableStyle", style.getStyle().getName());
-
-        DifferentialStyleProvider firstColumn = style.getStyle().getStyle(TableStyleType.firstColumn);
-        assertNotNull("no first column style", firstColumn);
-        FontFormatting font = firstColumn.getFontFormatting();
-        assertNotNull("no first col font", font);
-        assertTrue("wrong first col bold", font.isBold());
-        
-        wb.close();
+        try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("tableStyle.xlsx")) {
+            Table table = wb.getTable("Table1");
+            assertNotNull(table, "missing table");
+
+            TableStyleInfo style = table.getStyle();
+            assertNotNull(style, "Missing table style info");
+            assertNotNull(style.getStyle(), "Missing table style");
+            assertEquals("TestTableStyle", style.getName(), "Wrong name");
+            assertEquals("TestTableStyle", style.getStyle().getName(), "Wrong name");
+
+            DifferentialStyleProvider firstColumn = style.getStyle().getStyle(TableStyleType.firstColumn);
+            assertNotNull(firstColumn, "no first column style");
+            FontFormatting font = firstColumn.getFontFormatting();
+            assertNotNull(font, "no first col font");
+            assertTrue(font.isBold(), "wrong first col bold");
+        }
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java Thu Dec 24 18:42:29 2020
@@ -17,10 +17,10 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -51,7 +51,7 @@ import org.apache.poi.ss.util.RegionUtil
 import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.xssf.SXSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
 
 /**
@@ -105,13 +105,12 @@ public final class TestUnfixedBugs {
         int millisecondsInDay2 = (int)((value2 - wholeDays2) * DateUtil.DAY_MILLISECONDS + 0.5);
 
         assertEquals(wholeDays1, wholeDays2);
-        // here we see that the time-value is 5 milliseconds apart, one is 86399000 and the other is 86398995, 
+        // here we see that the time-value is 5 milliseconds apart, one is 86399000 and the other is 86398995,
         // thus one is one second higher than the other
-        assertEquals("The time-values are 5 milliseconds apart",
-                millisecondsInDay1, millisecondsInDay2);
+        assertEquals(millisecondsInDay1, millisecondsInDay2, "The time-values are 5 milliseconds apart");
 
         // when we do the calendar-stuff, there is a boolean which determines if
-        // the milliseconds are rounded or not, having this at "false" causes the 
+        // the milliseconds are rounded or not, having this at "false" causes the
         // second to be different here!
         int startYear = 1900;
         int dayAdjust = -1; // Excel thinks 2/29/1900 is a valid date, which it isn't
@@ -133,7 +132,7 @@ public final class TestUnfixedBugs {
         assertEquals(DateUtil.getJavaDate(value1, false), DateUtil.getJavaDate(value2, false));
     }
 
-    // When this is fixed, the test case should go to BaseTestXCell with 
+    // When this is fixed, the test case should go to BaseTestXCell with
     // adjustments to use _testDataProvider to also verify this for XSSF
     @Test
     public void testBug57294() throws IOException {
@@ -263,8 +262,7 @@ public final class TestUnfixedBugs {
         checkRow57423(testSheet, 8, "8");
         checkRow57423(testSheet, 9, "9");
 
-        assertNull("Row number 10 should be gone after the shift",
-                testSheet.getRow(10));
+        assertNull(testSheet.getRow(10), "Row number 10 should be gone after the shift");
 
         checkRow57423(testSheet, 11, "11");
         checkRow57423(testSheet, 12, "10");
@@ -291,21 +289,19 @@ public final class TestUnfixedBugs {
         assertTrue(posR12 != -1);
         assertTrue(posR13 != -1);
 
-        assertTrue("Need to find row 12 before row 13 after the shifting, but had row 12 at " + posR12 + " and row 13 at " + posR13,
-                posR12 < posR13);
+        assertTrue(posR12 < posR13, "Need to find row 12 before row 13 after the shifting, but had row 12 at " + posR12 + " and row 13 at " + posR13);
     }
 
     private void checkRow57423(Sheet testSheet, int rowNum, String contents) {
         Row row = testSheet.getRow(rowNum);
-        assertNotNull("Expecting row at rownum " + rowNum, row);
+        assertNotNull(row, "Expecting row at rownum " + rowNum);
 
         CTRow ctRow = ((XSSFRow)row).getCTRow();
         assertEquals(rowNum+1, ctRow.getR());
 
         Cell cell = row.getCell(0);
-        assertNotNull("Expecting cell at rownum " + rowNum, cell);
-        assertEquals("Did not have expected contents at rownum " + rowNum,
-                contents + ".0", cell.toString());
+        assertNotNull(cell, "Expecting cell at rownum " + rowNum);
+        assertEquals( contents + ".0", cell.toString(), "Did not have expected contents at rownum " + rowNum );
     }
 
     @Test
@@ -338,8 +334,7 @@ public final class TestUnfixedBugs {
         long maxSeenRowNum = 0; //1-based
         for (final CTRow ctRow : wb.getSheetAt(0).getCTWorksheet().getSheetData().getRowList()) {
             final long rowNum = ctRow.getR(); //1-based
-            assertTrue("Row " + rowNum + " (1-based) is not in ascending order; previously saw " + maxSeenRowNum,
-                    rowNum > maxSeenRowNum);
+            assertTrue(rowNum > maxSeenRowNum, "Row " + rowNum + " (1-based) is not in ascending order; previously saw " + maxSeenRowNum);
             maxSeenRowNum = rowNum;
         }
     }
@@ -371,10 +366,10 @@ public final class TestUnfixedBugs {
         }
     }
 
-    public class HsGetValue implements FreeRefFunction {
+    public static class HsGetValue implements FreeRefFunction {
         public static final String name = "HsGetValue";
 
-        private Hashtable<CellAddress, String> cellValues;
+        private final Hashtable<CellAddress, String> cellValues;
 
         public HsGetValue(Hashtable<CellAddress, String> cellValues) {
             super();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Thu Dec 24 18:42:29 2020
@@ -19,14 +19,16 @@ package org.apache.poi.xssf.usermodel;
 
 import static org.apache.poi.extractor.ExtractorFactory.OOXML_PACKAGE;
 import static org.apache.poi.openxml4j.opc.TestContentType.isOldXercesActive;
-import static org.junit.Assert.assertArrayEquals;
-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.junit.jupiter.api.Assertions.assertArrayEquals;
+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.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -113,10 +115,11 @@ import org.apache.poi.xssf.model.Calcula
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
 import org.apache.xmlbeans.XmlException;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.junit.jupiter.params.provider.ValueSource;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName;
@@ -351,7 +354,7 @@ public final class TestXSSFBugs extends
                                 String formula = c.getCellFormula();
                                 double cachedFormulaResult = c.getNumericCellValue();
                                 double evaluatedFormulaResult = cv.getNumberValue();
-                                assertEquals(formula, cachedFormulaResult, evaluatedFormulaResult, 1E-7);
+                                assertEquals(cachedFormulaResult, evaluatedFormulaResult, 1E-7, formula);
                             }
                         }
                     }
@@ -465,10 +468,10 @@ public final class TestXSSFBugs extends
             assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());
 
             Name nm1 = wb.getName("sale_1");
-            assertNotNull("name sale_1 should be present", nm1);
+            assertNotNull(nm1, "name sale_1 should be present");
             assertEquals("Sheet1!#REF!", nm1.getRefersToFormula());
             Name nm2 = wb.getName("sale_2");
-            assertNotNull("name sale_2 should be present", nm2);
+            assertNotNull(nm2, "name sale_2 should be present");
             assertEquals("Sheet1!#REF!", nm2.getRefersToFormula());
 
             cell = sheet.getRow(1).getCell(0);
@@ -1437,7 +1440,7 @@ public final class TestXSSFBugs extends
                     //simulate correct answer
                     String correct = "$A" + (rInd + 1) + "*" + columns[cInd] + "$2";
 
-                    assertEquals("Incorrect formula in " + ref.formatAsString(), correct, formula);
+                    assertEquals(correct, formula, "Incorrect formula in " + ref.formatAsString());
                 }
 
             }
@@ -1555,40 +1558,31 @@ public final class TestXSSFBugs extends
 
     @Test
     public void bug56468() throws IOException, InterruptedException {
-        XSSFWorkbook wb = new XSSFWorkbook();
-        XSSFSheet sheet = wb.createSheet();
-        XSSFRow row = sheet.createRow(0);
-        XSSFCell cell = row.createCell(0);
-        cell.setCellValue("Hi");
-        sheet.setRepeatingRows(new CellRangeAddress(0, 0, 0, 0));
-
-        // small hack to try to make this test stable, previously it failed whenever the two written ZIP files had different file-creation
-        // dates stored.
-        // We try to do a loop until the current second changes in order to avoid problems with some date information that is written to the ZIP and thus
-        // causes differences
-        long start = System.currentTimeMillis() / 1000;
-        while (System.currentTimeMillis() / 1000 == start) {
-            Thread.sleep(10);
-        }
-
-        ByteArrayOutputStream bos = new ByteArrayOutputStream(8096);
-        wb.write(bos);
-        byte[] firstSave = bos.toByteArray();
-        bos.reset();
-        wb.write(bos);
-        byte[] secondSave = bos.toByteArray();
-
-        /*OutputStream stream = new FileOutputStream("C:\\temp\\poi.xlsx");
-        try {
-            wb.write(stream);
-        } finally {
-            stream.close();
-        }*/
+        try (XSSFWorkbook wb = new XSSFWorkbook()) {
+            XSSFSheet sheet = wb.createSheet();
+            XSSFRow row = sheet.createRow(0);
+            XSSFCell cell = row.createCell(0);
+            cell.setCellValue("Hi");
+            sheet.setRepeatingRows(new CellRangeAddress(0, 0, 0, 0));
 
-        assertArrayEquals("Had: \n" + Arrays.toString(firstSave) + " and \n" + Arrays.toString(secondSave),
-                firstSave, secondSave);
+            // small hack to try to make this test stable, previously it failed whenever the two written ZIP files had
+            // different file-creation dates stored. We try to do a loop until the current second changes in order to
+            // avoid problems with some date information that is written to the ZIP and thus causes differences
+            long start = System.currentTimeMillis() / 1000;
+            while (System.currentTimeMillis() / 1000 == start) {
+                Thread.sleep(10);
+            }
+
+            ByteArrayOutputStream bos = new ByteArrayOutputStream(8096);
+            wb.write(bos);
+            byte[] firstSave = bos.toByteArray();
+            bos.reset();
+            wb.write(bos);
+            byte[] secondSave = bos.toByteArray();
 
-        wb.close();
+            assertArrayEquals(firstSave, secondSave,
+                "Had: \n" + Arrays.toString(firstSave) + " and \n" + Arrays.toString(secondSave));
+        }
     }
 
     /**
@@ -1624,7 +1618,7 @@ public final class TestXSSFBugs extends
         }
     }
 
-    @Ignore("Shifting rows is not yet implemented in SXSSFSheet")
+    @Disabled("Shifting rows is not yet implemented in SXSSFSheet")
     @Test
     public void testBug53798XLSXStream() throws IOException {
         try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("53798_shiftNegative_TMPL.xlsx")) {
@@ -1904,31 +1898,21 @@ public final class TestXSSFBugs extends
 
     @Test
     public void bug54764() throws IOException, OpenXML4JException, XmlException {
-        OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("54764.xlsx");
+        try (OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("54764.xlsx")) {
+            // Check the core properties - will be found but empty, due
+            //  to the expansion being too much to be considered valid
+            POIXMLProperties props = new POIXMLProperties(pkg);
+            assertNull(props.getCoreProperties().getTitle());
+            assertNull(props.getCoreProperties().getSubject());
+            assertNull(props.getCoreProperties().getDescription());
 
-        // Check the core properties - will be found but empty, due
-        //  to the expansion being too much to be considered valid
-        POIXMLProperties props = new POIXMLProperties(pkg);
-        assertNull(props.getCoreProperties().getTitle());
-        assertNull(props.getCoreProperties().getSubject());
-        assertNull(props.getCoreProperties().getDescription());
-
-        // Now check the spreadsheet itself
-        try {
-            new XSSFWorkbook(pkg).close();
-            fail("Should fail as too much expansion occurs");
-        } catch (POIXMLException e) {
-            // Expected
+            // Now check the spreadsheet itself
+            assertThrows(POIXMLException.class, () -> new XSSFWorkbook(pkg), "Should fail as too much expansion occurs");
         }
-        pkg.close();
 
         // Try with one with the entities in the Content Types
-        try {
-            XSSFTestDataSamples.openSamplePackage("54764-2.xlsx").close();
-            fail("Should fail as too much expansion occurs");
-        } catch (Exception e) {
-            // Expected
-        }
+        assertThrows(Exception.class, () -> XSSFTestDataSamples.openSamplePackage("54764-2.xlsx"),
+            "Should fail as too much expansion occurs");
 
         // Check we can still parse valid files after all that
         try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx")) {
@@ -1942,13 +1926,10 @@ public final class TestXSSFBugs extends
         try (ZipFile zip = new ZipFile(testFile)) {
             ZipArchiveEntry ze = zip.getEntry("xl/sharedStrings.xml");
             XMLReader reader = XMLHelper.newXMLReader();
-            try {
-                reader.parse(new InputSource(zip.getInputStream(ze)));
-                fail("should have thrown SAXParseException");
-            } catch (SAXParseException e) {
-                assertNotNull(e.getMessage());
-                assertTrue(e.getMessage().contains("more than \"1\" entity"));
-            }
+            SAXParseException e = assertThrows(SAXParseException.class,
+                () -> reader.parse(new InputSource(zip.getInputStream(ze))));
+            assertNotNull(e.getMessage());
+            assertTrue(e.getMessage().contains("more than \"1\" entity"));
         }
     }
 
@@ -1957,13 +1938,10 @@ public final class TestXSSFBugs extends
         File testFile = XSSFTestDataSamples.getSampleFile("54764.xlsx");
         try (ZipFile zip = new ZipFile(testFile)) {
             ZipArchiveEntry ze = zip.getEntry("xl/sharedStrings.xml");
-            try {
-                DocumentHelper.readDocument(zip.getInputStream(ze));
-                fail("should have thrown SAXParseException");
-            } catch (SAXParseException e) {
-                assertNotNull(e.getMessage());
-                assertNotEquals(isOldXercesActive(), e.getMessage().contains("DOCTYPE is disallowed when the feature"));
-            }
+            SAXParseException e = assertThrows(SAXParseException.class,
+                () -> DocumentHelper.readDocument(zip.getInputStream(ze)));
+            assertNotNull(e.getMessage());
+            assertNotEquals(isOldXercesActive(), e.getMessage().contains("DOCTYPE is disallowed when the feature"));
         }
     }
 
@@ -1991,34 +1969,17 @@ public final class TestXSSFBugs extends
     @Test
     public void bug56800_xlsb() throws IOException {
         // Can be opened at the OPC level
-        OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("Simple.xlsb");
-
-        // XSSF Workbook gives helpful error
-        try {
-            new XSSFWorkbook(pkg).close();
-            fail(".xlsb files not supported");
-        } catch (XLSBUnsupportedException e) {
-            // Good, detected and warned
-        }
+        try (OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("Simple.xlsb")) {
+            // XSSF Workbook gives helpful error
+            assertThrows(XLSBUnsupportedException.class, () -> new XSSFWorkbook(pkg), ".xlsb files not supported");
 
-        // Workbook Factory gives helpful error on package
-        try {
-            XSSFWorkbookFactory.createWorkbook(pkg).close();
-            fail(".xlsb files not supported");
-        } catch (XLSBUnsupportedException e) {
-            // Good, detected and warned
+            // Workbook Factory gives helpful error on package
+            assertThrows(XLSBUnsupportedException.class, () -> XSSFWorkbookFactory.createWorkbook(pkg), ".xlsb files not supported");
         }
 
         // Workbook Factory gives helpful error on file
         File xlsbFile = HSSFTestDataSamples.getSampleFile("Simple.xlsb");
-        try {
-            WorkbookFactory.create(xlsbFile).close();
-            fail(".xlsb files not supported");
-        } catch (XLSBUnsupportedException e) {
-            // Good, detected and warned
-        }
-
-        pkg.close();
+        assertThrows(XLSBUnsupportedException.class, () -> WorkbookFactory.create(xlsbFile), ".xlsb files not supported");
     }
 
     private void checkValue(XSSFWorkbook excel, String expect) {
@@ -2157,61 +2118,50 @@ public final class TestXSSFBugs extends
      * A .xlsx file with no Shared Strings table should open fine
      * in read-only mode
      */
-    @SuppressWarnings("resource")
-    @Test
-    public void bug57482() throws IOException, InvalidFormatException {
-        for (PackageAccess access : new PackageAccess[]{
-                PackageAccess.READ_WRITE, PackageAccess.READ
-        }) {
-            File file = HSSFTestDataSamples.getSampleFile("57482-OnlyNumeric.xlsx");
-            OPCPackage pkg = OPCPackage.open(file, access);
-            try {
-                // Try to open it and read the contents
-                XSSFWorkbook wb1 = new XSSFWorkbook(pkg);
-                assertNotNull(wb1.getSharedStringSource());
-                assertEquals(0, wb1.getSharedStringSource().getCount());
+    @ParameterizedTest
+    @EnumSource(value = PackageAccess.class, names = {"READ_WRITE", "READ"})
+    public void bug57482(PackageAccess access) throws IOException, InvalidFormatException {
+        File file = HSSFTestDataSamples.getSampleFile("57482-OnlyNumeric.xlsx");
+        try (OPCPackage pkg = OPCPackage.open(file, access);
+             XSSFWorkbook wb1 = new XSSFWorkbook(pkg)) {
+            // Try to open it and read the contents
+
+            assertNotNull(wb1.getSharedStringSource());
+            assertEquals(0, wb1.getSharedStringSource().getCount());
+
+            DataFormatter fmt = new DataFormatter();
+            XSSFSheet s = wb1.getSheetAt(0);
+            assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
+            assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
+            assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
+
+            // Add a text cell
+            s.getRow(0).createCell(3).setCellValue("Testing");
+            assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
 
-                DataFormatter fmt = new DataFormatter();
-                XSSFSheet s = wb1.getSheetAt(0);
+            // Try to write-out and read again, should only work
+            //  in read-write mode, not read-only mode
+            try (XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1)) {
+                if (access == PackageAccess.READ) {
+                    fail("Shouln't be able to write from read-only mode");
+                }
+
+                // Check again
+                s = wb2.getSheetAt(0);
                 assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
                 assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
                 assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
-
-                // Add a text cell
-                s.getRow(0).createCell(3).setCellValue("Testing");
                 assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
 
-                // Try to write-out and read again, should only work
-                //  in read-write mode, not read-only mode
-                XSSFWorkbook wb2 = null;
-                try {
-                    wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
-                    if (access == PackageAccess.READ) {
-                        fail("Shouln't be able to write from read-only mode");
-                    }
-
-                    // Check again
-                    s = wb2.getSheetAt(0);
-                    assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
-                    assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
-                    assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
-                    assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
-
-                } catch (InvalidOperationException e) {
-                    if (access == PackageAccess.READ_WRITE) {
-                        // Shouldn't occur in write-mode
-                        throw e;
-                    }
-                } finally {
-                    if (wb2 != null) {
-                        wb2.getPackage().revert();
-                    }
+                wb2.getPackage().revert();
+            } catch (InvalidOperationException e) {
+                if (access == PackageAccess.READ_WRITE) {
+                    // Shouldn't occur in write-mode
+                    throw e;
                 }
-
-                wb1.getPackage().revert();
-            } finally {
-                pkg.revert();
             }
+
+            pkg.revert();
         }
     }
 
@@ -2364,7 +2314,7 @@ public final class TestXSSFBugs extends
      * Not currently working - namespace mis-match from XMLBeans
      */
     @Test
-    @Ignore("XMLBeans namespace mis-match on ooxml-strict files")
+    @Disabled("XMLBeans namespace mis-match on ooxml-strict files")
     public void test57699() throws IOException {
         try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.strict.xlsx")) {
             assertEquals(3, wb.getNumberOfSheets());
@@ -2433,7 +2383,7 @@ public final class TestXSSFBugs extends
     public void testBug57826() throws IOException {
         XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("57826.xlsx");
 
-        assertTrue("no sheets in workbook", workbook.getNumberOfSheets() >= 1);
+        assertTrue(workbook.getNumberOfSheets() >= 1, "no sheets in workbook");
         XSSFSheet sheet = workbook.getSheetAt(0);
 
         XSSFDrawing drawing = sheet.getDrawingPatriarch();
@@ -2910,7 +2860,7 @@ public final class TestXSSFBugs extends
         workbook.close();
     }
 
-    @Ignore("Creates files for checking results manually, actual values are tested in Test*CellStyle")
+    @Disabled("Creates files for checking results manually, actual values are tested in Test*CellStyle")
     @Test
     public void test58043() throws IOException {
         saveRotatedTextExample(new HSSFWorkbook(), TempFile.createTempFile("rotated", ".xls"));
@@ -2967,7 +2917,7 @@ public final class TestXSSFBugs extends
         workbook.close();
     }
 
-    @Ignore("bug 59442")
+    @Disabled("bug 59442")
     @Test
     public void testSetRGBBackgroundColor() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
@@ -3011,7 +2961,7 @@ public final class TestXSSFBugs extends
         nwb.close();
     }
 
-    @Ignore("currently fails on POI 3.15 beta 2")
+    @Disabled("currently fails on POI 3.15 beta 2")
     @Test
     public void test55273() throws IOException {
         try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("ExcelTables.xlsx")) {
@@ -3054,7 +3004,7 @@ public final class TestXSSFBugs extends
     public void noRowNumbers59746() throws IOException {
         try (Workbook wb = XSSFTestDataSamples.openSampleWorkbook("59746_NoRowNums.xlsx")) {
             Sheet sheet = wb.getSheetAt(0);
-            assertTrue("Last row num: " + sheet.getLastRowNum(), sheet.getLastRowNum() > 20);
+            assertTrue(sheet.getLastRowNum() > 20, "Last row num: " + sheet.getLastRowNum());
             assertEquals("Checked", sheet.getRow(0).getCell(0).getStringCellValue());
             assertEquals("Checked", sheet.getRow(9).getCell(2).getStringCellValue());
             assertFalse(sheet.getRow(70).getCell(8).getBooleanCellValue());
@@ -3079,40 +3029,43 @@ public final class TestXSSFBugs extends
     }
 
     // This bug is currently open. When this bug is fixed, it should not throw an AssertionError
-    @Test(expected = AssertionError.class)
+    @Test
     public void test55076_collapseColumnGroups() throws Exception {
-        Workbook wb = new XSSFWorkbook();
-        Sheet sheet = wb.createSheet();
+        try (Workbook wb = new XSSFWorkbook()) {
+            Sheet sheet = wb.createSheet();
 
-        // this column collapsing bug only occurs when the grouped columns are different widths
-        sheet.setColumnWidth(1, 400);
-        sheet.setColumnWidth(2, 600);
-        sheet.setColumnWidth(3, 800);
-
-        assertEquals(400, sheet.getColumnWidth(1));
-        assertEquals(600, sheet.getColumnWidth(2));
-        assertEquals(800, sheet.getColumnWidth(3));
-
-        sheet.groupColumn(1, 3);
-        sheet.setColumnGroupCollapsed(1, true);
-
-        assertEquals(0, sheet.getColumnOutlineLevel(0));
-        assertEquals(1, sheet.getColumnOutlineLevel(1));
-        assertEquals(1, sheet.getColumnOutlineLevel(2));
-        assertEquals(1, sheet.getColumnOutlineLevel(3));
-        assertEquals(0, sheet.getColumnOutlineLevel(4));
-
-        // none of the columns should be hidden
-        // column group collapsing is a different concept
-        for (int c = 0; c < 5; c++) {
-            assertFalse("Column " + c, sheet.isColumnHidden(c));
-        }
-
-        assertEquals(400, sheet.getColumnWidth(1));
-        assertEquals(600, sheet.getColumnWidth(2));
-        assertEquals(800, sheet.getColumnWidth(3));
+            // this column collapsing bug only occurs when the grouped columns are different widths
+            sheet.setColumnWidth(1, 400);
+            sheet.setColumnWidth(2, 600);
+            sheet.setColumnWidth(3, 800);
+
+            assertEquals(400, sheet.getColumnWidth(1));
+            assertEquals(600, sheet.getColumnWidth(2));
+            assertEquals(800, sheet.getColumnWidth(3));
+
+            sheet.groupColumn(1, 3);
+            sheet.setColumnGroupCollapsed(1, true);
+
+            assertEquals(0, sheet.getColumnOutlineLevel(0));
+            assertEquals(1, sheet.getColumnOutlineLevel(1));
+            assertEquals(1, sheet.getColumnOutlineLevel(2));
+            assertEquals(1, sheet.getColumnOutlineLevel(3));
+            assertEquals(0, sheet.getColumnOutlineLevel(4));
+
+            // none of the columns should be hidden
+            // column group collapsing is a different concept
+            for (int c = 0; c < 5; c++) {
+                // if this fails for c == 1 in the future, then the implementation will be correct
+                // and we need to adapt this test accordingly
+                assertEquals(c == 1, sheet.isColumnHidden(c), "Column " + c);
+            }
+
+            assertEquals(400, sheet.getColumnWidth(1));
+            // 600 is the correct value! ... 2048 is just for pacifying the test (see above comment)
+            assertEquals(2048, sheet.getColumnWidth(2));
+            assertEquals(800, sheet.getColumnWidth(3));
 
-        wb.close();
+        }
     }
 
     /**
@@ -3217,7 +3170,7 @@ public final class TestXSSFBugs extends
             eval.setDebugEvaluationOutputForNextEval(true);
             CellValue cv = eval.evaluate(c);
             assertNotNull(cv);
-            assertEquals("Had: " + cv, 2.0, cv.getNumberValue(), 0.00001);
+            assertEquals(2.0, cv.getNumberValue(), 0.00001, "Had: " + cv);
         }
     }
 
@@ -3246,8 +3199,8 @@ public final class TestXSSFBugs extends
             formulaShifter.adjustFormula(ptgs, 0);    // adjusted to [A]
             String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);    //A
             //System.out.println(String.format("initial formula : A1; expected formula value after shifting up : #REF!; actual formula value : %s", shiftedFmla));
-            assertEquals("On copy we expect the formula to be adjusted, in this case it would point to row -1, which is an invalid REF",
-                    expectedFormula, shiftedFmla);
+            assertEquals(expectedFormula, shiftedFmla,
+                "On copy we expect the formula to be adjusted, in this case it would point to row -1, which is an invalid REF");
         }
 
         {
@@ -3258,14 +3211,14 @@ public final class TestXSSFBugs extends
             formulaShifter.adjustFormula(ptgs, 0);    // adjusted to [A]
             String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);    //A
             //System.out.println(String.format("initial formula : A1; expected formula value after shifting up : #REF!; actual formula value : %s", shiftedFmla));
-            assertEquals("On move we expect the formula to stay the same, thus expecting the initial formula A1 here",
-                    initialFormula, shiftedFmla);
+            assertEquals(initialFormula, shiftedFmla,
+                "On move we expect the formula to stay the same, thus expecting the initial formula A1 here");
         }
 
         sheet.shiftRows(2, 2, -1);
         {
             Cell c2 = sheet.getRow(1).getCell(2);
-            assertNotNull("cell C2 needs to exist now", c2);
+            assertNotNull(c2, "cell C2 needs to exist now");
             assertEquals(CellType.FORMULA, c2.getCellType());
             assertEquals(initialFormula, c2.getCellFormula());
             FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -3285,8 +3238,8 @@ public final class TestXSSFBugs extends
             WorkbookEvaluatorProvider fe = (WorkbookEvaluatorProvider) wb.getCreationHelper().createFormulaEvaluator();
             ConditionalFormattingEvaluator condfmt = new ConditionalFormattingEvaluator(wb, fe);
 
-            assertEquals("Conditional formatting is not triggered for this cell",
-                    "[]", condfmt.getConditionalFormattingForCell(cell).toString());
+            assertEquals("[]", condfmt.getConditionalFormattingForCell(cell).toString(),
+                "Conditional formatting is not triggered for this cell");
 
             // but we can read the conditional formatting itself
             List<EvaluationConditionalFormatRule> rules = condfmt.getFormatRulesForSheet(sheet);
@@ -3419,7 +3372,7 @@ public final class TestXSSFBugs extends
         String value = cell.getStringCellValue();
         //System.out.println(value);
 
-        assertEquals("The data in the text-file should exactly match the data that we read from the workbook", testData, value);
+        assertEquals(testData, value, "The data in the text-file should exactly match the data that we read from the workbook");
     }
 
 
@@ -3532,12 +3485,10 @@ public final class TestXSSFBugs extends
         }
     }
 
-    @Test(expected = POIXMLException.class)
-    public void test64045() throws IOException, InvalidFormatException {
+    @Test
+    public void test64045() {
         File file = XSSFTestDataSamples.getSampleFile("xlsx-corrupted.xlsx");
-        try (XSSFWorkbook ignored = new XSSFWorkbook(file)) {
-            fail("Should catch exception as the file is corrupted");
-        }
+        assertThrows(POIXMLException.class, () -> new XSSFWorkbook(file), "Should catch exception as the file is corrupted");
     }
 
     @Test
@@ -3572,26 +3523,25 @@ public final class TestXSSFBugs extends
             Cell cell = row.createCell(0, CellType.FORMULA);
             cell.setCellFormula("SUM(B1:E1)");
 
-            assertNull("Element 'v' should not be set for formulas unless the value was calculated",
-                    ((XSSFCell) cell).getCTCell().getV());
+            assertNull(((XSSFCell) cell).getCTCell().getV(),
+                "Element 'v' should not be set for formulas unless the value was calculated");
 
             try (Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb)) {
                 Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(0);
-                assertNull("Element 'v' should not be set for formulas unless the value was calculated",
-                        ((XSSFCell) cellBack).getCTCell().getV());
-                assertNotNull("Formula should be set internally now",
-                        ((XSSFCell) cellBack).getCTCell().getF());
+                assertNull(((XSSFCell) cellBack).getCTCell().getV(),
+                    "Element 'v' should not be set for formulas unless the value was calculated");
+                assertNotNull(((XSSFCell) cellBack).getCTCell().getF(),
+                    "Formula should be set internally now");
 
                 wbBack.getCreationHelper().createFormulaEvaluator().evaluateInCell(cellBack);
 
-                assertEquals("Element 'v' should be set now as the formula was calculated manually",
-                        "0.0", ((XSSFCell) cellBack).getCTCell().getV());
+                assertEquals("0.0", ((XSSFCell) cellBack).getCTCell().getV(),
+                    "Element 'v' should be set now as the formula was calculated manually");
 
                 cellBack.setCellValue("123");
-                assertEquals("String value should be set now",
-                        "123", cellBack.getStringCellValue());
-                assertNull("No formula should be set any more",
-                        ((XSSFCell) cellBack).getCTCell().getF());
+                assertEquals("123", cellBack.getStringCellValue(),
+                    "String value should be set now");
+                assertNull(((XSSFCell) cellBack).getCTCell().getF(), "No formula should be set any more");
             }
         }
     }
@@ -3608,13 +3558,13 @@ public final class TestXSSFBugs extends
             try (Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb)) {
                 Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(2);
 
-                assertNull("Element 'v' should not be set for formulas unless the value was calculated",
-                        ((XSSFCell) cellBack).getCTCell().getV());
+                assertNull(((XSSFCell) cellBack).getCTCell().getV(),
+                    "Element 'v' should not be set for formulas unless the value was calculated");
 
                 wbBack.getCreationHelper().createFormulaEvaluator().evaluateInCell(cellBack);
 
-                assertEquals("Element 'v' should be set now as the formula was calculated manually",
-                        "7.0", ((XSSFCell) cellBack).getCTCell().getV());
+                assertEquals("7.0", ((XSSFCell) cellBack).getCTCell().getV(),
+                    "Element 'v' should be set now as the formula was calculated manually");
             }
         }
     }
@@ -3627,8 +3577,8 @@ public final class TestXSSFBugs extends
             Row row = sheet1.getRow(1);
             CellReference aCellReference = new CellReference("E2");
             Cell aCell = row.getCell(aCellReference.getCol());
-            Assert.assertEquals(CellType.STRING, aCell.getCellType());
-            Assert.assertEquals("", aCell.getStringCellValue());
+            assertEquals(CellType.STRING, aCell.getCellType());
+            assertEquals("", aCell.getStringCellValue());
         }
     }
 
@@ -3646,7 +3596,7 @@ public final class TestXSSFBugs extends
 
     @Test
     public void testXLSXinPPT() throws Exception {
-        Assume.assumeFalse(Boolean.getBoolean("scratchpad.ignore"));
+        assumeFalse(Boolean.getBoolean("scratchpad.ignore"));
 
         try (SlideShow<?,?> ppt = SlideShowFactory.create(
                 POIDataSamples.getSlideShowInstance().openResourceAsStream("testPPT_oleWorkbook.ppt"))) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java Thu Dec 24 18:42:29 2020
@@ -17,14 +17,15 @@
 
 package org.apache.poi.xssf.usermodel;
 
-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.assertSame;
-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.assertNull;
+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 static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.List;
@@ -56,7 +57,7 @@ import org.apache.poi.xssf.SXSSFITestDat
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.model.SharedStringsTable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
@@ -140,19 +141,19 @@ public final class TestXSSFCell extends
         assertNull(str.getString());
         cell_0.setCellValue(str);
         assertEquals(0, sst.getCount());
-        assertEquals("Having: " + cell_0, CellType.BLANK, cell_0.getCellType());
+        assertEquals(CellType.BLANK, cell_0.getCellType(), "Having: " + cell_0);
 
         //case 2. cell.setCellValue((String)null);
         Cell cell_1 = row.createCell(1);
         cell_1.setCellValue((String)null);
         assertEquals(0, sst.getCount());
-        assertEquals("Having: " + cell_1, CellType.BLANK, cell_1.getCellType());
+        assertEquals(CellType.BLANK, cell_1.getCellType(), "Having: " + cell_1);
 
         //case 3. cell.setCellValue((RichTextString)null);
         Cell cell_2 = row.createCell(2);
         cell_2.setCellValue((RichTextString) null);
         assertEquals(0, sst.getCount());
-        assertEquals("Having: " + cell_2, CellType.BLANK, cell_2.getCellType());
+        assertEquals(CellType.BLANK, cell_2.getCellType(), "Having: " + cell_2);
 
         wb.close();
     }
@@ -201,12 +202,7 @@ public final class TestXSSFCell extends
             cell.setCellFormula(validFormula);
 
             // check that invalid formula does throw exception
-            try {
-                cell.setCellFormula(invalidFormula);
-                fail("Should catch exception here");
-            } catch (FormulaParseException e) {
-                // expected here
-            }
+            assertThrows(FormulaParseException.class, () -> cell.setCellFormula(invalidFormula));
 
             // set cell formula validation to false
             wb.setCellFormulaValidation(false);
@@ -322,8 +318,8 @@ public final class TestXSSFCell extends
             XSSFRow rowRef = (XSSFRow)r;
             XSSFRow row = sheet.getRow(rowRef.getRowNum());
 
-            assertEquals("number of cells in row["+row.getRowNum()+"]",
-                    rowRef.getPhysicalNumberOfCells(), row.getPhysicalNumberOfCells());
+            assertEquals(rowRef.getPhysicalNumberOfCells(), row.getPhysicalNumberOfCells(),
+                "number of cells in row["+row.getRowNum()+"]");
 
             for(Cell c :  rowRef){
                 XSSFCell cellRef = (XSSFCell)c;
@@ -333,7 +329,7 @@ public final class TestXSSFCell extends
                 assertEquals(cellRef.getReference(), cell.getReference());
 
                 if(!cell.getCTCell().isSetR()){
-                    assertTrue("R must e set in cellRef", cellRef.getCTCell().isSetR());
+                    assertTrue(cellRef.getCTCell().isSetR(), "R must e set in cellRef");
 
                     String valRef = formater.formatCellValue(cellRef);
                     String val = formater.formatCellValue(cell);
@@ -423,12 +419,7 @@ public final class TestXSSFCell extends
             validateRow(row);
 
             // once again with removing the same cell, this throws an exception
-            try {
-                row.removeCell(cell1);
-                fail("Should catch an exception");
-            } catch (IllegalArgumentException e) {
-                // expected here
-            }
+            assertThrows(IllegalArgumentException.class, () -> row.removeCell(cell1));
 
             // now check again
             validateRow(row);
@@ -605,15 +596,13 @@ public final class TestXSSFCell extends
         destCell.copyCellFrom(srcCell, policy);
         assertNotNull(destCell.getHyperlink());
 
-        assertSame("unit test assumes srcCell and destCell are on the same sheet",
-                srcCell.getSheet(), destCell.getSheet());
+        assertSame(srcCell.getSheet(), destCell.getSheet(),
+            "unit test assumes srcCell and destCell are on the same sheet");
 
         final List<XSSFHyperlink> links = srcCell.getSheet().getHyperlinkList();
-        assertEquals("number of hyperlinks on sheet", 2, links.size());
-        assertEquals("source hyperlink",
-                new CellAddress(srcCell).formatAsString(), links.get(0).getCellRef());
-        assertEquals("destination hyperlink",
-                new CellAddress(destCell).formatAsString(), links.get(1).getCellRef());
+        assertEquals(2, links.size(), "number of hyperlinks on sheet");
+        assertEquals(new CellAddress(srcCell).formatAsString(), links.get(0).getCellRef(), "source hyperlink");
+        assertEquals(new CellAddress(destCell).formatAsString(), links.get(1).getCellRef(), "destination hyperlink");
 
         wb.close();
     }
@@ -642,8 +631,8 @@ public final class TestXSSFCell extends
         setLinkCellStyle(wb, destCell);
 
         // Pre-condition assumptions. This test is broken if either of these fail.
-        assertSame("unit test assumes srcCell and destCell are on the same sheet",
-                srcCell.getSheet(), destCell.getSheet());
+        assertSame(srcCell.getSheet(), destCell.getSheet(),
+            "unit test assumes srcCell and destCell are on the same sheet");
         assertNull(srcCell.getHyperlink());
 
         // Merge hyperlink - since srcCell doesn't have a hyperlink, destCell's hyperlink is not overwritten (cleared).
@@ -655,9 +644,8 @@ public final class TestXSSFCell extends
 
         List<XSSFHyperlink> links;
         links = srcCell.getSheet().getHyperlinkList();
-        assertEquals("number of hyperlinks on sheet", 1, links.size());
-        assertEquals("source hyperlink",
-                new CellAddress(destCell).formatAsString(), links.get(0).getCellRef());
+        assertEquals(1, links.size(), "number of hyperlinks on sheet");
+        assertEquals(new CellAddress(destCell).formatAsString(), links.get(0).getCellRef(), "source hyperlink");
 
         // Merge destCell's hyperlink to srcCell. Since destCell does have a hyperlink, this should copy destCell's hyperlink to srcCell.
         srcCell.copyCellFrom(destCell, policy);
@@ -665,11 +653,9 @@ public final class TestXSSFCell extends
         assertNotNull(destCell.getHyperlink());
 
         links = srcCell.getSheet().getHyperlinkList();
-        assertEquals("number of hyperlinks on sheet", 2, links.size());
-        assertEquals("dest hyperlink",
-                new CellAddress(destCell).formatAsString(), links.get(0).getCellRef());
-        assertEquals("source hyperlink",
-                new CellAddress(srcCell).formatAsString(), links.get(1).getCellRef());
+        assertEquals(2, links.size(), "number of hyperlinks on sheet");
+        assertEquals(new CellAddress(destCell).formatAsString(), links.get(0).getCellRef(), "dest hyperlink");
+        assertEquals(new CellAddress(srcCell).formatAsString(), links.get(1).getCellRef(), "source hyperlink");
 
         wb.close();
     }
@@ -763,9 +749,9 @@ public final class TestXSSFCell extends
         }
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void getErrorCellValue_returns0_onABlankCell() {
         Cell cell = new XSSFWorkbook().createSheet().createRow(0).createCell(0);
-        cell.getErrorCellValue();
+        assertThrows(IllegalStateException.class, cell::getErrorCellValue);
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Thu Dec 24 18:42:29 2020
@@ -17,14 +17,14 @@
 
 package org.apache.poi.xssf.usermodel;
 
-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.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
@@ -46,8 +46,8 @@ import org.apache.poi.xssf.XSSFTestDataS
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
@@ -63,7 +63,7 @@ public class TestXSSFCellStyle {
 	private StylesTable stylesTable;
     private XSSFCellStyle cellStyle;
 
-    @Before
+    @BeforeEach
 	public void setUp() {
 		stylesTable = new StylesTable();
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChart.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChart.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChart.java Thu Dec 24 18:42:29 2020
@@ -17,14 +17,14 @@
 
 package org.apache.poi.xssf.usermodel;
 
-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 org.apache.poi.xssf.XSSFTestDataSamples;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestXSSFChart {
     @Test

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFChartSheet.java Thu Dec 24 18:42:29 2020
@@ -19,12 +19,12 @@ package org.apache.poi.xssf.usermodel;
 
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTChartsheet;
 
 import java.io.IOException;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 public final class TestXSSFChartSheet {
 
@@ -48,8 +48,7 @@ public final class TestXSSFChartSheet {
         try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chart_sheet.xlsx")) {
             XSSFChartSheet sheet = (XSSFChartSheet) wb.getSheetAt(2);
 
-            assertFalse("Row iterator for charts sheets should return zero rows",
-                    sheet.iterator().hasNext());
+            assertFalse(sheet.iterator().hasNext(), "Row iterator for charts sheets should return zero rows");
 
             //access to a arbitrary row
             assertNull(sheet.getRow(1));
@@ -68,7 +67,7 @@ public final class TestXSSFChartSheet {
             assertNotNull(sheet.getCTChartsheet());
         }
     }
-    
+
     @Test
     public void testGetCharts() throws Exception {
        try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chart_sheet.xlsx")) {



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