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 [25/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/TestFormulas.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java Thu Dec 24 18:42:29 2020
@@ -18,10 +18,10 @@
 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.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -40,7 +40,7 @@ import org.apache.poi.ss.usermodel.Sheet
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.TempFile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestFormulas {
 
@@ -66,7 +66,7 @@ public final class TestFormulas {
                 r = s.getRow(1);
                 c = r.getCell(1);
 
-                assertEquals("Formula is as expected", "1+1", c.getCellFormula());
+                assertEquals("1+1", c.getCellFormula(), "Formula is as expected");
             }
         }
     }
@@ -201,9 +201,10 @@ public final class TestFormulas {
             for (int y = 1; y < 256 && y > 0; y=(short)(y+2)) {
 
                 HSSFCell c = r.getCell(y);
-                assertNotNull("got a formula", c.getCellFormula());
+                assertNotNull(c.getCellFormula(), "got a formula");
 
-                assertEquals("loop Formula is as expected " + x + "." + y + operator + y + "." + x + "!=" + c.getCellFormula(), ("" + x + "." + y + operator + y + "." + x), c.getCellFormula());
+                assertEquals(("" + x + "." + y + operator + y + "." + x), c.getCellFormula(),
+                    "loop Formula is as expected " + x + "." + y + operator + y + "." + x + "!=" + c.getCellFormula());
             }
         }
     }
@@ -281,7 +282,8 @@ public final class TestFormulas {
         HSSFRow r = s.getRow(0);
         HSSFCell c = r.getCell(1);
         //get our minimum values
-        assertEquals("minval Formula is as expected A2" + operator + "A3 != " + c.getCellFormula(), ("A2" + operator + "A3"), c.getCellFormula());
+        assertEquals(("A2" + operator + "A3"), c.getCellFormula(),
+            "minval Formula is as expected A2" + operator + "A3 != " + c.getCellFormula());
 
 
         for (int x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) {
@@ -301,7 +303,8 @@ public final class TestFormulas {
                 String ref2=cr.formatAsString();
 
 
-                assertEquals("loop Formula is as expected " + ref + operator + ref2 + "!=" + c.getCellFormula(), ("" + ref + operator + ref2), c.getCellFormula());
+                assertEquals(("" + ref + operator + ref2), c.getCellFormula(),
+                    "loop Formula is as expected " + ref + operator + ref2 + "!=" + c.getCellFormula());
             }
         }
 
@@ -332,7 +335,7 @@ public final class TestFormulas {
                 //get our minimum values
                 r = s.getRow(0);
                 c = r.getCell(1);
-                assertEquals("minval Formula is as expected", formula, c.getCellFormula());
+                assertEquals(formula, c.getCellFormula(), "minval Formula is as expected");
             }
         }
     }
