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 [37/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/usermodel/BaseTestSheetHiding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java Thu Dec 24 18:42:29 2020
@@ -17,17 +17,17 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
 import org.apache.poi.ss.ITestDataProvider;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public abstract class BaseTestSheetHiding {
 
@@ -47,61 +47,50 @@ public abstract class BaseTestSheetHidin
         _file2 = file2;
     }
 
-	@Before
+	@BeforeEach
     public void setUp() {
         wbH = _testDataProvider.openSampleWorkbook(_file1);
         wbU = _testDataProvider.openSampleWorkbook(_file2);
     }
 
-	@After
+	@AfterEach
 	public void teadDown() throws IOException {
 	    wbH.close();
 	    wbU.close();
 	}
-	
+
     @Test
     public final void testSheetVisibility() throws IOException {
-        Workbook wb = _testDataProvider.createWorkbook();
-        wb.createSheet("MySheet");
-    
-        assertFalse(wb.isSheetHidden(0));
-        assertFalse(wb.isSheetVeryHidden(0));
-        assertEquals(SheetVisibility.VISIBLE, wb.getSheetVisibility(0));
-    
-        wb.setSheetVisibility(0, SheetVisibility.HIDDEN);
-        assertTrue(wb.isSheetHidden(0));
-        assertFalse(wb.isSheetVeryHidden(0));
-        assertEquals(SheetVisibility.HIDDEN, wb.getSheetVisibility(0));
-    
-        wb.setSheetVisibility(0, SheetVisibility.VERY_HIDDEN);
-        assertFalse(wb.isSheetHidden(0));
-        assertTrue(wb.isSheetVeryHidden(0));
-        assertEquals(SheetVisibility.VERY_HIDDEN, wb.getSheetVisibility(0));
-    
-        wb.setSheetVisibility(0, SheetVisibility.VISIBLE);
-        assertFalse(wb.isSheetHidden(0));
-        assertFalse(wb.isSheetVeryHidden(0));
-        assertEquals(SheetVisibility.VISIBLE, wb.getSheetVisibility(0));
-
-        // verify limits-check
-
-        // check sheet-index with one more => throws exception
-        try {
-            wb.setSheetVisibility(1, SheetVisibility.HIDDEN);
-            fail("Should catch exception here");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            wb.createSheet("MySheet");
 
-        // check sheet-index with index out of bounds => throws exception
-        try {
-            wb.setSheetVisibility(10, SheetVisibility.HIDDEN);
-            fail("Should catch exception here");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+            assertFalse(wb.isSheetHidden(0));
+            assertFalse(wb.isSheetVeryHidden(0));
+            assertEquals(SheetVisibility.VISIBLE, wb.getSheetVisibility(0));
+
+            wb.setSheetVisibility(0, SheetVisibility.HIDDEN);
+            assertTrue(wb.isSheetHidden(0));
+            assertFalse(wb.isSheetVeryHidden(0));
+            assertEquals(SheetVisibility.HIDDEN, wb.getSheetVisibility(0));
+
+            wb.setSheetVisibility(0, SheetVisibility.VERY_HIDDEN);
+            assertFalse(wb.isSheetHidden(0));
+            assertTrue(wb.isSheetVeryHidden(0));
+            assertEquals(SheetVisibility.VERY_HIDDEN, wb.getSheetVisibility(0));
+
+            wb.setSheetVisibility(0, SheetVisibility.VISIBLE);
+            assertFalse(wb.isSheetHidden(0));
+            assertFalse(wb.isSheetVeryHidden(0));
+            assertEquals(SheetVisibility.VISIBLE, wb.getSheetVisibility(0));
 
-        wb.close();
+            // verify limits-check
+
+            // check sheet-index with one more => throws exception
+            assertThrows(IllegalArgumentException.class, () -> wb.setSheetVisibility(1, SheetVisibility.HIDDEN));
+
+            // check sheet-index with index out of bounds => throws exception
+            assertThrows(IllegalArgumentException.class, () -> wb.setSheetVisibility(10, SheetVisibility.HIDDEN));
+        }
     }
 
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftColumns.java Thu Dec 24 18:42:29 2020
@@ -18,11 +18,12 @@
  */
 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.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;
 
@@ -31,8 +32,8 @@ import org.apache.poi.ss.ITestDataProvid
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellUtil;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public abstract class BaseTestSheetShiftColumns {
     protected Sheet sheet1;
@@ -41,7 +42,7 @@ public abstract class BaseTestSheetShift
 
     protected ITestDataProvider _testDataProvider;
 
-    @Before
+    @BeforeEach
     public void init() {
         int rowIndex = 0;
         sheet1 = workbook.createSheet("sheet1");
@@ -157,9 +158,9 @@ public abstract class BaseTestSheetShift
         assertNull(newb6Null);
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void testShiftTwoColumnsLeft() {
-        sheet1.shiftColumns(1, 2, -2);
+        assertThrows(IllegalStateException.class, () -> sheet1.shiftColumns(1, 2, -2));
     }
 
     @Test
@@ -229,8 +230,8 @@ public abstract class BaseTestSheetShift
         verifyHyperlink(shiftedRow.getCell(4), HyperlinkType.URL, "https://poi.apache.org/");
 
         // Make sure hyperlinks were moved and not copied
-        assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
-        assertNull("URL hyperlink should be moved, not copied", sh.getHyperlink(1, 0));
+        assertNull(sh.getHyperlink(0, 0), "Document hyperlink should be moved, not copied");
+        assertNull(sh.getHyperlink(1, 0), "URL hyperlink should be moved, not copied");
 
         assertEquals(4, sh.getHyperlinkList().size());
         read.close();
@@ -245,11 +246,10 @@ public abstract class BaseTestSheetShift
 
     private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) {
         assertTrue(cellHasHyperlink(cell));
-        if (cell != null) {
-            Hyperlink link = cell.getHyperlink();
-            assertEquals(linkType, link.getType());
-            assertEquals(ref, link.getAddress());
-        }
+        assertNotNull(cell);
+        Hyperlink link = cell.getHyperlink();
+        assertEquals(linkType, link.getType());
+        assertEquals(ref, link.getAddress());
     }
 
     private boolean cellHasHyperlink(Cell cell) {

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java Thu Dec 24 18:42:29 2020
@@ -19,12 +19,12 @@ package org.apache.poi.ss.usermodel;
 
 import static org.apache.poi.POITestCase.skipTest;
 import static org.apache.poi.POITestCase.testPassesNow;
-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.Assert.fail;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -36,7 +36,7 @@ import org.apache.poi.ss.ITestDataProvid
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests row shifting capabilities.
@@ -136,16 +136,17 @@ public abstract class BaseTestSheetShift
      * When shifting rows, the page breaks should go with it
      */
     @Test
-    public void testShiftRowBreaks() throws IOException { // TODO - enable XSSF test
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet s = wb.createSheet();
-        Row row = s.createRow(4);
-        row.createCell(0).setCellValue("test");
-        s.setRowBreak(4);
+    public void testShiftRowBreaks() throws IOException {
+        // TODO - enable XSSF test
+        try (Workbook wb = _testDataProvider.createWorkbook()) {
+            Sheet s = wb.createSheet();
+            Row row = s.createRow(4);
+            row.createCell(0).setCellValue("test");
+            s.setRowBreak(4);
 
-        s.shiftRows(4, 4, 2);
-        assertTrue("Row number 6 should have a pagebreak", s.isRowBroken(6));
-        wb.close();
+            s.shiftRows(4, 4, 2);
+            assertTrue(s.isRowBroken(6), "Row number 6 should have a pagebreak");
+        }
     }
 
     @Test
@@ -219,8 +220,8 @@ public abstract class BaseTestSheetShift
             assertEquals(2, sheet.getLastRowNum());
 
             // Verify comments are in the position expected
-            assertNull("Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()),
-                    sheet.getCellComment(new CellAddress(0,0)));
+            assertNull(sheet.getCellComment(new CellAddress(0,0)),
+                "Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()));
             assertNotNull(sheet.getCellComment(new CellAddress(1,0)));
             assertNotNull(sheet.getCellComment(new CellAddress(2,0)));
         }
@@ -570,18 +571,17 @@ public abstract class BaseTestSheetShift
         verifyHyperlink(shiftedRow.getCell(1), HyperlinkType.URL, "https://poi.apache.org/");
 
         // Make sure hyperlinks were moved and not copied
-        assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
-        assertNull("URL hyperlink should be moved, not copied", sh.getHyperlink(0, 1));
+        assertNull(sh.getHyperlink(0, 0), "Document hyperlink should be moved, not copied");
+        assertNull(sh.getHyperlink(0, 1), "URL hyperlink should be moved, not copied");
 
         // Make sure hyperlink in overwritten row is deleted
         assertEquals(3, sh.getHyperlinkList().size());
         CellAddress unexpectedLinkAddress = new CellAddress("C4");
         for (Hyperlink link : sh.getHyperlinkList()) {
             final CellAddress linkAddress = new CellAddress(link.getFirstRow(), link.getFirstColumn());
-            if (linkAddress.equals(unexpectedLinkAddress)) {
-                fail("Row 4, including the hyperlink at C4, should have " +
-                     "been deleted when Row 1 was shifted on top of it.");
-            }
+            assertNotEquals(linkAddress, unexpectedLinkAddress,
+                "Row 4, including the hyperlink at C4, should have " +
+                    "been deleted when Row 1 was shifted on top of it.");
         }
 
         // Make sure unaffected rows are not shifted

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java Thu Dec 24 18:42:29 2020
@@ -17,15 +17,15 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertArrayEquals;
-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.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+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.Assumptions.assumeTrue;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -34,8 +34,8 @@ import org.apache.poi.ss.ITestDataProvid
 import org.apache.poi.ss.formula.FormulaParseException;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Common superclass for testing usermodel API for array formulas.<br>
@@ -77,12 +77,8 @@ public abstract class BaseTestSheetUpdat
             Sheet sheet = workbook.createSheet();
             Cell cell = sheet.createRow(0).createCell(0);
             assertFalse(cell.isPartOfArrayFormulaGroup());
-            try {
-                cell.getArrayFormulaRange();
-                fail("expected exception");
-            } catch (IllegalStateException e) {
-                assertEquals("Cell Sheet0!A1 is not part of an array formula.", e.getMessage());
-            }
+            IllegalStateException e = assertThrows(IllegalStateException.class, cell::getArrayFormulaRange);
+            assertEquals("Cell Sheet0!A1 is not part of an array formula.", e.getMessage());
 
             // row 3 does not yet exist
             assertNull(sheet.getRow(2));
@@ -139,12 +135,12 @@ public abstract class BaseTestSheetUpdat
      * Passing an incorrect formula to sheet.setArrayFormula
      *  should throw FormulaParseException
      */
-    @Test(expected = FormulaParseException.class)
+    @Test
     public final void testSetArrayFormula_incorrectFormula() throws IOException {
         try (Workbook workbook = _testDataProvider.createWorkbook()) {
             Sheet sheet = workbook.createSheet();
             CellRangeAddress cra = new CellRangeAddress(10, 10, 10, 10);
-            sheet.setArrayFormula("incorrect-formula(C11_C12*D11_D12)", cra);
+            assertThrows(FormulaParseException.class, () -> sheet.setArrayFormula("incorrect-formula(C11_C12*D11_D12)", cra));
         }
     }
 
@@ -159,19 +155,11 @@ public abstract class BaseTestSheetUpdat
 
             Cell cell = sheet.createRow(0).createCell(0);
             assertFalse(cell.isPartOfArrayFormulaGroup());
-            try {
-                cell.getArrayFormulaRange();
-                fail("expected exception");
-            } catch (IllegalStateException e) {
-                assertEquals("Cell Sheet0!A1 is not part of an array formula.", e.getMessage());
-            }
+            IllegalStateException e = assertThrows(IllegalStateException.class, cell::getArrayFormulaRange);
+            assertEquals("Cell Sheet0!A1 is not part of an array formula.", e.getMessage());
 
-            try {
-                sheet.removeArrayFormula(cell);
-                fail("expected exception");
-            } catch (IllegalArgumentException e) {
-                assertEquals("Cell Sheet0!A1 is not part of an array formula.", e.getMessage());
-            }
+            IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> sheet.removeArrayFormula(cell));
+            assertEquals("Cell Sheet0!A1 is not part of an array formula.", e.getMessage());
         }
     }
 
@@ -201,13 +189,9 @@ public abstract class BaseTestSheetUpdat
             // cells C4:C6 are not included in array formula,
             // invocation of sheet.removeArrayFormula on any of them throws IllegalArgumentException
             for (Cell acell : cr) {
-                try {
-                    sheet.removeArrayFormula(acell);
-                    fail("expected exception");
-                } catch (IllegalArgumentException e) {
-                    String ref = new CellReference(acell).formatAsString();
-                    assertEquals("Cell " + ref + " is not part of an array formula.", e.getMessage());
-                }
+                IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> sheet.removeArrayFormula(acell));
+                String ref = new CellReference(acell).formatAsString();
+                assertEquals("Cell " + ref + " is not part of an array formula.", e.getMessage());
             }
         }
     }
