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 [27/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/hssf/usermodel/TestRowStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java Thu Dec 24 18:42:29 2020
@@ -18,14 +18,14 @@
 package org.apache.poi.hssf.usermodel;
 
 import static org.apache.poi.hssf.HSSFTestDataSamples.writeOutAndReadBack;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
 
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.FillPatternType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test row styling functionality
@@ -58,8 +58,8 @@ public final class TestRowStyle {
             try (HSSFWorkbook wb2 = writeOutAndReadBack(wb)) {
                 SanityChecker sanityChecker = new SanityChecker();
                 sanityChecker.checkHSSFWorkbook(wb2);
-                assertEquals("LAST ROW == 99", 99, s.getLastRowNum());
-                assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum());
+                assertEquals(99, s.getLastRowNum(), "LAST ROW == 99");
+                assertEquals(0, s.getFirstRowNum(), "FIRST ROW == 0");
             }
         }
     }
@@ -90,8 +90,8 @@ public final class TestRowStyle {
                 SanityChecker sanityChecker = new SanityChecker();
                 sanityChecker.checkHSSFWorkbook(wb2);
 
-                assertEquals("LAST ROW ", 1, s.getLastRowNum());
-                assertEquals("FIRST ROW ", 0, s.getFirstRowNum());
+                assertEquals(1, s.getLastRowNum(), "LAST ROW");
+                assertEquals(0, s.getFirstRowNum(), "FIRST ROW");
             }
         }
     }
