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 [35/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/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.ss.formula.ptg;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link PercentPtg}.
@@ -37,12 +37,12 @@ public final class TestPercentPtg extend
         try (HSSFWorkbook workbook = loadWorkbook("PercentPtg.xls")) {
             HSSFSheet sheet = workbook.getSheetAt(0);
 
-            assertEquals("Wrong numeric value for original number", 53000.0,
-                         sheet.getRow(0).getCell(0).getNumericCellValue(), 0.0);
-            assertEquals("Wrong numeric value for percent formula result", 5300.0,
-                         sheet.getRow(1).getCell(0).getNumericCellValue(), 0.0);
-            assertEquals("Wrong formula string for percent formula", "A1*10%",
-                         sheet.getRow(1).getCell(0).getCellFormula());
+            assertEquals(53000.0, sheet.getRow(0).getCell(0).getNumericCellValue(), 0.0,
+                         "Wrong numeric value for original number");
+            assertEquals(5300.0, sheet.getRow(1).getCell(0).getNumericCellValue(), 0.0,
+                         "Wrong numeric value for percent formula result");
+            assertEquals("A1*10%", sheet.getRow(1).getCell(0).getCellFormula(),
+                         "Wrong formula string for percent formula");
         }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.ss.formula.ptg;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link RangePtg}.
@@ -36,8 +36,8 @@ public final class TestRangePtg extends
     public void testReading() throws IOException {
         try (HSSFWorkbook workbook = loadWorkbook("RangePtg.xls")) {
             HSSFCell cell = workbook.getSheetAt(0).getRow(3).getCell(1);
-            assertEquals("Wrong cell value", 10.0, cell.getNumericCellValue(), 0.0);
-            assertEquals("Wrong cell formula", "SUM(pineapple:B2)", cell.getCellFormula());
+            assertEquals(10.0, cell.getNumericCellValue(), 0.0, "Wrong cell value");
+            assertEquals("SUM(pineapple:B2)", cell.getCellFormula(), "Wrong cell formula");
         }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.ss.formula.ptg;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for Ref3DPtg

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestReferencePtg.java Thu Dec 24 18:42:29 2020
@@ -17,9 +17,9 @@
 
 package org.apache.poi.ss.formula.ptg;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+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 java.io.IOException;
 
@@ -28,7 +28,7 @@ import org.apache.poi.hssf.record.Testca
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.util.LittleEndianInput;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link RefPtg}.
@@ -43,42 +43,29 @@ public final class TestReferencePtg {
         HSSFSheet sheet = workbook.getSheetAt(0);
 
         // First row
-        assertEquals("Wrong numeric value for original number", 55.0,
-                     sheet.getRow(0).getCell(0).getNumericCellValue(), 0.0);
-        assertEquals("Wrong numeric value for referemce", 55.0,
-                     sheet.getRow(0).getCell(1).getNumericCellValue(), 0.0);
-        assertEquals("Wrong formula string for reference", "A1",
-                     sheet.getRow(0).getCell(1).getCellFormula());
+        assertEquals(55.0, sheet.getRow(0).getCell(0).getNumericCellValue(), 0.0,
+                     "Wrong numeric value for original number");
+        assertEquals(55.0, sheet.getRow(0).getCell(1).getNumericCellValue(), 0.0,
+                     "Wrong numeric value for referemce");
+        assertEquals("A1", sheet.getRow(0).getCell(1).getCellFormula(), "Wrong formula string for reference");
 
         // Now moving over the 2**15 boundary
         // (Remember that excel row (n) is poi row (n-1)
-        assertEquals("Wrong numeric value for original number", 32767.0,
-                sheet.getRow(32766).getCell(0).getNumericCellValue(), 0.0);
-        assertEquals("Wrong numeric value for referemce", 32767.0,
-                sheet.getRow(32766).getCell(1).getNumericCellValue(), 0.0);
-        assertEquals("Wrong formula string for reference", "A32767",
-                sheet.getRow(32766).getCell(1).getCellFormula());
-
-        assertEquals("Wrong numeric value for original number", 32768.0,
-                sheet.getRow(32767).getCell(0).getNumericCellValue(), 0.0);
-        assertEquals("Wrong numeric value for referemce", 32768.0,
-                sheet.getRow(32767).getCell(1).getNumericCellValue(), 0.0);
-        assertEquals("Wrong formula string for reference", "A32768",
-                sheet.getRow(32767).getCell(1).getCellFormula());
-
-        assertEquals("Wrong numeric value for original number", 32769.0,
-                sheet.getRow(32768).getCell(0).getNumericCellValue(), 0.0);
-        assertEquals("Wrong numeric value for referemce", 32769.0,
-                sheet.getRow(32768).getCell(1).getNumericCellValue(), 0.0);
-        assertEquals("Wrong formula string for reference", "A32769",
-                sheet.getRow(32768).getCell(1).getCellFormula());
-
-        assertEquals("Wrong numeric value for original number", 32770.0,
-                sheet.getRow(32769).getCell(0).getNumericCellValue(), 0.0);
-        assertEquals("Wrong numeric value for referemce", 32770.0,
-                sheet.getRow(32769).getCell(1).getNumericCellValue(), 0.0);
-        assertEquals("Wrong formula string for reference", "A32770",
-                sheet.getRow(32769).getCell(1).getCellFormula());
+        assertEquals(32767.0, sheet.getRow(32766).getCell(0).getNumericCellValue(), 0.0, "Wrong numeric value for original number");
+        assertEquals(32767.0, sheet.getRow(32766).getCell(1).getNumericCellValue(), 0.0, "Wrong numeric value for referemce");
+        assertEquals("A32767", sheet.getRow(32766).getCell(1).getCellFormula(), "Wrong formula string for reference");
+
+        assertEquals(32768.0, sheet.getRow(32767).getCell(0).getNumericCellValue(), 0.0, "Wrong numeric value for original number");
+        assertEquals(32768.0, sheet.getRow(32767).getCell(1).getNumericCellValue(), 0.0, "Wrong numeric value for referemce");
+        assertEquals("A32768", sheet.getRow(32767).getCell(1).getCellFormula(), "Wrong formula string for reference");
+
+        assertEquals(32769.0, sheet.getRow(32768).getCell(0).getNumericCellValue(), 0.0, "Wrong numeric value for original number");
+        assertEquals(32769.0, sheet.getRow(32768).getCell(1).getNumericCellValue(), 0.0, "Wrong numeric value for referemce");
+        assertEquals("A32769", sheet.getRow(32768).getCell(1).getCellFormula(), "Wrong formula string for reference");
+
+        assertEquals(32770.0, sheet.getRow(32769).getCell(0).getNumericCellValue(), 0.0, "Wrong numeric value for original number");
+        assertEquals(32770.0, sheet.getRow(32769).getCell(1).getNumericCellValue(), 0.0, "Wrong numeric value for referemce");
+        assertEquals("A32770", sheet.getRow(32769).getCell(1).getCellFormula(), "Wrong formula string for reference");
     }
 
     @Test
