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 [26/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/TestHSSFPalette.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java Thu Dec 24 18:42:29 2020
@@ -17,15 +17,14 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.awt.Color;
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -34,17 +33,16 @@ import org.apache.poi.hssf.util.HSSFColo
 import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
 import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.ss.usermodel.Font;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public final class TestHSSFPalette {
-    private PaletteRecord _palette;
     private HSSFPalette _hssfPalette;
 
 
-    @Before
+    @BeforeEach
     public void setUp() {
-        _palette = new PaletteRecord();
+        PaletteRecord _palette = new PaletteRecord();
         _hssfPalette = new HSSFPalette(_palette);
     }
 
@@ -66,27 +64,27 @@ public final class TestHSSFPalette {
 
         palette = book.getCustomPalette();
         HSSFColor color = palette.getColor(HSSFColorPredefined.CORAL.getIndex());  //unmodified
-        assertNotNull("Unexpected null in custom palette (unmodified index)", color);
+        assertNotNull(color, "Unexpected null in custom palette (unmodified index)");
         short[] expectedRGB = HSSFColorPredefined.CORAL.getTriplet();
         short[] actualRGB = color.getTriplet();
         String msg = "Expected palette position to remain unmodified";
-        assertEquals(msg, expectedRGB[0], actualRGB[0]);
-        assertEquals(msg, expectedRGB[1], actualRGB[1]);
-        assertEquals(msg, expectedRGB[2], actualRGB[2]);
+        assertEquals(expectedRGB[0], actualRGB[0], msg);
+        assertEquals(expectedRGB[1], actualRGB[1], msg);
+        assertEquals(expectedRGB[2], actualRGB[2], msg);
 
         color = palette.getColor((short) 0x12);
-        assertNotNull("Unexpected null in custom palette (modified)", color);
+        assertNotNull(color, "Unexpected null in custom palette (modified)");
         actualRGB = color.getTriplet();
         msg = "Expected palette modification to be preserved across save";
-        assertEquals(msg, (short) 101, actualRGB[0]);
-        assertEquals(msg, (short) 230, actualRGB[1]);
-        assertEquals(msg, (short) 100, actualRGB[2]);
+        assertEquals((short) 101, actualRGB[0], msg);
+        assertEquals((short) 230, actualRGB[1], msg);
+        assertEquals((short) 100, actualRGB[2], msg);
     }
 
     /**
      * Uses the palette from cell stylings
      */
-    @SuppressWarnings("deprecation")
+    @SuppressWarnings("ConstantConditions")
     @Test
     public void testPaletteFromCellColours() {
         HSSFWorkbook book = HSSFTestDataSamples.openSampleWorkbook("SimpleWithColours.xls");
@@ -105,6 +103,7 @@ public final class TestHSSFPalette {
         assertEquals(64, cellA.getCellStyle().getFillBackgroundColor());
         assertEquals(Font.COLOR_NORMAL, cellA.getCellStyle().getFont(book).getColor());
         assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPattern());
+        assertNotNull(p.getColor((short)64));
         assertEquals("0:0:0", p.getColor((short)64).getHexString());
         assertNull(p.getColor((short) 32767));
 
@@ -145,11 +144,12 @@ public final class TestHSSFPalette {
         assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
     }
 
+    @SuppressWarnings("ConstantConditions")
     @Test
     public void testFindSimilar() throws IOException {
         HSSFWorkbook book = new HSSFWorkbook();
         HSSFPalette p = book.getCustomPalette();
-        
+
         /* first test the defaults */
         assertArrayEquals(
         				new short[] {(short) 255, (short) 255, (short) 0}, // not [204, 255, 255]
@@ -218,7 +218,7 @@ public final class TestHSSFPalette {
                 p.getColor((short)12).getHexString(),
                 p.findSimilarColor((byte)-1, (byte)2, (byte)10).getHexString()
         );
-        
+
         // And with ints not bytes
         assertEquals(
                 p.getColor((short)11).getHexString(),
@@ -228,23 +228,17 @@ public final class TestHSSFPalette {
                 p.getColor((short)12).getHexString(),
                 p.findSimilarColor(255, 2, 10).getHexString()
         );
-        
+
         book.close();
     }
-    
+
     /**
      * Verifies that the generated gnumeric-format string values match the
      * hardcoded values in the HSSFColor default color palette
      */
     @Test
     public void testGnumericStrings() {
-        compareToDefaults(new ColorComparator() {
-            @Override
-            public void compare(HSSFColor expected, HSSFColor palette)
-            {
-                assertEquals(expected.getHexString(), palette.getHexString());
-            }
-        });
+        compareToDefaults((expected, palette) -> assertEquals(expected.getHexString(), palette.getHexString()));
     }
 
     /**
@@ -258,25 +252,18 @@ public final class TestHSSFPalette {
         _hssfPalette.setColorAtIndex((short) 0x45, (byte) 255, (byte) 255, (byte) 255);
 
         //should still match defaults;
-        compareToDefaults(new ColorComparator() {
-            @Override
-            public void compare(HSSFColor expected, HSSFColor palette)
-            {
-                short[] s1 = expected.getTriplet();
-                short[] s2 = palette.getTriplet();
-                assertEquals(s1[0], s2[0]);
-                assertEquals(s1[1], s2[1]);
-                assertEquals(s1[2], s2[2]);
-            }
+        compareToDefaults((expected, palette) -> {
+            short[] s1 = expected.getTriplet();
+            short[] s2 = palette.getTriplet();
+            assertEquals(s1[0], s2[0]);
+            assertEquals(s1[1], s2[1]);
+            assertEquals(s1[2], s2[2]);
         });
     }
 
     private void compareToDefaults(ColorComparator c) {
         Map<Integer,HSSFColor> colors = HSSFColor.getIndexHash();
-        Iterator<Integer> it = colors.keySet().iterator();
-        while (it.hasNext())
-        {
-            Number index = it.next();
+        for (Integer index : colors.keySet()) {
             HSSFColor expectedColor = colors.get(index);
             HSSFColor paletteColor = _hssfPalette.getColor(index.shortValue());
             c.compare(expectedColor, paletteColor);
@@ -285,16 +272,11 @@ public final class TestHSSFPalette {
 
     @Test
     public void testAddColor() {
-        try
-        {
-            _hssfPalette.addColor((byte)10,(byte)10,(byte)10);
-            fail();
-        } catch (RuntimeException e) {
-            // Failing because by default there are no colours left in the palette.
-        }
+        assertThrows(RuntimeException.class, () -> _hssfPalette.addColor((byte)10,(byte)10,(byte)10),
+            "Failing because by default there are no colours left in the palette.");
     }
 
-    private static interface ColorComparator {
+    private interface ColorComparator {
         void compare(HSSFColor expected, HSSFColor palette);
     }
 
@@ -304,7 +286,7 @@ public final class TestHSSFPalette {
 
         Color color = Color.decode("#006B6B");
         HSSFPalette palette = wb.getCustomPalette();
-        
+
         HSSFColor hssfColor = palette.findColor((byte) color.getRed(),
                 (byte) color.getGreen(), (byte) color.getBlue());
         assertNull(hssfColor);
@@ -317,7 +299,7 @@ public final class TestHSSFPalette {
         assertNotNull(hssfColor);
         assertEquals(55, hssfColor.getIndex());
         assertArrayEquals(new short[] {0, 107, 107}, hssfColor.getTriplet());
-        
+
         wb.close();
     }
 }

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

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java Thu Dec 24 18:42:29 2020
@@ -17,8 +17,8 @@
 
 package org.apache.poi.hssf.usermodel;
 
-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 java.util.Arrays;
@@ -34,7 +34,7 @@ import org.apache.poi.ss.usermodel.Clien
 import org.apache.poi.ss.usermodel.CreationHelper;
 import org.apache.poi.ss.usermodel.PictureData;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestHSSFPicture extends BaseTestPicture {
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPictureData.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.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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 java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
@@ -31,15 +31,15 @@ import javax.imageio.IIOException;
 import javax.imageio.ImageIO;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test <code>HSSFPictureData</code>.
  * The code to retrieve images from a workbook provided by Trejkaz (trejkaz at trypticon dot org) in Bug 41223.
  */
 public final class TestHSSFPictureData {
-    @BeforeClass
+    @BeforeAll
     public static void setUpClass() {
         final String tmpDirProperty = System.getProperty("java.io.tmpdir");
         if(tmpDirProperty == null || "".equals(tmpDirProperty)) {
@@ -86,7 +86,7 @@ public final class TestHSSFPictureData {
                 }
             }
         } catch (IIOException e) {
-            assertFalse(e.getMessage(), e.getMessage().contains("Can't create cache file"));
+            assertFalse(e.getMessage().contains("Can't create cache file"), e.getMessage());
         }
     }
 
@@ -100,7 +100,7 @@ public final class TestHSSFPictureData {
 
             HSSFPictureData pict = lst.get(0);
             String ext = pict.suggestFileExtension();
-            assertEquals("Expected a PNG.", "png", ext);
+            assertEquals("png", ext, "Expected a PNG.");
 
             //try to read image data using javax.imageio.* (JDK 1.4+)
             byte[] data = pict.getData();
@@ -111,7 +111,7 @@ public final class TestHSSFPictureData {
             assertEquals(HSSFWorkbook.PICTURE_TYPE_PNG, pict.getFormat());
             assertEquals("image/png", pict.getMimeType());
         } catch (IIOException e) {
-            assertFalse(e.getMessage(), e.getMessage().contains("Can't create cache file"));
+            assertFalse(e.getMessage().contains("Can't create cache file"), e.getMessage());
         }
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java Thu Dec 24 18:42:29 2020
@@ -22,7 +22,7 @@ package org.apache.poi.hssf.usermodel;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.BaseTestRangeCopier;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 
 public class TestHSSFRangeCopier extends BaseTestRangeCopier {
 
@@ -32,7 +32,7 @@ public class TestHSSFRangeCopier extends
         testDataProvider = HSSFITestDataProvider.instance;
     }
 
-    @Before
+    @BeforeEach
     public void init() {
         workbook = HSSFTestDataSamples.openSampleWorkbook("tile-range-test.xls");
         initSheets();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.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.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestHSSFRichTextString {
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java Thu Dec 24 18:42:29 2020
@@ -17,6 +17,13 @@
 
 package org.apache.poi.hssf.usermodel;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFITestDataProvider;
@@ -24,9 +31,7 @@ import org.apache.poi.hssf.record.BlankR
 import org.apache.poi.hssf.record.RowRecord;
 import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.usermodel.BaseTestRow;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test HSSFRow is okay.
@@ -67,9 +72,8 @@ public final class TestHSSFRow extends B
         HSSFRow row = new HSSFRow(workbook, sheet, rowRec);
         HSSFCell cell = row.createCellFromRecord(br);
 
-        if (row.getFirstCellNum() == 2 && row.getLastCellNum() == 5) {
-            fail("Identified bug 46654a");
-        }
+        assertFalse(row.getFirstCellNum() == 2 && row.getLastCellNum() == 5, "Identified bug 46654a");
+
         assertEquals(COL_IX, row.getFirstCellNum());
         assertEquals(COL_IX + 1, row.getLastCellNum());
         row.removeCell(cell);
@@ -100,20 +104,10 @@ public final class TestHSSFRow extends B
         assertEquals(4, row.getLastCellNum());
 
         // Try to move to somewhere else that's used
-        try {
-            row.moveCell(cellB2, (short)3);
-            fail("IllegalArgumentException should have been thrown");
-        } catch(IllegalArgumentException e) {
-            // expected during successful test
-        }
+        assertThrows(IllegalArgumentException.class, () -> row.moveCell(cellB2, (short)3));
 
         // Try to move one off a different row
-        try {
-            row.moveCell(cellA2, (short)3);
-            fail("IllegalArgumentException should have been thrown");
-        } catch(IllegalArgumentException e) {
-            // expected during successful test
-        }
+        assertThrows(IllegalArgumentException.class, () -> row.moveCell(cellA2, (short)3));
 
         // Move somewhere spare
         assertNotNull(row.getCell(1));
@@ -124,7 +118,7 @@ public final class TestHSSFRow extends B
         assertEquals(5, cellB2.getColumnIndex());
         assertEquals(2, row.getFirstCellNum());
         assertEquals(6, row.getLastCellNum());
-        
+
         workbook.close();
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java Thu Dec 24 18:42:29 2020
@@ -18,7 +18,15 @@
 package org.apache.poi.hssf.usermodel;
 
 import static org.apache.poi.hssf.HSSFTestDataSamples.writeOutAndReadBack;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -43,7 +51,7 @@ import org.apache.poi.ss.usermodel.Sheet
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddressList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests HSSFSheet.  This test case is very incomplete at the moment.
@@ -390,10 +398,10 @@ public final class TestHSSFSheet extends
             HSSFSheet s = wb.createSheet();
             s.protectSheet("abcdefghij");
             WorksheetProtectionBlock pb = s.getSheet().getProtectionBlock();
-            assertTrue("protection should be on", pb.isSheetProtected());
-            assertTrue("object protection should be on", pb.isObjectProtected());
-            assertTrue("scenario protection should be on", pb.isScenarioProtected());
-            assertEquals("well known value for top secret hash should be " + Integer.toHexString(expectedHash).substring(4), expectedHash, pb.getPasswordHash());
+            assertTrue(pb.isSheetProtected(), "protection should be on");
+            assertTrue(pb.isObjectProtected(), "object protection should be on");
+            assertTrue(pb.isScenarioProtected(), "scenario protection should be on");
+            assertEquals(expectedHash, pb.getPasswordHash(), "well known value for top secret hash should be " + Integer.toHexString(expectedHash).substring(4));
         }
     }
 
@@ -465,30 +473,18 @@ public final class TestHSSFSheet extends
             assertEquals(sclLoc, window2Loc + 1);
 
             // verify limits
-            try {
-                sheet.setZoom(0);
-                fail("Should catch Exception here");
-            } catch (IllegalArgumentException e) {
-                assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
-            }
-            try {
-                sheet.setZoom(65536);
-                fail("Should catch Exception here");
-            } catch (IllegalArgumentException e) {
-                assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
-            }
-            try {
-                sheet.setZoom(2, 0);
-                fail("Should catch Exception here");
-            } catch (IllegalArgumentException e) {
-                assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
-            }
-            try {
-                sheet.setZoom(2, 65536);
-                fail("Should catch Exception here");
-            } catch (IllegalArgumentException e) {
-                assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
-            }
+            IllegalArgumentException e;
+            e = assertThrows(IllegalArgumentException.class, () -> sheet.setZoom(0));
+            assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
+
+            e = assertThrows(IllegalArgumentException.class, () -> sheet.setZoom(65536));
+            assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
+
+            e = assertThrows(IllegalArgumentException.class, () -> sheet.setZoom(2, 0));
+            assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
+
+            e = assertThrows(IllegalArgumentException.class, () -> sheet.setZoom(2, 65536));
+            assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
         }
     }
 
@@ -504,26 +500,26 @@ public final class TestHSSFSheet extends
             HSSFSheet sheet = wb1.getSheetAt(0);
             assertNotNull(sheet);
 
-            assertEquals("1 row page break", 1, sheet.getRowBreaks().length);
-            assertEquals("1 column page break", 1, sheet.getColumnBreaks().length);
+            assertEquals(1, sheet.getRowBreaks().length, "1 row page break");
+            assertEquals(1, sheet.getColumnBreaks().length, "1 column page break");
 
-            assertTrue("No row page break", sheet.isRowBroken(22));
-            assertTrue("No column page break", sheet.isColumnBroken((short) 4));
+            assertTrue(sheet.isRowBroken(22), "No row page break");
+            assertTrue(sheet.isColumnBroken((short) 4), "No column page break");
 
             sheet.setRowBreak(10);
             sheet.setColumnBreak((short) 13);
 
-            assertEquals("row breaks number", 2, sheet.getRowBreaks().length);
-            assertEquals("column breaks number", 2, sheet.getColumnBreaks().length);
+            assertEquals(2, sheet.getRowBreaks().length, "row breaks number");
+            assertEquals(2, sheet.getColumnBreaks().length, "column breaks number");
 
             try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) {
                 sheet = wb2.getSheetAt(0);
 
-                assertTrue("No row page break", sheet.isRowBroken(22));
-                assertTrue("No column page break", sheet.isColumnBroken((short) 4));
+                assertTrue(sheet.isRowBroken(22), "No row page break");
+                assertTrue(sheet.isColumnBroken((short) 4), "No column page break");
 
-                assertEquals("row breaks number", 2, sheet.getRowBreaks().length);
-                assertEquals("column breaks number", 2, sheet.getColumnBreaks().length);
+                assertEquals(2, sheet.getRowBreaks().length, "row breaks number");
+                assertEquals(2, sheet.getColumnBreaks().length, "column breaks number");
             }
         }
     }
@@ -532,8 +528,8 @@ public final class TestHSSFSheet extends
     public void dbcsName () throws IOException {
         try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DBCSSheetName.xls")) {
             wb.getSheetAt(1);
-            assertEquals("DBCS Sheet Name 2", wb.getSheetName(1), "\u090f\u0915");
-            assertEquals("DBCS Sheet Name 1", wb.getSheetName(0), "\u091c\u093e");
+            assertEquals(wb.getSheetName(1), "\u090f\u0915", "DBCS Sheet Name 2");
+            assertEquals(wb.getSheetName(0), "\u091c\u093e", "DBCS Sheet Name 1");
         }
     }
 