@@ -382,14 +385,16 @@ public final class TestFormulas {
         //get our minimum values
         HSSFRow r = s.getRow(0);
         HSSFCell c = r.getCell(1);
-        assertEquals("minval Formula is as expected 1" + operator + "1 != " + c.getCellFormula(), ("1" + operator + "1"), c.getCellFormula());
+        assertEquals(("1" + operator + "1"), c.getCellFormula(),
+            "minval Formula is as expected 1" + operator + "1 != " + c.getCellFormula());
 
         for (int x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) {
             r = s.getRow(x);
 
             for (int y = 1; y < 256 && y > 0; y++) {
                 c = r.getCell(y);
-                assertEquals("loop Formula is as expected " + x + operator + y + "!=" + c.getCellFormula(), ("" + x + operator + y), c.getCellFormula());
+                assertEquals(("" + x + operator + y), c.getCellFormula(),
+                    "loop Formula is as expected " + x + operator + y + "!=" + c.getCellFormula());
             }
         }
 
@@ -397,7 +402,8 @@ public final class TestFormulas {
         r = s.getRow(0);
         c = r.getCell(0);
 
-        assertEquals("maxval Formula is as expected", ("" + Short.MAX_VALUE + operator + Short.MAX_VALUE), c.getCellFormula());
+        assertEquals(("" + Short.MAX_VALUE + operator + Short.MAX_VALUE), c.getCellFormula(),
+            "maxval Formula is as expected");
     }
 
     /**
@@ -415,7 +421,8 @@ public final class TestFormulas {
                 r = s.getRow(0);
                 c = r.getCell(0);
 
-                assertEquals("function =" + function + "(A2:A3)", function + "(A2:A3)", c.getCellFormula());
+                assertEquals(function + "(A2:A3)", c.getCellFormula(),
+                    "function =" + function + "(A2:A3)");
             }
         }
     }
@@ -436,7 +443,7 @@ public final class TestFormulas {
                 r = s.getRow(0);
                 c = r.getCell(0);
 
-                assertEquals("function =" + function + "(A2,A3)", (function + "(A2,A3)"), c.getCellFormula());
+                assertEquals((function + "(A2,A3)"), c.getCellFormula(), "function =" + function + "(A2,A3)");
             }
         }
     }
@@ -461,10 +468,10 @@ public final class TestFormulas {
                 r = s.getRow(0);
                 c = r.getCell(0);
 
-                assertEquals("function =" + function + "(A2:A4,B2:B4)", (function + "(A2:A4,B2:B4)"), c.getCellFormula());
+                assertEquals((function + "(A2:A4,B2:B4)"), c.getCellFormula(), "function =" + function + "(A2:A4,B2:B4)");
 
                 c = r.getCell(1);
-                assertEquals("function =" + function + "($A$2:$A4,B$2:B4)", (function + "($A$2:$A4,B$2:B4)"), c.getCellFormula());
+                assertEquals((function + "($A$2:$A4,B$2:B4)"), c.getCellFormula(), "function =" + function + "($A$2:$A4,B$2:B4)");
             }
         }
     }
@@ -490,15 +497,15 @@ public final class TestFormulas {
                 s = wb2.getSheetAt(0);
                 r = s.getRow(0);
                 c = r.getCell(0);
-                assertEquals("A3+A2", ("A3+A2"), c.getCellFormula());
+                assertEquals("A3+A2", c.getCellFormula());
                 c = r.getCell(1);
-                assertEquals("$A3+$A2", ("$A3+$A2"), c.getCellFormula());
+                assertEquals("$A3+$A2", c.getCellFormula());
                 c = r.getCell(2);
-                assertEquals("A$3+A$2", ("A$3+A$2"), c.getCellFormula());
+                assertEquals("A$3+A$2", c.getCellFormula());
                 c = r.getCell(3);
-                assertEquals("$A$3+$A$2", ("$A$3+$A$2"), c.getCellFormula());
+                assertEquals("$A$3+$A$2", c.getCellFormula());
                 c = r.getCell(4);
-                assertEquals("SUM($A$3,$A$2)", ("SUM($A$3,$A$2)"), c.getCellFormula());
+                assertEquals("SUM($A$3,$A$2)", c.getCellFormula());
             }
         }
     }
@@ -526,9 +533,11 @@ public final class TestFormulas {
                 s = wb2.getSheet("B");
                 r = s.getRow(0);
                 c = r.getCell(0);
-                assertEquals("expected: AVERAGE(A!A1:B1) got: " + c.getCellFormula(), ("AVERAGE(A!A1:B1)"), c.getCellFormula());
+                assertEquals("AVERAGE(A!A1:B1)", c.getCellFormula(),
+                    "expected: AVERAGE(A!A1:B1) got: " + c.getCellFormula());
                 c = r.getCell(1);
-                assertEquals("expected: A!A1+A!B1 got: " + c.getCellFormula(), ("A!A1+A!B1"), c.getCellFormula());
+                assertEquals("A!A1+A!B1", c.getCellFormula(),
+                    "expected: A!A1+A!B1 got: " + c.getCellFormula());
             }
         }
     }
@@ -568,7 +577,7 @@ public final class TestFormulas {
             try (FileOutputStream out = new FileOutputStream(file)) {
                 wb.write(out);
             }
-            assertTrue("file exists", file.exists());
+            assertTrue(file.exists());
         }
     }
 
@@ -607,7 +616,7 @@ public final class TestFormulas {
                 s = wb2.getSheetAt(0);
                 r = s.getRow(0);
                 c = r.getCell(1);
-                assertEquals("Formula in cell 1 ", "IF(A1<A2,B1,B2)", c.getCellFormula());
+                assertEquals("IF(A1<A2,B1,B2)", c.getCellFormula(), "Formula in cell 1 ");
             }
         }
     }
@@ -661,7 +670,8 @@ public final class TestFormulas {
                 r = s.getRow(0);
                 c = r.getCell(4);
 
-                assertEquals("expected: IF(A1=D1,\"A1\",\"B1\") got " + c.getCellFormula(), ("IF(A1=D1,\"A1\",\"B1\")"), c.getCellFormula());
+                assertEquals("IF(A1=D1,\"A1\",\"B1\")", c.getCellFormula(),
+                    "expected: IF(A1=D1,\"A1\",\"B1\") got " + c.getCellFormula());
             }
         }
 
@@ -669,7 +679,8 @@ public final class TestFormulas {
             HSSFSheet s = wb1.getSheetAt(0);
             HSSFRow r = s.getRow(3);
             HSSFCell c = r.getCell(0);
-            assertEquals("expected: IF(A3=A1,\"A1\",\"A2\") got " + c.getCellFormula(), ("IF(A3=A1,\"A1\",\"A2\")"), c.getCellFormula());
+            assertEquals("IF(A3=A1,\"A1\",\"A2\")", c.getCellFormula(),
+                "expected: IF(A3=A1,\"A1\",\"A2\") got " + c.getCellFormula());
             //c = r.getCell((short)1);
             //assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula()));
         }
@@ -805,7 +816,7 @@ public final class TestFormulas {
     public void testStringFormulaRead() throws IOException {
         try (HSSFWorkbook w = openSample("StringFormulas.xls")) {
             HSSFCell c = w.getSheetAt(0).getRow(0).getCell(0);
-            assertEquals("String Cell value", "XYZ", c.getRichStringCellValue().getString());
+            assertEquals("XYZ", c.getRichStringCellValue().getString(), "String Cell value");
         }
     }
 
@@ -834,7 +845,7 @@ public final class TestFormulas {
     public void test27272_1() throws IOException {
         try (HSSFWorkbook wb = openSample("27272_1.xls")) {
             wb.getSheetAt(0);
-            assertEquals("Reference for named range ", "Compliance!#REF!", wb.getNameAt(0).getRefersToFormula());
+            assertEquals("Compliance!#REF!", wb.getNameAt(0).getRefersToFormula(), "Reference for named range");
             writeOutAndReadBack(wb).close();
         }
     }
@@ -843,7 +854,7 @@ public final class TestFormulas {
     @Test
     public void test27272_2() throws IOException {
         try (HSSFWorkbook wb = openSample("27272_2.xls")) {
-            assertEquals("Reference for named range ", "LOAD.POD_HISTORIES!#REF!", wb.getNameAt(0).getRefersToFormula());
+            assertEquals("LOAD.POD_HISTORIES!#REF!", wb.getNameAt(0).getRefersToFormula(), "Reference for named range");
             writeOutAndReadBack(wb).close();
         }
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.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.Assert.assertFalse;
-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.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 java.io.IOException;
 import java.util.ArrayList;
@@ -35,7 +35,6 @@ import org.apache.poi.hssf.HSSFTestDataS
 import org.apache.poi.hssf.model.InternalSheet;
 import org.apache.poi.hssf.record.DBCellRecord;
 import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.StringRecord;
 import org.apache.poi.ss.usermodel.BaseTestCell;
 import org.apache.poi.ss.usermodel.Cell;
@@ -46,7 +45,7 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests various functionality having to do with {@link HSSFCell}.  For instance support for
@@ -72,18 +71,18 @@ public final class TestHSSFCell extends
 		try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("1900DateWindowing.xls")) {
 			HSSFSheet sheet = wb.getSheetAt(0);
 
-			assertEquals("Date from file using 1900 Date Windowing",
-						 date.getTime(),
-						 sheet.getRow(0).getCell(0).getDateCellValue().getTime());
+			assertEquals(date.getTime(),
+						 sheet.getRow(0).getCell(0).getDateCellValue().getTime(),
+						 "Date from file using 1900 Date Windowing");
 		}
 
 		// now check a file with 1904 Date Windowing
 		try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("1904DateWindowing.xls")) {
 			HSSFSheet sheet = wb.getSheetAt(0);
 
-			assertEquals("Date from file using 1904 Date Windowing",
-						 date.getTime(),
-						 sheet.getRow(0).getCell(0).getDateCellValue().getTime());
+			assertEquals(date.getTime(),
+						 sheet.getRow(0).getCell(0).getDateCellValue().getTime(),
+						 "Date from file using 1904 Date Windowing");
 		}
 	}
 
@@ -106,9 +105,9 @@ public final class TestHSSFCell extends
 			setCell(wb1, 0, 1, date);
 			try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
 
-				assertEquals("Date from file using 1900 Date Windowing",
-							 date.getTime(),
-							 readCell(wb2, 0, 1).getTime());
+				assertEquals(date.getTime(),
+							 readCell(wb2, 0, 1).getTime(),
+							 "Date from file using 1900 Date Windowing");
 			}
 		}
 
@@ -116,9 +115,9 @@ public final class TestHSSFCell extends
 		try (HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("1904DateWindowing.xls")) {
 			setCell(wb1, 0, 1, date);
 			try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
-				assertEquals("Date from file using 1900 Date Windowing",
-							 date.getTime(),
-							 readCell(wb2, 0, 1).getTime());
+				assertEquals(date.getTime(),
+							 readCell(wb2, 0, 1).getTime(),
+							 "Date from file using 1900 Date Windowing");
 			}
 		}
 	}
@@ -152,28 +151,22 @@ public final class TestHSSFCell extends
 			//check initial position
 			HSSFSheet umSheet = wb1.getSheetAt(0);
 			InternalSheet s = umSheet.getSheet();
-			assertEquals("Initial active cell should be in col 0",
-						 (short) 0, s.getActiveCellCol());
-			assertEquals("Initial active cell should be on row 1",
-						 1, s.getActiveCellRow());
+			assertEquals((short) 0, s.getActiveCellCol(), "Initial active cell should be in col 0");
+			assertEquals(1, s.getActiveCellRow(), "Initial active cell should be on row 1");
 
 			//modify position through HSSFCell
 			HSSFCell cell = umSheet.createRow(3).createCell(2);
 			cell.setAsActiveCell();
-			assertEquals("After modify, active cell should be in col 2",
-						 (short) 2, s.getActiveCellCol());
-			assertEquals("After modify, active cell should be on row 3",
-						 3, s.getActiveCellRow());
+			assertEquals((short) 2, s.getActiveCellCol(), "After modify, active cell should be in col 2");
+			assertEquals(3, s.getActiveCellRow(), "After modify, active cell should be on row 3");
 
 			//write book to temp file; read and verify that position is serialized
 			try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
 				umSheet = wb2.getSheetAt(0);
 				s = umSheet.getSheet();
 
-				assertEquals("After serialize, active cell should be in col 2",
-							 (short) 2, s.getActiveCellCol());
-				assertEquals("After serialize, active cell should be on row 3",
-							 3, s.getActiveCellRow());
+				assertEquals((short) 2, s.getActiveCellCol(), "After serialize, active cell should be in col 2");
+				assertEquals(3, s.getActiveCellRow(), "After serialize, active cell should be on row 3");
 			}
 		}
 	}
@@ -278,36 +271,16 @@ public final class TestHSSFCell extends
 
 			styA.verifyBelongsToWorkbook(wbA);
 			styB.verifyBelongsToWorkbook(wbB);
-			try {
-				styA.verifyBelongsToWorkbook(wbB);
-				fail("expected IllegalArgumentException");
-			} catch (IllegalArgumentException e) {
-				// expected during successful test
-			}
-			try {
-				styB.verifyBelongsToWorkbook(wbA);
-				fail("expected IllegalArgumentException");
-			} catch (IllegalArgumentException e) {
-				// expected during successful test
-			}
+			assertThrows(IllegalArgumentException.class, () -> styA.verifyBelongsToWorkbook(wbB));
+			assertThrows(IllegalArgumentException.class, () -> styB.verifyBelongsToWorkbook(wbA));
 
 			Cell cellA = wbA.createSheet().createRow(0).createCell(0);
 			Cell cellB = wbB.createSheet().createRow(0).createCell(0);
 
 			cellA.setCellStyle(styA);
 			cellB.setCellStyle(styB);
-			try {
-				cellA.setCellStyle(styB);
-				fail("expected IllegalArgumentException");
-			} catch (IllegalArgumentException e) {
-				// expected during successful test
-			}
-			try {
-				cellB.setCellStyle(styA);
-				fail("expected IllegalArgumentException");
-			} catch (IllegalArgumentException e) {
-				// expected during successful test
-			}
+			assertThrows(IllegalArgumentException.class, () -> cellA.setCellStyle(styB));
+			assertThrows(IllegalArgumentException.class, () -> cellB.setCellStyle(styA));
 		}
 	}
 
@@ -329,7 +302,7 @@ public final class TestHSSFCell extends
 
 			final List<org.apache.poi.hssf.record.Record> recs = new ArrayList<>();
 			sheet.getSheet().visitContainedRecords(recs::add, 0);
-			assertFalse("Identified bug - leftover StringRecord", recs.size() == 28 && recs.get(23) instanceof StringRecord);
+			assertFalse(recs.size() == 28 && recs.get(23) instanceof StringRecord, "Identified bug - leftover StringRecord");
 			confirmStringRecord(sheet, false);
 
 			// string to error code
@@ -390,12 +363,7 @@ public final class TestHSSFCell extends
 			// cover some deprecated methods and other smaller stuff...
 			assertEquals(wb.getWorkbook(), cell.getBoundWorkbook());
 
-			try {
-				cell.getCachedFormulaResultType();
-				fail("Should catch exception");
-			} catch (IllegalStateException e) {
-				// expected here
-			}
+			assertThrows(IllegalStateException.class, cell::getCachedFormulaResultType);
 
 			cell.removeCellComment();
 			cell.removeCellComment();
@@ -410,7 +378,7 @@ public final class TestHSSFCell extends
 			Cell cell = row.createCell(0);
 
 			cell.setBlank();
-			assertNull(null, cell.getDateCellValue());
+			assertNull(cell.getDateCellValue());
 			assertFalse(cell.getBooleanCellValue());
 			assertEquals("", cell.toString());
 
@@ -440,11 +408,11 @@ public final class TestHSSFCell extends
 		}
     }
 
-	@Test(expected = IllegalStateException.class)
+	@Test
 	public void getErrorCellValue_throwsISE_onABlankCell() throws IOException {
 		try (HSSFWorkbook wb = new HSSFWorkbook()) {
 			Cell cell = wb.createSheet().createRow(0).createCell(0);
-			cell.getErrorCellValue();
+			assertThrows(IllegalStateException.class, cell::getErrorCellValue);
 		}
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.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.assertNotSame;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.io.IOException;
 
@@ -29,7 +29,7 @@ import org.apache.poi.hssf.record.chart.
 import org.apache.poi.hssf.usermodel.HSSFChart.HSSFSeries;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddressBase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link HSSFChart}
@@ -139,26 +139,26 @@ public final class TestHSSFChart {
 		assertEquals("Base Numbers", charts[0].getSeries()[1].getSeriesTitle());
 		assertEquals("Sheet 3 Chart with Title", charts[0].getChartTitle());
 	}
-	
+
     @Test
     public void testExistingSheet3() throws Exception {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls");
-        
+
         HSSFSheet sheet = wb.getSheetAt( 2 ) ;
         HSSFChart[] charts = HSSFChart.getSheetCharts( sheet ) ;
         assertEquals(1, charts.length);
-        
+
         for ( HSSFChart chart : charts ) {
             for ( HSSFSeries series : chart.getSeries() ) {
                 chart.removeSeries( series ) ;
             }
         }
-        
+
         // Save and re-check
         wb = HSSFITestDataProvider.instance.writeOutAndReadBack(wb);
         sheet = wb.getSheetAt( 2 ) ;
         assertEquals(1, HSSFChart.getSheetCharts(sheet).length);
-        
+
         HSSFChart c = HSSFChart.getSheetCharts(sheet)[0];
         assertEquals(0, c.getSeries().length);
     }
@@ -168,11 +168,11 @@ public final class TestHSSFChart {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls");
         HSSFSheet sheet = wb.getSheetAt( 1 ) ;
         HSSFChart[] charts = HSSFChart.getSheetCharts( sheet ) ;
-        
+
         assertEquals(1, charts.length);
         for ( HSSFChart chart : charts ) {
             HSSFSeries series ;
-            
+
             // Starts with one
             assertEquals(1, chart.getSeries().length);
 
@@ -185,12 +185,12 @@ public final class TestHSSFChart {
             series.setCategoryLabelsCellRange( new CellRangeAddress( 6, 7, 0, 0 ) ) ;
             series.setValuesCellRange( new CellRangeAddress( 6, 7, 1, 1 ) ) ;
         }
-        
+
         // Save and re-check
         wb = HSSFITestDataProvider.instance.writeOutAndReadBack(wb);
         sheet = wb.getSheetAt( 1 ) ;
         assertEquals(1, HSSFChart.getSheetCharts(sheet).length);
-        
+
         HSSFChart c = HSSFChart.getSheetCharts(sheet)[0];
         assertEquals(3, c.getSeries().length);
     }
@@ -200,7 +200,7 @@ public final class TestHSSFChart {
        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49581.xls");
         HSSFSheet sheet = wb.getSheetAt( 0 ) ;
         HSSFChart[] charts = HSSFChart.getSheetCharts( sheet ) ;
-        
+
         for ( HSSFChart chart : charts ) {
             //System.out.println( chart.getType() ) ;
             HSSFSeries[] seriesArray = chart.getSeries() ;
@@ -237,7 +237,7 @@ public final class TestHSSFChart {
         HSSFChart chart = charts[ 2 ] ;
         chart.removeSeries( chart.getSeries()[ 0 ] ) ;
     }
-    
+
     /**
      * Bug 26862: HSSFWorkbook.cloneSheet copies charts
      */
@@ -248,10 +248,10 @@ public final class TestHSSFChart {
         HSSFChart[] srcCharts = HSSFChart.getSheetCharts(srcSheet);
         assertEquals(1, srcCharts.length);
         HSSFChart srcChart = srcCharts[0];
-        
+
         // Clone the sheet
         HSSFSheet clonedSheet = wb.cloneSheet(0);
-        
+
         // Verify the chart was copied
         HSSFChart[] clonedCharts = HSSFChart.getSheetCharts(clonedSheet);
         assertEquals(1, clonedCharts.length);
@@ -263,11 +263,11 @@ public final class TestHSSFChart {
         assertEquals(srcChart.getChartHeight(), clonedChart.getChartHeight());
         assertEquals(srcChart.getChartX(), clonedChart.getChartX());
         assertEquals(srcChart.getChartY(), clonedChart.getChartY());
-        
+
         // Check if chart was shallow copied or deep copied
         clonedChart.setChartWidth(clonedChart.getChartWidth()+10);
         assertEquals(srcChart.getChartWidth()+10, clonedChart.getChartWidth());
-        
+
         wb.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFClientAnchor.java Thu Dec 24 18:42:29 2020
@@ -17,13 +17,14 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
 
 import org.apache.poi.ddf.EscherClientAnchorRecord;
 import org.apache.poi.hssf.model.ConvertAnchor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Various tests for HSSFClientAnchor.
@@ -128,9 +129,10 @@ public final class TestHSSFClientAnchor
         assertEquals(65535, anchor.getRow2());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testCannotHaveRowGreaterThan65535() {
-        new HSSFClientAnchor(0, 0, 0, 0, (short) 0, 65536, (short) 0, 65536);
+        assertThrows(IllegalArgumentException.class, () ->
+            new HSSFClientAnchor(0, 0, 0, 0, (short) 0, 65536, (short) 0, 65536));
     }
 
     /**
@@ -146,13 +148,15 @@ public final class TestHSSFClientAnchor
         assertEquals(65535, anchor.getRow2());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testCannotSetRow1GreaterThan65535() {
-        new HSSFClientAnchor().setRow1(65536);
+        assertThrows(IllegalArgumentException.class, () ->
+            new HSSFClientAnchor().setRow1(65536));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testCannotSetRow2GreaterThan65535() {
-        new HSSFClientAnchor().setRow2(65536);
+        assertThrows(IllegalArgumentException.class, () ->
+            new HSSFClientAnchor().setRow2(65536));
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java Thu Dec 24 18:42:29 2020
@@ -17,12 +17,12 @@
 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.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 
@@ -44,7 +44,7 @@ import org.apache.poi.ss.usermodel.RichT
 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;
 
 /**
  * Tests TestHSSFCellComment.
@@ -97,10 +97,10 @@ public final class TestHSSFComment exten
         cell = sheet.getRow(5).getCell(2);
         comment = cell.getCellComment();
         assertEquals("c6", comment.getString().getString());
-        
+
         wb.close();
     }
-    
+
     @Test
     public void testBug56380InsertComments() throws Exception {
         HSSFWorkbook workbook = new HSSFWorkbook();
@@ -108,7 +108,7 @@ public final class TestHSSFComment exten
         Drawing<?> drawing = sheet.createDrawingPatriarch();
         int noOfRows = 1025;
         String comment = "c";
-        
+
         for(int i = 0; i < noOfRows; i++) {
             Row row = sheet.createRow(i);
             Cell cell = row.createCell(0);
@@ -125,14 +125,14 @@ public final class TestHSSFComment exten
         } finally {
             fs.close();
         }*/
-        
+
         // save and recreate the workbook from the saved file
         HSSFWorkbook workbookBack = HSSFTestDataSamples.writeOutAndReadBack(workbook);
         sheet = workbookBack.getSheetAt(0);
-        
+
         // assert that the comments are created properly after reading back in
         checkComments(sheet, noOfRows, comment);
-        
+
         workbook.close();
         workbookBack.close();
     }
@@ -173,7 +173,7 @@ public final class TestHSSFComment exten
         for(int i = 0; i < noOfRows; i++) {
             assertNotNull(sheet.getRow(i));
             assertNotNull(sheet.getRow(i).getCell(0));
-            assertNotNull("Did not get a Cell Comment for row " + i, sheet.getRow(i).getCell(0).getCellComment());
+            assertNotNull(sheet.getRow(i).getCell(0).getCellComment(), "Did not get a Cell Comment for row " + i);
             assertNotNull(sheet.getRow(i).getCell(0).getCellComment().getString());
             assertEquals(comment + i, sheet.getRow(i).getCell(0).getCellComment().getString().getString());
         }
@@ -181,27 +181,27 @@ public final class TestHSSFComment exten
 
     private Comment insertComment(Drawing<?> drawing, Cell cell, String message) {
         CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();
-        
+
         ClientAnchor anchor = factory.createClientAnchor();
         anchor.setCol1(cell.getColumnIndex());
         anchor.setCol2(cell.getColumnIndex() + 1);
         anchor.setRow1(cell.getRowIndex());
         anchor.setRow2(cell.getRowIndex() + 1);
-        anchor.setDx1(100); 
+        anchor.setDx1(100);
         anchor.setDx2(100);
         anchor.setDy1(100);
         anchor.setDy2(100);
-            
+
         Comment comment = drawing.createCellComment(anchor);
-        
+
         RichTextString str = factory.createRichTextString(message);
         comment.setString(str);
         comment.setAuthor("fanfy");
         cell.setCellComment(comment);
-        
+
         return comment;
     }
-    
+
     @Test
     public void resultEqualsToNonExistingAbstractShape() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
@@ -308,7 +308,7 @@ public final class TestHSSFComment exten
         assertEquals(((HSSFComment) patriarch.getChildren().get(0)).getString().getString(), "comment1");
         assertEquals(((HSSFComment) patriarch.getChildren().get(1)).getString().getString(), "comment2");
         assertEquals(((HSSFComment) patriarch.getChildren().get(2)).getString().getString(), "comment3");
-        
+
         wb.close();
         wbBack.close();
         wbBack2.close();
@@ -364,7 +364,7 @@ public final class TestHSSFComment exten
         assertEquals(comment.getColumn(), 32);
         assertEquals(comment.getRow(), 42);
         assertTrue(comment.isVisible());
-        
+
         wb.close();
         wbBack.close();
         wbBack2.close();
@@ -403,7 +403,7 @@ public final class TestHSSFComment exten
 
         assertNotNull(sh.findCellComment(5, 4));
         assertNull(sh.findCellComment(5, 5));
-        
+
         wb.close();
         wbBack.close();
     }
@@ -424,7 +424,7 @@ public final class TestHSSFComment exten
         assertNotNull(shape);
 
         assertEquals(comment.getOptRecord().getEscherProperties().size(), 10);
-        
+
         wb.close();
     }
 