@@ -98,7 +85,7 @@ public final class TestReferencePtg {
         Ptg[] ptgs = Ptg.readTokens(tRefN_data.length, in);
         byte[] outData = new byte[5];
         Ptg.serializePtgs(ptgs, outData, 0);
-        assertNotEquals("Identified bug 45091", 0x24, outData[0]);
+        assertNotEquals(0x24, outData[0], "Identified bug 45091");
         assertArrayEquals(tRefN_data, outData);
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.ss.formula.ptg;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link UnionPtg}.
@@ -36,8 +36,8 @@ public final class TestUnionPtg extends
     public void testReading() throws IOException {
         try (HSSFWorkbook workbook = loadWorkbook("UnionPtg.xls")) {
             HSSFCell cell = workbook.getSheetAt(0).getRow(4).getCell(2);
-            assertEquals("Wrong cell value", 24.0, cell.getNumericCellValue(), 0.0);
-            assertEquals("Wrong cell formula", "SUM(A1:B2,B2:C3)", cell.getCellFormula());
+            assertEquals(24.0, cell.getNumericCellValue(), 0.0, "Wrong cell value");
+            assertEquals("SUM(A1:B2,B2:C3)", cell.getCellFormula(), "Wrong cell formula");
         }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/BaseTestUDFFinder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/BaseTestUDFFinder.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/BaseTestUDFFinder.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/BaseTestUDFFinder.java Thu Dec 24 18:42:29 2020
@@ -16,11 +16,11 @@
 ==================================================================== */
 package org.apache.poi.ss.formula.udf;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.apache.poi.ss.formula.functions.FreeRefFunction;
-import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.OperationEvaluationContext;
+import org.apache.poi.ss.formula.eval.ValueEval;
+import org.apache.poi.ss.formula.functions.FreeRefFunction;
 
 public class BaseTestUDFFinder {
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java Thu Dec 24 18:42:29 2020
@@ -17,7 +17,7 @@
 package org.apache.poi.ss.formula.udf;
 
 import org.apache.poi.ss.formula.atp.AnalysisToolPak;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestAggregatingUDFFinder extends BaseTestUDFFinder {
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java Thu Dec 24 18:42:29 2020
@@ -17,7 +17,7 @@
 package org.apache.poi.ss.formula.udf;
 
 import org.apache.poi.ss.formula.functions.FreeRefFunction;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestDefaultUDFFinder extends BaseTestUDFFinder {
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java Thu Dec 24 18:42:29 2020
@@ -16,23 +16,23 @@
 
    2012 - Alfresco Software, Ltd.
    Alfresco Software has modified source of this file
-   The details of changes as svn diff can be found in svn at location root/projects/3rd-party/src 
+   The details of changes as svn diff can be found in svn at location root/projects/3rd-party/src
 ==================================================================== */
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.ss.ITestDataProvider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests of {@link BorderStyle}
  */
 public abstract class BaseTestBorderStyle {
-    
+
     private final ITestDataProvider _testDataProvider;
 
     protected BaseTestBorderStyle(ITestDataProvider testDataProvider) {
@@ -48,7 +48,7 @@ public abstract class BaseTestBorderStyl
         String ext = _testDataProvider.getStandardFileNameExtension();
         Workbook wb = _testDataProvider.openSampleWorkbook("59264."+ext);
         Sheet sh = wb.getSheetAt(0);
-        
+
         assertBorderStyleEquals(BorderStyle.NONE, getDiagonalCell(sh, 0));
         assertBorderStyleEquals(BorderStyle.THIN, getDiagonalCell(sh, 1));
         assertBorderStyleEquals(BorderStyle.MEDIUM, getDiagonalCell(sh, 2));
@@ -63,14 +63,14 @@ public abstract class BaseTestBorderStyl
         assertBorderStyleEquals(BorderStyle.DASH_DOT_DOT, getDiagonalCell(sh, 11));
         assertBorderStyleEquals(BorderStyle.MEDIUM_DASH_DOT_DOT, getDiagonalCell(sh, 12));
         assertBorderStyleEquals(BorderStyle.SLANTED_DASH_DOT, getDiagonalCell(sh, 13));
-        
+
         wb.close();
     }
-    
+
     private Cell getDiagonalCell(Sheet sheet, int n) {
         return sheet.getRow(n).getCell(n);
     }
-    
+
     protected void assertBorderStyleEquals(BorderStyle expected, Cell cell) {
         CellStyle style = cell.getCellStyle();
         assertEquals(expected, style.getBorderTop());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Thu Dec 24 18:42:29 2020
@@ -17,12 +17,13 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+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.Assumptions.assumeTrue;
 
 import java.awt.font.FontRenderContext;
 import java.awt.font.TextAttribute;
@@ -44,9 +45,8 @@ import org.apache.poi.ss.util.PaneInform
 import org.apache.poi.ss.util.SheetUtil;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
-import org.junit.Assume;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * A base class for bugzilla issues that can be described in terms of common ss interfaces.
@@ -74,9 +74,7 @@ public abstract class BaseTestBugzillaIs
     private static void assertAlmostEquals(double expected, double actual, float factor) {
         double diff = Math.abs(expected - actual);
         double fuzz = expected * factor;
-        if (diff > fuzz) {
-            fail(actual + " not within " + fuzz + " of " + expected);
-        }
+        assertTrue(diff <= fuzz, actual + " not within " + fuzz + " of " + expected);
     }
 
     /**
@@ -160,14 +158,14 @@ public abstract class BaseTestBugzillaIs
 
             Sheet clone = wb.cloneSheet(0);
             int originalMerged = template.getNumMergedRegions();
-            assertEquals("2 merged regions", 2, originalMerged);
+            assertEquals(2, originalMerged, "2 merged regions");
 
             //remove merged regions from clone
             for (int i = template.getNumMergedRegions() - 1; i >= 0; i--) {
                 clone.removeMergedRegion(i);
             }
 
-            assertEquals("Original Sheet's Merged Regions were removed", originalMerged, template.getNumMergedRegions());
+            assertEquals(originalMerged, template.getNumMergedRegions(), "Original Sheet's Merged Regions were removed");
             //check if template's merged regions are OK
             if (template.getNumMergedRegions() > 0) {
                 // fetch the first merged region...EXCEPTION OCCURS HERE
@@ -352,13 +350,11 @@ public abstract class BaseTestBugzillaIs
                 fmla = createFunction(name, ssVersion.getMaxFunctionArgs());
                 cell.setCellFormula(fmla);
 
-                try {
-                    fmla = createFunction(name, ssVersion.getMaxFunctionArgs() + 1);
-                    cell.setCellFormula(fmla);
-                    fail("Expected FormulaParseException");
-                } catch (FormulaParseException e) {
-                    assertTrue(e.getMessage().startsWith("Too many arguments to function '" + name + "'"));
-                }
+                FormulaParseException e = assertThrows(FormulaParseException.class, () -> {
+                    String fmla2 = createFunction(name, ssVersion.getMaxFunctionArgs() + 1);
+                    cell.setCellFormula(fmla2);
+                });
+                assertTrue(e.getMessage().startsWith("Too many arguments to function '" + name + "'"));
             }
         }
     }
@@ -396,13 +392,11 @@ public abstract class BaseTestBugzillaIs
 
             // autoSize will fail if required fonts are not installed, skip this test then
             Font font = wb.getFontAt(cell0.getCellStyle().getFontIndex());
-            Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
-                              SheetUtil.canComputeColumnWidth(font));
+            assumeTrue(SheetUtil.canComputeColumnWidth(font),
+               "Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font);
 
-            assertEquals("Expecting no indentation in this test",
-                         0, cell0.getCellStyle().getIndention());
-            assertEquals("Expecting no rotation in this test",
-                         0, cell0.getCellStyle().getRotation());
+            assertEquals(0, cell0.getCellStyle().getIndention(), "Expecting no indentation in this test");
+            assertEquals(0, cell0.getCellStyle().getRotation(), "Expecting no rotation in this test");
 
             // check computing size up to a large size
 //        StringBuilder b = new StringBuilder();
@@ -417,16 +411,16 @@ public abstract class BaseTestBugzillaIs
             String info = widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
                     SheetUtil.canComputeColumnWidth(font) + "/" + computeCellWidthFixed(font, "1") + "/" + computeCellWidthFixed(font, "w") + "/" +
                     computeCellWidthFixed(font, "1w") + "/" + computeCellWidthFixed(font, "0000") + "/" + computeCellWidthFixed(font, longValue);
-            assertTrue("Expected to have cell width > 0 when computing manually, but had " + info, widthManual > 0);
-            assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + info, widthBeforeCell > 0);
-            assertTrue("Expected to have column width > 0 BEFORE auto-size, but had " + info, widthBeforeCol > 0);
+            assertTrue(widthManual > 0, "Expected to have cell width > 0 when computing manually, but had " + info);
+            assertTrue(widthBeforeCell > 0, "Expected to have cell width > 0 BEFORE auto-size, but had " + info);
+            assertTrue(widthBeforeCol > 0, "Expected to have column width > 0 BEFORE auto-size, but had " + info);
 
             sheet.autoSizeColumn(0);
 
             double width = SheetUtil.getColumnWidth(sheet, 0, false);
-            assertTrue("Expected to have column width > 0 AFTER auto-size, but had " + width, width > 0);
+            assertTrue(width > 0, "Expected to have column width > 0 AFTER auto-size, but had " + width);
             width = SheetUtil.getCellWidth(cell0, 8, null, false);
-            assertTrue("Expected to have cell width > 0 AFTER auto-size, but had " + width, width > 0);
+            assertTrue(width > 0, "Expected to have cell width > 0 AFTER auto-size, but had " + width);
 
             assertEquals(255 * 256, sheet.getColumnWidth(0)); // maximum column width is 255 characters
             sheet.setColumnWidth(0, sheet.getColumnWidth(0)); // Bug 50681 reports exception at this point
@@ -466,11 +460,11 @@ public abstract class BaseTestBugzillaIs
             double trailingWhitespaceRatio = ((double) leadingWhitespaceColWidth) / noWhitespaceColWidth;
 
             assertGreaterThan("leading whitespace is longer than no whitespace",
-                              leadingWhitespaceRatio, expectedRatioThreshold);
+                leadingWhitespaceRatio, expectedRatioThreshold);
             assertGreaterThan("trailing whitespace is longer than no whitespace",
-                              trailingWhitespaceRatio, expectedRatioThreshold);
-            assertEquals("cells with equal leading and trailing whitespace have equal width",
-                         leadingWhitespaceColWidth, trailingWhitespaceColWidth);
+                trailingWhitespaceRatio, expectedRatioThreshold);
+            assertEquals(leadingWhitespaceColWidth, trailingWhitespaceColWidth,
+                "cells with equal leading and trailing whitespace have equal width");
 
         }
     }
@@ -479,10 +473,7 @@ public abstract class BaseTestBugzillaIs
      * Test if a > b. Fails if false.
      */
     private void assertGreaterThan(String message, double a, double b) {
-        if (a <= b) {
-            String msg = "Expected: " + a + " > " + b;
-            fail(message + ": " + msg);
-        }
+        assertTrue(a > b, message + ": " + "Expected: " + a + " > " + b);
     }
 
     // FIXME: this function is a self-fulfilling prophecy: this test will always pass as long
@@ -503,7 +494,7 @@ public abstract class BaseTestBugzillaIs
 
         TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
         double frameWidth = getFrameWidth(layout);
-        return ((frameWidth / 1) / 8);
+        return (frameWidth / 8);
     }
 
     private double getFrameWidth(TextLayout layout) {
@@ -878,82 +869,67 @@ public abstract class BaseTestBugzillaIs
      * TODO Fix this to evaluate for XSSF
      * TODO Fix this to work at all for HSSF
      */
-    @Ignore("Fix this to evaluate for XSSF, Fix this to work at all for HSSF")
+    @Disabled("Fix this to evaluate for XSSF, Fix this to work at all for HSSF")
     @Test
     public void bug46670() throws IOException {
-        Workbook wb1 = _testDataProvider.createWorkbook();
-        Sheet s = wb1.createSheet();
-        Row r1 = s.createRow(0);
-
-
-        // References to try
-        String ext = _testDataProvider.getStandardFileNameExtension();
-        String refLocal = "'[test."+ext+"]Sheet1'!$A$2";
-        String refHttp  = "'[http://example.com/test."+ext+"]Sheet1'!$A$2";
-        String otherCellText = "In Another Workbook";
+        try (Workbook wb1 = _testDataProvider.createWorkbook()) {
+            Sheet s = wb1.createSheet();
+            Row r1 = s.createRow(0);
 
 
-        // Create the references
-        Cell c1 = r1.createCell(0, CellType.FORMULA);
-        c1.setCellFormula(refLocal);
+            // References to try
+            String ext = _testDataProvider.getStandardFileNameExtension();
+            String refLocal = "'[test." + ext + "]Sheet1'!$A$2";
+            String refHttp = "'[http://example.com/test." + ext + "]Sheet1'!$A$2";
+            String otherCellText = "In Another Workbook";
 
-        Cell c2 = r1.createCell(1, CellType.FORMULA);
-        c2.setCellFormula(refHttp);
 
+            // Create the references
+            r1.createCell(0, CellType.FORMULA).setCellFormula(refLocal);
+            r1.createCell(1, CellType.FORMULA).setCellFormula(refHttp);
 
-        // Check they were set correctly
-        assertEquals(refLocal, c1.getCellFormula());
-        assertEquals(refHttp,  c2.getCellFormula());
 
+            // Check they were set correctly
+            assertEquals(refLocal, r1.getCell(0).getCellFormula());
+            assertEquals(refHttp, r1.getCell(1).getCellFormula());
 
-        // Reload, and ensure they were serialised and read correctly
-        Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
-        wb1.close();
-        s = wb2.getSheetAt(0);
-        r1 = s.getRow(0);
 
-        c1 = r1.getCell(0);
-        c2 = r1.getCell(1);
-        assertEquals(refLocal, c1.getCellFormula());
-        assertEquals(refHttp,  c2.getCellFormula());
+            // Reload, and ensure they were serialised and read correctly
+            try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1)) {
+                s = wb2.getSheetAt(0);
+                r1 = s.getRow(0);
 
+                final Cell c1 = r1.getCell(0);
+                final Cell c2 = r1.getCell(1);
+                assertEquals(refLocal, c1.getCellFormula());
+                assertEquals(refHttp, c2.getCellFormula());
+
+                // Try to evaluate, without giving a way to get at the other file
+                assertThrows(Exception.class, () -> evaluateCell(wb2, c1),
+                    "Shouldn't be able to evaluate without the other file");
+                assertThrows(Exception.class, () -> evaluateCell(wb2, c2),
+                    "Shouldn't be able to evaluate without the other file");
+
+                // Set up references to the other file
+                try (Workbook wb3 = _testDataProvider.createWorkbook()) {
+                    wb3.createSheet().createRow(1).createCell(0).setCellValue(otherCellText);
+
+                    Map<String, FormulaEvaluator> evaluators = new HashMap<>();
+                    evaluators.put(refLocal, wb3.getCreationHelper().createFormulaEvaluator());
+                    evaluators.put(refHttp, wb3.getCreationHelper().createFormulaEvaluator());
+
+                    FormulaEvaluator evaluator = wb2.getCreationHelper().createFormulaEvaluator();
+                    evaluator.setupReferencedWorkbooks(evaluators);
+
+                    // Try to evaluate, with the other file
+                    evaluator.evaluateFormulaCell(c1);
+                    evaluator.evaluateFormulaCell(c2);
 
-        // Try to evaluate, without giving a way to get at the other file
-        try {
-            evaluateCell(wb2, c1);
-            fail("Shouldn't be able to evaluate without the other file");
-        } catch (Exception e) {
-            // expected here
-        }
-        try {
-            evaluateCell(wb2, c2);
-            fail("Shouldn't be able to evaluate without the other file");
-        } catch (Exception e) {
-            // expected here
+                    assertEquals(otherCellText, c1.getStringCellValue());
+                    assertEquals(otherCellText, c2.getStringCellValue());
+                }
+            }
         }
-
-
-        // Set up references to the other file
-        Workbook wb3 = _testDataProvider.createWorkbook();
-        wb3.createSheet().createRow(1).createCell(0).setCellValue(otherCellText);
-
-        Map<String,FormulaEvaluator> evaluators = new HashMap<>();
-        evaluators.put(refLocal, wb3.getCreationHelper().createFormulaEvaluator());
-        evaluators.put(refHttp,  wb3.getCreationHelper().createFormulaEvaluator());
-
-        FormulaEvaluator evaluator = wb2.getCreationHelper().createFormulaEvaluator();
-        evaluator.setupReferencedWorkbooks(evaluators);
-
-
-        // Try to evaluate, with the other file
-        evaluator.evaluateFormulaCell(c1);
-        evaluator.evaluateFormulaCell(c2);
-
-        assertEquals(otherCellText, c1.getStringCellValue());
-        assertEquals(otherCellText, c2.getStringCellValue());
-
-        wb3.close();
-        wb2.close();
     }
 
     @Test
@@ -1159,36 +1135,16 @@ public abstract class BaseTestBugzillaIs
 
             // Different ways of retrieving
             assertEquals(1.2, cn.getNumericCellValue(), 0);
-            try {
-                cn.getRichStringCellValue();
-                fail();
-            } catch (IllegalStateException e) {
-                // expected here
-            }
+            assertThrows(IllegalStateException.class, cn::getRichStringCellValue);
 
             assertEquals("Testing", cs.getStringCellValue());
-            try {
-                cs.getNumericCellValue();
-                fail();
-            } catch (IllegalStateException e) {
-                // expected here
-            }
+            assertThrows(IllegalStateException.class, cs::getNumericCellValue);
 
             assertEquals(1.2, cfn.getNumericCellValue(), 0);
-            try {
-                cfn.getRichStringCellValue();
-                fail();
-            } catch (IllegalStateException e) {
-                // expected here
-            }
+            assertThrows(IllegalStateException.class, cfn::getRichStringCellValue);
 
             assertEquals("Testing", cfs.getStringCellValue());
-            try {
-                cfs.getNumericCellValue();
-                fail();
-            } catch (IllegalStateException e) {
-                // expected here
-            }
+            assertThrows(IllegalStateException.class, cfs::getNumericCellValue);
         }
     }
 
@@ -1203,8 +1159,8 @@ public abstract class BaseTestBugzillaIs
             // verify that null-values can be set, this was possible up to 3.11, but broken in 3.12
             cell.setCellValue((String) null);
             String value = cell.getStringCellValue();
-            assertTrue("HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value,
-                       value == null || value.length() == 0);
+            assertTrue(value == null || value.length() == 0,
+                "HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
 
             cell = row.createCell(1);
             cell.setCellFormula("0");
@@ -1213,20 +1169,20 @@ public abstract class BaseTestBugzillaIs
             wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
 
             value = cell.getStringCellValue();
-            assertTrue("HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value,
-                       value == null || value.length() == 0);
+            assertTrue(value == null || value.length() == 0,
+                "HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
 
             // set some value
             cell.setCellValue("somevalue");
 
             value = cell.getStringCellValue();
-            assertEquals("can set value afterwards: " + value, "somevalue", value);
+            assertEquals("somevalue", value, "can set value afterwards: " + value);
 
             // verify that the null-value is actually set even if there was some value in the cell before
             cell.setCellValue((String) null);
             value = cell.getStringCellValue();
-            assertTrue("HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value,
-                       value == null || value.length() == 0);
+            assertTrue(value == null || value.length() == 0,
+                "HSSF will currently return empty string, XSSF/SXSSF will return null, but had: " + value);
         }
     }
 
@@ -1312,12 +1268,7 @@ public abstract class BaseTestBugzillaIs
                 //Row row = worksheet.createRow(i);
 
                 //Create cell style
-                CellStyle style = null;
-                try {
-                    style = wb.createCellStyle();
-                } catch (IllegalStateException e) {
-                    fail("Failed for row " + i);
-                }
+                CellStyle style = wb.createCellStyle();
                 style.setAlignment(HorizontalAlignment.RIGHT);
                 if ((wb instanceof HSSFWorkbook)) {
                     // there are some predefined styles
@@ -1340,12 +1291,8 @@ public abstract class BaseTestBugzillaIs
             }
 
             // should fail if we try to add more now
-            try {
-                wb.createCellStyle();
-                fail("Should fail after " + maxStyles + " styles, but did not fail");
-            } catch (IllegalStateException e) {
-                // expected here
-            }
+            assertThrows(IllegalStateException.class, wb::createCellStyle,
+                "Should fail after " + maxStyles + " styles, but did not fail");
 
             /*//add column width for appearance sake
             worksheet.setColumnWidth(0, 5000);
@@ -1499,7 +1446,7 @@ public abstract class BaseTestBugzillaIs
         return time() - startTimeMillis;
     }
 
-    @Ignore("bug 59393")
+    @Disabled("bug 59393")
     @Test
     public void bug59393_commentsCanHaveSameAnchor() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
@@ -1580,7 +1527,7 @@ public abstract class BaseTestBugzillaIs
         }
     }
 
-    @Ignore
+    @Disabled
     @Test
     public void test57929() throws IOException {
         // Create a workbook with print areas on 2 sheets
@@ -1599,13 +1546,14 @@ public abstract class BaseTestBugzillaIs
             wb.setPrintArea(1, "$A$1:$A$1");
 
             // Verify that the changes were made
-            assertNull("Sheet0 before write", wb.getPrintArea(0));
-            assertEquals("Sheet1 before write", "Sheet1!$A$1:$A$1", wb.getPrintArea(1));
+            assertNull(wb.getPrintArea(0), "Sheet0 before write");
+            assertEquals(wb.getPrintArea(1), "Sheet1 before write", "Sheet1!$A$1:$A$1");
 
             // Verify that the changes are non-volatile
             try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb)) {
-                assertNull("Sheet0 after write", wb2.getPrintArea(0)); // CURRENTLY FAILS with "Sheet0!$A$1:$C$6"
-                assertEquals("Sheet1 after write", "Sheet1!$A$1:$A$1", wb2.getPrintArea(1));
+                // CURRENTLY FAILS with "Sheet0!$A$1:$C$6"
+                assertNull(wb2.getPrintArea(0), "Sheet0 after write");
+                assertEquals(wb2.getPrintArea(1), "Sheet1 after write", "Sheet1!$A$1:$A$1");
             }
         }
     }
@@ -1657,18 +1605,13 @@ public abstract class BaseTestBugzillaIs
         assertEquals(10, row.getRowNum());
 
         for (Cell cell : row) {
-            String cellValue;
-            switch (cell.getCellType()) {
-                case STRING:
-                    cellValue = cell.getRichStringCellValue().getString();
-                    break;
-                case FORMULA:
-                    cellValue = cell.getCellFormula();
-                    break;
-                default:
-                    fail("unexpected cell type");
-                    return;
-            }
+            CellType ctype = cell.getCellType();
+            assertTrue(ctype == CellType.STRING || ctype == CellType.FORMULA, "unexpected cell type");
+
+            String cellValue = (ctype == CellType.STRING)
+                ? cell.getRichStringCellValue().getString()
+                : cell.getCellFormula();
+
             assertNotNull(cellValue);
             cellValue = cellValue.isEmpty() ? null : cellValue;
             assertNotNull(cellValue);
@@ -1729,11 +1672,11 @@ public abstract class BaseTestBugzillaIs
 
                 // The name should still refer to the same sheet after the sheets are re-ordered
                 assertEquals(i % 3, wb.getSheetIndex("Sheet3"));
-                assertEquals(nameOnSheet1.getNameName(), "Sheet1", nameOnSheet1.getSheetName());
-                assertEquals(nameOnSheet2.getNameName(), "Sheet2", nameOnSheet2.getSheetName());
-                assertEquals(nameOnSheet3.getNameName(), "Sheet3", nameOnSheet3.getSheetName());
-                assertEquals(name.getNameName(), -1, name.getSheetIndex());
-                assertEquals(name.getNameName(), "Sheet2!A1", name.getRefersToFormula());
+                assertEquals("Sheet1", nameOnSheet1.getSheetName());
+                assertEquals("Sheet2", nameOnSheet2.getSheetName());
+                assertEquals("Sheet3", nameOnSheet3.getSheetName());
+                assertEquals(-1, name.getSheetIndex());
+                assertEquals("Sheet2!A1", name.getRefersToFormula());
 
                 // make sure the changes to the names stick after writing out the workbook
                 try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb)) {
@@ -1747,11 +1690,11 @@ public abstract class BaseTestBugzillaIs
 
                     // Saving the workbook should not change the sheet names
                     assertEquals(i % 3, wb2.getSheetIndex("Sheet3"));
-                    assertEquals(nameOnSheet1.getNameName(), "Sheet1", nameOnSheet1.getSheetName());
-                    assertEquals(nameOnSheet2.getNameName(), "Sheet2", nameOnSheet2.getSheetName());
-                    assertEquals(nameOnSheet3.getNameName(), "Sheet3", nameOnSheet3.getSheetName());
-                    assertEquals(name.getNameName(), -1, name.getSheetIndex());
-                    assertEquals(name.getNameName(), "Sheet2!A1", name.getRefersToFormula());
+                    assertEquals("Sheet1", nameOnSheet1.getSheetName());
+                    assertEquals("Sheet2", nameOnSheet2.getSheetName());
+                    assertEquals("Sheet3", nameOnSheet3.getSheetName());
+                    assertEquals(-1, name.getSheetIndex());
+                    assertEquals("Sheet2!A1", name.getRefersToFormula());
 
                     // Verify names in wb2
                     nameOnSheet1 = wb2.getName("NameOnSheet1");
@@ -1760,11 +1703,11 @@ public abstract class BaseTestBugzillaIs
                     name = wb2.getName("WorkbookScopedName");
 
                     assertEquals(i % 3, wb2.getSheetIndex("Sheet3"));
-                    assertEquals(nameOnSheet1.getNameName(), "Sheet1", nameOnSheet1.getSheetName());
-                    assertEquals(nameOnSheet2.getNameName(), "Sheet2", nameOnSheet2.getSheetName());
-                    assertEquals(nameOnSheet3.getNameName(), "Sheet3", nameOnSheet3.getSheetName());
-                    assertEquals(name.getNameName(), -1, name.getSheetIndex());
-                    assertEquals(name.getNameName(), "Sheet2!A1", name.getRefersToFormula());
+                    assertEquals("Sheet1", nameOnSheet1.getSheetName());
+                    assertEquals("Sheet2", nameOnSheet2.getSheetName());
+                    assertEquals("Sheet3", nameOnSheet3.getSheetName());
+                    assertEquals(-1, name.getSheetIndex());
+                    assertEquals("Sheet2!A1", name.getRefersToFormula());
                 }
             }
         }
@@ -1783,20 +1726,24 @@ public abstract class BaseTestBugzillaIs
 
             // HSSF has 32/255 limits as part of the Spec, XSSF has no limit in the spec, but Excel applies a 255 length limit!
             // more than 255 fail for all
-            checkFailures(dataValidation, TEST_256, TEST_32, true);
-            checkFailures(dataValidation, TEST_32, TEST_256, true);
+            checkFails(dataValidation, TEST_256, TEST_32);
+            checkFails(dataValidation, TEST_32, TEST_256);
 
             // null does work
-            checkFailures(dataValidation, null, null, false);
+            checkPasses(dataValidation, null, null);
 
             // more than 32 title fail for HSSFWorkbook
-            checkFailures(dataValidation, TEST_255, TEST_32, wb instanceof HSSFWorkbook);
+            if (wb instanceof HSSFWorkbook) {
+                checkFails(dataValidation, TEST_255, TEST_32);
+            } else {
+                checkPasses(dataValidation, TEST_255, TEST_32);
+            }
 
             // special characters work
-            checkFailures(dataValidation, TEST_SPECIAL_TITLE, TEST_SPECIAL, false);
+            checkPasses(dataValidation, TEST_SPECIAL_TITLE, TEST_SPECIAL);
 
             // 32 length title and 255 length text work for both
-            checkFailures(dataValidation, TEST_32, TEST_255, false);
+            checkPasses(dataValidation, TEST_32, TEST_255);
 
             dataValidation.setShowErrorBox(false);
             sheet.addValidationData(dataValidation);
@@ -1810,20 +1757,14 @@ public abstract class BaseTestBugzillaIs
         }
     }
 
-    private void checkFailures(DataValidation dataValidation, String title, String text, boolean shouldFail) {
-        try {
-            dataValidation.createPromptBox(title, text);
-            assertFalse("Should fail in a length-check, had " + (title == null ? null : title.length()) + " and " + (text == null ? null : text.length()), shouldFail);
-        } catch (IllegalStateException e) {
-            assertTrue("Should not fail in a length-check, had " + (title == null ? null : title.length()) + " and " + (text == null ? null : text.length()), shouldFail);
-            // expected here
-        }
-        try {
-            dataValidation.createErrorBox(title, text);
-            assertFalse("Should fail in a length-check, had " + (title == null ? null : title.length()) + " and " + (text == null ? null : text.length()), shouldFail);
-        } catch (IllegalStateException e) {
-            assertTrue("Should not fail in a length-check, had " + (title == null ? null : title.length()) + " and " + (text == null ? null : text.length()), shouldFail);
-        }
+    private void checkFails(DataValidation dataValidation, String title, String text) {
+        assertThrows(IllegalStateException.class, () -> dataValidation.createPromptBox(title, text));
+        assertThrows(IllegalStateException.class, () -> dataValidation.createErrorBox(title, text));
+    }
+
+    private void checkPasses(DataValidation dataValidation, String title, String text) {
+        dataValidation.createPromptBox(title, text);
+        dataValidation.createErrorBox(title, text);
     }
 
     @Test
@@ -1836,7 +1777,7 @@ public abstract class BaseTestBugzillaIs
             DataValidationConstraint constraint = sheet.getDataValidationHelper().createCustomConstraint("A1<>\"\"");
 
             dataValidation = sheet.getDataValidationHelper().createValidation(constraint, headerCell);
-            checkFailures(dataValidation, TEST_SPECIAL_TITLE, TEST_SPECIAL, false);
+            checkPasses(dataValidation, TEST_SPECIAL_TITLE, TEST_SPECIAL);
 
             dataValidation.setShowErrorBox(true);
             dataValidation.setShowPromptBox(true);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Thu Dec 24 18:42:29 2020
@@ -18,12 +18,13 @@
 package org.apache.poi.ss.usermodel;
 
 import static org.apache.poi.ss.usermodel.FormulaError.forInt;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+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.mockito.Mockito.doCallRealMethod;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -42,9 +43,10 @@ import org.apache.poi.common.usermodel.H
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.formula.eval.NotImplementedException;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Common superclass for testing implementations of
@@ -198,32 +200,32 @@ public abstract class BaseTestCell {
             assertEquals(0, c.getRowIndex());
             assertEquals(1, c.getColumnIndex());
             c.setCellValue(true);
-            assertTrue("B1 value", c.getBooleanCellValue());
+            assertTrue(c.getBooleanCellValue(), "B1 value");
 
             // C1
             c = r.createCell(2);
             assertEquals(0, c.getRowIndex());
             assertEquals(2, c.getColumnIndex());
             c.setCellValue(false);
-            assertFalse("C1 value", c.getBooleanCellValue());
+            assertFalse(c.getBooleanCellValue(), "C1 value");
 
             // Make sure values are saved and re-read correctly.
             try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1)) {
                 s = wb2.getSheet("testSheet1");
                 r = s.getRow(0);
-                assertEquals("Row 1 should have 2 cells", 2, r.getPhysicalNumberOfCells());
+                assertEquals(2, r.getPhysicalNumberOfCells(), "Row 1 should have 2 cells");
 
                 c = r.getCell(1);
                 assertEquals(0, c.getRowIndex());
                 assertEquals(1, c.getColumnIndex());
                 assertEquals(CellType.BOOLEAN, c.getCellType());
-                assertTrue("B1 value", c.getBooleanCellValue());
+                assertTrue(c.getBooleanCellValue(), "B1 value");
 
                 c = r.getCell(2);
                 assertEquals(0, c.getRowIndex());
                 assertEquals(2, c.getColumnIndex());
                 assertEquals(CellType.BOOLEAN, c.getCellType());
-                assertFalse("C1 value", c.getBooleanCellValue());
+                assertFalse(c.getBooleanCellValue(), "C1 value");
             }
         }
     }
@@ -246,32 +248,32 @@ public abstract class BaseTestCell {
             assertEquals(0, c.getRowIndex());
             assertEquals(1, c.getColumnIndex());
             c.setCellErrorValue(FormulaError.NULL.getCode());
-            assertEquals("B1 value == #NULL!", FormulaError.NULL.getCode(), c.getErrorCellValue());
+            assertEquals(FormulaError.NULL.getCode(), c.getErrorCellValue(), "B1 value == #NULL!");
 
             // C1
             c = r.createCell(2);
             assertEquals(0, c.getRowIndex());
             assertEquals(2, c.getColumnIndex());
             c.setCellErrorValue(FormulaError.DIV0.getCode());
-            assertEquals("C1 value == #DIV/0!", FormulaError.DIV0.getCode(), c.getErrorCellValue());
+            assertEquals(FormulaError.DIV0.getCode(), c.getErrorCellValue(), "C1 value == #DIV/0!");
 
             try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1)) {
                 s = wb2.getSheet("testSheet1");
 
                 r = s.getRow(0);
-                assertEquals("Row 1 should have 2 cells", 2, r.getPhysicalNumberOfCells());
+                assertEquals(2, r.getPhysicalNumberOfCells(), "Row 1 should have 2 cells");
 
                 c = r.getCell(1);
                 assertEquals(0, c.getRowIndex());
                 assertEquals(1, c.getColumnIndex());
                 assertEquals(CellType.ERROR, c.getCellType());
-                assertEquals("B1 value == #NULL!", FormulaError.NULL.getCode(), c.getErrorCellValue());
+                assertEquals(FormulaError.NULL.getCode(), c.getErrorCellValue(), "B1 value == #NULL!");
 
                 c = r.getCell(2);
                 assertEquals(0, c.getRowIndex());
                 assertEquals(2, c.getColumnIndex());
                 assertEquals(CellType.ERROR, c.getCellType());
-                assertEquals("C1 value == #DIV/0!", FormulaError.DIV0.getCode(), c.getErrorCellValue());
+                assertEquals(FormulaError.DIV0.getCode(), c.getErrorCellValue(), "C1 value == #DIV/0!");
             }
         }
     }
@@ -308,15 +310,15 @@ public abstract class BaseTestCell {
                 r = s.getRow(0);
                 c = r.getCell(0);
 
-                assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellType());
+                assertEquals(CellType.FORMULA, c.getCellType(), "Formula Cell at 0,0");
                 cs = c.getCellStyle();
 
-                assertNotNull("Formula Cell Style", cs);
-                assertEquals("Font Index Matches", f.getIndex(), cs.getFontIndex());
-                assertEquals("Top Border", BorderStyle.THIN, cs.getBorderTop());
-                assertEquals("Left Border", BorderStyle.THIN, cs.getBorderLeft());
-                assertEquals("Right Border", BorderStyle.THIN, cs.getBorderRight());
-                assertEquals("Bottom Border", BorderStyle.THIN, cs.getBorderBottom());
+                assertNotNull(cs, "Formula Cell Style");
+                assertEquals(f.getIndex(), cs.getFontIndex(), "Font Index Matches");
+                assertEquals(BorderStyle.THIN, cs.getBorderTop(), "Top Border");
+                assertEquals(BorderStyle.THIN, cs.getBorderLeft(), "Left Border");
+                assertEquals(BorderStyle.THIN, cs.getBorderRight(), "Right Border");
+                assertEquals(BorderStyle.THIN, cs.getBorderBottom(), "Bottom Border");
             }
         }
     }
@@ -345,31 +347,31 @@ public abstract class BaseTestCell {
             dateStyle.setDataFormat(formatId);
             r.getCell(7).setCellStyle(dateStyle);
 
-            assertEquals("Boolean", "FALSE", r.getCell(0).toString());
-            assertEquals("Boolean", "TRUE", r.getCell(1).toString());
-            assertEquals("Numeric", "1.5", r.getCell(2).toString());
-            assertEquals("String", "Astring", r.getCell(3).toString());
-            assertEquals("Error", "#DIV/0!", r.getCell(4).toString());
-            assertEquals("Formula", "A1+B1", r.getCell(5).toString());
-            assertEquals("Blank", "", r.getCell(6).toString());
+            assertEquals("FALSE", r.getCell(0).toString(), "Boolean");
+            assertEquals("TRUE", r.getCell(1).toString(), "Boolean");
+            assertEquals("1.5", r.getCell(2).toString(), "Numeric");
+            assertEquals("Astring", r.getCell(3).toString(), "String");
+            assertEquals("#DIV/0!", r.getCell(4).toString(), "Error");
+            assertEquals("A1+B1", r.getCell(5).toString(), "Formula");
+            assertEquals("", r.getCell(6).toString(), "Blank");
             // toString on a date-formatted cell displays dates as dd-MMM-yyyy, which has locale problems with the month
             String dateCell1 = r.getCell(7).toString();
-            assertTrue("Date (Day)", dateCell1.startsWith("02-"));
-            assertTrue("Date (Year)", dateCell1.endsWith("-2010"));
+            assertTrue(dateCell1.startsWith("02-"), "Date (Day)");
+            assertTrue(dateCell1.endsWith("-2010"), "Date (Year)");
 
 
             //Write out the file, read it in, and then check cell values
             try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1)) {
                 r = wb2.getSheetAt(0).getRow(0);
-                assertEquals("Boolean", "FALSE", r.getCell(0).toString());
-                assertEquals("Boolean", "TRUE", r.getCell(1).toString());
-                assertEquals("Numeric", "1.5", r.getCell(2).toString());
-                assertEquals("String", "Astring", r.getCell(3).toString());
-                assertEquals("Error", "#DIV/0!", r.getCell(4).toString());
-                assertEquals("Formula", "A1+B1", r.getCell(5).toString());
-                assertEquals("Blank", "", r.getCell(6).toString());
+                assertEquals("FALSE", r.getCell(0).toString(), "Boolean");
+                assertEquals("TRUE", r.getCell(1).toString(), "Boolean");
+                assertEquals("1.5", r.getCell(2).toString(), "Numeric");
+                assertEquals("Astring", r.getCell(3).toString(), "String");
+                assertEquals("#DIV/0!", r.getCell(4).toString(), "Error");
+                assertEquals("A1+B1", r.getCell(5).toString(), "Formula");
+                assertEquals("", r.getCell(6).toString(), "Blank");
                 String dateCell2 = r.getCell(7).toString();
-                assertEquals("Date", dateCell1, dateCell2);
+                assertEquals(dateCell1, dateCell2, "Date");
             }
         }
     }
@@ -436,12 +438,7 @@ public abstract class BaseTestCell {
 
     private static void confirmFormulaWithUnknownUDF(String expectedFormula, Cell cell, FormulaEvaluator evaluator) {
         assertEquals(expectedFormula, cell.getCellFormula());
-        try {
-            evaluator.evaluate(cell);
-            fail("Expected NotImplementedFunctionException/NotImplementedException");
-        } catch (final org.apache.poi.ss.formula.eval.NotImplementedException e) {
-            // expected
-        }
+        assertThrows(NotImplementedException.class, () -> evaluator.evaluate(cell));
     }
 
     @Test
@@ -525,7 +522,7 @@ public abstract class BaseTestCell {
             assertEquals("abc", cellA1.getStringCellValue());
 
             fe.evaluateInCell(cellA1);
-            assertFalse("Identified bug with writing back formula result of type string", cellA1.getStringCellValue().isEmpty());
+            assertFalse(cellA1.getStringCellValue().isEmpty(), "Identified bug with writing back formula result of type string");
             assertEquals("abc", cellA1.getStringCellValue());
         }
     }
@@ -587,7 +584,7 @@ public abstract class BaseTestCell {
             cell.setCellFormula("1=1");
             cell.setCellValue(true);
             cell.setCellType(CellType.BOOLEAN);
-            assertTrue("Identified bug 46479d", cell.getBooleanCellValue());
+            assertTrue(cell.getBooleanCellValue(), "Identified bug 46479d");
             assertTrue(cell.getBooleanCellValue());
         }
     }
@@ -690,18 +687,18 @@ public abstract class BaseTestCell {
 
             Cell cell0 = row.createCell(0);
             cell0.setCellValue(Double.NaN);
-            assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellType());
-            assertEquals("Double.NaN should change cell value to #NUM!", FormulaError.NUM, forInt(cell0.getErrorCellValue()));
+            assertEquals(CellType.ERROR, cell0.getCellType(), "Double.NaN should change cell type to CellType#ERROR");
+            assertEquals(FormulaError.NUM, forInt(cell0.getErrorCellValue()), "Double.NaN should change cell value to #NUM!");
 
             Cell cell1 = row.createCell(1);
             cell1.setCellValue(Double.POSITIVE_INFINITY);
-            assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellType());
-            assertEquals("Double.POSITIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell1.getErrorCellValue()));
+            assertEquals(CellType.ERROR, cell1.getCellType(), "Double.POSITIVE_INFINITY should change cell type to CellType#ERROR");
+            assertEquals(FormulaError.DIV0, forInt(cell1.getErrorCellValue()), "Double.POSITIVE_INFINITY should change cell value to #DIV/0!");
 
             Cell cell2 = row.createCell(2);
             cell2.setCellValue(Double.NEGATIVE_INFINITY);
-            assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellType());
-            assertEquals("Double.NEGATIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell2.getErrorCellValue()));
+            assertEquals(CellType.ERROR, cell2.getCellType(), "Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR");
+            assertEquals(FormulaError.DIV0, forInt(cell2.getErrorCellValue()), "Double.NEGATIVE_INFINITY should change cell value to #DIV/0!");
 
             try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1)) {
                 row = wb2.getSheetAt(0).getRow(0);
@@ -965,12 +962,8 @@ public abstract class BaseTestCell {
 
             b.append("X");
             // 32768 produces an invalid XLS file
-            try {
-                cell.setCellValue(b.toString());
-                fail("Expected exception");
-            } catch (IllegalArgumentException e) {
-                assertEquals("The maximum length of cell contents (text) is 32767 characters", e.getMessage());
-            }
+            IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> cell.setCellValue(b.toString()));
+            assertEquals("The maximum length of cell contents (text) is 32767 characters", e.getMessage());
         }
     }
 
@@ -1032,35 +1025,14 @@ public abstract class BaseTestCell {
             cell.setCellFormula("A2");
             cell.setCellErrorValue(FormulaError.NAME.getCode());
 
-            assertEquals("Should still be a formula even after we set an error value",
-                    CellType.FORMULA, cell.getCellType());
-            assertEquals("Should still be a formula even after we set an error value",
-                    CellType.ERROR, cell.getCachedFormulaResultType());
+            assertEquals(CellType.FORMULA, cell.getCellType(), "Should still be a formula even after we set an error value");
+            assertEquals(CellType.ERROR, cell.getCachedFormulaResultType(), "Should still be a formula even after we set an error value");
             assertEquals("A2", cell.getCellFormula());
-            try {
-                cell.getNumericCellValue();
-                fail("Should catch exception here");
-            } catch (IllegalStateException e) {
-                // expected here
-            }
-            try {
-                cell.getStringCellValue();
-                fail("Should catch exception here");
-            } catch (IllegalStateException e) {
-                // expected here
-            }
-            try {
-                cell.getRichStringCellValue();
-                fail("Should catch exception here");
-            } catch (IllegalStateException e) {
-                // expected here
-            }
-            try {
-                cell.getDateCellValue();
-                fail("Should catch exception here");
-            } catch (IllegalStateException e) {
-                // expected here
-            }
+            assertThrows(IllegalStateException.class, cell::getNumericCellValue);
+            assertThrows(IllegalStateException.class, cell::getStringCellValue);
+            assertThrows(IllegalStateException.class, cell::getRichStringCellValue);
+            assertThrows(IllegalStateException.class, cell::getDateCellValue);
+
             assertEquals(FormulaError.NAME.getCode(), cell.getErrorCellValue());
             assertNull(cell.getHyperlink());
         }
@@ -1214,19 +1186,19 @@ public abstract class BaseTestCell {
         }
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void setCellType_null_throwsIAE() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             Cell cell = getInstance(wb);
-            cell.setCellType(null);
+            assertThrows(IllegalArgumentException.class, () -> cell.setCellType(null));
         }
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void setCellType_NONE_throwsIAE() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             Cell cell = getInstance(wb);
-            cell.setCellType(CellType._NONE);
+            assertThrows(IllegalArgumentException.class, () -> cell.setCellType(CellType._NONE));
         }
     }
 
@@ -1248,17 +1220,17 @@ public abstract class BaseTestCell {
         }
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             Cell cell = getInstance(wb);
             cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1:B1"));
             cell.setCellValue("foo");
-            cell.setBlank();
+            assertThrows(IllegalStateException.class, cell::setBlank);
         }
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void setCellFormula_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             Cell cell = getInstance(wb);
@@ -1267,7 +1239,7 @@ public abstract class BaseTestCell {
             assertTrue(cell.isPartOfArrayFormulaGroup());
             assertEquals(CellType.FORMULA, cell.getCellType());
 
-            cell.setCellFormula("1");
+            assertThrows(IllegalStateException.class, () -> cell.setCellFormula("1"));
         }
     }
 
@@ -1349,8 +1321,7 @@ public abstract class BaseTestCell {
             cell.setCellFormula("\"foo\"");
             assertEquals(CellType.FORMULA, cell.getCellType());
             assertEquals(CellType.BOOLEAN, cell.getCachedFormulaResultType());
-            assertTrue("Expected a boolean cell-value, but had 'false'",
-                    cell.getBooleanCellValue());
+            assertTrue(cell.getBooleanCellValue(), "Expected a boolean cell-value, but had 'false'");
         }
     }
 
@@ -1367,8 +1338,7 @@ public abstract class BaseTestCell {
             cell.setCellFormula("\"bar\"");
             assertEquals(CellType.FORMULA, cell.getCellType());
             assertEquals(CellType.BOOLEAN, cell.getCachedFormulaResultType());
-            assertTrue("Expected a boolean cell-value, but had 'false'",
-                    cell.getBooleanCellValue());
+            assertTrue(cell.getBooleanCellValue(), "Expected a boolean cell-value, but had 'false'");
         }
     }
 
@@ -1386,18 +1356,18 @@ public abstract class BaseTestCell {
 
             cell.getSheet().setArrayFormula("\"bar\"", CellRangeAddress.valueOf("A1"));
             assertEquals(CellType.FORMULA, cell.getCellType());
-            assertEquals("Expected a boolean cell-value, but had " + cell.getCachedFormulaResultType(),
-                    CellType.BOOLEAN, cell.getCachedFormulaResultType());
-            assertTrue("Expected a boolean cell-value, but had 'false'",
-                    cell.getBooleanCellValue());
+            assertEquals(CellType.BOOLEAN, cell.getCachedFormulaResultType(),
+                "Expected a boolean cell-value, but had " + cell.getCachedFormulaResultType());
+            assertTrue(cell.getBooleanCellValue(),
+                "Expected a boolean cell-value, but had 'false'");
         }
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void setCellType_FORMULA_onANonFormulaCell_throwsIllegalArgumentException() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             Cell cell = getInstance(wb);
-            cell.setCellType(CellType.FORMULA);
+            assertThrows(IllegalArgumentException.class, () -> cell.setCellType(CellType.FORMULA));
         }
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java Thu Dec 24 18:42:29 2020
@@ -18,20 +18,21 @@
 package org.apache.poi.ss.usermodel;
 
 import static org.apache.poi.util.Units.EMU_PER_PIXEL;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+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 java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.util.Units;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Common superclass for testing implementations of
@@ -102,7 +103,7 @@ public abstract class BaseTestCellCommen
 
         Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
         wb1.close();
-        
+
         sheet = wb2.getSheetAt(0);
         cell = sheet.getRow(cellRow).getCell(cellColumn);
         comment = cell.getCellComment();
@@ -135,7 +136,7 @@ public abstract class BaseTestCellCommen
         // Test Comment.equals and Comment.hashCode
         assertEquals(comment, cell.getCellComment());
         assertEquals(comment.hashCode(), cell.getCellComment().hashCode());
-        
+
         wb3.close();
     }
 
@@ -157,7 +158,7 @@ public abstract class BaseTestCellCommen
             row = sheet.getRow(rownum);
             cell = row.getCell(0);
             comment = cell.getCellComment();
-            assertNull("Cells in the first column are not commented", comment);
+            assertNull(comment, "Cells in the first column are not commented");
             assertNull(sheet.getCellComment(new CellAddress(rownum, 0)));
         }
 
@@ -165,15 +166,15 @@ public abstract class BaseTestCellCommen
             row = sheet.getRow(rownum);
             cell = row.getCell(1);
             comment = cell.getCellComment();
-            assertNotNull("Cells in the second column have comments", comment);
-            assertNotNull("Cells in the second column have comments", sheet.getCellComment(new CellAddress(rownum, 1)));
+            assertNotNull(comment, "Cells in the second column have comments");
+            assertNotNull(sheet.getCellComment(new CellAddress(rownum, 1)), "Cells in the second column have comments");
 
             assertEquals("Yegor Kozlov", comment.getAuthor());
             assertFalse(comment.getString().getString().isEmpty());
             assertEquals(rownum, comment.getRow());
             assertEquals(cell.getColumnIndex(), comment.getColumn());
         }
-        
+
         wb.close();
     }
 
@@ -212,7 +213,7 @@ public abstract class BaseTestCellCommen
             assertEquals("Mofified[" + rownum + "] by Yegor", comment.getAuthor());
             assertEquals("Modified comment at row " + rownum, comment.getString().getString());
         }
-        
+
         wb2.close();
     }
 
@@ -242,7 +243,7 @@ public abstract class BaseTestCellCommen
         assertNull(sheet.getRow(0).getCell(1).getCellComment());
         assertNotNull(sheet.getRow(1).getCell(1).getCellComment());
         assertNull(sheet.getRow(2).getCell(1).getCellComment());
-        
+
         wb2.close();
     }
 
@@ -280,24 +281,24 @@ public abstract class BaseTestCellCommen
         assertEquals("Apache POI", comment.getAuthor());
         assertEquals(3, comment.getRow());
         assertEquals(5, comment.getColumn());
-        
+
         wb2.close();
     }
 
     @Test
     public void getClientAnchor() throws IOException {
         Workbook wb = _testDataProvider.createWorkbook();
-        
+
         Sheet sheet = wb.createSheet();
         Row row = sheet.createRow(10);
         Cell cell = row.createCell(5);
         CreationHelper factory = wb.getCreationHelper();
-        
+
         Drawing<?> drawing = sheet.createDrawingPatriarch();
-        
+
         double r_mul, c_mul;
         if (sheet instanceof HSSFSheet) {
-            double rowheight = Units.toEMU(row.getHeightInPoints())/EMU_PER_PIXEL;
+            double rowheight = Units.toEMU(row.getHeightInPoints())/(double)EMU_PER_PIXEL;
             r_mul = 256.0/rowheight;
             double colwidth = sheet.getColumnWidthInPixels(2);
             c_mul = 1024.0/colwidth;
@@ -313,12 +314,12 @@ public abstract class BaseTestCellCommen
         int row1 = row.getRowNum();
         int col2 = cell.getColumnIndex()+2;
         int row2 = row.getRowNum()+1;
-        
+
         ClientAnchor anchor = drawing.createAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
         Comment comment = drawing.createCellComment(anchor);
         comment.setVisible(true);
         cell.setCellComment(comment);
-        
+
         anchor = comment.getClientAnchor();
         assertEquals(dx1, anchor.getDx1());
         assertEquals(dy1, anchor.getDy1());
@@ -333,7 +334,7 @@ public abstract class BaseTestCellCommen
         comment = drawing.createCellComment(anchor);
         cell.setCellComment(comment);
         anchor = comment.getClientAnchor();
-        
+
         if (sheet instanceof HSSFSheet) {
             assertEquals(0, anchor.getCol1());
             assertEquals(0, anchor.getDx1());
@@ -342,7 +343,7 @@ public abstract class BaseTestCellCommen
             assertEquals(0, anchor.getCol2());
             assertEquals(0, anchor.getDx2());
             assertEquals(0, anchor.getRow2());
-            assertEquals(0, anchor.getDy2());            
+            assertEquals(0, anchor.getDy2());
         } else {
             // when anchor is initialized without parameters, the comment anchor attributes default to
             // "1, 15, 0, 2, 3, 15, 3, 16" ... see XSSFVMLDrawing.newCommentShape()
@@ -355,33 +356,35 @@ public abstract class BaseTestCellCommen
             assertEquals( 3, anchor.getRow2());
             assertEquals(16*EMU_PER_PIXEL, anchor.getDy2());
         }
-        
+
         wb.close();
     }
-    
+
     @Test
     public void attemptToSave2CommentsWithSameCoordinates() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
-        CreationHelper factory = wb.getCreationHelper();
-        Drawing<?> patriarch = sh.createDrawingPatriarch();
-        patriarch.createCellComment(factory.createClientAnchor());
-        
-        try {
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet sh = wb.createSheet();
+            CreationHelper factory = wb.getCreationHelper();
+            Drawing<?> patriarch = sh.createDrawingPatriarch();
             patriarch.createCellComment(factory.createClientAnchor());
-            _testDataProvider.writeOutAndReadBack(wb);
-            fail("Should not be able to create a corrupted workbook with multiple cell comments in one cell");
-        } catch (IllegalStateException e) {
-            // HSSFWorkbooks fail when writing out workbook
-            assertEquals("found multiple cell comments for cell $A$1", e.getMessage());
-        } catch (IllegalArgumentException e) {
-            // XSSFWorkbooks fail when creating and setting the cell address of the comment
-            assertEquals("Multiple cell comments in one cell are not allowed, cell: A1", e.getMessage());
-        } finally {
-            wb.close();
+
+            RuntimeException e = assertThrows(RuntimeException.class, () -> {
+                patriarch.createCellComment(factory.createClientAnchor());
+                _testDataProvider.writeOutAndReadBack(wb);
+            }, "Should not be able to create a corrupted workbook with multiple cell comments in one cell");
+
+            if (wb instanceof HSSFWorkbook) {
+                // HSSFWorkbooks fail when writing out workbook
+                assertTrue(e instanceof IllegalStateException);
+                assertEquals("found multiple cell comments for cell $A$1", e.getMessage());
+            } else {
+                // XSSFWorkbooks fail when creating and setting the cell address of the comment
+                assertTrue(e instanceof IllegalArgumentException);
+                assertEquals("Multiple cell comments in one cell are not allowed, cell: A1", e.getMessage());
+            }
         }
     }
-    
+
     @Test
     public void getAddress() {
         Workbook wb = _testDataProvider.createWorkbook();
@@ -389,13 +392,13 @@ public abstract class BaseTestCellCommen
         CreationHelper factory = wb.getCreationHelper();
         Drawing<?> patriarch = sh.createDrawingPatriarch();
         Comment comment = patriarch.createCellComment(factory.createClientAnchor());
-        
+
         assertEquals(CellAddress.A1, comment.getAddress());
         Cell C2 = sh.createRow(1).createCell(2);
         C2.setCellComment(comment);
         assertEquals(new CellAddress("C2"), comment.getAddress());
     }
-    
+
     @Test
     public void setAddress() {
         Workbook wb = _testDataProvider.createWorkbook();
@@ -403,13 +406,13 @@ public abstract class BaseTestCellCommen
         CreationHelper factory = wb.getCreationHelper();
         Drawing<?> patriarch = sh.createDrawingPatriarch();
         Comment comment = patriarch.createCellComment(factory.createClientAnchor());
-        
+
         assertEquals(CellAddress.A1, comment.getAddress());
         CellAddress C2 = new CellAddress("C2");
         assertEquals("C2", C2.formatAsString());
         comment.setAddress(C2);
         assertEquals(C2, comment.getAddress());
-        
+
         CellAddress E10 = new CellAddress(9, 4);
         assertEquals("E10", E10.formatAsString());
         comment.setAddress(9, 4);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCloneSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCloneSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCloneSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCloneSheet.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,15 @@
 
 package org.apache.poi.ss.usermodel;
 
-import org.apache.poi.ss.ITestDataProvider;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
-import static org.junit.Assert.*;
+import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.junit.jupiter.api.Test;
 
 /**
  * Common superclass for testing implementations of
@@ -44,7 +46,7 @@ public abstract class BaseTestCloneSheet
         assertEquals(0, s.addMergedRegion(new CellRangeAddress(0, 1, 0, 1)));
         Sheet clonedSheet = b.cloneSheet(0);
 
-        assertEquals("One merged area", 1, clonedSheet.getNumMergedRegions());
+        assertEquals(1, clonedSheet.getNumMergedRegions(), "One merged area");
 
         b.close();
     }
@@ -60,12 +62,12 @@ public abstract class BaseTestCloneSheet
         s.setColumnBreak((short) 6);
 
         Sheet clone = b.cloneSheet(0);
-        assertTrue("Row 3 not broken", clone.isRowBroken(3));
-        assertTrue("Column 6 not broken", clone.isColumnBroken((short) 6));
+        assertTrue(clone.isRowBroken(3), "Row 3 not broken");
+        assertTrue(clone.isColumnBroken((short) 6), "Column 6 not broken");
 
         s.removeRowBreak(3);
 
-        assertTrue("Row 3 still should be broken", clone.isRowBroken(3));
+        assertTrue(clone.isRowBroken(3), "Row 3 still should be broken");
 
         b.close();
     }
@@ -76,24 +78,14 @@ public abstract class BaseTestCloneSheet
         wb.createSheet("Sheet01");
         wb.cloneSheet(0);
         assertEquals(2, wb.getNumberOfSheets());
-        try {
-            wb.cloneSheet(2);
-            fail("ShouldFail");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> wb.cloneSheet(2));
     }
 
     @Test
     public void testCloneSheetIntInvalid() {
         Workbook wb = _testDataProvider.createWorkbook();
         wb.createSheet("Sheet01");
-        try {
-            wb.cloneSheet(1);
-            fail("Should Fail");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> wb.cloneSheet(1));
         assertEquals(1, wb.getNumberOfSheets());
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java Thu Dec 24 18:42:29 2020
@@ -18,21 +18,20 @@
  */
 package org.apache.poi.ss.usermodel;
 
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import org.apache.poi.ss.usermodel.helpers.ColumnShifter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public abstract class BaseTestColumnShifting {
     protected Workbook wb;
     protected Sheet sheet1;
     protected ColumnShifter columnShifter;
 
-    @Before
+    @BeforeEach
     public void init() {
         int rowIndex = 0;
         sheet1 = wb.createSheet("sheet1");
@@ -63,7 +62,7 @@ public abstract class BaseTestColumnShif
     @Test
     public void testShift3ColumnsRight() {
         columnShifter.shiftColumns(1, 2, 3);
-        
+
         Cell cell = sheet1.getRow(0).getCell(4);
         assertNull(cell);
         cell = sheet1.getRow(1).getCell(4);
@@ -76,12 +75,7 @@ public abstract class BaseTestColumnShif
 
     @Test
     public void testShiftLeft() {
-        try {
-            columnShifter.shiftColumns(1, 2, -3);
-            fail("Shift to negative indices should throw exception");
-        }
-        catch(IllegalStateException e){
-            assertTrue(true);
-        }
+        assertThrows(IllegalStateException.class, () -> columnShifter.shiftColumns(1, 2, -3),
+            "Shift to negative indices should throw exception");
     }
 }



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