@@ -299,15 +283,12 @@ public abstract class BaseTestSheetUpdat
             CellRange<? extends Cell> mrange =
                     sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
             for (Cell mcell : mrange) {
-                try {
-                    assertEquals(CellType.FORMULA, mcell.getCellType());
-                    mcell.setCellType(CellType.NUMERIC);
-                    fail("expected exception");
-                } catch (IllegalStateException e) {
-                    CellReference ref = new CellReference(mcell);
-                    String msg = "Cell " + ref.formatAsString() + " is part of a multi-cell array formula. You cannot change part of an array.";
-                    assertEquals(msg, e.getMessage());
-                }
+                assertEquals(CellType.FORMULA, mcell.getCellType());
+                IllegalStateException e = assertThrows(IllegalStateException.class, () -> mcell.setCellType(CellType.NUMERIC));
+                CellReference ref = new CellReference(mcell);
+                String msg = "Cell " + ref.formatAsString() + " is part of a multi-cell array formula. You cannot change part of an array.";
+                assertEquals(msg, e.getMessage());
+
                 // a failed invocation of Cell.setCellType leaves the cell
                 // in the state that it was in prior to the invocation
                 assertEquals(CellType.FORMULA, mcell.getCellType());
@@ -342,15 +323,12 @@ public abstract class BaseTestSheetUpdat
                     sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
             for (Cell mcell : mrange) {
                 //we cannot set individual formulas for cells included in an array formula
-                try {
-                    assertEquals("A1:A3*B1:B3", mcell.getCellFormula());
-                    mcell.setCellFormula("A1+A2");
-                    fail("expected exception");
-                } catch (IllegalStateException e) {
-                    CellReference ref = new CellReference(mcell);
-                    String msg = "Cell " + ref.formatAsString() + " is part of a multi-cell array formula. You cannot change part of an array.";
-                    assertEquals(msg, e.getMessage());
-                }
+                assertEquals("A1:A3*B1:B3", mcell.getCellFormula());
+                IllegalStateException e = assertThrows(IllegalStateException.class, () -> mcell.setCellFormula("A1+A2"));
+                CellReference ref = new CellReference(mcell);
+                String msg = "Cell " + ref.formatAsString() + " is part of a multi-cell array formula. You cannot change part of an array.";
+                assertEquals(msg, e.getMessage());
+
                 // a failed invocation of Cell.setCellFormula leaves the cell
                 // in the state that it was in prior to the invocation
                 assertEquals("A1:A3*B1:B3", mcell.getCellFormula());
@@ -386,14 +364,11 @@ public abstract class BaseTestSheetUpdat
             for (Cell mcell : mrange) {
                 int columnIndex = mcell.getColumnIndex();
                 Row mrow = mcell.getRow();
-                try {
-                    mrow.removeCell(mcell);
-                    fail("expected exception");
-                } catch (IllegalStateException e) {
-                    CellReference ref = new CellReference(mcell);
-                    String msg = "Cell " + ref.formatAsString() + " is part of a multi-cell array formula. You cannot change part of an array.";
-                    assertEquals(msg, e.getMessage());
-                }
+                IllegalStateException e = assertThrows(IllegalStateException.class, () -> mrow.removeCell(mcell));
+                CellReference ref = new CellReference(mcell);
+                String msg = "Cell " + ref.formatAsString() + " is part of a multi-cell array formula. You cannot change part of an array.";
+                assertEquals(msg, e.getMessage());
+
                 // a failed invocation of Row.removeCell leaves the row
                 // in the state that it was in prior to the invocation
                 assertSame(mcell, mrow.getCell(columnIndex));
@@ -432,13 +407,10 @@ public abstract class BaseTestSheetUpdat
             for (Cell mcell : mrange) {
                 int columnIndex = mcell.getColumnIndex();
                 Row mrow = mcell.getRow();
-                try {
-                    sheet.removeRow(mrow);
-                    fail("expected exception");
-                } catch (IllegalStateException e) {
-                    // String msg = "Row[rownum="+mrow.getRowNum()+"] contains cell(s) included in a multi-cell array formula. You cannot change part of an array.";
-                    // assertEquals(msg, e.getMessage());
-                }
+                assertThrows(IllegalStateException.class, () -> sheet.removeRow(mrow));
+                // String msg = "Row[rownum="+mrow.getRowNum()+"] contains cell(s) included in a multi-cell array formula. You cannot change part of an array.";
+                // assertEquals(msg, e.getMessage());
+
                 // a failed invocation of Row.removeCell leaves the row
                 // in the state that it was in prior to the invocation
                 assertSame(mrow, sheet.getRow(mrow.getRowNum()));
@@ -485,13 +457,9 @@ public abstract class BaseTestSheetUpdat
                     "B1:D6", "B1:G3", "E1:G6", "B4:G6"  // 2-row/2-column intersection
             )) {
                 CellRangeAddress cra = CellRangeAddress.valueOf(ref);
-                try {
-                    sheet.addMergedRegion(cra);
-                    fail("expected exception with ref " + ref);
-                } catch (IllegalStateException e) {
-                    String msg = "The range " + cra.formatAsString() + " intersects with a multi-cell array formula. You cannot merge cells of an array.";
-                    assertEquals(msg, e.getMessage());
-                }
+                IllegalStateException e = assertThrows(IllegalStateException.class, () -> sheet.addMergedRegion(cra));
+                String msg = "The range " + cra.formatAsString() + " intersects with a multi-cell array formula. You cannot merge cells of an array.";
+                assertEquals(msg, e.getMessage());
             }
             //the number of merged regions remains the same
             assertEquals(expectedNumMergedRegions, sheet.getNumMergedRegions());
@@ -503,13 +471,9 @@ public abstract class BaseTestSheetUpdat
                     "C6:F6",  //bottom
                     "B2:B5", "H7:J9")) {
                 CellRangeAddress cra = CellRangeAddress.valueOf(ref);
-                try {
-                    sheet.addMergedRegion(cra);
-                    expectedNumMergedRegions++;
-                    assertEquals(expectedNumMergedRegions, sheet.getNumMergedRegions());
-                } catch (IllegalStateException e) {
-                    fail("did not expect exception with ref: " + ref + "\n" + e.getMessage());
-                }
+                sheet.addMergedRegion(cra);
+                expectedNumMergedRegions++;
+                assertEquals(expectedNumMergedRegions, sheet.getNumMergedRegions());
             }
 
         }