@@ -446,7 +446,7 @@ public final class TestHSSFComment exten
         assertEquals(2024, spRecord.getShapeId(), 2024);
         assertEquals(2024, comment.getShapeId(), 2024);
         assertEquals(2024, comment.getNoteRecord().getShapeId());
-        
+
         wb.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java Thu Dec 24 18:42:29 2020
@@ -18,14 +18,19 @@
 package org.apache.poi.hssf.usermodel;
 
 
-import static org.junit.Assert.*;
+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.HSSFITestDataProvider;
 import org.apache.poi.hssf.util.HSSFColor;
-import org.apache.poi.ss.usermodel.*;
-import org.junit.Test;
+import org.apache.poi.ss.usermodel.BaseTestConditionalFormatting;
+import org.apache.poi.ss.usermodel.Color;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.junit.jupiter.api.Test;
 
 /**
  * HSSF-specific Conditional Formatting tests
@@ -35,8 +40,8 @@ public final class TestHSSFConditionalFo
         super(HSSFITestDataProvider.instance);
     }
     @Override
-    protected void assertColour(String hexExpected, Color actual) {
-        assertNotNull("Colour must be given", actual);
+    protected void assertColor(String hexExpected, Color actual) {
+        assertNotNull(actual, "Colour must be given");
         if (actual instanceof HSSFColor) {
             HSSFColor colour = (HSSFColor)actual;
             assertEquals(hexExpected, colour.getHexString());
@@ -54,7 +59,7 @@ public final class TestHSSFConditionalFo
     public void testRead() throws IOException {
         testRead("WithConditionalFormatting.xls");
     }
-    
+
     @Test
     public void testReadOffice2007() throws IOException {
         testReadOffice2007("NewStyleConditionalFormattings.xls");
@@ -73,10 +78,10 @@ public final class TestHSSFConditionalFo
         }
 
         wb.removeSheetAt(1);*/