@@ -551,8 +547,8 @@ public final class TestHSSFSheet extends
             short toprow = (short) 100;
             short leftcol = (short) 50;
             sheet.showInPane(toprow, leftcol);
-            assertEquals("HSSFSheet.getTopRow()", toprow, sheet.getTopRow());
-            assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
+            assertEquals(toprow, sheet.getTopRow(), "HSSFSheet.getTopRow()");
+            assertEquals(leftcol, sheet.getLeftCol(), "HSSFSheet.getLeftCol()");
         }
     }
 
@@ -597,8 +593,8 @@ public final class TestHSSFSheet extends
             // autoSize the first column and check its size before the merged region (1,0,1,1) is set:
             // it has to be based on the 2nd row width
             sheet.autoSizeColumn((short) 0);
-            assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth(0) >= minWithRow1And2);
-            assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth(0) <= maxWithRow1And2);
+            assertTrue(sheet.getColumnWidth(0) >= minWithRow1And2, "Column autosized with only one row: wrong width");
+            assertTrue(sheet.getColumnWidth(0) <= maxWithRow1And2, "Column autosized with only one row: wrong width");
 
             //create a region over the 2nd row and auto size the first column
             assertEquals(1, sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 1)));
@@ -779,11 +775,11 @@ public final class TestHSSFSheet extends
         try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex41187-19267.xls")) {
             HSSFSheet sheet = wb.getSheetAt(0);
             HSSFRow row = sheet.getRow(0);