@@ -522,7 +486,7 @@ public abstract class BaseTestSheetUpdat
 
             //single-cell array formulas behave just like normal cells - we can change the cell type
             CellRange<? extends Cell> srange =
-                    sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
+                sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
             Cell scell = srange.getTopLeftCell();
             assertEquals("SUM(A4:A6,B4:B6)", scell.getCellFormula());
             sheet.shiftRows(0, 0, 1);
@@ -530,14 +494,9 @@ public abstract class BaseTestSheetUpdat
 
             //we cannot set individual formulas for cells included in an array formula
             sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
-
-            try {
-                sheet.shiftRows(0, 0, 1);
-                fail("expected exception");
-            } catch (IllegalStateException e) {
-                String msg = "Row[rownum=0] contains cell(s) included in a multi-cell array formula. You cannot change part of an array.";
-                assertEquals(msg, e.getMessage());
-            }
+            IllegalStateException e = assertThrows(IllegalStateException.class, () -> sheet.shiftRows(0, 0, 1));
+            String msg = "Row[rownum=0] contains cell(s) included in a multi-cell array formula. You cannot change part of an array.";
+            assertEquals(msg, e.getMessage());
         /*
          TODO: enable shifting the whole array
 
@@ -556,8 +515,8 @@ public abstract class BaseTestSheetUpdat
         }
     }
 
-    @Ignore("See bug 59728")
-    @Test(expected = IllegalStateException.class)
+    @Disabled("See bug 59728")
+    @Test
     public void shouldNotBeAbleToCreateArrayFormulaOnPreexistingMergedRegion() throws IOException {
         /*
          *  m  = merged region
@@ -578,7 +537,7 @@ public abstract class BaseTestSheetUpdat
             assumeTrue(mergedRegion.intersects(arrayFormula));
             assumeTrue(arrayFormula.intersects(mergedRegion));
             // expected exception: should not be able to create an array formula that intersects with a merged region
-            sheet.setArrayFormula("SUM(A1:A3)", arrayFormula);
+            assertThrows(IllegalStateException.class, () -> sheet.setArrayFormula("SUM(A1:A3)", arrayFormula));
         }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java Thu Dec 24 18:42:29 2020
@@ -17,15 +17,14 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertArrayEquals;
-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.assertSame;
-import static org.junit.Assert.assertThrows;
-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.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 java.io.IOException;
 import java.io.OutputStream;
@@ -38,7 +37,7 @@ import org.apache.poi.ss.usermodel.Clien
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.NullOutputStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public abstract class BaseTestWorkbook {
 
@@ -67,7 +66,7 @@ public abstract class BaseTestWorkbook {
      * should not be able to advance an iterator when the
      * underlying data has been reordered
      */