-        
+
         // initially it is good
         writeTemp53691(wb, "agood");
-        
+
         // clone sheet corrupts it
         Sheet sheet = wb.cloneSheet(0);
         writeTemp53691(wb, "bbad");
@@ -84,28 +89,28 @@ public final class TestHSSFConditionalFo
         // removing the sheet makes it good again
         wb.removeSheetAt(wb.getSheetIndex(sheet));
         writeTemp53691(wb, "cgood");
-        
+
         // cloning again and removing the conditional formatting makes it good again
         sheet = wb.cloneSheet(0);
-        removeConditionalFormatting(sheet);        
+        removeConditionalFormatting(sheet);
         writeTemp53691(wb, "dgood");
-        
+
         // cloning the conditional formatting manually makes it bad again
         cf = sheet.getSheetConditionalFormatting();
         SheetConditionalFormatting scf = wb.getSheetAt(0).getSheetConditionalFormatting();
         for (int j = 0; j < scf.getNumConditionalFormattings(); j++) {
             cf.addConditionalFormatting(scf.getConditionalFormattingAt(j));
-        }        
+        }
         writeTemp53691(wb, "ebad");
 
         // remove all conditional formatting for comparing BIFF output
-        removeConditionalFormatting(sheet);        
-        removeConditionalFormatting(wb.getSheetAt(0));        
+        removeConditionalFormatting(sheet);
+        removeConditionalFormatting(wb.getSheetAt(0));
         writeTemp53691(wb, "fgood");
-        
+
         wb.close();
     }
-    
+
     private void removeConditionalFormatting(Sheet sheet) {
         SheetConditionalFormatting cf = sheet.getSheetConditionalFormatting();
         for (int j = 0; j < cf.getNumConditionalFormattings(); j++) {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormat.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.io.IOException;
 
@@ -32,7 +32,7 @@ import org.apache.poi.ss.usermodel.DataF
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link HSSFDataFormat}
@@ -62,12 +62,12 @@ public final class TestHSSFDataFormat ex
         short customFmtIdx = dataFormat.getFormat("\u00a3##.00[Yellow]");
         assertTrue(customFmtIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX );
         assertEquals("\u00a3##.00[Yellow]", dataFormat.getFormat(customFmtIdx));
-        
+
         wb.close();
     }
 
     /**
-     * [Bug 58532] Handle formats that go numnum, numK, numM etc 
+     * [Bug 58532] Handle formats that go numnum, numK, numM etc
      */
     @Override
     @Test

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.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.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
@@ -35,9 +35,9 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit tests for HSSFDataFormatter.java
@@ -45,14 +45,14 @@ import org.junit.Test;
 public final class TestHSSFDataFormatter {
     private static TimeZone userTimeZone;
 
-    @BeforeClass
+    @BeforeAll
     public static void setTimeZone() {
         userTimeZone = LocaleUtil.getUserTimeZone();
         LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CET"));
         LocaleUtil.setUserLocale(Locale.US);
     }
 
-    @AfterClass
+    @AfterAll
     public static void resetTimeZone() {
         LocaleUtil.setUserTimeZone(userTimeZone);
         LocaleUtil.setUserLocale(Locale.ROOT);
@@ -109,10 +109,10 @@ public final class TestHSSFDataFormatter
         String[] goodTimePatterns = {
             "HH:MM",
             "HH:MM:SS",
-            "HH:MM;HH:MM;HH:MM", 
+            "HH:MM;HH:MM;HH:MM",
             // This is fun - blue if positive time,
             //  red if negative time or green for zero!
-            "[BLUE]HH:MM;[RED]HH:MM;[GREEN]HH:MM", 
+            "[BLUE]HH:MM;[RED]HH:MM;[GREEN]HH:MM",
             "yyyy-mm-dd hh:mm",
             "yyyy-mm-dd hh:mm:ss",
         };
@@ -241,7 +241,7 @@ public final class TestHSSFDataFormatter
 
             // should not be equal to "555.555"
             assertTrue( DateUtil.isCellDateFormatted(cell) );
-            assertFalse("555.555".equals(fmtval));
+            assertNotEquals(fmtval, "555.555");
 
             String fmt = cell.getCellStyle().getDataFormatString();
 
@@ -257,7 +257,7 @@ public final class TestHSSFDataFormatter
                 jul = jul.substring(0,1);
             }
             // check we found july properly
-            assertTrue("Format came out incorrect - " + fmt, fmtval.contains(jul));
+            assertTrue(fmtval.contains(jul), "Format came out incorrect - " + fmt);
         }
 
         row = wb.getSheetAt(0).getRow(1);