-            assertNotNull("Identified bug 41187 a", row);
+            assertNotNull(row, "Identified bug 41187 a");
 
-            assertNotEquals("Identified bug 41187 b", (short) 0, row.getHeight());
+            assertNotEquals((short) 0, row.getHeight(), "Identified bug 41187 b");
 
-            assertEquals("Hi Excel!", row.getCell(0).getRichStringCellValue().getString());
+            assertEquals(row.getCell(0).getRichStringCellValue().getString(), "Hi Excel!");
             // check row height for 'default' flag
             assertEquals((short) 0xFF, row.getHeight());
 
@@ -838,12 +834,10 @@ public final class TestHSSFSheet extends
             final String SAME_PREFIX = "A123456789B123456789C123456789"; // 30 chars
 
             wb.createSheet(SAME_PREFIX + "Dxxxx");
-            try {
-                wb.createSheet(SAME_PREFIX + "Dyyyy"); // identical up to the 32nd char
-                fail("Expected exception not thrown");
-            } catch (IllegalArgumentException e) {
-                assertEquals("The workbook already contains a sheet named 'A123456789B123456789C123456789Dyyyy'", e.getMessage());
-            }
+            // identical up to the 32nd char
+            IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> wb.createSheet(SAME_PREFIX + "Dyyyy"));
+            assertEquals("The workbook already contains a sheet named 'A123456789B123456789C123456789Dyyyy'", e.getMessage());
+
             wb.createSheet(SAME_PREFIX + "Exxxx"); // OK - differs in the 31st char
         }
     }