-    @Test(expected=ConcurrentModificationException.class)
+    @Test
     public void sheetIterator_sheetsReordered() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             wb.createSheet("Sheet0");
@@ -79,7 +78,7 @@ public abstract class BaseTestWorkbook {
             wb.setSheetOrder("Sheet2", 1);
 
             // Iterator order should be fixed when iterator is created
-            assertEquals("Sheet1", it.next().getSheetName());
+            assertThrows(ConcurrentModificationException.class, it::next);
         }
     }
 
@@ -88,7 +87,7 @@ public abstract class BaseTestWorkbook {
      * should not be able to advance an iterator when the
      * underlying data has been reordered
      */
-    @Test(expected=ConcurrentModificationException.class)
+    @Test
     public void sheetIterator_sheetRemoved() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             wb.createSheet("Sheet0");
@@ -99,7 +98,7 @@ public abstract class BaseTestWorkbook {
             wb.removeSheetAt(1);
 
             // Iterator order should be fixed when iterator is created
-            it.next();
+            assertThrows(ConcurrentModificationException.class, it::next);
         }
     }
 
@@ -107,14 +106,14 @@ public abstract class BaseTestWorkbook {
      * Expected UnsupportedOperationException:
      * should not be able to remove sheets from the sheet iterator
      */
-    @Test(expected=UnsupportedOperationException.class)
+    @Test
     public void sheetIterator_remove() throws IOException {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
             wb.createSheet("Sheet0");
 
             Iterator<Sheet> it = wb.sheetIterator();
             it.next(); //Sheet0
-            it.remove();
+            assertThrows(UnsupportedOperationException.class, it::remove);
         }
     }
 