@@ -271,11 +271,11 @@ public final class TestHSSFDataFormatter
 
             // should not be equal to "555.47431"
             assertTrue( DateUtil.isCellDateFormatted(cell) );
-            assertFalse("555.47431".equals(fmtval));
+            assertNotEquals(fmtval, "555.47431");
 
             // check we found the time properly
-            assertTrue("Format came out incorrect - " + fmt + " - found " + fmtval + 
-                       ", but expected to find '11:23'", fmtval.contains("11:23"));
+            assertTrue(fmtval.contains("11:23"),
+                "Format came out incorrect - " + fmt + " - found " + fmtval + ", but expected to find '11:23'");
         }
 
         // test number formats
@@ -367,10 +367,10 @@ public final class TestHSSFDataFormatter
             Cell cell = it.next();
             cell.setCellValue(cell.getNumericCellValue() * Math.random() / 1000000 - 1000);
             log(formatter.formatCellValue(cell));
-            
-            String formatted = formatter.formatCellValue(cell); 
-            assertTrue("Doesn't start with Balance: " + formatted, formatted.startsWith("Balance "));
-            assertTrue("Doesn't end with USD: " + formatted, formatted.endsWith(" USD"));
+
+            String formatted = formatter.formatCellValue(cell);
+            assertTrue(formatted.startsWith("Balance "), "Doesn't start with Balance: " + formatted);
+            assertTrue(formatted.endsWith(" USD"), "Doesn't end with USD: " + formatted);
         }
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java Thu Dec 24 18:42:29 2020
@@ -17,10 +17,10 @@
 
 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.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.util.TimeZone;