@@ -109,7 +109,6 @@ public final class TestRowStyle {
     public void testWriteSheetStyle() throws IOException {
         try (HSSFWorkbook wb = new HSSFWorkbook()) {
             HSSFSheet s = wb.createSheet();
-            HSSFRow r = null;
             HSSFFont fnt = wb.createFont();
             HSSFCellStyle cs = wb.createCellStyle();
             HSSFCellStyle cs2 = wb.createCellStyle();
@@ -126,7 +125,7 @@ public final class TestRowStyle {
             cs2.setFillPattern(FillPatternType.BRICKS);
             cs2.setFont(fnt);
             for (int rownum = 0; rownum < 100; rownum++) {
-                r = s.createRow(rownum);
+                HSSFRow r = s.createRow(rownum);
                 r.setRowStyle(cs);
                 r.createCell(0);
 
@@ -140,34 +139,34 @@ public final class TestRowStyle {
             try (HSSFWorkbook wb2 = writeOutAndReadBack(wb)) {
                 SanityChecker sanityChecker = new SanityChecker();
                 sanityChecker.checkHSSFWorkbook(wb2);
-                assertEquals("LAST ROW == 99", 99, s.getLastRowNum());
-                assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum());
+                assertEquals(99, s.getLastRowNum(), "LAST ROW == 99");
+                assertEquals(0, s.getFirstRowNum(), "FIRST ROW == 0");
 
                 s = wb2.getSheetAt(0);
-                assertNotNull("Sheet is not null", s);
+                assertNotNull(s, "Sheet is not null");
 
                 for (int rownum = 0; rownum < 100; rownum++) {
-                    r = s.getRow(rownum);
-                    assertNotNull("Row is not null", r);
+                    HSSFRow r = s.getRow(rownum);
+                    assertNotNull(r, "Row is not null");
 
                     cs = r.getRowStyle();
                     assertNotNull(cs);
-                    assertEquals("Bottom Border Style for row:", BorderStyle.THIN, cs.getBorderBottom());
-                    assertEquals("Left Border Style for row:", BorderStyle.THIN, cs.getBorderLeft());
-                    assertEquals("Right Border Style for row:", BorderStyle.THIN, cs.getBorderRight());
-                    assertEquals("Top Border Style for row:", BorderStyle.THIN, cs.getBorderTop());
-                    assertEquals("FillForegroundColor for row:", 0xA, cs.getFillForegroundColor());
-                    assertEquals("FillPattern for row:", FillPatternType.BRICKS, cs.getFillPattern());
+                    assertEquals(BorderStyle.THIN, cs.getBorderBottom(), "Bottom Border Style for row:");
+                    assertEquals(BorderStyle.THIN, cs.getBorderLeft(), "Left Border Style for row:");
+                    assertEquals(BorderStyle.THIN, cs.getBorderRight(), "Right Border Style for row:");
+                    assertEquals(BorderStyle.THIN, cs.getBorderTop(), "Top Border Style for row:");
+                    assertEquals(0xA, cs.getFillForegroundColor(), "FillForegroundColor for row:");
+                    assertEquals(FillPatternType.BRICKS, cs.getFillPattern(), "FillPattern for row:");
 
                     rownum++;
                     if (rownum >= 100) break; // I feel too lazy to check if this isreqd :-/
 
                     r = s.getRow(rownum);
-                    assertNotNull("Row is not null", r);
+                    assertNotNull(r, "Row is not null");
                     cs2 = r.getRowStyle();
                     assertNotNull(cs2);
-                    assertEquals("FillForegroundColor for row: ", cs2.getFillForegroundColor(), (short) 0x0);
-                    assertEquals("FillPattern for row: ", cs2.getFillPattern(), FillPatternType.BRICKS);
+                    assertEquals(cs2.getFillForegroundColor(), (short) 0x0, "FillForegroundColor for row:");
+                    assertEquals(cs2.getFillPattern(), FillPatternType.BRICKS, "FillPattern for row:");
                 }
             }
         }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSanityChecker.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSanityChecker.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSanityChecker.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSanityChecker.java Thu Dec 24 18:42:29 2020
@@ -17,7 +17,8 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -30,7 +31,7 @@ import org.apache.poi.hssf.record.Interf
 import org.apache.poi.hssf.record.NameRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.usermodel.SanityChecker.CheckRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * A Test case for a test utility class.<br>
@@ -43,7 +44,7 @@ public final class TestSanityChecker {
 	private static BoundSheetRecord createBoundSheetRec() {
 		return new BoundSheetRecord("Sheet1");
 	}
-	
+
 	@Test
 	public void testCheckRecordOrder() {
 		final SanityChecker c = new SanityChecker();
@@ -119,20 +120,10 @@ public final class TestSanityChecker {
 				EOFRecord.instance,
 		});
 	}
+
 	private static void confirmBadRecordOrder(final SanityChecker.CheckRecord[] check, Record[] recs) {
 		final SanityChecker c = new SanityChecker();
 		final List<org.apache.poi.hssf.record.Record> records = Arrays.asList(recs);
-		try {
-			new Runnable() {
-				@Override
-                public void run() {
-					c.checkRecordOrder(records, check);
-				}
-			}.run();
-		} catch (AssertionError pass) {
-			// expected during normal test
-			return;
-		}
-		fail("Did not get failure exception as expected");
+		assertThrows(AssertionError.class, () -> c.checkRecordOrder(records, check));
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestShapeGroup.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestShapeGroup.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestShapeGroup.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestShapeGroup.java Thu Dec 24 18:42:29 2020
@@ -17,9 +17,9 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
@@ -28,7 +28,7 @@ import org.apache.poi.ddf.EscherContaine
 import org.apache.poi.ddf.EscherSpgrRecord;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.record.EscherAggregate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestShapeGroup {
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java Thu Dec 24 18:42:29 2020
@@ -21,12 +21,13 @@ import org.apache.poi.hssf.HSSFITestData
 import org.apache.poi.hssf.model.InternalWorkbook;
 import org.apache.poi.ss.usermodel.BaseTestSheetHiding;
 import org.apache.poi.ss.usermodel.SheetVisibility;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-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 static org.junit.jupiter.api.Assertions.fail;
 
 public final class TestSheetHiding extends BaseTestSheetHiding {
     public TestSheetHiding() {
@@ -60,11 +61,6 @@ public final class TestSheetHiding exten
         assertEquals(SheetVisibility.HIDDEN, intWb.getSheetVisibility(1));
 
         // check sheet-index with index out of bounds => throws exception
-        try {
-            wb.setSheetVisibility(10, SheetVisibility.HIDDEN);
-            fail("Should catch exception here");
-        } catch (RuntimeException e) {
-            // expected here
-        }
+        assertThrows(RuntimeException.class, () -> wb.setSheetVisibility(10, SheetVisibility.HIDDEN));
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java Thu Dec 24 18:42:29 2020
@@ -18,15 +18,15 @@
 package org.apache.poi.hssf.usermodel;
 
 import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.record.ObjRecord;
 import org.apache.poi.hssf.record.TextObjectRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Evgeniy Berlog
@@ -75,7 +75,7 @@ public class TestText {
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
-        
+
         TextObjectRecord tor = textbox.getTextObjectRecord();
 
         expected = decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");
@@ -83,7 +83,7 @@ public class TestText {
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
-        
+
         wb.close();
     }
 
@@ -118,7 +118,7 @@ public class TestText {
         assertEquals(((HSSFTextbox) patriarch.getChildren().get(0)).getString().getString(), "just for test");
         assertEquals(((HSSFTextbox) patriarch.getChildren().get(1)).getString().getString(), "just for test2");
         assertEquals(((HSSFTextbox) patriarch.getChildren().get(2)).getString().getString(), "text3");
-        
+
         wb3.close();
     }
 
@@ -191,7 +191,7 @@ public class TestText {
         assertEquals(textbox.getMarginLeft(), 81);
         assertEquals(textbox.getMarginRight(), 91);
         assertEquals(textbox.getMarginTop(), 101);
-        
+
         wb3.close();
     }
 

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

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestUnicodeWorkbook.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestUnicodeWorkbook {
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java Thu Dec 24 18:42:29 2020
@@ -23,13 +23,12 @@ import org.apache.poi.hssf.HSSFTestDataS
 import org.apache.poi.hssf.model.InternalWorkbook;
 import org.apache.poi.hssf.record.BackupRecord;
 import org.apache.poi.hssf.record.LabelSSTRecord;
-import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Class to test Workbook functionality
@@ -62,23 +61,22 @@ public final class TestWorkbook {
      */
     @Test
     public void testWriteSheetSimple() throws IOException {
-        HSSFWorkbook wb1  = new HSSFWorkbook();
-        HSSFSheet s = wb1.createSheet();
-
-        populateSheet(s);
+        try (HSSFWorkbook wb1  = new HSSFWorkbook()) {
+            HSSFSheet s = wb1.createSheet();
 
-        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
-        
-        sanityChecker.checkHSSFWorkbook(wb1);
-        assertEquals("LAST ROW == 99", 99, s.getLastRowNum());
-        assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum());
+            populateSheet(s);
 
-        sanityChecker.checkHSSFWorkbook(wb2);
-        s = wb2.getSheetAt(0);
-        assertEquals("LAST ROW == 99", 99, s.getLastRowNum());
-        assertEquals("FIRST ROW == 0", 0, s.getFirstRowNum());
-        wb2.close();
-        wb1.close();
+            try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
+                sanityChecker.checkHSSFWorkbook(wb1);
+                assertEquals(99, s.getLastRowNum(), "LAST ROW == 99");
+                assertEquals(0, s.getFirstRowNum(), "FIRST ROW == 0");
+
+                sanityChecker.checkHSSFWorkbook(wb2);
+                s = wb2.getSheetAt(0);
+                assertEquals(99, s.getLastRowNum(), "LAST ROW == 99");
+                assertEquals(0, s.getFirstRowNum(), "FIRST ROW == 0");
+            }
+        }
     }
 
     /**
@@ -107,16 +105,16 @@ public final class TestWorkbook {
         }
 
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
-        
+
         sanityChecker.checkHSSFWorkbook(wb1);
-        assertEquals("LAST ROW == 74", 74, s.getLastRowNum());
-        assertEquals("FIRST ROW == 25", 25, s.getFirstRowNum());
+        assertEquals(74, s.getLastRowNum(), "LAST ROW == 74");
+        assertEquals(25, s.getFirstRowNum(), "FIRST ROW == 25");
 
         sanityChecker.checkHSSFWorkbook(wb2);
         s = wb2.getSheetAt(0);
-        assertEquals("LAST ROW == 74", 74, s.getLastRowNum());
-        assertEquals("FIRST ROW == 25", 25, s.getFirstRowNum());
-    
+        assertEquals(74, s.getLastRowNum(), "LAST ROW == 74");
+        assertEquals(25, s.getFirstRowNum(), "FIRST ROW == 25");
+
         wb2.close();
         wb1.close();
     }
@@ -155,7 +153,7 @@ public final class TestWorkbook {
         assertEquals(1.25,cell.getNumericCellValue(), 1e-10);
 
         assertEquals(format.getFormat(cell.getCellStyle().getDataFormat()), "0.0");
-        
+
         wb.close();
     }
 
@@ -214,7 +212,7 @@ public final class TestWorkbook {
         assertEquals(LAST_NAME_KEY, sheet.getRow(3).getCell(2).getRichStringCellValue().getString());
         assertEquals(FIRST_NAME_KEY, sheet.getRow(4).getCell(2).getRichStringCellValue().getString());
         assertEquals(SSN_KEY, sheet.getRow(5).getCell(2).getRichStringCellValue().getString());
-        
+
         wb.close();
     }
 
@@ -241,7 +239,7 @@ public final class TestWorkbook {
         sheet    = wb2.getSheetAt(0);
         cell     = sheet.getRow(0).getCell(0);
         assertEquals(REPLACED, cell.getRichStringCellValue().getString());
-        
+
         wb2.close();
         wb1.close();
     }
@@ -279,7 +277,7 @@ public final class TestWorkbook {
         assertEquals(REPLACED, cell.getRichStringCellValue().getString());
         cell = sheet.getRow(1).getCell(1);
         assertEquals(DO_NOT_REPLACE, cell.getRichStringCellValue().getString());
-        
+
         wb2.close();
         wb1.close();
     }
@@ -312,7 +310,7 @@ public final class TestWorkbook {
             HSSFCell cell = sheet.getRow(k).getCell(0);
             assertEquals(REPLACED, cell.getRichStringCellValue().getString());
         }
-        
+
         wb2.close();
         wb1.close();
     }
@@ -347,7 +345,7 @@ public final class TestWorkbook {
         assertEquals(LAST_NAME_VALUE, sheet.getRow(3).getCell(2).getRichStringCellValue().getString());
         assertEquals(FIRST_NAME_VALUE, sheet.getRow(4).getCell(2).getRichStringCellValue().getString());
         assertEquals(SSN_VALUE, sheet.getRow(5).getCell(2).getRichStringCellValue().getString());
-        
+
         wb2.close();
         wb1.close();
     }
@@ -366,7 +364,7 @@ public final class TestWorkbook {
         HSSFCell     c  = s.getRow(0).getCell(0);
 
         assertEquals(CellType.NUMERIC, c.getCellType());
-        
+
         wb.close();
     }
 
@@ -442,7 +440,7 @@ public final class TestWorkbook {
         wb.setBackupFlag(false);
         assertEquals(0, record.getBackup());
         assertFalse(wb.getBackupFlag());
-        
+
         wb.close();
     }
 
@@ -482,7 +480,7 @@ public final class TestWorkbook {
         RecordCounter rc = new RecordCounter();
         sheet.getSheet().visitContainedRecords(rc, 0);
         assertEquals(1, rc.getCount());
-        
+
         workbook.close();
     }
 
@@ -503,7 +501,7 @@ public final class TestWorkbook {
             cell.setCellValue(i);
         }
         sanityChecker.checkHSSFWorkbook(wb1);
-        assertEquals("LAST ROW == 32770", 32770, sheet.getLastRowNum());
+        assertEquals(32770, sheet.getLastRowNum(), "LAST ROW == 32770");
         cell = sheet.getRow(32770).getCell(0);
         double lastVal = cell.getNumericCellValue();
 
@@ -511,9 +509,9 @@ public final class TestWorkbook {
         HSSFSheet       s    = wb2.getSheetAt(0);
         row = s.getRow(32770);
         cell = row.getCell(0);
-        assertEquals("Value from last row == 32770", lastVal, cell.getNumericCellValue(), 0);
-        assertEquals("LAST ROW == 32770", 32770, s.getLastRowNum());
-        
+        assertEquals(lastVal, cell.getNumericCellValue(), 0, "Value from last row == 32770");
+        assertEquals(32770, s.getLastRowNum(), "LAST ROW == 32770");
+
         wb2.close();
         wb1.close();
     }
@@ -539,7 +537,7 @@ public final class TestWorkbook {
         sheet = wb2.getSheetAt(0);
         assertEquals("A:B", sheet.getRepeatingColumns().formatAsString());
         assertEquals("1:1", sheet.getRepeatingRows().formatAsString());
-        
+
         wb2.close();
         wb1.close();
     }
@@ -558,25 +556,14 @@ public final class TestWorkbook {
         HSSFCell cell = row.createCell(1);
         cell.setCellValue(new HSSFRichTextString("hi"));
         CellRangeAddress cra = new CellRangeAddress(-1, 1, -1, 1);
-        try {
-            sheet.setRepeatingColumns(cra);
-            fail("invalid start index is ignored");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
-        
-        try {
-            sheet.setRepeatingRows(cra);
-            fail("invalid start index is ignored");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> sheet.setRepeatingColumns(cra), "invalid start index is ignored");
+        assertThrows(IllegalArgumentException.class, () -> sheet.setRepeatingRows(cra), "invalid start index is ignored");
 
         sheet.setRepeatingColumns(null);
         sheet.setRepeatingRows(null);
-        
+
         HSSFTestDataSamples.writeOutAndReadBack(workbook).close();
-        
+
         workbook.close();
     }
 
@@ -590,12 +577,12 @@ public final class TestWorkbook {
         sheet1.createRow(0).createCell((short) 0).setCellValue("val1");
         sheet2.createRow(0).createCell((short) 0).setCellValue("val2");
         sheet3.createRow(0).createCell((short) 0).setCellValue("val3");
-        
+
         Name namedCell1 = wb1.createName();
         namedCell1.setNameName("name1");
         String reference1 = "sheet1!$A$1";
         namedCell1.setRefersToFormula(reference1);
-        
+
         Name namedCell2= wb1.createName();
         namedCell2.setNameName("name2");
         String reference2 = "sheet2!$A$1";
@@ -608,23 +595,29 @@ public final class TestWorkbook {
 
         Workbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
         wb1.close();
-        
+
         Name nameCell = wb2.getName("name1");
+        assertNotNull(nameCell);
         assertEquals("sheet1!$A$1", nameCell.getRefersToFormula());
         nameCell = wb2.getName("name2");
+        assertNotNull(nameCell);
         assertEquals("sheet2!$A$1", nameCell.getRefersToFormula());
         nameCell = wb2.getName("name3");
+        assertNotNull(nameCell);
         assertEquals("sheet3!$A$1", nameCell.getRefersToFormula());
-        
+
         wb2.removeSheetAt(wb2.getSheetIndex("sheet1"));
-        
+
         nameCell = wb2.getName("name1");
+        assertNotNull(nameCell);
         assertEquals("#REF!$A$1", nameCell.getRefersToFormula());
         nameCell = wb2.getName("name2");
+        assertNotNull(nameCell);
         assertEquals("sheet2!$A$1", nameCell.getRefersToFormula());
         nameCell = wb2.getName("name3");
+        assertNotNull(nameCell);
         assertEquals("sheet3!$A$1", nameCell.getRefersToFormula());
-        
+
         wb2.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/util/TestAreaReference.java Thu Dec 24 18:42:29 2020
@@ -17,12 +17,12 @@
 
 package org.apache.poi.hssf.util;
 
-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.InputStream;
 
@@ -44,27 +44,27 @@ import org.apache.poi.ss.formula.ptg.Ptg
 import org.apache.poi.ss.formula.ptg.UnionPtg;
 import org.apache.poi.ss.util.AreaReference;
 import org.apache.poi.ss.util.CellReference;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestAreaReference {
 
     @Test
     public void testAreaRef1() {
         AreaReference ar = new AreaReference("$A$1:$B$2", SpreadsheetVersion.EXCEL97);
-        assertFalse("Two cells expected", ar.isSingleCell());
+        assertFalse(ar.isSingleCell(), "Two cells expected");
         CellReference cf = ar.getFirstCell();
-        assertEquals("row is 4", 0, cf.getRow());
-        assertEquals("col is 1", 0, cf.getCol());
-        assertTrue("row is abs", cf.isRowAbsolute());
-        assertTrue("col is abs", cf.isColAbsolute());
-        assertEquals("string is $A$1", "$A$1", cf.formatAsString());
+        assertEquals(0, cf.getRow(), "row is 4");
+        assertEquals(0, cf.getCol(), "col is 1");
+        assertTrue(cf.isRowAbsolute(), "row is abs");
+        assertTrue(cf.isColAbsolute(), "col is abs");
+        assertEquals("$A$1", cf.formatAsString(), "string is $A$1");
 
         cf = ar.getLastCell();
-        assertEquals("row is 4", 1, cf.getRow());
-        assertEquals("col is 1", 1, cf.getCol());
-        assertTrue("row is abs", cf.isRowAbsolute());
-        assertTrue("col is abs", cf.isColAbsolute());
-        assertEquals("string is $B$2", "$B$2", cf.formatAsString());
+        assertEquals(1, cf.getRow(), "row is 4");
+        assertEquals(1, cf.getCol(), "col is 1");
+        assertTrue(cf.isRowAbsolute(), "row is abs");
+        assertTrue(cf.isColAbsolute(), "col is abs");
+        assertEquals("$B$2", cf.formatAsString(), "string is $B$2");
 
         CellReference[] refs = ar.getAllReferencedCells();
         assertEquals(4, refs.length);
@@ -136,24 +136,9 @@ public final class TestAreaReference {
         // Check we can only create contiguous entries
         new AreaReference(refSimple, SpreadsheetVersion.EXCEL97);
         new AreaReference(ref2D, SpreadsheetVersion.EXCEL97);
-        try {
-            new AreaReference(refDCSimple, SpreadsheetVersion.EXCEL97);
-            fail("expected IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected during successful test
-        }
-        try {
-            new AreaReference(refDC2D, SpreadsheetVersion.EXCEL97);
-            fail("expected IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected during successful test
-        }
-        try {
-            new AreaReference(refDC3D, SpreadsheetVersion.EXCEL97);
-            fail("expected IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected during successful test
-        }
+        assertThrows(IllegalArgumentException.class, () -> new AreaReference(refDCSimple, SpreadsheetVersion.EXCEL97));
+        assertThrows(IllegalArgumentException.class, () -> new AreaReference(refDC2D, SpreadsheetVersion.EXCEL97));
+        assertThrows(IllegalArgumentException.class, () -> new AreaReference(refDC3D, SpreadsheetVersion.EXCEL97));
 
         // Test that we split as expected
         AreaReference[] refs;
@@ -251,6 +236,7 @@ public final class TestAreaReference {
             HSSFName aNamedCell = wb.getName("test");
 
             // Should have 2 references
+            assertNotNull(aNamedCell);
             String formulaRefs = aNamedCell.getRefersToFormula();
             assertNotNull(formulaRefs);
             assertEquals(ref, formulaRefs);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/util/TestCellReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/util/TestCellReference.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/util/TestCellReference.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/util/TestCellReference.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hssf.util;
 
-import org.junit.Test;
-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.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.ss.util.CellReference.NameType;
-import org.apache.poi.ss.SpreadsheetVersion;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for the HSSF and SS versions of CellReference.
@@ -41,7 +41,7 @@ public final class TestCellReference {
         assertEquals(701, CellReference.convertColStringToIndex("ZZ"));
         assertEquals(702, CellReference.convertColStringToIndex("AAA"));
         assertEquals(18277, CellReference.convertColStringToIndex("ZZZ"));
-        
+
         assertEquals("A", CellReference.convertNumToColString(0));
         assertEquals("B", CellReference.convertNumToColString(1));
         assertEquals("Z", CellReference.convertNumToColString(25));
@@ -49,19 +49,15 @@ public final class TestCellReference {
         assertEquals("ZZ", CellReference.convertNumToColString(701));
         assertEquals("AAA", CellReference.convertNumToColString(702));
         assertEquals("ZZZ", CellReference.convertNumToColString(18277));
-        
+
         // Absolute references are allowed for the string ones
         assertEquals(0, CellReference.convertColStringToIndex("$A"));
         assertEquals(25, CellReference.convertColStringToIndex("$Z"));
         assertEquals(26, CellReference.convertColStringToIndex("$AA"));
-        
+
         // $ sign isn't allowed elsewhere though
-        try {
-            CellReference.convertColStringToIndex("A$B$");
-            fail("Column reference is invalid and shouldn't be accepted");
-        } catch (IllegalArgumentException e) {
-            // expected here
-        }
+        assertThrows(IllegalArgumentException.class, () -> CellReference.convertColStringToIndex("A$B$"),
+            "Column reference is invalid and shouldn't be accepted");
     }
 
     @Test
@@ -129,11 +125,11 @@ public final class TestCellReference {
             int expCol, boolean expIsRowAbs, boolean expIsColAbs, String expText) {
 
         assertEquals(expSheetName, cf.getSheetName());
-        assertEquals("row index is wrong", expRow, cf.getRow());
-        assertEquals("col index is wrong", expCol, cf.getCol());
-        assertEquals("isRowAbsolute is wrong", expIsRowAbs, cf.isRowAbsolute());
-        assertEquals("isColAbsolute is wrong", expIsColAbs, cf.isColAbsolute());
-        assertEquals("text is wrong", expText, cf.formatAsString());
+        assertEquals(expRow, cf.getRow(), "row index is wrong");
+        assertEquals(expCol, cf.getCol(), "col index is wrong");
+        assertEquals(expIsRowAbs, cf.isRowAbsolute(), "isRowAbsolute is wrong");
+        assertEquals(expIsColAbs, cf.isColAbsolute(), "isColAbsolute is wrong");
+        assertEquals(expText, cf.formatAsString(), "text is wrong");
     }
 
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hssf.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Map;
 
 import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestHSSFColor {
     @Test
@@ -31,7 +31,7 @@ public final class TestHSSFColor {
 		assertTrue(HSSFColorPredefined.YELLOW.getIndex() > 0);
 		assertTrue(HSSFColorPredefined.YELLOW.getIndex2() > 0);
 	}
-	
+
     @Test
 	public void testContents() {
 	    short[] triplet = HSSFColorPredefined.YELLOW.getTriplet();
@@ -39,14 +39,14 @@ public final class TestHSSFColor {
 		assertEquals(255, triplet[0]);
 		assertEquals(255, triplet[1]);
 		assertEquals(0, triplet[2]);
-		
+
 		assertEquals("FFFF:FFFF:0", HSSFColorPredefined.YELLOW.getHexString());
 	}
-	
+
     @Test
 	public void testTripletHash() {
 		Map<String, HSSFColor> triplets = HSSFColor.getTripletHash();
-		
+
 		assertEquals(
 				HSSFColorPredefined.MAROON.getColor(),
 				triplets.get(HSSFColorPredefined.MAROON.getHexString())

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

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestBiff8DecryptingStream.java Thu Dec 24 18:42:29 2020
@@ -17,9 +17,9 @@
 
 package org.apache.poi.poifs.crypt;
 
-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.InputStream;
 
@@ -27,7 +27,7 @@ import javax.crypto.spec.SecretKeySpec;
 
 import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream;
 import org.apache.poi.util.HexRead;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link Biff8DecryptingStream}
@@ -118,7 +118,7 @@ public final class TestBiff8DecryptingSt
 			byte[] expData = HexRead.readFromString(expHexData);
 			byte[] actData = new byte[expData.length];
 			_bds.readFully(actData);
-			assertArrayEquals("Data mismatch", expData, actData);
+			assertArrayEquals(expData, actData, "Data mismatch");
 		}
 	}
 
@@ -180,9 +180,9 @@ public final class TestBiff8DecryptingSt
 		Biff8DecryptingStream bds = st.getBDS();
 		int hval = bds.readDataSize();   // unencrypted
 		int nextInt = bds.readInt();
-		assertNotEquals("Indentified bug in key alignment after call to readHeaderUShort()",0x8F534029, nextInt);
+		assertNotEquals(0x8F534029, nextInt, "Indentified bug in key alignment after call to readHeaderUShort()");
 		assertEquals(0x16885243, nextInt);
-		assertNotEquals("readHeaderUShort() incorrectly decrypted result", 0x283E, hval);
+		assertNotEquals(0x283E, hval, "readHeaderUShort() incorrectly decrypted result");
 		assertEquals(0x504F, hval);
 
 		// confirm next key change

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestCipherAlgorithm.java Thu Dec 24 18:42:29 2020
@@ -17,16 +17,17 @@
 
 package org.apache.poi.poifs.crypt;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import org.apache.poi.EncryptedDocumentException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestCipherAlgorithm {
     @Test
     public void validInputs() {
         assertEquals(128, CipherAlgorithm.aes128.defaultKeySize);
-        
+
         for(CipherAlgorithm alg : CipherAlgorithm.values()) {
             assertEquals(alg, CipherAlgorithm.valueOf(alg.toString()));
         }
@@ -34,19 +35,11 @@ public class TestCipherAlgorithm {
         assertEquals(CipherAlgorithm.aes128, CipherAlgorithm.fromEcmaId(0x660E));
         assertEquals(CipherAlgorithm.aes192, CipherAlgorithm.fromXmlId("AES", 192));
     }
-    
-    @Test(expected=EncryptedDocumentException.class)
-    public void invalidEcmaId() {
-        CipherAlgorithm.fromEcmaId(0);
-    }
-    
-    @Test(expected=EncryptedDocumentException.class)
-    public void invalidXmlId1() {
-        CipherAlgorithm.fromXmlId("AES", 1);
-    }
-    
-    @Test(expected=EncryptedDocumentException.class)
-    public void invalidXmlId2() {
-        CipherAlgorithm.fromXmlId("RC1", 0x40);
+
+    @Test
+    public void invalidInputs() {
+        assertThrows(EncryptedDocumentException.class, () -> CipherAlgorithm.fromEcmaId(0));
+        assertThrows(EncryptedDocumentException.class, () -> CipherAlgorithm.fromXmlId("AES", 1));
+        assertThrows(EncryptedDocumentException.class, () -> CipherAlgorithm.fromXmlId("RC1", 0x40));
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java Thu Dec 24 18:42:29 2020
@@ -19,7 +19,7 @@ package org.apache.poi.poifs.crypt;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -33,8 +33,8 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.HexRead;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 public class TestXorEncryption {
 
@@ -73,7 +73,7 @@ public class TestXorEncryption {
     }
 
     @Test
-    @Ignore("currently not supported")
+    @Disabled("currently not supported")
     public void encrypt() throws IOException {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         try {

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/crypt/binaryrc4/TestBinaryRC4.java Thu Dec 24 18:42:29 2020
@@ -18,9 +18,8 @@
 package org.apache.poi.poifs.crypt.binaryrc4;
 
 import static org.apache.poi.util.HexRead.readFromString;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.security.GeneralSecurityException;
 
@@ -29,20 +28,20 @@ import javax.crypto.SecretKey;
 import org.apache.poi.poifs.crypt.Decryptor;
 import org.apache.poi.poifs.crypt.EncryptionInfo;
 import org.apache.poi.poifs.crypt.EncryptionMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestBinaryRC4 {
     @Test
-    public void createKeyDigest() throws GeneralSecurityException {
+    public void createKeyDigest() {
         byte[] docIdData = readFromString("17 F6 D1 6B 09 B1 5F 7B 4C 9D 03 B4 81 B5 B4 4A");
         byte[] expResult = readFromString("C2 D9 56 B2 6B");
-        
+
         EncryptionInfo ei = new EncryptionInfo(EncryptionMode.binaryRC4);
         BinaryRC4EncryptionVerifier ver = (BinaryRC4EncryptionVerifier)ei.getVerifier();
         ver.setSalt(docIdData);
         SecretKey sk = BinaryRC4Decryptor.generateSecretKey("MoneyForNothing", ver);
-        
-        assertArrayEquals("keyDigest mismatch", expResult, sk.getEncoded());
+
+        assertArrayEquals(expResult, sk.getEncoded(), "keyDigest mismatch");
     }
 
     @Test
@@ -81,7 +80,7 @@ public class TestBinaryRC4 {
             String docIdHex, String saltDataHex, String saltHashHex) throws GeneralSecurityException {
         confirmValid(expectedResult, docIdHex, saltDataHex, saltHashHex, null);
     }
-    
+
     private static void confirmValid(boolean expectedResult, String docIdHex,
             String saltDataHex, String saltHashHex, String password) throws GeneralSecurityException {
         byte[] docId = readFromString(docIdHex);
@@ -96,11 +95,6 @@ public class TestBinaryRC4 {
 
         String pass = password == null ? Decryptor.DEFAULT_PASSWORD : password;
         boolean actResult = ei.getDecryptor().verifyPassword(pass);
-        if (expectedResult) {
-            assertTrue("validate failed", actResult);
-        } else {
-            assertFalse("validate succeeded unexpectedly", actResult);
-        }        
+        assertEquals(expectedResult, actResult, expectedResult ? "validate failed" : "validate succeeded unexpectedly");
     }
-    
 }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java Thu Dec 24 18:42:29 2020
@@ -16,26 +16,35 @@
 ==================================================================== */
 package org.apache.poi.poifs.dev;
 
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.filesystem.NotOLE2FileException;
 import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.property.PropertyTable;
 import org.apache.poi.util.TempFile;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.*;
-
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 public class TestPOIFSDump {
 
     private static PrintStream SYSTEM;
-    @BeforeClass
+    @BeforeAll
     public static void setUp() throws UnsupportedEncodingException {
         SYSTEM = System.out;
         System.setOut(new PrintStream(new OutputStream() {
@@ -46,7 +55,7 @@ public class TestPOIFSDump {
         }, false, "UTF-8"));
     }
 
-    @AfterClass
+    @AfterAll
     public static void resetSystemOut() {
         System.setOut(SYSTEM);
     }
@@ -65,7 +74,7 @@ public class TestPOIFSDump {
         "-dump-mini-stream",
     };
 
-    @After
+    @AfterEach
     public void tearDown() throws IOException {
         // clean up the directory that POIFSDump writes to
         deleteDirectory(new File(new File(TEST_FILE+"_dump").getName()));
@@ -140,60 +149,28 @@ public class TestPOIFSDump {
         }
     }
     @Test
-    public void testInvalidFile() throws Exception {
-        try {
-            POIFSDump.main(new String[]{
-                    INVALID_FILE
-            });
-            fail("Should fail with an exception");
-        } catch (NotOLE2FileException e) {
-            // expected here
-        }
-
-        try {
-            POIFSDump.main(new String[]{
-                    INVALID_XLSX_FILE
-            });
-            fail("Should fail with an exception");
-        } catch (OfficeXmlFileException e) {
-            // expected here
-        }
+    public void testInvalidFile() {
+        assertThrows(NotOLE2FileException.class, () -> POIFSDump.main(new String[]{INVALID_FILE}));
+        assertThrows(OfficeXmlFileException.class, () -> POIFSDump.main(new String[]{INVALID_XLSX_FILE}));
 
         for(String option : DUMP_OPTIONS) {
-            try {
-                POIFSDump.main(new String[]{
-                        option,
-                        INVALID_FILE
-                });
-                fail("Should fail with an exception");
-            } catch (NotOLE2FileException e) {
-                // expected here
-            }
-
-            try {
-                POIFSDump.main(new String[]{
-                        option,
-                        INVALID_XLSX_FILE
-                });
-                fail("Should fail with an exception");
-            } catch (OfficeXmlFileException e) {
-                // expected here
-            }
+            assertThrows(NotOLE2FileException.class, () -> POIFSDump.main(new String[]{option, INVALID_FILE}));
+            assertThrows(OfficeXmlFileException.class, () -> POIFSDump.main(new String[]{option, INVALID_XLSX_FILE}));
         }
     }
 
-    @Ignore("Calls System.exit()")
+    @Disabled("Calls System.exit()")
     @Test
     public void testMainNoArgs() throws Exception {
         POIFSDump.main(new String[] {});
     }
 
-    @Test(expected=IndexOutOfBoundsException.class)
+    @Test
     public void testFailToWrite() throws IOException {
         File dir = TempFile.createTempFile("TestPOIFSDump", ".tst");
-        assertTrue("Had: " + dir, dir.exists());
-        assertTrue("Had: " + dir, dir.delete());
-        assertTrue("Had: " + dir, dir.mkdirs());
+        assertTrue(dir.exists(), "Had: " + dir);
+        assertTrue(dir.delete(), "Had: " + dir);
+        assertTrue(dir.mkdirs(), "Had: " + dir);
 
         FileInputStream is = new FileInputStream(TEST_FILE);
         POIFSFileSystem fs = new POIFSFileSystem(is);
@@ -204,6 +181,6 @@ public class TestPOIFSDump {
 
         // try with an invalid startBlock to trigger an exception
         // to validate that file-handles are closed properly
-        POIFSDump.dump(fs, 999999999, "mini-stream", dir);
+        assertThrows(IndexOutOfBoundsException.class, () -> POIFSDump.dump(fs, 999999999, "mini-stream", dir));
     }
 }
\ No newline at end of file

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java Thu Dec 24 18:42:29 2020
@@ -17,16 +17,16 @@
 
 package org.apache.poi.poifs.eventfilesystem;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
 
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.poi.poifs.filesystem.POIFSDocumentPath;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test POIFSReaderRegistry functionality

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java Thu Dec 24 18:42:29 2020
@@ -18,11 +18,11 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.FileNotFoundException;
@@ -31,7 +31,7 @@ import java.util.Iterator;
 
 import org.apache.poi.poifs.property.DirectoryProperty;
 import org.apache.poi.poifs.property.DocumentProperty;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test DirectoryNode functionality
@@ -70,13 +70,7 @@ public final class TestDirectoryNode {
             assertEquals(0, node.getEntryCount());
 
             // verify behavior of getEntry
-            try {
-                node.getEntry("foo");
-                fail("should have caught FileNotFoundException");
-            } catch (FileNotFoundException ignored) {
-
-                // as expected
-            }
+            assertThrows(FileNotFoundException.class, () -> node.getEntry("foo"));
 
             // verify behavior of isDirectoryEntry
             assertTrue(node.isDirectoryEntry());
@@ -128,13 +122,7 @@ public final class TestDirectoryNode {
 
             child1.getEntry("child3");
             node.getEntry("child2");
-            try {
-                node.getEntry("child3");
-                fail("should have caught FileNotFoundException");
-            } catch (FileNotFoundException ignored) {
-
-                // as expected
-            }
+            assertThrows(FileNotFoundException.class, () -> node.getEntry("child3"));
 
             // verify behavior of isDirectoryEntry
             assertTrue(node.isDirectoryEntry());

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java Thu Dec 24 18:42:29 2020
@@ -18,10 +18,10 @@
 package org.apache.poi.poifs.filesystem;
 
 import static org.apache.poi.poifs.common.POIFSConstants.LARGER_BIG_BLOCK_SIZE;
-import static org.junit.Assert.assertArrayEquals;
-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.assertArrayEquals;
+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.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -32,7 +32,7 @@ import java.util.stream.IntStream;
 import org.apache.poi.poifs.property.DocumentProperty;
 import org.apache.poi.poifs.storage.RawDataUtil;
 import org.apache.poi.util.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test POIFSDocument functionality

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java Thu Dec 24 18:42:29 2020
@@ -17,10 +17,10 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test DocumentDescriptor functionality
@@ -50,7 +50,7 @@ public final class TestDocumentDescripto
                         DocumentDescriptor d2 = new DocumentDescriptor(paths[ k ], names[ n ]);
 
                         if (m == n) {
-                            assertEquals("" + j + "," + k + "," + m + "," + n, d1, d2);
+                            assertEquals(d1, d2, "" + j + "," + k + "," + m + "," + n);
                         } else {
                             assertNotEquals(d1, d2);
                         }
@@ -80,7 +80,7 @@ public final class TestDocumentDescripto
                         DocumentDescriptor d2 = new DocumentDescriptor(builtUpPaths[ k ], names[ n ]);
 
                         if ((k == j) && (m == n)) {
-                            assertEquals("" + j + "," + k + "," + m + "," + n, d1, d2);
+                            assertEquals(d1, d2, "" + j + "," + k + "," + m + "," + n);
                         } else {
                             assertNotEquals(d1, d2);
                         }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java Thu Dec 24 18:42:29 2020
@@ -17,10 +17,10 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -30,8 +30,8 @@ import java.util.Arrays;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.util.SuppressForbidden;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test DocumentInputStream functionality
@@ -45,7 +45,7 @@ public final class TestDocumentInputStre
     // any block size
     private static final int _buffer_size = 6;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         int blocks = (_workbook_size + 511) / 512;
 
@@ -87,13 +87,13 @@ public final class TestDocumentInputStre
     /**
      * test available() behavior
      */
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void testAvailable() throws IOException {
         DocumentInputStream nstream = new DocumentInputStream(_workbook_n);
         assertEquals(_workbook_size, available(nstream));
         nstream.close();
 
-        available(nstream);
+        assertThrows(IllegalStateException.class, () -> available(nstream));
     }
 
     /**
@@ -109,10 +109,7 @@ public final class TestDocumentInputStre
         // Read a fifth of it, and check all's correct
         stream.read(buffer);
         for (int j = 0; j < buffer.length; j++) {
-            assertEquals(
-                    "checking byte " + j,
-                    _workbook_data[j], buffer[j]
-            );
+            assertEquals(_workbook_data[j], buffer[j], "checking byte " + j);
         }
         assertEquals(_workbook_size - buffer.length, available(stream));
 
@@ -125,10 +122,7 @@ public final class TestDocumentInputStre
         // Read part of a block
         stream.read(small_buffer);
         for (int j = 0; j < small_buffer.length; j++) {
-            assertEquals(
-                    "checking byte " + j,
-                    _workbook_data[j], small_buffer[j]
-            );
+            assertEquals(_workbook_data[j], small_buffer[j], "checking byte " + j);
         }
         assertEquals(_workbook_size - small_buffer.length, available(stream));
         stream.mark(0);
@@ -136,10 +130,7 @@ public final class TestDocumentInputStre
         // Read the next part
         stream.read(small_buffer);
         for (int j = 0; j < small_buffer.length; j++) {
-            assertEquals(
-                    "checking byte " + j,
-                    _workbook_data[j + small_buffer.length], small_buffer[j]
-            );
+            assertEquals(_workbook_data[j + small_buffer.length], small_buffer[j], "checking byte " + j);
         }
         assertEquals(_workbook_size - 2 * small_buffer.length, available(stream));
 
@@ -150,10 +141,7 @@ public final class TestDocumentInputStre
         // Read
         stream.read(small_buffer);
         for (int j = 0; j < small_buffer.length; j++) {
-            assertEquals(
-                    "checking byte " + j,
-                    _workbook_data[j + small_buffer.length], small_buffer[j]
-            );
+            assertEquals(_workbook_data[j + small_buffer.length], small_buffer[j], "checking byte " + j);
         }
         assertEquals(_workbook_size - 2 * small_buffer.length, available(stream));
 
@@ -179,7 +167,7 @@ public final class TestDocumentInputStre
                 pos++;
             }
 
-            assertEquals("checking byte " + j, exp, small_buffer[j]);
+            assertEquals(exp, small_buffer[j], "checking byte " + j);
         }
 
         // Now repeat it with spanning multiple blocks
@@ -188,10 +176,7 @@ public final class TestDocumentInputStre
         buffer = new byte[_workbook_size / 5];
         stream.read(buffer);
         for (int j = 0; j < buffer.length; j++) {
-            assertEquals(
-                    "checking byte " + j,
-                    _workbook_data[j], buffer[j]
-            );
+            assertEquals(_workbook_data[j], buffer[j], "checking byte " + j);
         }
         assertEquals(_workbook_size - buffer.length, available(stream));
 
@@ -201,20 +186,15 @@ public final class TestDocumentInputStre
 
         stream.read(buffer);
         for (int j = 0; j < buffer.length; j++) {
-            assertEquals(
-                    "checking byte " + j,
-                    _workbook_data[j], buffer[j]
-            );
+            assertEquals(_workbook_data[j], buffer[j], "checking byte " + j);
         }
 
         // Mark our position, and read another whole buffer
         stream.mark(12);
         stream.read(buffer);
-        assertEquals(_workbook_size - (2 * buffer.length),
-                available(stream));
+        assertEquals(_workbook_size - (2 * buffer.length), available(stream));
         for (int j = buffer.length; j < (2 * buffer.length); j++) {
-            assertEquals("checking byte " + j, _workbook_data[j],
-                    buffer[j - buffer.length]);
+            assertEquals(_workbook_data[j], buffer[j - buffer.length], "checking byte " + j);
         }
 
         // Reset, should go back to only one buffer full read
@@ -223,11 +203,9 @@ public final class TestDocumentInputStre
 
         // Read the buffer again
         stream.read(buffer);
-        assertEquals(_workbook_size - (2 * buffer.length),
-                available(stream));
+        assertEquals(_workbook_size - (2 * buffer.length), available(stream));
         for (int j = buffer.length; j < (2 * buffer.length); j++) {
-            assertEquals("checking byte " + j, _workbook_data[j],
-                    buffer[j - buffer.length]);
+            assertEquals(_workbook_data[j], buffer[j - buffer.length], "checking byte " + j);
         }
         assertTrue(stream.markSupported());
     }
@@ -236,7 +214,7 @@ public final class TestDocumentInputStre
      * test simple read method
      */
     @SuppressWarnings("ResultOfMethodCallIgnored")
-    @Test(expected = IOException.class)
+    @Test
     public void testReadSingleByte() throws IOException {
         DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         int remaining = _workbook_size;
@@ -244,12 +222,10 @@ public final class TestDocumentInputStre
         // Try and read each byte in turn
         for (int j = 0; j < _workbook_size; j++) {
             int b = stream.read();
-            assertTrue("checking sign of " + j, b >= 0);
-            assertEquals("validating byte " + j, _workbook_data[j],
-                    (byte) b);
+            assertTrue(b >= 0, "checking sign of " + j);
+            assertEquals(_workbook_data[j], (byte) b, "validating byte " + j);
             remaining--;
-            assertEquals("checking remaining after reading byte " + j,
-                    remaining, available(stream));
+            assertEquals(remaining, available(stream), "checking remaining after reading byte " + j);
         }
 
         // Ensure we fell off the end
@@ -257,7 +233,7 @@ public final class TestDocumentInputStre
 
         // Check that after close we can no longer read
         stream.close();
-        stream.read();
+        assertThrows(IOException.class, stream::read);
     }
 
     /**
@@ -268,12 +244,7 @@ public final class TestDocumentInputStre
     public void testBufferRead() throws IOException {
         DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         // Need to give a byte array to read
-        try {
-            stream.read(null);
-            fail("Should have caught NullPointerException");
-        } catch (NullPointerException ignored) {
-            // as expected
-        }
+        assertThrows(NullPointerException.class, () -> stream.read(null));
 
         // test reading zero length buffer
         assertEquals(0, stream.read(new byte[0]));
@@ -284,12 +255,10 @@ public final class TestDocumentInputStre
         while (available(stream) >= buffer.length) {
             assertEquals(_buffer_size, stream.read(buffer));
             for (byte element : buffer) {
-                assertEquals("in main loop, byte " + offset,
-                        _workbook_data[offset], element);
+                assertEquals(_workbook_data[offset], element, "in main loop, byte " + offset);
                 offset++;
             }
-            assertEquals("offset " + offset, _workbook_size - offset,
-                    available(stream));
+            assertEquals(_workbook_size - offset, available(stream), "offset " + offset);
         }
         assertEquals(_workbook_size % _buffer_size, available(stream));
         Arrays.fill(buffer, (byte) 0);
@@ -297,22 +266,17 @@ public final class TestDocumentInputStre
 
         assertEquals(_workbook_size % _buffer_size, count);
         for (int j = 0; j < count; j++) {
-            assertEquals("past main loop, byte " + offset,
-                    _workbook_data[offset], buffer[j]);
+            assertEquals(_workbook_data[offset], buffer[j], "past main loop, byte " + offset);
             offset++;
         }
         assertEquals(_workbook_size, offset);
         for (int j = count; j < buffer.length; j++) {
-            assertEquals("checking remainder, byte " + j, 0, buffer[j]);
+            assertEquals(0, buffer[j], "checking remainder, byte " + j);
         }
         assertEquals(-1, stream.read(buffer));
         stream.close();
-        try {
-            stream.read(buffer);
-            fail("Should have caught IOException");
-        } catch (IOException ignored) {
-            // as expected
-        }
+
+        assertThrows(IOException.class, () -> stream.read(buffer));
     }
 
     /**
@@ -322,32 +286,12 @@ public final class TestDocumentInputStre
     @Test
     public void testComplexBufferRead() throws IOException {
         DocumentInputStream stream = new DocumentInputStream(_workbook_n);
-        try {
-            stream.read(null, 0, 1);
-            fail("Should have caught NullPointerException");
-        } catch (IllegalArgumentException ignored) {
-            // as expected
-        }
+        assertThrows(IllegalArgumentException.class, () -> stream.read(null, 0, 1));
 
         // test illegal offsets and lengths
-        try {
-            stream.read(new byte[5], -4, 0);
-            fail("Should have caught IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ignored) {
-            // as expected
-        }
-        try {
-            stream.read(new byte[5], 0, -4);
-            fail("Should have caught IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ignored) {
-            // as expected
-        }
-        try {
-            stream.read(new byte[5], 0, 6);
-            fail("Should have caught IndexOutOfBoundsException");
-        } catch (IndexOutOfBoundsException ignored) {
-            // as expected
-        }
+        assertThrows(IndexOutOfBoundsException.class, () -> stream.read(new byte[5], -4, 0));
+        assertThrows(IndexOutOfBoundsException.class, () -> stream.read(new byte[5], 0, -4));
+        assertThrows(IndexOutOfBoundsException.class, () -> stream.read(new byte[5], 0, 6));
 
         // test reading zero
         assertEquals(0, stream.read(new byte[5], 0, 0));
@@ -357,48 +301,39 @@ public final class TestDocumentInputStre
 
         while (available(stream) >= _buffer_size) {
             Arrays.fill(buffer, (byte) 0);
-            assertEquals(_buffer_size,
-                    stream.read(buffer, offset, _buffer_size));
+            assertEquals(_buffer_size, stream.read(buffer, offset, _buffer_size));
             for (int j = 0; j < offset; j++) {
-                assertEquals("checking byte " + j, 0, buffer[j]);
+                assertEquals(0, buffer[j], "checking byte " + j);
             }
             for (int j = offset; j < (offset + _buffer_size); j++) {
-                assertEquals("checking byte " + j, _workbook_data[j],
-                        buffer[j]);
+                assertEquals(_workbook_data[j], buffer[j], "checking byte " + j);
             }
             for (int j = offset + _buffer_size; j < buffer.length; j++) {
-                assertEquals("checking byte " + j, 0, buffer[j]);
+                assertEquals(0, buffer[j], "checking byte " + j);
             }
             offset += _buffer_size;
-            assertEquals("offset " + offset, _workbook_size - offset,
-                    available(stream));
+            assertEquals(_workbook_size - offset, available(stream), "offset " + offset);
         }
         assertEquals(_workbook_size % _buffer_size, available(stream));
         Arrays.fill(buffer, (byte) 0);
-        int count = stream.read(buffer, offset,
-                _workbook_size % _buffer_size);
+        int count = stream.read(buffer, offset, _workbook_size % _buffer_size);
 
         assertEquals(_workbook_size % _buffer_size, count);
         for (int j = 0; j < offset; j++) {
-            assertEquals("checking byte " + j, 0, buffer[j]);
+            assertEquals(0, buffer[j], "checking byte " + j);
         }
         for (int j = offset; j < buffer.length; j++) {
-            assertEquals("checking byte " + j, _workbook_data[j],
-                    buffer[j]);
+            assertEquals(_workbook_data[j], buffer[j], "checking byte " + j);
         }
         assertEquals(_workbook_size, offset + count);
         for (int j = count; j < offset; j++) {
-            assertEquals("byte " + j, 0, buffer[j]);
+            assertEquals(0, buffer[j], "byte " + j);
         }
 
         assertEquals(-1, stream.read(buffer, 0, 1));
         stream.close();
-        try {
-            stream.read(buffer, 0, 1);
-            fail("Should have caught IOException");
-        } catch (IOException ignored) {
-            // as expected
-        }
+
+        assertThrows(IOException.class, () -> stream.read(buffer, 0, 1));
     }
 
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java Thu Dec 24 18:42:29 2020
@@ -18,15 +18,16 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 
 import org.apache.poi.util.IOUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class to test DocumentOutputStream functionality
@@ -51,12 +52,7 @@ public final class TestDocumentOutputStr
                 fail("stream exhausted too early");
             }
 
-            try {
-                dstream.write(0);
-                fail("Should have caught IOException");
-            }
-            catch (IOException ignored) {
-            }
+            assertThrows(IOException.class, () -> dstream.write(0));
         };
 
         compare(l, expected);
@@ -78,11 +74,7 @@ public final class TestDocumentOutputStr
                 fail("stream exhausted too early");
             }
 
-            try {
-                dstream.write(new byte[]{'7','7','7','7'});
-                fail("Should have caught IOException");
-            } catch (IOException ignored) {
-            }
+            assertThrows(IOException.class, () -> dstream.write(new byte[]{'7','7','7','7'}));
         };
 
         compare(l, expected);
@@ -103,11 +95,7 @@ public final class TestDocumentOutputStr
             } catch (IOException ignored) {
                 fail("stream exhausted too early");
             }
-            try {
-                dstream.write(input, 0, 1);
-                fail("Should have caught IOException");
-            }
-            catch (IOException ignored) {}
+            assertThrows(IOException.class, () -> dstream.write(input, 0, 1));
         };
 
         compare(l, expected);

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEmptyDocument.java Thu Dec 24 18:42:29 2020
@@ -17,8 +17,8 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -27,7 +27,7 @@ import java.io.IOException;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestEmptyDocument {
     private static final POILogger LOG = POILogFactory.getLogger(TestEmptyDocument.class);
@@ -48,12 +48,7 @@ public final class TestEmptyDocument {
 	public void testSingleEmptyDocumentEvent() throws IOException {
 		POIFSFileSystem fs = new POIFSFileSystem();
 		DirectoryEntry dir = fs.getRoot();
-		dir.createDocument("Foo", 0, new POIFSWriterListener() {
-			@Override
-            public void processPOIFSWriterEvent(POIFSWriterEvent event) {
-				LOG.log(POILogger.WARN, "written");
-			}
-		});
+		dir.createDocument("Foo", 0, event -> LOG.log(POILogger.WARN, "written"));
 
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
 		fs.writeFilesystem(out);
@@ -78,21 +73,14 @@ public final class TestEmptyDocument {
 	public void testEmptyDocumentEventWithFriend() throws IOException {
 		POIFSFileSystem fs = new POIFSFileSystem();
 		DirectoryEntry dir = fs.getRoot();
-		dir.createDocument("Bar", 1, new POIFSWriterListener() {
-			@Override
-            public void processPOIFSWriterEvent(POIFSWriterEvent event) {
-				try {
-					event.getStream().write(0);
-				} catch (IOException exception) {
-					throw new RuntimeException("exception on write: " + exception);
-				}
-			}
-		});
-		dir.createDocument("Foo", 0, new POIFSWriterListener() {
-			@Override
-            public void processPOIFSWriterEvent(POIFSWriterEvent event) {
+		dir.createDocument("Bar", 1, event -> {
+			try {
+				event.getStream().write(0);
+			} catch (IOException exception) {
+				throw new RuntimeException("exception on write: " + exception);
 			}
 		});
+		dir.createDocument("Foo", 0, event -> {});
 
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
 		fs.writeFilesystem(out);
@@ -116,15 +104,15 @@ public final class TestEmptyDocument {
 		fs = new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray()));
 
 		DocumentEntry entry = (DocumentEntry) fs.getRoot().getEntry("Empty");
-		assertEquals("Expected zero size", 0, entry.getSize());
+		assertEquals(0, entry.getSize(), "Expected zero size");
 		byte[] actualReadbackData;
 		actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
-		assertEquals("Expected zero read from stream", 0, actualReadbackData.length);
+		assertEquals(0, actualReadbackData.length, "Expected zero read from stream");
 
 		entry = (DocumentEntry) fs.getRoot().getEntry("NotEmpty");
 		actualReadbackData = IOUtils.toByteArray(new DocumentInputStream(entry));
-		assertEquals("Expected size was wrong", testData.length, entry.getSize());
-		assertArrayEquals("Expected same data read from stream", testData, actualReadbackData);
+		assertEquals(testData.length, entry.getSize(), "Expected size was wrong");
+		assertArrayEquals(testData, actualReadbackData, "Expected same data read from stream");
 		fs.close();
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java Thu Dec 24 18:42:29 2020
@@ -17,11 +17,11 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -30,7 +30,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestEntryUtils {
     private static final byte[] dataSmallA = new byte[] { 12, 42, 11, -12, -121 };
@@ -42,23 +42,23 @@ public class TestEntryUtils {
        POIFSFileSystem fs = new POIFSFileSystem();
        DirectoryEntry dirA = fs.createDirectory("DirA");
        DirectoryEntry dirB = fs.createDirectory("DirB");
-       
+
        DocumentEntry entryR = fs.createDocument(new ByteArrayInputStream(dataSmallA), "EntryRoot");
        DocumentEntry entryA1 = dirA.createDocument("EntryA1", new ByteArrayInputStream(dataSmallA));
        DocumentEntry entryA2 = dirA.createDocument("EntryA2", new ByteArrayInputStream(dataSmallB));
-       
+
        // Copy docs
        assertEquals(0, fsD.getRoot().getEntryCount());
        EntryUtils.copyNodeRecursively(entryR, fsD.getRoot());
-       
+
        assertEquals(1, fsD.getRoot().getEntryCount());
        assertNotNull(fsD.getRoot().getEntry("EntryRoot"));
-       
+
        EntryUtils.copyNodeRecursively(entryA1, fsD.getRoot());
        assertEquals(2, fsD.getRoot().getEntryCount());
        assertNotNull(fsD.getRoot().getEntry("EntryRoot"));
        assertNotNull(fsD.getRoot().getEntry("EntryA1"));
-       
+
        EntryUtils.copyNodeRecursively(entryA2, fsD.getRoot());
        assertEquals(3, fsD.getRoot().getEntryCount());
        assertNotNull(fsD.getRoot().getEntry("EntryRoot"));
@@ -66,16 +66,16 @@ public class TestEntryUtils {
        assertNotNull(fsD.getRoot().getEntry("EntryA2"));
 
        fsD.close();
-       
+
        // Copy directories
        fsD = new POIFSFileSystem();
        assertEquals(0, fsD.getRoot().getEntryCount());
-       
+
        EntryUtils.copyNodeRecursively(dirB, fsD.getRoot());
        assertEquals(1, fsD.getRoot().getEntryCount());
        assertNotNull(fsD.getRoot().getEntry("DirB"));
        assertEquals(0, ((DirectoryEntry)fsD.getRoot().getEntry("DirB")).getEntryCount());
-       
+
        EntryUtils.copyNodeRecursively(dirA, fsD.getRoot());
        assertEquals(2, fsD.getRoot().getEntryCount());
        assertNotNull(fsD.getRoot().getEntry("DirB"));
@@ -83,11 +83,11 @@ public class TestEntryUtils {
        assertNotNull(fsD.getRoot().getEntry("DirA"));
        assertEquals(2, ((DirectoryEntry)fsD.getRoot().getEntry("DirA")).getEntryCount());
        fsD.close();
-       
+
        // Copy the whole lot
        fsD = new POIFSFileSystem();
        assertEquals(0, fsD.getRoot().getEntryCount());
-       
+
        EntryUtils.copyNodes(fs, fsD, new ArrayList<>());
        assertEquals(3, fsD.getRoot().getEntryCount());
        assertNotNull(fsD.getRoot().getEntry(dirA.getName()));
@@ -104,32 +104,32 @@ public class TestEntryUtils {
        POIFSFileSystem fs = new POIFSFileSystem();
        DirectoryEntry dirA = fs.createDirectory("DirA");
        DirectoryEntry dirB = fs.createDirectory("DirB");
-       
+
        DocumentEntry entryA1 = dirA.createDocument("Entry1", new ByteArrayInputStream(dataSmallA));
        DocumentEntry entryA1b = dirA.createDocument("Entry1b", new ByteArrayInputStream(dataSmallA));
        DocumentEntry entryA2 = dirA.createDocument("Entry2", new ByteArrayInputStream(dataSmallB));
        DocumentEntry entryB1 = dirB.createDocument("Entry1", new ByteArrayInputStream(dataSmallA));
-       
-       
+
+
        // Names must match
        assertNotEquals(entryA1.getName(), entryA1b.getName());
        assertFalse(EntryUtils.areDocumentsIdentical(entryA1, entryA1b));
-       
+
        // Contents must match
        assertFalse(EntryUtils.areDocumentsIdentical(entryA1, entryA2));
-       
+
        // Parents don't matter if contents + names are the same
        assertNotEquals(entryA1.getParent(), entryB1.getParent());
        assertTrue(EntryUtils.areDocumentsIdentical(entryA1, entryB1));
-       
-       
+
+
        // Can work with POIFS
        ByteArrayOutputStream tmpO = new ByteArrayOutputStream();
        fs.writeFilesystem(tmpO);
-       
+
        ByteArrayInputStream tmpI = new ByteArrayInputStream(tmpO.toByteArray());
        POIFSFileSystem nfs = new POIFSFileSystem(tmpI);
-       
+
        DirectoryEntry dN1 = (DirectoryEntry)nfs.getRoot().getEntry("DirA");
        DirectoryEntry dN2 = (DirectoryEntry)nfs.getRoot().getEntry("DirB");
        DocumentEntry eNA1 = (DocumentEntry)dN1.getEntry(entryA1.getName());
@@ -153,59 +153,59 @@ public class TestEntryUtils {
        POIFSFileSystem fs = new POIFSFileSystem();
        DirectoryEntry dirA = fs.createDirectory("DirA");
        DirectoryEntry dirB = fs.createDirectory("DirB");
-       
+
        // Names must match
        assertFalse(EntryUtils.areDirectoriesIdentical(dirA, dirB));
-       
+
        // Empty dirs are fine
-       DirectoryEntry dirA1 = dirA.createDirectory("TheDir"); 
+       DirectoryEntry dirA1 = dirA.createDirectory("TheDir");
        DirectoryEntry dirB1 = dirB.createDirectory("TheDir");
        assertEquals(0, dirA1.getEntryCount());
        assertEquals(0, dirB1.getEntryCount());
        assertTrue(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
-       
+
        // Otherwise children must match
        dirA1.createDocument("Entry1", new ByteArrayInputStream(dataSmallA));
        assertFalse(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
-       
+
        dirB1.createDocument("Entry1", new ByteArrayInputStream(dataSmallA));
        assertTrue(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
-       
+
        dirA1.createDirectory("DD");
        assertFalse(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
        dirB1.createDirectory("DD");
        assertTrue(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
-       
-       
+
+
        // Excludes support
        List<String> excl = Arrays.asList("Ignore1", "IgnDir/Ign2");
        FilteringDirectoryNode fdA = new FilteringDirectoryNode(dirA1, excl);
        FilteringDirectoryNode fdB = new FilteringDirectoryNode(dirB1, excl);
 
        assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        // Add an ignored doc, no notice is taken
        fdA.createDocument("Ignore1", new ByteArrayInputStream(dataSmallA));
        assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        // Add a directory with filtered contents, not the same
        DirectoryEntry dirAI = dirA1.createDirectory("IgnDir");
        assertFalse(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        DirectoryEntry dirBI = dirB1.createDirectory("IgnDir");
        assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        // Add something to the filtered subdir that gets ignored
        dirAI.createDocument("Ign2", new ByteArrayInputStream(dataSmallA));
        assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        // And something that doesn't
        dirAI.createDocument("IgnZZ", new ByteArrayInputStream(dataSmallA));
        assertFalse(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        dirBI.createDocument("IgnZZ", new ByteArrayInputStream(dataSmallA));
        assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
-       
+
        fs.close();
     }
 }



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