@@ -127,9 +126,9 @@ public abstract class BaseTestWorkbook {
             //getting a sheet by invalid index or non-existing name
             assertNull(wb.getSheet("Sheet1"));
             IllegalArgumentException ex = assertThrows(
-                "should have thrown exception due to invalid sheet index",
                 IllegalArgumentException.class,
-                () -> wb.getSheetAt(0)
+                () -> wb.getSheetAt(0),
+                "should have thrown exception due to invalid sheet index"
             );
             // expected during successful test no negative index in the range message
             assertFalse(ex.getMessage().contains("-1"));
@@ -145,16 +144,15 @@ public abstract class BaseTestWorkbook {
             //fetching sheets by name is case-insensitive
             Sheet originalSheet = wb.createSheet("Sheet3");
             Sheet fetchedSheet = wb.getSheet("sheet3");
-            if (fetchedSheet == null) {
-                fail("Identified bug 44892");
-            }
+            assertNotNull(fetchedSheet, "Identified bug 44892");
+
             assertEquals("Sheet3", fetchedSheet.getSheetName());
             assertEquals(3, wb.getNumberOfSheets());
             assertSame(originalSheet, fetchedSheet);
             ex = assertThrows(
-                "should have thrown exception due to duplicate sheet name",
                 IllegalArgumentException.class,
-                () -> wb.createSheet("sHeeT3")
+                () -> wb.createSheet("sHeeT3"),
+                "should have thrown exception due to duplicate sheet name"
             );
             // expected during successful test
             assertEquals("The workbook already contains a sheet named 'sHeeT3'", ex.getMessage());
@@ -165,9 +163,9 @@ public abstract class BaseTestWorkbook {
                     "My:Sheet"};
             for (String sheetName : invalidNames) {
                 assertThrows(
-                    "should have thrown exception due to invalid sheet name: " + sheetName,
                     IllegalArgumentException.class,
-                    () -> wb.createSheet(sheetName)
+                    () -> wb.createSheet(sheetName),
+                    "should have thrown exception due to invalid sheet name: " + sheetName
                 );
             }
             //still have 3 sheets
@@ -177,28 +175,12 @@ public abstract class BaseTestWorkbook {
             wb.setSheetName(2, "I changed!");
 
             //try to assign an invalid name to the 2nd sheet
-            try {
-                wb.setSheetName(1, "[I'm invalid]");
-                fail("should have thrown exceptiuon due to invalid sheet name");
-            } catch (IllegalArgumentException e) {
-                // expected during successful test
-            }
+            assertThrows(IllegalArgumentException.class, () -> wb.setSheetName(1, "[I'm invalid]"));
 
             //try to assign an invalid name to the 2nd sheet
-            try {
-                wb.createSheet(null);
-                fail("should have thrown exceptiuon due to invalid sheet name");
-            } catch (IllegalArgumentException e) {
-                // expected during successful test
-            }
+            assertThrows(IllegalArgumentException.class, () -> wb.createSheet(null));
 
-            try {
-                wb.setSheetName(2, null);
-
-                fail("should have thrown exceptiuon due to invalid sheet name");
-            } catch (IllegalArgumentException e) {
-                // expected during successful test
-            }
+            assertThrows(IllegalArgumentException.class, () -> wb.setSheetName(2, null));
 
             //check
             assertEquals(0, wb.getSheetIndex("sheet0"));
@@ -244,14 +226,9 @@ public abstract class BaseTestWorkbook {
 
             String sheetName2 = "My very long sheet name which is longer than 31 chars " +
                     "and sheetName2.substring(0, 31) == sheetName1.substring(0, 31)";
-            try {
-                /*Sheet sh2 =*/
-                wb1.createSheet(sheetName2);
-                fail("expected exception");
-            } catch (IllegalArgumentException e) {
-                // expected during successful test
-                assertEquals("The workbook already contains a sheet named 'My very long sheet name which is longer than 31 chars and sheetName2.substring(0, 31) == sheetName1.substring(0, 31)'", e.getMessage());
-            }
+
+            IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> wb1.createSheet(sheetName2));
+            assertEquals("The workbook already contains a sheet named 'My very long sheet name which is longer than 31 chars and sheetName2.substring(0, 31) == sheetName1.substring(0, 31)'", e.getMessage());
 
             String sheetName3 = "POI allows creating sheets with names longer than 31 characters";
             String truncatedSheetName3 = sheetName3.substring(0, 31);
@@ -777,11 +754,9 @@ public abstract class BaseTestWorkbook {
 		for(int i = 0;i < wb.getNumberOfSheets();i++) {
 			sheetNames.append(wb.getSheetAt(i).getSheetName()).append(",");
 		}
-		assertEquals("Had: " + sheetNames,
-				sheets.length, wb.getNumberOfSheets());
+		assertEquals(sheets.length, wb.getNumberOfSheets(), "Had: " + sheetNames);
 		for(int i = 0;i < wb.getNumberOfSheets();i++) {
-			assertEquals("Had: " + sheetNames,
-					sheets[i], wb.getSheetAt(i).getSheetName());
+			assertEquals(sheets[i], wb.getSheetAt(i).getSheetName(), "Had: " + sheetNames);
 		}
 	}
 
@@ -823,8 +798,7 @@ public abstract class BaseTestWorkbook {
         final byte[] before = HSSFTestDataSamples.getTestDataFileContent(filename);
         wb.close();
         final byte[] after = HSSFTestDataSamples.getTestDataFileContent(filename);
-        assertArrayEquals(filename + " sample file was modified as a result of closing the workbook",
-                before, after);
+        assertArrayEquals(before, after, filename + " sample file was modified as a result of closing the workbook");
     }
 
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestXEvaluationSheet.java Thu Dec 24 18:42:29 2020
@@ -17,12 +17,12 @@
 
 package org.apache.poi.ss.usermodel;
 
-import org.apache.poi.ss.formula.EvaluationSheet;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
+import org.apache.poi.ss.formula.EvaluationSheet;
+import org.junit.jupiter.api.Test;
 
 public abstract class BaseTestXEvaluationSheet {
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java Thu Dec 24 18:42:29 2020
@@ -16,19 +16,22 @@
 
    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.Assert.assertFalse;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.text.DateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -41,9 +44,9 @@ import org.apache.poi.ss.util.CellRefere
 import org.apache.poi.ss.util.NumberToTextConverter;
 import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.SuppressForbidden;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests of {@link DataFormatter}
@@ -54,7 +57,7 @@ import org.junit.Test;
 public class TestDataFormatter {
     private static final double _15_MINUTES = 0.041666667;
 
-    @BeforeClass
+    @BeforeAll
     @SuppressForbidden
     public static void setUpClass() {
         // some pre-checks to hunt for a problem in the Maven build
@@ -74,8 +77,8 @@ public class TestDataFormatter {
 
         CellFormat cfmt = CellFormat.getInstance("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
         CellFormatResult result = cfmt.apply(cellValueO);
-        assertEquals("This failure can indicate that the wrong locale is used during test-execution, ensure you run with english/US via -Duser.language=en -Duser.country=US",
-                "    1,234.56 ", result.text);
+        assertEquals("    1,234.56 ", result.text,
+            "This failure can indicate that the wrong locale is used during test-execution, ensure you run with english/US via -Duser.language=en -Duser.country=US");
     }
 
     /**
@@ -109,7 +112,7 @@ public class TestDataFormatter {
 
         // Regular numeric style formats
         assertEquals("63", dfUS.formatRawCellContents(63.0, -1, "[$-1010409]##"));
-        assertEquals("63", dfUS.formatRawCellContents(63.0, -1, "[$-1010409]00"));        
+        assertEquals("63", dfUS.formatRawCellContents(63.0, -1, "[$-1010409]00"));
 
     }
 
@@ -148,14 +151,14 @@ public class TestDataFormatter {
         };
         for (String format : formats) {
             assertEquals(
-                "Wrong format for: " + format,
                 "12.34",
-                dfUS.formatRawCellContents(12.343, -1, format)
+                dfUS.formatRawCellContents(12.343, -1, format),
+                "Wrong format for: " + format
             );
             assertEquals(
-                "Wrong format for: " + format,
                 "-12.34",
-                dfUS.formatRawCellContents(-12.343, -1, format)
+                dfUS.formatRawCellContents(-12.343, -1, format),
+                "Wrong format for: " + format
             );
         }
 
@@ -172,14 +175,14 @@ public class TestDataFormatter {
         String[] formats = { "#,##0.00;[Blue](#,##0.00)" };
         for (String format : formats) {
             assertEquals(
-                "Wrong format for: " + format,
                 "12.34",
-                dfUS.formatRawCellContents(12.343, -1, format)
+                dfUS.formatRawCellContents(12.343, -1, format),
+                "Wrong format for: " + format
             );
             assertEquals(
-                "Wrong format for: " + format,
                 "(12.34)",
-                dfUS.formatRawCellContents(-12.343, -1, format)
+                dfUS.formatRawCellContents(-12.343, -1, format),
+                "Wrong format for: " + format
             );
         }
 
@@ -187,14 +190,14 @@ public class TestDataFormatter {
         formats = new String[] { "$#,##0.00;[Red]($#,##0.00)" };
         for (String format : formats) {
             assertEquals(
-                "Wrong format for: " + format,
                 "$12.34",
-                dfUS.formatRawCellContents(12.343, -1, format)
+                dfUS.formatRawCellContents(12.343, -1, format),
+                "Wrong format for: " + format
             );
             assertEquals(
-                "Wrong format for: " + format,
                 "($12.34)",
-                dfUS.formatRawCellContents(-12.343, -1, format)
+                dfUS.formatRawCellContents(-12.343, -1, format),
+                "Wrong format for: " + format
             );
         }
     }
@@ -204,8 +207,8 @@ public class TestDataFormatter {
         DataFormatter dfUS = new DataFormatter(Locale.US);
 
         String format = "[>=10]#,##0;[<10]0.0";
-        assertEquals("Wrong format for " + format, "17,876", dfUS.formatRawCellContents(17876.000, -1, format));
-        assertEquals("Wrong format for " + format, "9.7", dfUS.formatRawCellContents(9.71, -1, format));
+        assertEquals("17,876", dfUS.formatRawCellContents(17876.000, -1, format), "Wrong format for " + format);
+        assertEquals("9.7", dfUS.formatRawCellContents(9.71, -1, format), "Wrong format for " + format);
     }
 
     /**
@@ -646,7 +649,7 @@ public class TestDataFormatter {
      * TODO Fix these so that they work
      */
     @Test
-    @Ignore
+    @Disabled
     public void testCustomFormats() {
         DataFormatter dfUS = new DataFormatter(Locale.US, true);
         String fmt;
@@ -700,7 +703,7 @@ public class TestDataFormatter {
         String format = "[h]\"\"h\"\" m\"\"m\"\"";
         assertTrue(DateUtil.isADateFormat(-1,format));
         assertTrue(DateUtil.isValidExcelDate(_15_MINUTES));
-        
+
         assertEquals("1h 0m", formatter.formatRawCellContents(_15_MINUTES, -1, format, false));
         assertEquals("0.041666667", formatter.formatRawCellContents(_15_MINUTES, -1, "[h]'h'", false));
         assertEquals("1h 0m\"", formatter.formatRawCellContents(_15_MINUTES, -1, "[h]\"\"h\"\" m\"\"m\"\"\"", false));
@@ -710,15 +713,13 @@ public class TestDataFormatter {
         assertEquals(" 60", formatter.formatRawCellContents(_15_MINUTES, -1, " [m]", false));
         assertEquals("h60", formatter.formatRawCellContents(_15_MINUTES, -1, "\"\"h\"\"[m]", false));
         assertEquals("m1", formatter.formatRawCellContents(_15_MINUTES, -1, "\"\"m\"\"h", false));
-        
-        try {
-            assertEquals("1h 0m\"", formatter.formatRawCellContents(_15_MINUTES, -1, "[h]\"\"h\"\" m\"\"m\"\"\"\"", false));
-            fail("Catches exception because of invalid format, i.e. trailing quoting");
-        } catch (IllegalArgumentException e) {
-            assertTrue(e.getMessage().contains("Cannot format given Object as a Number"));
-        }
+
+        IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () ->
+            formatter.formatRawCellContents(_15_MINUTES, -1, "[h]\"\"h\"\" m\"\"m\"\"\"\"", false),
+            "Catches exception because of invalid format, i.e. trailing quoting");
+        assertTrue(e.getMessage().contains("Cannot format given Object as a Number"));
     }
-    
+
     @Test
     public void testIsADateFormat() {
         // first check some cases that should not be a date, also call multiple times to ensure the cache is used
@@ -926,7 +927,7 @@ public class TestDataFormatter {
         String value = df.formatCellValue(cell, wb.getCreationHelper().createFormulaEvaluator());
         assertEquals("-130", value);
     }
-    
+
     /**
      * Bug #63292
      */
@@ -965,7 +966,7 @@ public class TestDataFormatter {
         doFormatTestSequential(formatter1);
         doFormatTestConcurrent(formatter1, formatter2);
     }
-    
+
     /**
      * Bug #64319
      *
@@ -976,24 +977,24 @@ public class TestDataFormatter {
     @Test
     public void testWithEinFormat() throws Exception {
         DataFormatter formatter = new DataFormatter();
-        
+
         // Format string literals with an E in them shouldn't be
         //  treated as a Scientific format, so shouldn't become E+
-        assertEquals("TRUE", formatter.formatRawCellContents(1.0, 170, 
+        assertEquals("TRUE", formatter.formatRawCellContents(1.0, 170,
                        "\"TRUE\";\"FALSE\";\"ZERO\""));
-        assertEquals("ZERO", formatter.formatRawCellContents(0.0, 170, 
+        assertEquals("ZERO", formatter.formatRawCellContents(0.0, 170,
                        "\"TRUE\";\"FALSE\";\"ZERO\""));
-        assertEquals("FALSE", formatter.formatRawCellContents(-1.0, 170, 
+        assertEquals("FALSE", formatter.formatRawCellContents(-1.0, 170,
                        "\"TRUE\";\"FALSE\";\"ZERO\""));
 
         // Explicit Scientific format does need E+
-        assertEquals("1E+05", formatter.formatRawCellContents(1e05, 170, 
+        assertEquals("1E+05", formatter.formatRawCellContents(1e05, 170,
                        "0E+00"));
-        assertEquals("1E+10", formatter.formatRawCellContents(1e10, 170, 
+        assertEquals("1E+10", formatter.formatRawCellContents(1e10, 170,
                        "0E+00"));
-        assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170, 
+        assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170,
                       "0E+00"));
-        
+
         // Large numbers with "General" need E+
         assertEquals("100000", formatter.formatRawCellContents(1e05, -1, "General"));
         assertEquals("1E+12", formatter.formatRawCellContents(1e12, -1, "General"));
@@ -1001,20 +1002,20 @@ public class TestDataFormatter {
         // Less common Scientific-like formats which don't ask for
         //  the + on >1 exponentials don't need it adding
         // (Java will put the -ve ones in for E-## automatically)
-        assertEquals("1E5", formatter.formatRawCellContents(1e05, 170, 
+        assertEquals("1E5", formatter.formatRawCellContents(1e05, 170,
                        "0E0"));
-        assertEquals("1E10", formatter.formatRawCellContents(1e10, 170, 
+        assertEquals("1E10", formatter.formatRawCellContents(1e10, 170,
                        "0E0"));
-        assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170, 
+        assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170,
                        "0E0"));
 
-        assertEquals("1E5", formatter.formatRawCellContents(1e05, 170, 
+        assertEquals("1E5", formatter.formatRawCellContents(1e05, 170,
                        "0E-0"));
-        assertEquals("1E10", formatter.formatRawCellContents(1e10, 170, 
+        assertEquals("1E10", formatter.formatRawCellContents(1e10, 170,
                        "0E-0"));
-        assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170, 
+        assertEquals("1E-10", formatter.formatRawCellContents(1e-10, 170,
                        "0E-0"));
-        
+
     }
 
     private void doFormatTestSequential(DataFormatter formatter) {
@@ -1052,7 +1053,7 @@ public class TestDataFormatter {
         int formatIndex = 105;
         String formatString = "[$-F400]m/d/yy h:mm:ss\\ AM/PM;[$-F400]m/d/yy h:mm:ss\\ AM/PM;_-* \"\"??_-;_-@_-";
         String actual = formatter.formatRawCellContents(n, formatIndex, formatString);
-        assertEquals("Failed on iteration " + iteration, expected, actual);
+        assertEquals(expected, actual, "Failed on iteration " + iteration);
         return true;
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java [UTF-8] (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java [UTF-8] Thu Dec 24 18:42:29 2020
@@ -24,12 +24,12 @@ import static java.util.Calendar.JULY;
 import static java.util.Calendar.MARCH;
 import static java.util.Calendar.MAY;
 import static java.util.Calendar.OCTOBER;
-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 java.text.ParseException;
@@ -45,21 +45,21 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 public class TestDateUtil {
 
     static TimeZone userTimeZone;
 
-    @BeforeClass
+    @BeforeAll
     public static void setCEST() {
         userTimeZone = LocaleUtil.getUserTimeZone();
         LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CEST"));
     }
 
-    @AfterClass
+    @AfterAll
     public static void resetTimeZone() {
         LocaleUtil.setUserTimeZone(userTimeZone);
     }
@@ -194,12 +194,12 @@ public class TestDateUtil {
         for (int hour = 0; hour < 24; hour++) {
             double excelDate = DateUtil.getExcelDate(cal.getTime(), false);
 
-            assertEquals("getJavaDate: Checking hour = " + hour, cal.getTime().getTime(),
-                    DateUtil.getJavaDate(excelDate, false).getTime());
+            assertEquals(cal.getTime().getTime(), DateUtil.getJavaDate(excelDate, false).getTime(),
+                "getJavaDate: Checking hour = " + hour);
 
             LocalDateTime ldt = LocalDateTime.ofInstant(cal.toInstant(), cal.getTimeZone().toZoneId());
-            assertEquals("getLocalDateTime: Checking hour = " + hour, ldt,
-                    DateUtil.getLocalDateTime(excelDate, false));
+            assertEquals(ldt, DateUtil.getLocalDateTime(excelDate, false),
+                "getLocalDateTime: Checking hour = " + hour);
 
             cal.add(Calendar.HOUR_OF_DAY, 1);
         }
@@ -214,21 +214,17 @@ public class TestDateUtil {
         cal.add(Calendar.DATE,1); // now Jan. 2, 2004
         Date dateIf1904 = cal.getTime();
         // 1900 windowing
-        assertEquals("Checking 1900 Date Windowing",
-                dateIf1900.getTime(),
-                DateUtil.getJavaDate(excelDate,false).getTime());
+        assertEquals(dateIf1900.getTime(), DateUtil.getJavaDate(excelDate,false).getTime(),
+            "Checking 1900 Date Windowing");
         // 1904 windowing
-        assertEquals("Checking 1904 Date Windowing",
-                dateIf1904.getTime(),
-                DateUtil.getJavaDate(excelDate,true).getTime());
+        assertEquals(dateIf1904.getTime(), DateUtil.getJavaDate(excelDate,true).getTime(),
+            "Checking 1904 Date Windowing");
         // 1900 windowing (LocalDateTime)
-        assertEquals("Checking 1900 Date Windowing",
-                LocalDateTime.of(2000,1,1,0,0),
-                DateUtil.getLocalDateTime(excelDate,false));
+        assertEquals(LocalDateTime.of(2000,1,1,0,0), DateUtil.getLocalDateTime(excelDate,false),
+            "Checking 1900 Date Windowing");
         // 1904 windowing (LocalDateTime)
-        assertEquals("Checking 1904 Date Windowing",
-                LocalDateTime.of(2004,1,2,0,0),
-                DateUtil.getLocalDateTime(excelDate,true));
+        assertEquals(LocalDateTime.of(2004,1,2,0,0), DateUtil.getLocalDateTime(excelDate,true),
+            "Checking 1904 Date Windowing");
     }
 
     /**
@@ -252,12 +248,9 @@ public class TestDateUtil {
             double difference = excelDate - Math.floor(excelDate);
             int differenceInHours = (int) (difference * 24 * 60 + 0.5) / 60;
 
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time start date",
-                    hour,
-                    differenceInHours);
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time start date",
-                    javaDate.getTime(),
-                    DateUtil.getJavaDate(excelDate, false).getTime());
+            assertEquals(hour, differenceInHours, "Checking " + hour + " hour on Daylight Saving Time start date");
+            assertEquals(javaDate.getTime(), DateUtil.getJavaDate(excelDate, false).getTime(),
+                "Checking " + hour + " hour on Daylight Saving Time start date");
 
             // perform the same checks with LocalDateTime
             LocalDateTime localDate = LocalDateTime.of(2004,3,28,hour,0,0);
@@ -265,12 +258,10 @@ public class TestDateUtil {
             double differenceLocalDate = excelLocalDate - Math.floor(excelLocalDate);
             int differenceLocalDateInHours = (int) (differenceLocalDate * 24 * 60 + 0.5) / 60;
 
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time start date (LocalDateTime)",
-                    hour,
-                    differenceLocalDateInHours);
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time start date (LocalDateTime)",
-                    localDate,
-                    DateUtil.getLocalDateTime(excelLocalDate, false));
+            assertEquals(hour, differenceLocalDateInHours,
+                "Checking " + hour + " hour on Daylight Saving Time start date (LocalDateTime)");
+            assertEquals(localDate, DateUtil.getLocalDateTime(excelLocalDate, false),
+                "Checking " + hour + " hour on Daylight Saving Time start date (LocalDateTime)");
         }
     }
 
@@ -295,15 +286,15 @@ public class TestDateUtil {
             cal.set(Calendar.HOUR_OF_DAY, hour);
             Date javaDate = DateUtil.getJavaDate(excelDate, false);
             double actDate = DateUtil.getExcelDate(javaDate, false);
-            assertEquals("Checking " + hour + " hours on Daylight Saving Time start date",
-                    excelDate, actDate, oneMinute);
+            assertEquals(excelDate, actDate, oneMinute,
+                "Checking " + hour + " hours on Daylight Saving Time start date");
 
             // perform the same check with LocalDateTime
             cal.set(Calendar.HOUR_OF_DAY, hour);
             LocalDateTime localDate = DateUtil.getLocalDateTime(excelDate, false);
             double actLocalDate = DateUtil.getExcelDate(localDate, false);
-            assertEquals("Checking " + hour + " hours on Daylight Saving Time start date (LocalDateTime)",
-                    excelDate, actLocalDate, oneMinute);
+            assertEquals(excelDate, actLocalDate, oneMinute,
+                "Checking " + hour + " hours on Daylight Saving Time start date (LocalDateTime)");
         }
     }
 
@@ -320,23 +311,19 @@ public class TestDateUtil {
             double excelDate = DateUtil.getExcelDate(javaDate, false);
             double difference = excelDate - Math.floor(excelDate);
             int differenceInHours = (int) (difference * 24 * 60 + 0.5) / 60;
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time end date",
-                    hour,
-                    differenceInHours);
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time start date",
-                    javaDate.getTime(),
-                    DateUtil.getJavaDate(excelDate, false).getTime());
+            assertEquals(hour, differenceInHours,
+                "Checking " + hour + " hour on Daylight Saving Time end date");
+            assertEquals(javaDate.getTime(), DateUtil.getJavaDate(excelDate, false).getTime(),
+                "Checking " + hour + " hour on Daylight Saving Time start date");
 
             // perform the same checks using LocalDateTime
             LocalDateTime localDate = LocalDateTime.of(2004,10,31,hour,0,0);
             double excelLocalDate = DateUtil.getExcelDate(localDate, false);
             int differenceLocalDateInHours = (int) (difference * 24 * 60 + 0.5) / 60;
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time end date (LocalDateTime)",
-                    hour,
-                    differenceLocalDateInHours);
-            assertEquals("Checking " + hour + " hour on Daylight Saving Time start date (LocalDateTime)",
-                    localDate,
-                    DateUtil.getLocalDateTime(excelLocalDate, false));
+            assertEquals(hour, differenceLocalDateInHours,
+                "Checking " + hour + " hour on Daylight Saving Time end date (LocalDateTime)");
+            assertEquals(localDate, DateUtil.getLocalDateTime(excelLocalDate, false),
+                "Checking " + hour + " hour on Daylight Saving Time start date (LocalDateTime)");
         }
     }
 
@@ -353,15 +340,13 @@ public class TestDateUtil {
         for (int hour = 0; hour < 24; hour++, excelDate += oneHour) {
             cal.set(Calendar.HOUR_OF_DAY, hour);
             Date javaDate = DateUtil.getJavaDate(excelDate, false);
-            assertEquals("Checking " + hour + " hours on Daylight Saving Time start date",
-                    excelDate,
-                    DateUtil.getExcelDate(javaDate, false), oneMinute);
+            assertEquals(excelDate, DateUtil.getExcelDate(javaDate, false), oneMinute,
+                "Checking " + hour + " hours on Daylight Saving Time start date");
 
             // perform the same checks using LocalDateTime
             LocalDateTime localDate = DateUtil.getLocalDateTime(excelDate, false);
-            assertEquals("Checking " + hour + " hours on Daylight Saving Time start date",
-                    excelDate,
-                    DateUtil.getExcelDate(localDate, false), oneMinute);
+            assertEquals(excelDate, DateUtil.getExcelDate(localDate, false), oneMinute,
+                "Checking " + hour + " hours on Daylight Saving Time start date");
         }
     }
 
@@ -386,7 +371,7 @@ public class TestDateUtil {
                 Date javaDate = DateUtil.getJavaDate(excelDate);
 
                 // Should match despite time-zone
-                assertEquals("Checking timezone " + id, expected.getTime(), javaDate.getTime());
+                assertEquals(expected.getTime(), javaDate.getTime(), "Checking timezone " + id);
             }
 
             // Check that the timezone aware getter works correctly
@@ -398,8 +383,8 @@ public class TestDateUtil {
 
             // Same, no change
             assertEquals(
-                    DateUtil.getJavaDate(excelDate, false).getTime(),
-                    DateUtil.getJavaDate(excelDate, false, cet).getTime()
+                DateUtil.getJavaDate(excelDate, false).getTime(),
+                DateUtil.getJavaDate(excelDate, false, cet).getTime()
             );
 
             // London vs Copenhagen, should differ by an hour
@@ -464,10 +449,7 @@ public class TestDateUtil {
                 "[yeLLow]yyyy-mm-dd"
         };
         for (String format : formats) {
-            assertTrue(
-                    format + " is a date format",
-                    DateUtil.isADateFormat(formatId, format)
-            );
+            assertTrue(DateUtil.isADateFormat(formatId, format), format + " is a date format");
         }
 
         // Then time based ones too
@@ -482,10 +464,7 @@ public class TestDateUtil {
                 "[hh]", "[mm]", "[ss]", "[SS]", "[red][hh]"
         };
         for (String format : formats) {
-            assertTrue(
-                    format + " is a datetime format",
-                    DateUtil.isADateFormat(formatId, format)
-            );
+            assertTrue(DateUtil.isADateFormat(formatId, format), format + " is a datetime format");
         }
 
         // Then invalid ones
@@ -498,10 +477,7 @@ public class TestDateUtil {
                 "", null
         };
         for (String format : formats) {
-            assertFalse(
-                    format + " is not a date or datetime format",
-                    DateUtil.isADateFormat(formatId, format)
-            );
+            assertFalse(DateUtil.isADateFormat(formatId, format), format + " is not a date or datetime format");
         }
 
         // And these are ones we probably shouldn't allow,
@@ -624,47 +600,26 @@ public class TestDateUtil {
     public void absoluteDay() {
         // 1 Jan 1900 is 1 day after 31 Dec 1899
         Calendar cal = LocaleUtil.getLocaleCalendar(1900,JANUARY,1,0,0,0);
-        assertEquals("Checking absolute day (1 Jan 1900)", 1, DateUtil.absoluteDay(cal, false));
+        assertEquals(1, DateUtil.absoluteDay(cal, false), "Checking absolute day (1 Jan 1900)");
         LocalDateTime ldt = LocalDateTime.of(1900,1,1,0,0,0);
-        assertEquals("Checking absolute day (1 Jan 1900) (LocalDateTime)", 1, DateUtil.absoluteDay(ldt, false));
+        assertEquals(1, DateUtil.absoluteDay(ldt, false), "Checking absolute day (1 Jan 1900) (LocalDateTime)");
         // 1 Jan 1901 is 366 days after 31 Dec 1899
         ldt = LocalDateTime.of(1901,1,1,0,0,0);
         cal.set(1901,JANUARY,1,0,0,0);
-        assertEquals("Checking absolute day (1 Jan 1901) (LocalDateTime)", 366, DateUtil.absoluteDay(ldt, false));
+        assertEquals(366, DateUtil.absoluteDay(ldt, false), "Checking absolute day (1 Jan 1901) (LocalDateTime)");
     }
 
     @Test
     public void absoluteDayYearTooLow() {
         Calendar cal = LocaleUtil.getLocaleCalendar(1899,JANUARY,1,0,0,0);
-        try {
-            DateUtil.absoluteDay(cal, false);
-            fail("Should fail here");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> DateUtil.absoluteDay(cal, false));
 
-        try {
-            cal.set(1903,JANUARY,1,0,0,0);
-            DateUtil.absoluteDay(cal, true);
-            fail("Should fail here");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        cal.set(1903,JANUARY,1,0,0,0);
+        assertThrows(IllegalArgumentException.class, () -> DateUtil.absoluteDay(cal, true));
 
         // same for LocalDateTime
-        try {
-            DateUtil.absoluteDay(LocalDateTime.of(1899,1,1,0,0,0), false);
-            fail("Should fail here");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
-
-        try {
-            DateUtil.absoluteDay(LocalDateTime.of(1903,1,1,0,0,0), true);
-            fail("Should fail here");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> DateUtil.absoluteDay(LocalDateTime.of(1899,1,1,0,0,0), false));
+        assertThrows(IllegalArgumentException.class, () -> DateUtil.absoluteDay(LocalDateTime.of(1903,1,1,0,0,0), true));
     }
 
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestExcelStyleDateFormatter.java Thu Dec 24 18:42:29 2020
@@ -17,9 +17,9 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.text.DateFormatSymbols;
 import java.text.FieldPosition;
@@ -34,7 +34,7 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestExcelStyleDateFormatter {
     private static final String EXCEL_DATE_FORMAT = "MMMMM";
@@ -77,9 +77,9 @@ public class TestExcelStyleDateFormatter
 
                 int actIdx = localeIndex(locale);
 
-                assertNotNull(msg, result);
-                assertTrue(msg, result.length() > actIdx);
-                assertEquals(msg, expected.charAt(month), result.charAt(actIdx));
+                assertNotNull(result, msg);
+                assertTrue(result.length() > actIdx, msg);
+                assertEquals(expected.charAt(month), result.charAt(actIdx), msg);
                 month++;
             }
         }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestFractionFormat.java Thu Dec 24 18:42:29 2020
@@ -17,7 +17,8 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -27,8 +28,8 @@ import java.io.InputStreamReader;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for the Fraction Formatting part of DataFormatter.
@@ -43,15 +44,12 @@ public final class TestFractionFormat {
         assertEquals("26027/81", ret);
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void testInvalid() {
-        FractionFormat f = new FractionFormat("", "9999999999999999999999999999");
-        double val = 321.321;
-        String ret = f.format(val);
-        assertEquals("26027/81", ret);
+        assertThrows(IllegalStateException.class, () -> new FractionFormat("", "9999999999999999999999999999"));
     }
 
-    @Ignore("Runs for some longer time")
+    @Disabled("Runs for some longer time")
     @Test
     public void microBenchmark() {
         FractionFormat f = new FractionFormat("", "##");
@@ -105,7 +103,7 @@ public final class TestFractionFormat {
 
                     String truth = clean(truths[j]);
                     String testKey = truths[0] + ":" + truths[1] + ":" + headers[j];
-                    assertEquals(testKey, truth, formatted);
+                    assertEquals(truth, formatted, testKey);
                 }
                 truthLine = reader.readLine();
             }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestIndexedColors.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestIndexedColors.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestIndexedColors.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestIndexedColors.java Thu Dec 24 18:42:29 2020
@@ -17,10 +17,10 @@
 
 package org.apache.poi.ss.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Yegor Kozlov
@@ -31,24 +31,18 @@ public final class TestIndexedColors {
     public void fromInt() {
         int[] illegalIndices = { -1, 65 };
         for (int index : illegalIndices) {
-            try {
-                IndexedColors.fromInt(index);
-                fail("Expected IllegalArgumentException: " + index);
-            }
-            catch (final IllegalArgumentException e) {
-                // expected
-            }
+            assertThrows(IllegalArgumentException.class, () -> IndexedColors.fromInt(index));
         }
         assertEquals(IndexedColors.BLACK, IndexedColors.fromInt(8));
         assertEquals(IndexedColors.GOLD, IndexedColors.fromInt(51));
         assertEquals(IndexedColors.AUTOMATIC, IndexedColors.fromInt(64));
     }
-    
+
     @Test
     public void getIndex() {
         assertEquals(51, IndexedColors.GOLD.getIndex());
     }
-    
+
     @Test
     public void index() {
         assertEquals(51, IndexedColors.GOLD.index);



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