@@ -29,9 +29,9 @@ import org.apache.poi.hssf.HSSFTestDataS
 import org.apache.poi.hssf.model.InternalWorkbook;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.util.LocaleUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 /**
  * Class TestHSSFDateUtil
@@ -39,14 +39,14 @@ import org.junit.Test;
 public class TestHSSFDateUtil {
 
     static TimeZone userTimeZone;
-    
-    @BeforeClass
+
+    @BeforeAll
     public static void setCEST() {
         userTimeZone = LocaleUtil.getUserTimeZone();
         LocaleUtil.setUserTimeZone(TimeZone.getTimeZone("CEST"));
     }
-    
-    @AfterClass
+
+    @AfterAll
     public static void resetTimeZone() {
         LocaleUtil.setUserTimeZone(userTimeZone);
     }
@@ -54,7 +54,7 @@ public class TestHSSFDateUtil {
     /**
      * Test that against a real, test file, we still do everything
      *  correctly
-     * @throws IOException 
+     * @throws IOException
      */
     @Test
     public void onARealFile() throws IOException {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java Thu Dec 24 18:42:29 2020
@@ -17,15 +17,15 @@
 
 package org.apache.poi.hssf.usermodel;
 
+import java.util.AbstractMap;
+import java.util.Map;
+
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.formula.EvaluationSheet;
 import org.apache.poi.ss.usermodel.BaseTestXEvaluationSheet;
 import org.apache.poi.ss.usermodel.Name;
 import org.apache.poi.ss.usermodel.Sheet;
-import org.junit.Test;
-
-import java.util.AbstractMap;
-import java.util.Map;
+import org.junit.jupiter.api.Test;
 
 public class TestHSSFEvaluationSheet extends BaseTestXEvaluationSheet {
     @Override
@@ -33,7 +33,7 @@ public class TestHSSFEvaluationSheet ext
         HSSFSheet sheet = new HSSFWorkbook().createSheet();
         return new AbstractMap.SimpleEntry<>(sheet, new HSSFEvaluationSheet(sheet));
     }
-    
+
     @Test
     public void testMissingExternalName() {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("external_name.xls");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFont.java Thu Dec 24 18:42:29 2020
@@ -22,7 +22,7 @@ import java.io.IOException;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.ss.usermodel.BaseTestFont;
 import org.apache.poi.ss.usermodel.Font;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests various functionality having to do with {@link org.apache.poi.ss.usermodel.Name}.

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java Thu Dec 24 18:42:29 2020
@@ -17,8 +17,10 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 
@@ -35,7 +37,7 @@ import org.apache.poi.ss.usermodel.BaseT
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
 
@@ -43,258 +45,249 @@ public final class TestHSSFFormulaEvalua
         super(HSSFITestDataProvider.instance);
     }
 
-	/**
-	 * Test that the HSSFFormulaEvaluator can evaluate simple named ranges
-	 *  (single cells and rectangular areas)
-	 */
+    /**
+     * Test that the HSSFFormulaEvaluator can evaluate simple named ranges
+     * (single cells and rectangular areas)
+     */
     @Test
-	public void testEvaluateSimple() throws IOException {
-		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testNames.xls");
-		HSSFSheet sheet = wb.getSheetAt(0);
-		HSSFCell cell = sheet.getRow(8).getCell(0);
-		HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
-		CellValue cv = fe.evaluate(cell);
-		assertEquals(CellType.NUMERIC, cv.getCellType());
-		assertEquals(3.72, cv.getNumberValue(), 0.0);
-		wb.close();
-	}
-
-	/**
-	 * When evaluating defined names, POI has to decide whether it is capable.  Currently
-	 * (May2009) POI only supports simple cell and area refs.<br>
-	 * The sample spreadsheet (bugzilla attachment 23508) had a name flagged as 'complex'
-	 * which contained a simple area ref.  It is not clear what the 'complex' flag is used
-	 * for but POI should look elsewhere to decide whether it can evaluate the name.
-	 */
-    @Test
-	public void testDefinedNameWithComplexFlag_bug47048() throws IOException {
-		// Mock up a spreadsheet to match the critical details of the sample
-		HSSFWorkbook wb = new HSSFWorkbook();
-		HSSFSheet sheet = wb.createSheet("Input");
-		HSSFName definedName = wb.createName();
-		definedName.setNameName("Is_Multicar_Vehicle");
-		definedName.setRefersToFormula("Input!$B$17:$G$17");
-
-		// Set up some data and the formula
-		HSSFRow row17 = sheet.createRow(16);
-		row17.createCell(0).setCellValue(25.0);
-		row17.createCell(1).setCellValue(1.33);
-		row17.createCell(2).setCellValue(4.0);
-
-		HSSFRow row = sheet.createRow(0);
-		HSSFCell cellA1 = row.createCell(0);
-		cellA1.setCellFormula("SUM(Is_Multicar_Vehicle)");
-
-		// Set the complex flag - POI doesn't usually manipulate this flag
-		NameRecord nameRec = TestHSSFName.getNameRecord(definedName);
-		nameRec.setOptionFlag((short)0x10); // 0x10 -> complex
-
-		HSSFFormulaEvaluator hsf = new HSSFFormulaEvaluator(wb);
-		CellValue value;
-		try {
-			value = hsf.evaluate(cellA1);
-
-	        assertEquals(CellType.NUMERIC, value.getCellType());
-	        assertEquals(5.33, value.getNumberValue(), 0.0);
-	        
-		} catch (RuntimeException e) {
-			if (e.getMessage().equals("Don't know how to evaluate name 'Is_Multicar_Vehicle'")) {
-				fail("Identified bug 47048a");
-			}
-			throw e;
-		} finally {
-	        wb.close();
-		}
-	}
-    
-	private static final class EvalCountListener extends EvaluationListener {
-		private int _evalCount;
-		public EvalCountListener() {
-			_evalCount = 0;
-		}
-		@Override
-		public void onStartEvaluate(EvaluationCell cell, ICacheEntry entry) {
-			_evalCount++;
-		}
-		public int getEvalCount() {
-			return _evalCount;
-		}
-	}
+    public void testEvaluateSimple() throws IOException {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testNames.xls");
+        HSSFSheet sheet = wb.getSheetAt(0);
+        HSSFCell cell = sheet.getRow(8).getCell(0);
+        HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+        CellValue cv = fe.evaluate(cell);
+        assertEquals(CellType.NUMERIC, cv.getCellType());
+        assertEquals(3.72, cv.getNumberValue(), 0.0);
+        wb.close();
+    }
 
-	/**
-	 * The HSSFFormula evaluator performance benefits greatly from caching of intermediate cell values
-	 */
-	@Test
-	public void testShortCircuitIfEvaluation() throws IOException {
-		// Set up a simple IF() formula that has measurable evaluation cost for its operands.
-		HSSFWorkbook wb = new HSSFWorkbook();
-		HSSFSheet sheet = wb.createSheet("Sheet1");
-		HSSFRow row = sheet.createRow(0);
-		HSSFCell cellA1 = row.createCell(0);
-		cellA1.setCellFormula("if(B1,C1,D1+E1+F1)");
-		// populate cells B1..F1 with simple formulas instead of plain values so we can use
-		// EvaluationListener to check which parts of the first formula get evaluated
-		for (int i=1; i<6; i++) {
-			// formulas are just literal constants "1".."5"
-			row.createCell(i).setCellFormula(String.valueOf(i));
-		}
+    /**
+     * When evaluating defined names, POI has to decide whether it is capable.  Currently
+     * (May2009) POI only supports simple cell and area refs.<br>
+     * The sample spreadsheet (bugzilla attachment 23508) had a name flagged as 'complex'
+     * which contained a simple area ref.  It is not clear what the 'complex' flag is used
+     * for but POI should look elsewhere to decide whether it can evaluate the name.
+     */
+    @Test
+    public void testDefinedNameWithComplexFlag_bug47048() throws IOException {
+        // Mock up a spreadsheet to match the critical details of the sample
+        HSSFWorkbook wb = new HSSFWorkbook();
+        HSSFSheet sheet = wb.createSheet("Input");
+        HSSFName definedName = wb.createName();
+        definedName.setNameName("Is_Multicar_Vehicle");
+        definedName.setRefersToFormula("Input!$B$17:$G$17");
+
+        // Set up some data and the formula
+        HSSFRow row17 = sheet.createRow(16);
+        row17.createCell(0).setCellValue(25.0);
+        row17.createCell(1).setCellValue(1.33);
+        row17.createCell(2).setCellValue(4.0);
+
+        HSSFRow row = sheet.createRow(0);
+        HSSFCell cellA1 = row.createCell(0);
+        cellA1.setCellFormula("SUM(Is_Multicar_Vehicle)");
+
+        // Set the complex flag - POI doesn't usually manipulate this flag
+        NameRecord nameRec = TestHSSFName.getNameRecord(definedName);
+        nameRec.setOptionFlag((short) 0x10); // 0x10 -> complex
+
+        HSSFFormulaEvaluator hsf = new HSSFFormulaEvaluator(wb);
+        CellValue value;
+        try {
+            value = hsf.evaluate(cellA1);
+
+            assertEquals(CellType.NUMERIC, value.getCellType());
+            assertEquals(5.33, value.getNumberValue(), 0.0);
+
+        } catch (RuntimeException e) {
+            if (e.getMessage().equals("Don't know how to evaluate name 'Is_Multicar_Vehicle'")) {
+                fail("Identified bug 47048a");
+            }
+            throw e;
+        } finally {
+            wb.close();
+        }
+    }
 
-		EvalCountListener evalListener = new EvalCountListener();
-		WorkbookEvaluator evaluator = WorkbookEvaluatorTestHelper.createEvaluator(wb, evalListener);
-		ValueEval ve = evaluator.evaluate(HSSFEvaluationTestHelper.wrapCell(cellA1));
-		int evalCount = evalListener.getEvalCount();
-		if (evalCount == 6) {
-			// Without short-circuit-if evaluation, evaluating cell 'A1' takes 3 extra evaluations (for D1,E1,F1)
-			fail("Identifed bug 48195 - Formula evaluator should short-circuit IF() calculations.");
-		}
-		assertEquals(3, evalCount);
-		assertEquals(2.0, ((NumberEval)ve).getNumberValue(), 0D);
+    private static final class EvalCountListener extends EvaluationListener {
+        private int _evalCount;
 
-		wb.close();
-	}
+        public EvalCountListener() {
+            _evalCount = 0;
+        }
+
+        @Override
+        public void onStartEvaluate(EvaluationCell cell, ICacheEntry entry) {
+            _evalCount++;
+        }
+
+        public int getEvalCount() {
+            return _evalCount;
+        }
+    }
 
-	/**
-	 * Ensures that we can handle NameXPtgs in the formulas
-	 *  we parse.
-	 */
-	@Test
-	public void testXRefs() throws IOException {
-      HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
-      HSSFWorkbook wb2 = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
-      Cell cell;
-      
-      // VLookup on a name in another file
-      cell = wb1.getSheetAt(0).getRow(1).getCell(2);
-      assertEquals(CellType.FORMULA, cell.getCellType());
-      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
-      assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
-      // WARNING - this is wrong!
-      // The file name should be showing, but bug #45970 is fixed
-      //  we seem to loose it
-      assertEquals("VLOOKUP(PART,COSTS,2,FALSE)", cell.getCellFormula());
-      
-      
-      // Simple reference to a name in another file
-      cell = wb1.getSheetAt(0).getRow(1).getCell(4);
-      assertEquals(CellType.FORMULA, cell.getCellType());
-      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
-      assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
-      // TODO Correct this!
-      // The file name should be shown too, see bug #56742
-      assertEquals("Cost*Markup_Cost", cell.getCellFormula());
-      
-      
-      // Evaluate the cells
-      HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb1);
-      HSSFFormulaEvaluator.setupEnvironment(
-            new String[] { "XRefCalc.xls", "XRefCalcData.xls" },
-            new HSSFFormulaEvaluator[] {
-                  eval,
-                  new HSSFFormulaEvaluator(wb2)
+    /**
+     * The HSSFFormula evaluator performance benefits greatly from caching of intermediate cell values
+     */
+    @Test
+    public void testShortCircuitIfEvaluation() throws IOException {
+        // Set up a simple IF() formula that has measurable evaluation cost for its operands.
+        try (HSSFWorkbook wb = new HSSFWorkbook()) {
+            HSSFSheet sheet = wb.createSheet("Sheet1");
+            HSSFRow row = sheet.createRow(0);
+            HSSFCell cellA1 = row.createCell(0);
+            cellA1.setCellFormula("if(B1,C1,D1+E1+F1)");
+            // populate cells B1..F1 with simple formulas instead of plain values so we can use
+            // EvaluationListener to check which parts of the first formula get evaluated
+            for (int i = 1; i < 6; i++) {
+                // formulas are just literal constants "1".."5"
+                row.createCell(i).setCellFormula(String.valueOf(i));
             }
-      );
-      eval.evaluateFormulaCell(
-            wb1.getSheetAt(0).getRow(1).getCell(2)
-      );      
-      eval.evaluateFormulaCell(
-            wb1.getSheetAt(0).getRow(1).getCell(4)
-      );      
-      
-
-      // Re-check VLOOKUP one
-      cell = wb1.getSheetAt(0).getRow(1).getCell(2);
-      assertEquals(CellType.FORMULA, cell.getCellType());
-      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
-      assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
-      
-      // Re-check ref one
-      cell = wb1.getSheetAt(0).getRow(1).getCell(4);
-      assertEquals(CellType.FORMULA, cell.getCellType());
-      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
-      assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
-      
-      
-      // Add a formula that refers to one of the existing external workbooks
-      cell = wb1.getSheetAt(0).getRow(1).createCell(40);
-      cell.setCellFormula("Cost*[XRefCalcData.xls]MarkupSheet!$B$1");
-      
-      // Check is was stored correctly
-      assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
-      
-      // Check it evaluates correctly
-      eval.evaluateFormulaCell(cell);
-      assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
-
-      // Try to add a formula for a new external workbook, won't be allowed to start
-      try {
-          cell = wb1.getSheetAt(0).getRow(1).createCell(42);
-          cell.setCellFormula("[alt.xls]Sheet0!$A$1");
-          fail("New workbook not linked, shouldn't be able to add");
-      } catch(Exception e) {
-      	// expected here
-	  }
-      
-      // Link our new workbook
-      HSSFWorkbook wb3 = new HSSFWorkbook();
-      wb3.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
-      assertEquals(2, wb1.linkExternalWorkbook("alt.xls", wb3));
-      
-      // Now add a formula that refers to our new workbook
-      cell.setCellFormula("[alt.xls]Sheet0!$A$1");
-      assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
-
-      // Evaluate it, without a link to that workbook
-      try {
-          eval.evaluate(cell);
-          fail("No cached value and no link to workbook, shouldn't evaluate");
-      } catch(Exception e) {
-		  // expected here
-	  }
-      
-      // Add a link, check it does
-      HSSFFormulaEvaluator.setupEnvironment(
-              new String[] { "XRefCalc.xls", "XRefCalcData.xls", "alt.xls" },
-              new HSSFFormulaEvaluator[] {
-                    eval,
-                    new HSSFFormulaEvaluator(wb2),
-                    new HSSFFormulaEvaluator(wb3)
-              }
-      );
-      eval.evaluateFormulaCell(cell);
-      assertEquals("In another workbook", cell.getStringCellValue());
-      
-      
-      // Save and re-load
-      HSSFWorkbook wb4 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
-      eval = new HSSFFormulaEvaluator(wb4);
-      HSSFFormulaEvaluator.setupEnvironment(
-              new String[] { "XRefCalc.xls", "XRefCalcData.xls", "alt.xls" },
-              new HSSFFormulaEvaluator[] {
-                    eval,
-                    new HSSFFormulaEvaluator(wb2),
-                    new HSSFFormulaEvaluator(wb3)
-              }
-      );
-      
-      // Check the one referring to the previously existing workbook behaves
-      cell = wb4.getSheetAt(0).getRow(1).getCell(40);
-      assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
-      eval.evaluateFormulaCell(cell);
-      assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
-      
-      // Now check the newly added reference
-      cell = wb4.getSheetAt(0).getRow(1).getCell(42);
-      assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
-      eval.evaluateFormulaCell(cell);
-      assertEquals("In another workbook", cell.getStringCellValue());
-      
-      wb4.close();
-      wb3.close();
-      wb2.close();
-      wb1.close();
-   }
 
-	@Test
+            EvalCountListener evalListener = new EvalCountListener();
+            WorkbookEvaluator evaluator = WorkbookEvaluatorTestHelper.createEvaluator(wb, evalListener);
+            ValueEval ve = evaluator.evaluate(HSSFEvaluationTestHelper.wrapCell(cellA1));
+            int evalCount = evalListener.getEvalCount();
+            // Without short-circuit-if evaluation, evaluating cell 'A1' takes 3 extra evaluations (for D1,E1,F1)
+            assertNotEquals(6, evalCount, "Identifed bug 48195 - Formula evaluator should short-circuit IF() calculations.");
+            assertEquals(3, evalCount);
+            assertEquals(2.0, ((NumberEval) ve).getNumberValue(), 0D);
+        }
+    }
+
+    /**
+     * Ensures that we can handle NameXPtgs in the formulas
+     * we parse.
+     */
+    @Test
+    public void testXRefs() throws IOException {
+        try (HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
+        HSSFWorkbook wb2 = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls")) {
+			Cell cell;
+
+			// VLookup on a name in another file
+			cell = wb1.getSheetAt(0).getRow(1).getCell(2);
+			assertEquals(CellType.FORMULA, cell.getCellType());
+			assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
+			assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
+			// WARNING - this is wrong!
+			// The file name should be showing, but bug #45970 is fixed
+			//  we seem to loose it
+			assertEquals("VLOOKUP(PART,COSTS,2,FALSE)", cell.getCellFormula());
+
+
+			// Simple reference to a name in another file
+			cell = wb1.getSheetAt(0).getRow(1).getCell(4);
+			assertEquals(CellType.FORMULA, cell.getCellType());
+			assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
+			assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
+			// TODO Correct this!
+			// The file name should be shown too, see bug #56742
+			assertEquals("Cost*Markup_Cost", cell.getCellFormula());
+
+
+			// Evaluate the cells
+			HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb1);
+			HSSFFormulaEvaluator.setupEnvironment(
+				new String[]{"XRefCalc.xls", "XRefCalcData.xls"},
+				new HSSFFormulaEvaluator[]{
+					eval,
+					new HSSFFormulaEvaluator(wb2)
+				}
+			);
+			eval.evaluateFormulaCell(
+				wb1.getSheetAt(0).getRow(1).getCell(2)
+			);
+			eval.evaluateFormulaCell(
+				wb1.getSheetAt(0).getRow(1).getCell(4)
+			);
+
+
+			// Re-check VLOOKUP one
+			cell = wb1.getSheetAt(0).getRow(1).getCell(2);
+			assertEquals(CellType.FORMULA, cell.getCellType());
+			assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
+			assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
+
+			// Re-check ref one
+			cell = wb1.getSheetAt(0).getRow(1).getCell(4);
+			assertEquals(CellType.FORMULA, cell.getCellType());
+			assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
+			assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
+
+
+			// Add a formula that refers to one of the existing external workbooks
+			cell = wb1.getSheetAt(0).getRow(1).createCell(40);
+			cell.setCellFormula("Cost*[XRefCalcData.xls]MarkupSheet!$B$1");
+
+			// Check is was stored correctly
+			assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
+
+			// Check it evaluates correctly
+			eval.evaluateFormulaCell(cell);
+			assertEquals(24.60 * 1.8, cell.getNumericCellValue(), 0);
+
+			// Try to add a formula for a new external workbook, won't be allowed to start
+            cell = wb1.getSheetAt(0).getRow(1).createCell(42);
+            final Cell cell2 = cell;
+            assertThrows(Exception.class, () -> cell2.setCellFormula("[alt.xls]Sheet0!$A$1"),
+                "New workbook not linked, shouldn't be able to add");
+
+			// Link our new workbook
+			try (HSSFWorkbook wb3 = new HSSFWorkbook()) {
+				wb3.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
+				assertEquals(2, wb1.linkExternalWorkbook("alt.xls", wb3));
+
+				// Now add a formula that refers to our new workbook
+				cell.setCellFormula("[alt.xls]Sheet0!$A$1");
+				assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
+
+				HSSFFormulaEvaluator eval2 = eval;
+				assertThrows(Exception.class, () -> eval2.evaluate(cell2),
+					"No cached value and no link to workbook, shouldn't evaluate");
+
+				// Add a link, check it does
+				HSSFFormulaEvaluator.setupEnvironment(
+					new String[]{"XRefCalc.xls", "XRefCalcData.xls", "alt.xls"},
+					new HSSFFormulaEvaluator[]{
+						eval,
+						new HSSFFormulaEvaluator(wb2),
+						new HSSFFormulaEvaluator(wb3)
+					}
+				);
+				eval.evaluateFormulaCell(cell);
+				assertEquals("In another workbook", cell.getStringCellValue());
+
+
+				// Save and re-load
+				try (HSSFWorkbook wb4 = HSSFTestDataSamples.writeOutAndReadBack(wb1)) {
+					eval = new HSSFFormulaEvaluator(wb4);
+					HSSFFormulaEvaluator.setupEnvironment(
+						new String[]{"XRefCalc.xls", "XRefCalcData.xls", "alt.xls"},
+						new HSSFFormulaEvaluator[]{
+							eval,
+							new HSSFFormulaEvaluator(wb2),
+							new HSSFFormulaEvaluator(wb3)
+						}
+					);
+
+					// Check the one referring to the previously existing workbook behaves
+					cell = wb4.getSheetAt(0).getRow(1).getCell(40);
+					assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
+					eval.evaluateFormulaCell(cell);
+					assertEquals(24.60 * 1.8, cell.getNumericCellValue(), 0);
+
+					// Now check the newly added reference
+					cell = wb4.getSheetAt(0).getRow(1).getCell(42);
+					assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
+					eval.evaluateFormulaCell(cell);
+					assertEquals("In another workbook", cell.getStringCellValue());
+				}
+			}
+		}
+    }
+
+    @Test
     public void testSharedFormulas() throws IOException {
         baseTestSharedFormulas("shared_formulas.xls");
     }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHeaderFooter.java Thu Dec 24 18:42:29 2020