@@ -923,8 +917,8 @@ public final class TestHSSFSheet extends
 
             // The built-in name for auto-filter must consist of a single Area3d Ptg.
             Ptg[] ptg = name.getNameDefinition();
-            assertEquals("The built-in name for auto-filter must consist of a single Area3d Ptg", 1, ptg.length);
-            assertTrue("The built-in name for auto-filter must consist of a single Area3d Ptg", ptg[0] instanceof Area3DPtg);
+            assertEquals(1, ptg.length, "The built-in name for auto-filter must consist of a single Area3d Ptg");
+            assertTrue(ptg[0] instanceof Area3DPtg, "The built-in name for auto-filter must consist of a single Area3d Ptg");
 
             Area3DPtg aref = (Area3DPtg) ptg[0];
             assertEquals(range.getFirstColumn(), aref.getFirstColumn());
@@ -1003,12 +997,10 @@ public final class TestHSSFSheet extends
             assertEquals(40000, sheet.getColumnWidth((short) 10));
 
             //The maximum column width for an individual cell is 255 characters
-            try {
-                sheet.setColumnWidth((short) 9, 256 * 256);
-                fail("expected exception");
-            } catch (IllegalArgumentException e) {
-                assertEquals("The maximum column width for an individual cell is 255 characters.", e.getMessage());
-            }
+            Sheet sheet2 = sheet;
+            IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () ->
+                sheet2.setColumnWidth((short) 9, 256 * 256));
+            assertEquals("The maximum column width for an individual cell is 255 characters.", e.getMessage());
 
             //serialize and read again
             try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetShiftColumns.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetShiftColumns.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetShiftColumns.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetShiftColumns.java Thu Dec 24 18:42:29 2020
@@ -24,14 +24,14 @@ import org.apache.poi.hssf.HSSFITestData
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.BaseTestSheetShiftColumns;
 import org.apache.poi.ss.usermodel.Workbook;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 public class TestHSSFSheetShiftColumns extends BaseTestSheetShiftColumns {
     public TestHSSFSheetShiftColumns() {
-        super(); 
+        super();
         workbook = new HSSFWorkbook();
-        _testDataProvider = HSSFITestDataProvider.instance; 
+        _testDataProvider = HSSFITestDataProvider.instance;
     }
 
     protected Workbook openWorkbook(String spreadsheetFileName)
@@ -42,45 +42,45 @@ public class TestHSSFSheetShiftColumns e
     protected Workbook getReadBackWorkbook(Workbook wb) throws IOException {
         return HSSFTestDataSamples.writeOutAndReadBack((HSSFWorkbook)wb);
     }
-    
-    @Override    
-    @Ignore("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
+
+    @Override
+    @Disabled("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
     @Test
     public void shiftMergedColumnsToMergedColumnsLeft() throws IOException {
-        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf, 
-        // so that original method from BaseTestSheetShiftColumns can be executed. 
+        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf,
+        // so that original method from BaseTestSheetShiftColumns can be executed.
     }
-    @Override    
-    @Ignore("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
+    @Override
+    @Disabled("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
     @Test
     public void shiftMergedColumnsToMergedColumnsRight() throws IOException {
-        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf, 
-        // so that original method from BaseTestSheetShiftColumns can be executed. 
+        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf,
+        // so that original method from BaseTestSheetShiftColumns can be executed.
     }
-    @Override    
-    @Ignore("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
+    @Override
+    @Disabled("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
     @Test
     public void testBug54524() throws IOException {
-        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf, 
-        // so that original method from BaseTestSheetShiftColumns can be executed. 
+        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf,
+        // so that original method from BaseTestSheetShiftColumns can be executed.
     }
-    @Override    
-    @Ignore("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
+    @Override
+    @Disabled("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
     @Test
     public void testCommentsShifting() throws IOException {
-        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf, 
-        // so that original method from BaseTestSheetShiftColumns can be executed. 
+        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf,
+        // so that original method from BaseTestSheetShiftColumns can be executed.
     }
-    @Override    
-    @Ignore("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
+    @Override
+    @Disabled("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
     @Test
     public void testShiftWithMergedRegions() throws IOException {
-        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf, 
-        // so that original method from BaseTestSheetShiftColumns can be executed. 
-        // After removing, you can re-add 'final' keyword to specification of original method. 
+        // This override is used only in order to test failing for HSSF. Please remove method after code is fixed on hssf,
+        // so that original method from BaseTestSheetShiftColumns can be executed.
+        // After removing, you can re-add 'final' keyword to specification of original method.
     }
     @Override
-    @Ignore("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
+    @Disabled("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030>")
     @Test
     public void testShiftHyperlinks() throws IOException {}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheetUpdateArrayFormulas.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -33,14 +33,13 @@ import org.apache.poi.POITestCase;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.record.ArrayRecord;
 import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
 import org.apache.poi.hssf.record.aggregates.RowRecordsAggregate;
 import org.apache.poi.hssf.record.aggregates.SharedValueManager;
 import org.apache.poi.ss.usermodel.BaseTestSheetUpdateArrayFormulas;
 import org.apache.poi.ss.usermodel.CellRange;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test array formulas in HSSF
@@ -113,7 +112,7 @@ public final class TestHSSFSheetUpdateAr
             RowRecordsAggregate rra = s.getSheet().getRowsAggregate();
 
             SharedValueManager svm = POITestCase.getFieldValue(RowRecordsAggregate.class, rra, SharedValueManager.class, "_sharedValueManager");
-            assertNull("Array record was not cleaned up properly.", svm.getArrayRecord(4, 1));
+            assertNull(svm.getArrayRecord(4, 1), "Array record was not cleaned up properly.");
         }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFTextbox.java Thu Dec 24 18:42:29 2020
@@ -17,11 +17,11 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test <code>HSSFTextbox</code>.

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java Thu Dec 24 18:42:29 2020
@@ -19,12 +19,13 @@ package org.apache.poi.hssf.usermodel;
 
 import static org.apache.poi.POITestCase.assertContains;
 import static org.apache.poi.hssf.HSSFTestDataSamples.openSampleWorkbook;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -70,14 +71,17 @@ import org.apache.poi.ss.usermodel.Workb
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.TempFile;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
 
 /**
  * Tests for {@link HSSFWorkbook}
  */
 public final class TestHSSFWorkbook extends BaseTestWorkbook {
     private static final HSSFITestDataProvider _testDataProvider = HSSFITestDataProvider.instance;
+    private static final POIDataSamples samples = POIDataSamples.getSpreadSheetInstance();
 
     public TestHSSFWorkbook() {
         super(_testDataProvider);
@@ -208,9 +212,9 @@ public final class TestHSSFWorkbook exte
 
         // Demonstrate bug 44525:
         // Well... not quite, since isActive + isSelected were also added in the same bug fix
-        assertFalse("Identified bug 44523 a", sheet1.isSelected());
+        assertFalse(sheet1.isSelected(), "Identified bug 44523 a");
         wb.setActiveSheet(1);
-        assertFalse("Identified bug 44523 b", sheet1.isActive());
+        assertFalse(sheet1.isActive(), "Identified bug 44523 b");
 
         confirmActiveSelected(sheet1, false);
         confirmActiveSelected(sheet2, true);
@@ -229,7 +233,7 @@ public final class TestHSSFWorkbook exte
     }
 
     private static void assertCollectionsEquals(Collection<Integer> expected, Collection<Integer> actual) {
-        assertEquals("size", expected.size(), actual.size());
+        assertEquals(expected.size(), actual.size());
         for (int e : expected) {
             assertTrue(actual.contains(e));
         }
@@ -278,22 +282,6 @@ public final class TestHSSFWorkbook exte
         assertFalse(sheet0.isActive());
         assertTrue(sheet2.isActive());
 
-        /*{ // helpful if viewing this workbook in excel:
-            sheet0.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet0"));
-            sheet1.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet1"));
-            sheet2.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet2"));
-            sheet3.createRow(0).createCell(0).setCellValue(new HSSFRichTextString("Sheet3"));
-
-            try {
-                File fOut = TempFile.createTempFile("sheetMultiSelect", ".xls");
-                FileOutputStream os = new FileOutputStream(fOut);
-                wb.write(os);
-                os.close();
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
-        }*/
-
         wb.close();
     }
 
@@ -325,8 +313,8 @@ public final class TestHSSFWorkbook exte
 
         wb.removeSheetAt(3);
         // after removing the only active/selected sheet, another should be active/selected in its place
-        assertTrue("identified bug 40414 a", sheet4.isSelected());
-        assertTrue("identified bug 40414 b", sheet4.isActive());
+        assertTrue(sheet4.isSelected(), "identified bug 40414 a");
+        assertTrue(sheet4.isActive(), "identified bug 40414 b");
 
         confirmActiveSelected(sheet0, false);
         confirmActiveSelected(sheet1, false);
@@ -370,8 +358,8 @@ public final class TestHSSFWorkbook exte
 
     private static void confirmActiveSelected(HSSFSheet sheet,
             boolean expectedActive, boolean expectedSelected) {
-        assertEquals("active", expectedActive, sheet.isActive());
-        assertEquals("selected", expectedSelected, sheet.isSelected());
+        assertEquals(expectedActive, sheet.isActive(), "active");
+        assertEquals(expectedSelected, sheet.isSelected(), "selected");
     }
 
     /**
@@ -382,21 +370,15 @@ public final class TestHSSFWorkbook exte
      */
     @Test
     public void sheetSerializeSizeMismatch_bug45066() throws IOException {
-        HSSFWorkbook wb = new HSSFWorkbook();
-        InternalSheet sheet = wb.createSheet("Sheet1").getSheet();
-        List<RecordBase> sheetRecords = sheet.getRecords();
-        // one way (of many) to cause the discrepancy is with a badly behaved record:
-        sheetRecords.add(new BadlyBehavedRecord());
-        // There is also much logic inside Sheet that (if buggy) might also cause the discrepancy
-        try {
-            wb.getBytes();
-            fail("Identified bug 45066 a");
-        } catch (IllegalStateException e) {
-            // Expected badly behaved sheet record to cause exception
+        try (HSSFWorkbook wb = new HSSFWorkbook()) {
+            InternalSheet sheet = wb.createSheet("Sheet1").getSheet();
+            List<RecordBase> sheetRecords = sheet.getRecords();
+            // one way (of many) to cause the discrepancy is with a badly behaved record:
+            sheetRecords.add(new BadlyBehavedRecord());
+            // There is also much logic inside Sheet that (if buggy) might also cause the discrepancy
+            IllegalStateException e = assertThrows(IllegalStateException.class, wb::getBytes, "Identified bug 45066 a");
             assertTrue(e.getMessage().startsWith("Actual serialized sheet size"));
         }
-
-        wb.close();
     }
 
     /**
@@ -572,7 +554,7 @@ public final class TestHSSFWorkbook exte
      */
     @Test
     public void bug47920() throws IOException {
-        POIFSFileSystem fs1 = new POIFSFileSystem(POIDataSamples.getSpreadSheetInstance().openResourceAsStream("47920.xls"));
+        POIFSFileSystem fs1 = new POIFSFileSystem(samples.openResourceAsStream("47920.xls"));
         HSSFWorkbook wb = new HSSFWorkbook(fs1);
         ClassID clsid1 = fs1.getRoot().getStorageClsid();
 
@@ -593,34 +575,19 @@ public final class TestHSSFWorkbook exte
      * If we try to open an old (pre-97) workbook, we get a helpful
      *  Exception give to explain what we've done wrong
      */
-    @Test
-    public void helpfulExceptionOnOldFiles() throws Exception {
-        InputStream excel4 = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("testEXCEL_4.xls");
-        try {
-            new HSSFWorkbook(excel4).close();
-            fail("Shouldn't be able to load an Excel 4 file");
-        } catch (OldExcelFormatException e) {
-            assertContains(e.getMessage(), "BIFF4");
-        }
-        excel4.close();
-
-        InputStream excel5 = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("testEXCEL_5.xls");
-        try {
-            new HSSFWorkbook(excel5).close();
-            fail("Shouldn't be able to load an Excel 5 file");
-        } catch (OldExcelFormatException e) {
-            assertContains(e.getMessage(), "BIFF5");
-        }
-        excel5.close();
-
-        InputStream excel95 = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("testEXCEL_95.xls");
-        try {
-            new HSSFWorkbook(excel95).close();
-            fail("Shouldn't be able to load an Excel 95 file");
-        } catch (OldExcelFormatException e) {
-            assertContains(e.getMessage(), "BIFF5");
+    @ParameterizedTest
+    @CsvSource({
+        "testEXCEL_4.xls,BIFF4",
+        "testEXCEL_5.xls,BIFF5",
+        "testEXCEL_95.xls,BIFF5"
+    })
+    public void helpfulExceptionOnOldFiles(String file, String format) throws Exception {
+        POIDataSamples xlsData = samples;
+        try (InputStream is = xlsData.openResourceAsStream(file)) {
+            OldExcelFormatException e = assertThrows(OldExcelFormatException.class, () -> new HSSFWorkbook(is),
+                "Shouldn't be able to load an Excel " + format + " file");
+            assertContains(e.getMessage(), format);
         }
-        excel95.close();
     }
 
     /**
@@ -717,25 +684,20 @@ public final class TestHSSFWorkbook exte
 
     @Test
     public void cellStylesLimit() throws IOException {
-        Workbook wb = new HSSFWorkbook();
-        int numBuiltInStyles = wb.getNumCellStyles();
-        int MAX_STYLES = 4030;
-        int limit = MAX_STYLES - numBuiltInStyles;
-        for(int i=0; i < limit; i++){
-            /* HSSFCellStyle style =*/ wb.createCellStyle();
-        }
+        try (Workbook wb = new HSSFWorkbook()) {
+            int numBuiltInStyles = wb.getNumCellStyles();
+            int MAX_STYLES = 4030;
+            int limit = MAX_STYLES - numBuiltInStyles;
+            for (int i = 0; i < limit; i++) {
+                wb.createCellStyle();
+            }
 
-        assertEquals(MAX_STYLES, wb.getNumCellStyles());
-        try {
-            /*HSSFCellStyle style =*/ wb.createCellStyle();
-            fail("expected exception");
-        } catch (IllegalStateException e){
+            assertEquals(MAX_STYLES, wb.getNumCellStyles());
+            IllegalStateException e = assertThrows(IllegalStateException.class, wb::createCellStyle);
             assertEquals("The maximum number of cell styles was exceeded. " +
-                    "You can define up to 4000 styles in a .xls workbook", e.getMessage());
+                "You can define up to 4000 styles in a .xls workbook", e.getMessage());
+            assertEquals(MAX_STYLES, wb.getNumCellStyles());
         }
-        assertEquals(MAX_STYLES, wb.getNumCellStyles());
-
-        wb.close();
     }
 
     @Test
@@ -831,10 +793,10 @@ public final class TestHSSFWorkbook exte
     }
 
     // Should throw exception about invalid POIFSFileSystem
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void emptyDirectoryNode() throws IOException {
         try (POIFSFileSystem fs = new POIFSFileSystem()) {
-            new HSSFWorkbook(fs).close();
+            assertThrows(IllegalArgumentException.class, () -> new HSSFWorkbook(fs).close());
         }
     }
 
@@ -856,9 +818,9 @@ public final class TestHSSFWorkbook exte
 
         // Demonstrate bug 44525:
         // Well... not quite, since isActive + isSelected were also added in the same bug fix
-        assertFalse("Identified bug 44523 a", sheet1.isSelected());
+        assertFalse(sheet1.isSelected(), "Identified bug 44523 a");
         wb.setActiveSheet(1);
-        assertFalse("Identified bug 44523 b", sheet1.isActive());
+        assertFalse(sheet1.isActive(), "Identified bug 44523 b");
 
         confirmActiveSelected(sheet1, false);
         confirmActiveSelected(sheet2, true);
@@ -876,12 +838,8 @@ public final class TestHSSFWorkbook exte
     public void names() throws IOException {
         HSSFWorkbook wb=new HSSFWorkbook();
 
-        try {
-            wb.getNameAt(0);
-            fail("Fails without any defined names");
-        } catch (IllegalStateException e) {
-            assertTrue(e.getMessage(), e.getMessage().contains("no defined names"));
-        }
+        IllegalStateException ex1 = assertThrows(IllegalStateException.class, () -> wb.getNameAt(0));
+        assertTrue(ex1.getMessage().contains("no defined names"));
 
         HSSFName name = wb.createName();
         assertNotNull(name);
@@ -894,19 +852,11 @@ public final class TestHSSFWorkbook exte
         assertEquals(0, wb.getNameIndex(name));
         assertEquals(0, wb.getNameIndex("myname"));
 
-        try {
-            wb.getNameAt(5);
-            fail("Fails without any defined names");
-        } catch (IllegalArgumentException e) {
-            assertTrue(e.getMessage(), e.getMessage().contains("outside the allowable range"));
-        }
+        IllegalArgumentException ex2 = assertThrows(IllegalArgumentException.class, () -> wb.getNameAt(5));
+        assertTrue(ex2.getMessage().contains("outside the allowable range"));
 
-        try {
-            wb.getNameAt(-3);
-            fail("Fails without any defined names");
-        } catch (IllegalArgumentException e) {
-            assertTrue(e.getMessage(), e.getMessage().contains("outside the allowable range"));
-        }
+        IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> wb.getNameAt(-3));
+        assertTrue(ex.getMessage().contains("outside the allowable range"));
 
         wb.close();
     }
@@ -930,13 +880,6 @@ public final class TestHSSFWorkbook exte
         wb.writeProtectWorkbook("mypassword", "myuser");
         assertTrue(wb.isWriteProtected());
 
-//        OutputStream os = new FileOutputStream("/tmp/protected.xls");
-//        try {
-//            wb.write(os);
-//        } finally {
-//            os.close();
-//        }
-
         wb.unwriteProtectWorkbook();
         assertFalse(wb.isWriteProtected());
 
@@ -969,8 +912,7 @@ public final class TestHSSFWorkbook exte
 		int expected = wb.getWorkbook().getSize();
 		int written = wb.getWorkbook().serialize(0, new byte[expected*2]);
 
-		assertEquals("Did not have the expected size when writing the workbook: written: " + written + ", but expected: " + expected,
-				expected, written);
+		assertEquals(expected, written, "Did not have the expected size when writing the workbook");
 
 		HSSFWorkbook read = HSSFTestDataSamples.writeOutAndReadBack(wb);
 		assertSheetOrder(read, "Invoice", "Invoice1", "Digest", "Deferred", "Received");
@@ -1012,8 +954,7 @@ public final class TestHSSFWorkbook exte
 		int expected = wb.getWorkbook().getSize();
 		int written = wb.getWorkbook().serialize(0, new byte[expected*2]);
 
-		assertEquals("Did not have the expected size when writing the workbook: written: " + written + ", but expected: " + expected,
-				expected, written);
+		assertEquals(expected, written, "Did not have the expected size when writing the workbook");
 
 		HSSFWorkbook read = HSSFTestDataSamples.writeOutAndReadBack(wb);
 		assertSheetOrder(read, "Invoice", "Deferred", "Received", "Digest");
@@ -1105,7 +1046,7 @@ public final class TestHSSFWorkbook exte
             }
         }
 
-        assertTrue("Should find some images via Client or Child anchors, but did not find any at all", found);
+        assertTrue(found, "Should find some images via Client or Child anchors, but did not find any at all");
         workbook.close();
     }
 
@@ -1159,7 +1100,7 @@ public final class TestHSSFWorkbook exte
     @Test
     public void closeDoesNotModifyWorkbook() throws IOException {
         final String filename = "SampleSS.xls";
-        final File file = POIDataSamples.getSpreadSheetInstance().getFile(filename);
+        final File file = samples.getFile(filename);
         Workbook wb;
 
         // File via POIFileStream (java.nio)
@@ -1186,47 +1127,29 @@ public final class TestHSSFWorkbook exte
 
     @Test
     public void invalidInPlaceWrite() throws Exception {
-        HSSFWorkbook wb;
-
         // Can't work for new files
-        wb = new HSSFWorkbook();
-        try {
-            wb.write();
-            fail("Shouldn't work for new files");
-        } catch (IllegalStateException e) {
-            // expected here
+        try (HSSFWorkbook wb = new HSSFWorkbook()) {
+            assertThrows(IllegalStateException.class, wb::write, "Shouldn't work for new files");
         }
-        wb.close();
 
         // Can't work for InputStream opened files
-        wb = new HSSFWorkbook(
-            POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SampleSS.xls"));
-        try {
-            wb.write();
-            fail("Shouldn't work for InputStream");
-        } catch (IllegalStateException e) {
-            // expected here
+        try (InputStream is = samples.openResourceAsStream("SampleSS.xls");
+            HSSFWorkbook wb = new HSSFWorkbook(is)) {
+            assertThrows(IllegalStateException.class, wb::write, "Shouldn't work for InputStream");
         }
-        wb.close();
 
         // Can't work for Read-Only files
-        POIFSFileSystem fs = new POIFSFileSystem(
-                POIDataSamples.getSpreadSheetInstance().getFile("SampleSS.xls"), true);
-        wb = new HSSFWorkbook(fs);
-        try {
-            wb.write();
-            fail("Shouldn't work for Read Only");
-        } catch (IllegalStateException e) {
-            // expected here
+        try (POIFSFileSystem fs = new POIFSFileSystem(samples.getFile("SampleSS.xls"), true);
+             HSSFWorkbook wb = new HSSFWorkbook(fs)) {
+            assertThrows(IllegalStateException.class, wb::write, "Shouldn't work for Read Only");
         }
-        wb.close();
     }
 
     @Test
     public void inPlaceWrite() throws Exception {
         // Setup as a copy of a known-good file
         final File file = TempFile.createTempFile("TestHSSFWorkbook", ".xls");
-        try (InputStream inputStream = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SampleSS.xls");
+        try (InputStream inputStream = samples.openResourceAsStream("SampleSS.xls");
              FileOutputStream outputStream = new FileOutputStream(file)) {
             IOUtils.copy(inputStream, outputStream);
         }
@@ -1255,7 +1178,7 @@ public final class TestHSSFWorkbook exte
     public void testWriteToNewFile() throws Exception {
         // Open from a Stream
         HSSFWorkbook wb = new HSSFWorkbook(
-                POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SampleSS.xls"));
+                samples.openResourceAsStream("SampleSS.xls"));
 
         // Save to a new temp file
         final File file = TempFile.createTempFile("TestHSSFWorkbook", ".xls");
@@ -1268,7 +1191,7 @@ public final class TestHSSFWorkbook exte
         wb.close();
     }
 
-    @Ignore
+    @Disabled
     @Test
     @Override
     public void createDrawing() throws Exception {

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

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNonStandardWorkbookStreamNames.java Thu Dec 24 18:42:29 2020
@@ -17,8 +17,8 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -26,11 +26,11 @@ import java.io.InputStream;
 import org.apache.poi.hpsf.SummaryInformation;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for how HSSFWorkbook behaves with XLS files
- *  with a WORKBOOK or BOOK directory entry (instead of 
+ *  with a WORKBOOK or BOOK directory entry (instead of
  *  the more usual, Workbook)
  */
 public final class TestNonStandardWorkbookStreamNames {
@@ -54,7 +54,7 @@ public final class TestNonStandardWorkbo
 
 		// But not a Workbook one
 		assertFalse(root.hasEntry("Workbook"));
-		
+
 		wb.close();
 	}
 
@@ -75,7 +75,7 @@ public final class TestNonStandardWorkbo
       // But not a Workbook one and not a Summary one
       assertFalse(root.hasEntry("Workbook"));
       assertFalse(root.hasEntry(SummaryInformation.DEFAULT_STREAM_NAME));
-      
+
       wb.close();
    }
 
@@ -93,9 +93,9 @@ public final class TestNonStandardWorkbo
            // Check now it can be opened
            HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb);
            wb.close();
-           
+
            DirectoryNode root = wb2.getDirectory();
-       
+
            // Check that we have the new entries
            assertTrue(root.hasEntry("Workbook"));
            assertFalse(root.hasEntry("BOOK"));
@@ -115,7 +115,7 @@ public final class TestNonStandardWorkbo
 		InputStream is = HSSFTestDataSamples.openSampleFileStream(xlsA);
         HSSFWorkbook wb = new HSSFWorkbook(is,true);
         is.close();
-        
+
         // Check now it can be opened
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb);
         wb.close();

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestOLE2Embeding.java Thu Dec 24 18:42:29 2020
@@ -17,8 +17,8 @@
 
 package org.apache.poi.hssf.usermodel;
 
-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;
@@ -34,38 +34,32 @@ import org.apache.poi.poifs.filesystem.P
 import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
 import org.apache.poi.ss.usermodel.CreationHelper;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
- * 
+ *
  */
 public final class TestOLE2Embeding {
 
     @Test
     public void testEmbeding() throws Exception {
         // This used to break, until bug #43116 was fixed
-        HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("ole2-embedding.xls");
-
-        // Check we can get at the Escher layer still
-        workbook.getAllPictures();
-        
-        workbook.close();
+        try (HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("ole2-embedding.xls")) {
+            // Check we can get at the Escher layer still
+            workbook.getAllPictures();
+        }
     }
 
     @Test
     public void testEmbeddedObjects() throws Exception {
-        HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("ole2-embedding.xls");
-
-        List<HSSFObjectData> objects = workbook.getAllEmbeddedObjects();
-        assertEquals("Wrong number of objects", 2, objects.size());
-        assertEquals("Wrong name for first object", "MBD06CAB431",
-                objects.get(0).getDirectory().getName());
-        assertEquals("Wrong name for second object", "MBD06CAC85A",
-                objects.get(1).getDirectory().getName());
-        
-        workbook.close();
+        try (HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("ole2-embedding.xls")) {
+            List<HSSFObjectData> objects = workbook.getAllEmbeddedObjects();
+            assertEquals(2, objects.size(), "Wrong number of objects");
+            assertEquals("MBD06CAB431", objects.get(0).getDirectory().getName(), "Wrong name for first object");
+            assertEquals("MBD06CAC85A", objects.get(1).getDirectory().getName(), "Wrong name for second object");
+        }
     }
-    
+
     @Test
     public void testReallyEmbedSomething() throws Exception {
     	HSSFWorkbook wb1 = new HSSFWorkbook();
@@ -81,7 +75,7 @@ public final class TestOLE2Embeding {
     	int imgPPT = wb1.addPicture(picturePPT, HSSFWorkbook.PICTURE_TYPE_JPEG);
     	int xlsIdx = wb1.addOlePackage(xlsPoifs, "Sample-XLS", "sample.xls", "sample.xls");
     	int txtIdx = wb1.addOlePackage(getSampleTXT(), "Sample-TXT", "sample.txt", "sample.txt");
-    	
+
         int rowoffset = 5;
         int coloffset = 5;
 
@@ -89,21 +83,21 @@ public final class TestOLE2Embeding {
         HSSFClientAnchor anchor = (HSSFClientAnchor)ch.createClientAnchor();
         anchor.setAnchor((short)(2+coloffset), 1+rowoffset, 0, 0, (short)(3+coloffset), 5+rowoffset, 0, 0);
         anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
-    	
+
         patriarch.createObjectData(anchor, pptIdx, imgPPT);
 
         anchor = (HSSFClientAnchor)ch.createClientAnchor();
         anchor.setAnchor((short)(5+coloffset), 1+rowoffset, 0, 0, (short)(6+coloffset), 5+rowoffset, 0, 0);
         anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
-        
+
         patriarch.createObjectData(anchor, xlsIdx, imgIdx);
-        
+
         anchor = (HSSFClientAnchor)ch.createClientAnchor();
         anchor.setAnchor((short)(3+coloffset), 10+rowoffset, 0, 0, (short)(5+coloffset), 11+rowoffset, 0, 0);
         anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
-        
+
         patriarch.createObjectData(anchor, txtIdx, imgIdx);
-        
+
         anchor = (HSSFClientAnchor)ch.createClientAnchor();
         anchor.setAnchor((short)(1+coloffset), -2+rowoffset, 0, 0, (short)(7+coloffset), 14+rowoffset, 0, 0);
         anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
@@ -117,10 +111,10 @@ public final class TestOLE2Embeding {
 //	        wb.write(fos);
 //	        fos.close();
 //        }
-        
+
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
         wb1.close();
-        
+
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         HSSFObjectData od = wb2.getAllEmbeddedObjects().get(0);
         Ole10Native ole10 = Ole10Native.createFromEmbeddedOleObject((DirectoryNode)od.getDirectory());
@@ -137,21 +131,21 @@ public final class TestOLE2Embeding {
         od = wb2.getAllEmbeddedObjects().get(2);
         ole10 = Ole10Native.createFromEmbeddedOleObject((DirectoryNode)od.getDirectory());
         assertArrayEquals(ole10.getDataBuffer(), getSampleTXT());
-    
+
         xlsPoifs.close();
         pptPoifs.close();
         wb2.close();
     }
-    
+
     static POIFSFileSystem getSamplePPT() throws IOException {
     	// scratchpad classes are not available, so we use something pre-cooked
     	InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream("with_textbox.ppt");
     	POIFSFileSystem poifs = new POIFSFileSystem(is);
     	is.close();
-        
+
         return poifs;
     }
-    
+
     static POIFSFileSystem getSampleXLS() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sheet = wb.createSheet();
@@ -163,8 +157,8 @@ public final class TestOLE2Embeding {
 
         return new POIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
     }
-    
+
     static byte[] getSampleTXT() {
         return "All your base are belong to us".getBytes(LocaleUtil.CHARSET_1252);
-    }    
+    }
 }
\ No newline at end of file

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPOIFSProperties.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.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -29,7 +29,7 @@ import org.apache.poi.hpsf.*;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.HexDump;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Old-style setting of POIFS properties doesn't work with POI 3.0.2
@@ -103,7 +103,7 @@ public class TestPOIFSProperties {
     private void checkFromByteArray(byte[] bytes) throws IOException, NoPropertySetStreamException, MarkUnsupportedException {
         // on some environments in CI we see strange failures, let's verify that the size is exactly right
         // this can be removed again after the problem is identified
-        assertEquals("Had: " + HexDump.toHex(bytes), 5120, bytes.length);
+        assertEquals(5120, bytes.length, "Had: " + HexDump.toHex(bytes));
 
         POIFSFileSystem fs2 = new POIFSFileSystem(new ByteArrayInputStream(bytes));
         SummaryInformation summary2 = (SummaryInformation) PropertySetFactory.create(fs2.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java Thu Dec 24 18:42:29 2020
@@ -17,15 +17,15 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import org.apache.poi.ddf.EscherDgRecord;
 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 TestPatriarch {
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java Thu Dec 24 18:42:29 2020
@@ -18,9 +18,9 @@
 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.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.assertTrue;
 
 import java.io.IOException;
 
@@ -29,7 +29,7 @@ import org.apache.poi.ddf.EscherProperty
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.record.ObjRecord;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public class TestPolygon {
     @Test
@@ -71,7 +71,7 @@ public class TestPolygon {
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
-        
+
         wb.close();
     }
 
@@ -100,10 +100,10 @@ public class TestPolygon {
             "</elements>" +
             "</record>";
         String actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");
-        
+
         assertEquals(verticesProp1.getNumberOfElementsInArray(), 5);
         assertEquals(expected, actual);
-        
+
         polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});
         assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});
         assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});
@@ -121,10 +121,10 @@ public class TestPolygon {
             "<item>AQAEAA==</item>" +
             "</elements></record>";
         actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");
-        
+
         assertEquals(verticesProp1.getNumberOfElementsInArray(), 4);
         assertEquals(expected, actual);
-        
+
         wb.close();
     }
 
@@ -173,7 +173,7 @@ public class TestPolygon {
         assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61});
         assertEquals(polygon.getDrawAreaHeight(), 1011);
         assertEquals(polygon.getDrawAreaWidth(), 1021);
-        
+
         wb3.close();
     }
 
@@ -227,7 +227,7 @@ public class TestPolygon {
         assertArrayEquals(polygon2.getYPoints(), new int[]{24,25,26});
         assertEquals(polygon2.getDrawAreaHeight(), 204);
         assertEquals(polygon2.getDrawAreaWidth(), 203);
-        
+
         wb3.close();
     }
 
@@ -243,7 +243,7 @@ public class TestPolygon {
         assertEquals(polygon.getDrawAreaWidth(), 3686175);
         assertArrayEquals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502});
         assertArrayEquals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18});
-        
+
         wb.close();
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestReadWriteChart.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.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Calendar;
 import java.util.Date;
@@ -31,7 +31,7 @@ import org.apache.poi.hssf.record.EOFRec
 import org.apache.poi.hssf.record.RecordBase;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author Glen Stampoultzis (glens at apache.org)
@@ -61,7 +61,7 @@ public final class TestReadWriteChart {
 
         assertTrue(records.get(0) instanceof BOFRecord);
         assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
-        
+
         workbook.close();
     }
 }



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