@@ -18,12 +18,12 @@
 package org.apache.poi.hssf.usermodel;
 
 import static org.apache.poi.hssf.HSSFTestDataSamples.openSampleWorkbook;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link HSSFHeader} / {@link HSSFFooter}
@@ -156,14 +156,14 @@ public final class TestHSSFHeaderFooter
 		try (HSSFWorkbook wb = openSampleWorkbook("DBCSHeader.xls")) {
 			HSSFSheet s = wb.getSheetAt(0);
 			HSSFHeader h = s.getHeader();
-			assertEquals("Header Left ", h.getLeft(), "\u090f\u0915");
-			assertEquals("Header Center ", h.getCenter(), "\u0939\u094b\u0917\u093e");
-			assertEquals("Header Right ", h.getRight(), "\u091c\u093e");
+			assertEquals(h.getLeft(), "\u090f\u0915", "Header Left");
+			assertEquals(h.getCenter(), "\u0939\u094b\u0917\u093e", "Header Center");
+			assertEquals(h.getRight(), "\u091c\u093e", "Header Right");
 
 			HSSFFooter f = s.getFooter();
-			assertEquals("Footer Left ", f.getLeft(), "\u091c\u093e");
-			assertEquals("Footer Center ", f.getCenter(), "\u091c\u093e");
-			assertEquals("Footer Right ", f.getRight(), "\u091c\u093e");
+			assertEquals(f.getLeft(), "\u091c\u093e", "Footer Left");
+			assertEquals(f.getCenter(), "\u091c\u093e", "Footer Center");
+			assertEquals(f.getRight(), "\u091c\u093e", "Footer Right");
 		}
 	}
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.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.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.io.IOException;
 
@@ -28,13 +28,7 @@ import org.apache.poi.hssf.HSSFITestData
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.BaseTestHyperlink;
 import org.apache.poi.ss.usermodel.Hyperlink;
-/*
-import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.xssf.usermodel.XSSFCreationHelper;
-import org.apache.poi.xssf.usermodel.XSSFHyperlink;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-*/
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests HSSFHyperlink.

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFName.java Thu Dec 24 18:42:29 2020
@@ -17,6 +17,12 @@
 
 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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import org.apache.poi.POITestCase;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -26,11 +32,8 @@ import org.apache.poi.ss.formula.Formula
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.usermodel.BaseTestNamedRange;
 import org.apache.poi.ss.usermodel.Name;
-import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests various functionality having to do with {@link org.apache.poi.ss.usermodel.Name}.
@@ -126,7 +129,7 @@ public final class TestHSSFName extends
 
         HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
         HSSFName nm = wb2.getNameAt(wb2.getNameIndex("RangeTest"));
-        assertEquals("Name is " + nm.getNameName(), "RangeTest", nm.getNameName());
+        assertEquals("RangeTest", nm.getNameName(), "Name is " + nm.getNameName());
         assertEquals(wb2.getSheetName(0)+"!$D$4:$E$8", nm.getRefersToFormula());
         wb2.close();
         wb1.close();
@@ -152,16 +155,16 @@ public final class TestHSSFName extends
         String reference = namedRange1.getRefersToFormula();
 
         assertEquals(sheetName+"!$A$1:$D$10", reference);
-        assertEquals(false, namedRange1.isDeleted());
-        assertEquals(false, namedRange1.isHidden());
+        assertFalse(namedRange1.isDeleted());
+        assertFalse(namedRange1.isHidden());
 
         HSSFName namedRange2 = wb.getNameAt(1);
 
         assertEquals(sheetName+"!$D$17:$G$27", namedRange2.getRefersToFormula());
         assertEquals("SecondNamedRange", namedRange2.getNameName());
-        assertEquals(false, namedRange2.isDeleted());
-        assertEquals(false, namedRange2.isHidden());
-        
+        assertFalse(namedRange2.isDeleted());
+        assertFalse(namedRange2.isHidden());
+
         wb.close();
     }
 
@@ -184,7 +187,7 @@ public final class TestHSSFName extends
 
         name.setRefersToFormula(newReference);
         assertEquals(newReference, name.getRefersToFormula());
-        
+
         wb.close();
     }
 
@@ -204,26 +207,23 @@ public final class TestHSSFName extends
 
     @Test
     public void testDeletedReference() throws Exception {
-        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("24207.xls");
-        assertEquals(2, wb.getNumberOfNames());
+        try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("24207.xls")) {
+            assertEquals(2, wb.getNumberOfNames());
 
-        HSSFName name1 = wb.getNameAt(0);
-        assertEquals("a", name1.getNameName());
-        assertEquals("Sheet1!$A$1", name1.getRefersToFormula());
-        wb.getCreationHelper().createAreaReference(name1.getRefersToFormula());
-        assertTrue("Successfully constructed first reference", true);
-
-        HSSFName name2 = wb.getNameAt(1);
-        assertEquals("b", name2.getNameName());
-        assertEquals("Sheet1!#REF!", name2.getRefersToFormula());
-        assertTrue(name2.isDeleted());
-        try {
-            wb.getCreationHelper().createAreaReference(name2.getRefersToFormula());
-            fail("attempt to supply an invalid reference to AreaReference constructor results in exception");
-        } catch (IllegalArgumentException e) { // TODO - use a stronger typed exception for this condition
-            // expected during successful test
+            HSSFName name1 = wb.getNameAt(0);
+            assertEquals("a", name1.getNameName());
+            assertEquals("Sheet1!$A$1", name1.getRefersToFormula());
+            wb.getCreationHelper().createAreaReference(name1.getRefersToFormula());
+
+            HSSFName name2 = wb.getNameAt(1);
+            assertEquals("b", name2.getNameName());
+            assertEquals("Sheet1!#REF!", name2.getRefersToFormula());
+            assertTrue(name2.isDeleted());
+            // TODO - use a stronger typed exception for this condition
+            assertThrows(IllegalArgumentException.class, () ->
+                wb.getCreationHelper().createAreaReference(name2.getRefersToFormula()),
+                "attempt to supply an invalid reference to AreaReference constructor results in exception");
         }
-        wb.close();
     }
 
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java?rev=1884783&r1=1884782&r2=1884783&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java Thu Dec 24 18:42:29 2020
@@ -16,13 +16,17 @@
 ==================================================================== */
 package org.apache.poi.hssf.usermodel;
 
-import java.io.IOException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.apache.poi.ss.usermodel.*;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.junit.jupiter.api.Test;
 
 public final class TestHSSFOptimiser {
     @Test
@@ -324,8 +328,8 @@ public final class TestHSSFOptimiser {
     @Test
     public void testColumnAndRowStyles() {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals("Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()",
-                21, wb.getNumCellStyles());
+        assertEquals(21, wb.getNumCellStyles(),
+            "Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()");
 
         HSSFSheet sheet = wb.createSheet();
 
@@ -357,8 +361,8 @@ public final class TestHSSFOptimiser {
     @Test
     public void testUnusedStyle() {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals("Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()",
-                21, wb.getNumCellStyles());
+        assertEquals(21, wb.getNumCellStyles(),
+            "Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()");
 
         HSSFSheet sheet = wb.createSheet();
 
@@ -395,8 +399,8 @@ public final class TestHSSFOptimiser {
     @Test
     public void testUnusedStyleOneUsed() {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals("Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()",
-                21, wb.getNumCellStyles());
+        assertEquals(21, wb.getNumCellStyles(),
+            "Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()");
 
         HSSFSheet sheet = wb.createSheet();
 
@@ -431,10 +435,10 @@ public final class TestHSSFOptimiser {
     }
 
     @Test
-    public void testDefaultColumnStyleWitoutCell() throws IOException {
+    public void testDefaultColumnStyleWitoutCell() {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals("Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()",
-                21, wb.getNumCellStyles());
+        assertEquals(21, wb.getNumCellStyles(),
+            "Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()");
 
         HSSFSheet sheet = wb.createSheet();
 
@@ -473,10 +477,10 @@ public final class TestHSSFOptimiser {
     }
 
     @Test
-    public void testUserDefinedStylesAreNeverOptimizedAway() throws IOException {
+    public void testUserDefinedStylesAreNeverOptimizedAway() {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals("Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()",
-                21, wb.getNumCellStyles());
+        assertEquals(21, wb.getNumCellStyles(),
+            "Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()");
 
         HSSFSheet sheet = wb.createSheet();
 
@@ -532,10 +536,10 @@ public final class TestHSSFOptimiser {
     }
 
     @Test
-    public void testBug57517() throws IOException {
+    public void testBug57517() {
         HSSFWorkbook wb = new HSSFWorkbook();
-        assertEquals("Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()",
-                21, wb.getNumCellStyles());
+        assertEquals(21, wb.getNumCellStyles(),
+            "Usually we have 21 pre-defined styles in a newly created Workbook, see InternalWorkbook.createWorkbook()");
 
         HSSFSheet sheet = wb.createSheet();
 
@@ -599,7 +603,7 @@ public final class TestHSSFOptimiser {
         // Create a test font and style, and use them
         for (int i = 3; i < 6; i++) {
             // Set Cell Color : GREEN
-            HSSFRow row = sheet.getRow(0 + 9);
+            HSSFRow row = sheet.getRow(9);
             row.createCell(i - 3).setCellStyle(
                     createColorStyle(wb, IndexedColors.GREEN));
             obj_cnt++;



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