Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java Thu Dec 24 18:42:29 2020 @@ -17,11 +17,14 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.util.Locale; @@ -48,7 +51,7 @@ import org.apache.poi.ss.usermodel.Formu import org.apache.poi.ss.usermodel.Name; import org.apache.poi.util.HexRead; import org.apache.poi.util.LittleEndianByteArrayInputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the low level formula parser functionality. High level tests are to @@ -61,7 +64,7 @@ public final class TestFormulaParser { */ /* package */ static Ptg[] parseFormula(String formula) { Ptg[] result = HSSFFormulaParser.parse(formula, null); - assertNotNull("Ptg array should not be null", result); + assertNotNull(result, "Ptg array should not be null"); return result; } private static String toFormulaString(Ptg[] ptgs) { @@ -279,18 +282,18 @@ public final class TestFormulaParser { String value = " hi "; Ptg[] ptgs = parseFormula("\"" + value + "\""); confirmTokenClasses(ptgs, StringPtg.class); - assertEquals("ptg0 contains exact value", ((StringPtg) ptgs[0]).getValue(), value); + assertEquals(((StringPtg) ptgs[0]).getValue(), value, "ptg0 contains exact value"); } @Test public void testLookupAndMatchFunctionArgs() { Ptg[] ptgs = parseFormula("lookup(A1, A3:A52, B3:B52)"); confirmTokenClasses(ptgs, RefPtg.class, AreaPtg.class, AreaPtg.class, FuncVarPtg.class); - assertEquals("ptg0 has Value class", ptgs[0].getPtgClass(), Ptg.CLASS_VALUE); + assertEquals(ptgs[0].getPtgClass(), Ptg.CLASS_VALUE, "ptg0 has Value class"); ptgs = parseFormula("match(A1, A3:A52)"); confirmTokenClasses(ptgs, RefPtg.class, AreaPtg.class, FuncVarPtg.class); - assertEquals("ptg0 has Value class", ptgs[0].getPtgClass(), Ptg.CLASS_VALUE); + assertEquals(ptgs[0].getPtgClass(), Ptg.CLASS_VALUE, "ptg0 has Value class"); } /** bug 33160*/ @@ -394,63 +397,63 @@ public final class TestFormulaParser { cell.setCellFormula("1.3E21/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "1.3E+21/3", formula); + assertEquals("1.3E+21/3", formula); cell.setCellFormula("-1.3E21/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-1.3E+21/3", formula); + assertEquals("-1.3E+21/3", formula); cell.setCellFormula("1322E21/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "1.322E+24/3", formula); + assertEquals("1.322E+24/3", formula); cell.setCellFormula("-1322E21/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-1.322E+24/3", formula); + assertEquals("-1.322E+24/3", formula); cell.setCellFormula("1.3E1/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "13/3", formula); + assertEquals("13/3", formula); cell.setCellFormula("-1.3E1/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-13/3", formula); + assertEquals("-13/3", formula); cell.setCellFormula("1.3E-4/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "0.00013/3", formula); + assertEquals("0.00013/3", formula); cell.setCellFormula("-1.3E-4/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-0.00013/3", formula); + assertEquals("-0.00013/3", formula); cell.setCellFormula("13E-15/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "0.000000000000013/3", formula); + assertEquals("0.000000000000013/3", formula); cell.setCellFormula("-13E-15/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-0.000000000000013/3", formula); + assertEquals("-0.000000000000013/3", formula); cell.setCellFormula("1.3E3/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "1300/3", formula); + assertEquals("1300/3", formula); cell.setCellFormula("-1.3E3/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-1300/3", formula); + assertEquals("-1300/3", formula); cell.setCellFormula("1300000000000000/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "1300000000000000/3", formula); + assertEquals("1300000000000000/3", formula); cell.setCellFormula("-1300000000000000/3"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-1300000000000000/3", formula); + assertEquals("-1300000000000000/3", formula); cell.setCellFormula("-10E-1/3.1E2*4E3/3E4"); formula = cell.getCellFormula(); - assertEquals("Exponential formula string", "-1/310*4000/30000", formula); + assertEquals("-1/310*4000/30000", formula); wb.close(); } @@ -653,11 +656,10 @@ public final class TestFormulaParser { private static void confirmTokenClasses(Ptg[] ptgs, Class<?>...expectedClasses) { assertEquals(expectedClasses.length, ptgs.length); for (int i = 0; i < expectedClasses.length; i++) { - if(expectedClasses[i] != ptgs[i].getClass()) { - fail("difference at token[" + i + "]: expected (" - + expectedClasses[i].getName() + ") but got (" - + ptgs[i].getClass().getName() + ")"); - } + assertEquals(expectedClasses[i], ptgs[i].getClass(), + "difference at token[" + i + "]: expected (" + + expectedClasses[i].getName() + ") but got (" + + ptgs[i].getClass().getName() + ")"); } } @@ -763,9 +765,7 @@ public final class TestFormulaParser { HSSFCell cell = row.createCell(0); cell.setCellFormula("right(\"test\"\"ing\", 3)"); String actualCellFormula = cell.getCellFormula(); - if ("RIGHT(\"test\"ing\",3)".equals(actualCellFormula)) { - fail("Identified bug 28754b"); - } + assertNotEquals("RIGHT(\"test\"ing\",3)", actualCellFormula, "Identified bug 28754b"); assertEquals("RIGHT(\"test\"\"ing\",3)", actualCellFormula); } } @@ -819,13 +819,8 @@ public final class TestFormulaParser { } private static void parseExpectedException(String formula) { - try { - parseFormula(formula); - fail("Expected FormulaParseException: " + formula); - } catch (FormulaParseException e) { - // expected during successful test - assertNotNull(e.getMessage()); - } + FormulaParseException e = assertThrows(FormulaParseException.class, () -> parseFormula(formula)); + assertNotNull(e.getMessage()); } @Test @@ -838,9 +833,7 @@ public final class TestFormulaParser { HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); cell.setCellFormula("SUM(A32769:A32770)"); - if("SUM(A-32767:A-32766)".equals(cell.getCellFormula())) { - fail("Identified bug 44539"); - } + assertNotEquals("SUM(A-32767:A-32766)", cell.getCellFormula(), "Identified bug 44539"); assertEquals("SUM(A32769:A32770)", cell.getCellFormula()); wb.close(); @@ -883,14 +876,10 @@ public final class TestFormulaParser { new IntPtg(1), DividePtg.instance, }; - try { - toFormulaString(ptgs); - fail("Expected exception was not thrown"); - } catch (IllegalStateException e) { - // expected during successful test - assertTrue(e.getMessage().startsWith("Too few arguments supplied to operation")); - } + IllegalStateException e = assertThrows(IllegalStateException.class, () -> toFormulaString(ptgs)); + assertTrue(e.getMessage().startsWith("Too few arguments supplied to operation")); } + /** * Make sure that POI uses the right Func Ptg when encoding formulas. Functions with variable * number of args should get FuncVarPtg, functions with fixed args should get FuncPtg.<p> @@ -904,9 +893,7 @@ public final class TestFormulaParser { Ptg[] ptgs = parseFormula("countif(A1:A2, 1)"); assertEquals(3, ptgs.length); - if(ptgs[2] instanceof FuncVarPtg) { - fail("Identified bug 44675"); - } + assertFalse(ptgs[2] instanceof FuncVarPtg, "Identified bug 44675"); confirmTokenClasses(ptgs, AreaPtg.class, IntPtg.class, FuncPtg.class); confirmTokenClasses("sin(1)", IntPtg.class, FuncPtg.class); @@ -921,34 +908,20 @@ public final class TestFormulaParser { } private static void confirmArgCountMsg(String formula, String expectedMessage) throws IOException { - HSSFWorkbook book = new HSSFWorkbook(); - try { - HSSFFormulaParser.parse(formula, book); - fail("Didn't get parse exception as expected"); - } catch (FormulaParseException e) { + try (HSSFWorkbook book = new HSSFWorkbook()) { + FormulaParseException e = assertThrows(FormulaParseException.class, () -> HSSFFormulaParser.parse(formula, book)); confirmParseException(e, expectedMessage); } - book.close(); } @Test public void testParseErrorExpectedMsg() { + FormulaParseException e; + e = assertThrows(FormulaParseException.class, () -> parseFormula("round(3.14;2)")); + confirmParseException(e, "Parse error near char 10 ';' in specified formula 'round(3.14;2)'. Expected ',' or ')'"); - try { - parseFormula("round(3.14;2)"); - fail("Didn't get parse exception as expected"); - } catch (FormulaParseException e) { - confirmParseException(e, - "Parse error near char 10 ';' in specified formula 'round(3.14;2)'. Expected ',' or ')'"); - } - - try { - parseFormula(" =2+2"); - fail("Didn't get parse exception as expected"); - } catch (FormulaParseException e) { - confirmParseException(e, - "The specified formula ' =2+2' starts with an equals sign which is not allowed."); - } + e = assertThrows(FormulaParseException.class, () -> parseFormula(" =2+2")); + confirmParseException(e, "The specified formula ' =2+2' starts with an equals sign which is not allowed."); } /** @@ -972,36 +945,30 @@ public final class TestFormulaParser { @Test public void testNamedRangeThatLooksLikeCell() throws IOException { - HSSFWorkbook wb = new HSSFWorkbook(); - HSSFSheet sheet = wb.createSheet("Sheet1"); - HSSFName name = wb.createName(); - name.setRefersToFormula("Sheet1!B1"); - name.setNameName("pfy1"); - - Ptg[] ptgs; - try { - ptgs = HSSFFormulaParser.parse("count(pfy1)", wb); - } catch (IllegalArgumentException e) { - if (e.getMessage().equals("Specified colIx (1012) is out of range")) { - fail("Identified bug 45354"); + try (HSSFWorkbook wb = new HSSFWorkbook()) { + HSSFSheet sheet = wb.createSheet("Sheet1"); + HSSFName name = wb.createName(); + name.setRefersToFormula("Sheet1!B1"); + name.setNameName("pfy1"); + + Ptg[] ptgs; + try { + ptgs = HSSFFormulaParser.parse("count(pfy1)", wb); + } catch (IllegalArgumentException e) { + if (e.getMessage().equals("Specified colIx (1012) is out of range")) { + fail("Identified bug 45354"); + } + throw e; } - wb.close(); - throw e; - } - confirmTokenClasses(ptgs, NamePtg.class, FuncVarPtg.class); + confirmTokenClasses(ptgs, NamePtg.class, FuncVarPtg.class); - HSSFCell cell = sheet.createRow(0).createCell(0); - cell.setCellFormula("count(pfy1)"); - assertEquals("COUNT(pfy1)", cell.getCellFormula()); - try { - cell.setCellFormula("count(pf1)"); - fail("Expected formula parse execption"); - } catch (FormulaParseException e) { - confirmParseException(e, - "Specified named range 'pf1' does not exist in the current workbook."); + HSSFCell cell = sheet.createRow(0).createCell(0); + cell.setCellFormula("count(pfy1)"); + assertEquals("COUNT(pfy1)", cell.getCellFormula()); + FormulaParseException e = assertThrows(FormulaParseException.class, () -> cell.setCellFormula("count(pf1)")); + confirmParseException(e, "Specified named range 'pf1' does not exist in the current workbook."); + cell.setCellFormula("count(fp1)"); // plain cell ref, col is in range } - cell.setCellFormula("count(fp1)"); // plain cell ref, col is in range - wb.close(); } @Test @@ -1014,9 +981,7 @@ public final class TestFormulaParser { ptgs = HSSFFormulaParser.parse("Sheet1!A10:A40000", book); aptg = (AreaI) ptgs[0]; - if (aptg.getLastRow() == -25537) { - fail("Identified bug 45358"); - } + assertNotEquals(-25537, aptg.getLastRow(), "Identified bug 45358"); assertEquals(39999, aptg.getLastRow()); ptgs = HSSFFormulaParser.parse("Sheet1!A10:A65536", book); @@ -1050,10 +1015,8 @@ public final class TestFormulaParser { ptgs = parseFormula("MAX({\"5\"},3)"); confirmTokenClasses(ptgs, ArrayPtg.class, IntPtg.class, FuncVarPtg.class); Object element = ((ArrayPtg)ptgs[0]).getTokenArrayValues()[0][0]; - if (element instanceof UnicodeString) { - // this would cause ClassCastException below - fail("Wrong encoding of array element value"); - } + // this would cause ClassCastException below + assertFalse(element instanceof UnicodeString, "Wrong encoding of array element value"); assertEquals(String.class, element.getClass()); // make sure the formula encodes OK @@ -1354,28 +1317,27 @@ public final class TestFormulaParser { @Test public void testRangeFuncOperand_bug46951() throws IOException { - HSSFWorkbook wb = new HSSFWorkbook(); - Ptg[] ptgs; - try { - ptgs = HSSFFormulaParser.parse("SUM(C1:OFFSET(C1,0,B1))", wb); - } catch (RuntimeException e) { - if (e.getMessage().equals("Specified named range 'OFFSET' does not exist in the current workbook.")) { - fail("Identified bug 46951"); + try (HSSFWorkbook wb = new HSSFWorkbook()) { + Ptg[] ptgs; + try { + ptgs = HSSFFormulaParser.parse("SUM(C1:OFFSET(C1,0,B1))", wb); + } catch (RuntimeException e) { + if (e.getMessage().equals("Specified named range 'OFFSET' does not exist in the current workbook.")) { + fail("Identified bug 46951"); + } + throw e; } - wb.close(); - throw e; + confirmTokenClasses(ptgs, + MemFuncPtg.class, // [len=23] + RefPtg.class, // [C1] + RefPtg.class, // [C1] + IntPtg.class, // [0] + RefPtg.class, // [B1] + FuncVarPtg.class, // [OFFSET nArgs=3] + RangePtg.class, // + AttrPtg.class // [sum ] + ); } - confirmTokenClasses(ptgs, - MemFuncPtg.class, // [len=23] - RefPtg.class, // [C1] - RefPtg.class, // [C1] - IntPtg.class, // [0] - RefPtg.class, // [B1] - FuncVarPtg.class, // [OFFSET nArgs=3] - RangePtg.class, // - AttrPtg.class // [sum ] - ); - wb.close(); } @Test @@ -1507,13 +1469,8 @@ public final class TestFormulaParser { } private static void confirmParseError(HSSFWorkbook wb, String formula, String expectedMessage) { - - try { - HSSFFormulaParser.parse(formula, wb); - fail("Expected formula parse execption"); - } catch (FormulaParseException e) { - confirmParseException(e, expectedMessage); - } + FormulaParseException e = assertThrows(FormulaParseException.class, () -> HSSFFormulaParser.parse(formula, wb)); + confirmParseException(e, expectedMessage); } /** @@ -1524,29 +1481,27 @@ public final class TestFormulaParser { public void testParseComplexName() throws IOException { // Mock up a spreadsheet to match the critical details of the sample - HSSFWorkbook wb = new HSSFWorkbook(); - wb.createSheet("Sheet1"); - HSSFName definedName = wb.createName(); - definedName.setNameName("foo"); - definedName.setRefersToFormula("Sheet1!B2"); - - // Set the complex flag - POI doesn't usually manipulate this flag - NameRecord nameRec = TestHSSFName.getNameRecord(definedName); - nameRec.setOptionFlag((short)0x10); // 0x10 -> complex - - Ptg[] result; - try { - result = HSSFFormulaParser.parse("1+foo", wb); - } catch (FormulaParseException e) { - if (e.getMessage().equals("Specified name 'foo' is not a range as expected.")) { - fail("Identified bug 47078c"); + try (HSSFWorkbook wb = new HSSFWorkbook()) { + wb.createSheet("Sheet1"); + HSSFName definedName = wb.createName(); + definedName.setNameName("foo"); + definedName.setRefersToFormula("Sheet1!B2"); + + // Set the complex flag - POI doesn't usually manipulate this flag + NameRecord nameRec = TestHSSFName.getNameRecord(definedName); + nameRec.setOptionFlag((short) 0x10); // 0x10 -> complex + + Ptg[] result; + try { + result = HSSFFormulaParser.parse("1+foo", wb); + } catch (FormulaParseException e) { + if (e.getMessage().equals("Specified name 'foo' is not a range as expected.")) { + fail("Identified bug 47078c"); + } + throw e; } - wb.close(); - throw e; + confirmTokenClasses(result, IntPtg.class, NamePtg.class, AddPtg.class); } - confirmTokenClasses(result, IntPtg.class, NamePtg.class, AddPtg.class); - - wb.close(); } /** @@ -1562,23 +1517,16 @@ public final class TestFormulaParser { String leadingZeroCellRef = "B000001"; // this should get parsed as "B1" HSSFWorkbook wb = new HSSFWorkbook(); - try { - HSSFFormulaParser.parse(badCellRef, wb); - fail("Identified bug 47312b - Shouldn't be able to parse cell ref '" - + badCellRef + "'."); - } catch (FormulaParseException e) { - // expected during successful test - confirmParseException(e, "Specified named range '" - + badCellRef + "' does not exist in the current workbook."); - } + FormulaParseException e = assertThrows(FormulaParseException.class, () -> HSSFFormulaParser.parse(badCellRef, wb), + "Identified bug 47312b - Shouldn't be able to parse cell ref '" + badCellRef + "'."); + confirmParseException(e, "Specified named range '" + badCellRef + "' does not exist in the current workbook."); Ptg[] ptgs; try { ptgs = HSSFFormulaParser.parse(leadingZeroCellRef, wb); assertEquals("B1", ptgs[0].toFormulaString()); - } catch (FormulaParseException e) { - confirmParseException(e, "Specified named range '" - + leadingZeroCellRef + "' does not exist in the current workbook."); + } catch (FormulaParseException e2) { + confirmParseException(e2, "Specified named range '" + leadingZeroCellRef + "' does not exist in the current workbook."); // close but no cigar fail("Identified bug 47312c - '" + leadingZeroCellRef + "' should parse as 'B1'."); } @@ -1601,7 +1549,7 @@ public final class TestFormulaParser { public void test57196_Formula() throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); Ptg[] ptgs = HSSFFormulaParser.parse("DEC2HEX(HEX2DEC(O8)-O2+D2)", wb, FormulaType.CELL, -1); - assertNotNull("Ptg array should not be null", ptgs); + assertNotNull(ptgs, "Ptg array should not be null"); confirmTokenClasses(ptgs, NameXPtg.class, // ??
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java Thu Dec 24 18:42:29 2020 @@ -17,7 +17,7 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; @@ -30,7 +30,7 @@ import org.apache.poi.ss.formula.ptg.Nam import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test the low level formula parser functionality, @@ -70,7 +70,7 @@ public final class TestFormulaParserEval */ private static void confirmParseFormula(HSSFWorkbook workbook) { Ptg[] ptgs = HSSFFormulaParser.parse("SUM(testName)", workbook); - assertEquals("two tokens expected, got " + ptgs.length, 2, ptgs.length); + assertEquals(2, ptgs.length, "two tokens expected, got " + ptgs.length); assertEquals(NamePtg.class, ptgs[0].getClass()); assertEquals(AttrPtg.class, ptgs[1].getClass()); } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java Thu Dec 24 18:42:29 2020 @@ -17,8 +17,8 @@ package org.apache.poi.hssf.model; -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 org.apache.poi.ss.formula.ptg.AddPtg; import org.apache.poi.ss.formula.ptg.AttrPtg; @@ -33,7 +33,7 @@ import org.apache.poi.ss.formula.ptg.Not import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.formula.ptg.RefPtg; import org.apache.poi.ss.formula.ptg.StringPtg; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests <tt>FormulaParser</tt> specifically with respect to IF() functions @@ -49,7 +49,7 @@ public final class TestFormulaParserIf { private static void confirmAttrData(Ptg[] ptgs, int i, int expectedData) { Ptg ptg = ptgs[i]; - assertTrue("Token[" + i + "] was not AttrPtg as expected", ptg instanceof AttrPtg); + assertTrue(ptg instanceof AttrPtg, "Token[" + i + "] was not AttrPtg as expected"); AttrPtg attrPtg = (AttrPtg) ptg; assertEquals(expectedData, attrPtg.getData()); } @@ -164,24 +164,24 @@ public final class TestFormulaParserIf { Ptg[] ptgs = parseFormula("IF(3>=1,\"*\",IF(4<>1,\"first\",\"second\"))"); assertEquals(17, ptgs.length); - assertEquals("6th Ptg is not a goto (Attr) ptg",AttrPtg.class,ptgs[5].getClass()); - assertEquals("9th Ptg is not a not equal ptg",NotEqualPtg.class,ptgs[8].getClass()); - assertEquals("15th Ptg is not the inner IF variable function ptg",FuncVarPtg.class,ptgs[14].getClass()); + assertEquals(AttrPtg.class, ptgs[5].getClass(), "6th Ptg is not a goto (Attr) ptg"); + assertEquals(NotEqualPtg.class, ptgs[8].getClass(), "9th Ptg is not a not equal ptg"); + assertEquals(FuncVarPtg.class, ptgs[14].getClass(), "15th Ptg is not the inner IF variable function ptg"); } @Test public void testSimpleLogical() { Ptg[] ptgs = parseFormula("IF(A1<A2,B1,B2)"); assertEquals(9, ptgs.length); - assertEquals("3rd Ptg is less than", LessThanPtg.class, ptgs[2].getClass()); + assertEquals(LessThanPtg.class, ptgs[2].getClass(), "3rd Ptg is less than"); } @Test public void testParenIf() { Ptg[] ptgs = parseFormula("IF((A1+A2)<=3,\"yes\",\"no\")"); assertEquals(12, ptgs.length); - assertEquals("6th Ptg is less than equal",LessEqualPtg.class,ptgs[5].getClass()); - assertEquals("11th Ptg is not a goto (Attr) ptg",AttrPtg.class,ptgs[10].getClass()); + assertEquals(LessEqualPtg.class, ptgs[5].getClass(), "6th Ptg is less than equal"); + assertEquals(AttrPtg.class, ptgs[10].getClass(), "11th Ptg is not a goto (Attr) ptg"); } @Test @@ -200,7 +200,7 @@ public final class TestFormulaParserIf { assertEquals("Y", y.getValue()); assertEquals("N", n.getValue()); assertEquals("IF", funif.toFormulaString()); - assertTrue("tAttrSkip ptg exists", goto1.isSkip()); + assertTrue(goto1.isSkip(), "tAttrSkip ptg exists"); } /** @@ -211,11 +211,11 @@ public final class TestFormulaParserIf { Ptg[] ptgs = parseFormula("IF(A1=B1,AVERAGE(A1:B1),AVERAGE(A2:B2))"); assertEquals(11, ptgs.length); - assertTrue("IF Attr set correctly", (ptgs[3] instanceof AttrPtg)); + assertTrue((ptgs[3] instanceof AttrPtg), "IF Attr set correctly"); AttrPtg ifFunc = (AttrPtg)ptgs[3]; - assertTrue("It is not an if", ifFunc.isOptimizedIf()); + assertTrue(ifFunc.isOptimizedIf(), "It is not an if"); - assertTrue("Average Function set correctly", (ptgs[5] instanceof FuncVarPtg)); + assertTrue((ptgs[5] instanceof FuncVarPtg), "Average Function set correctly"); } @Test @@ -223,16 +223,16 @@ public final class TestFormulaParserIf { Ptg[] ptgs = parseFormula("IF(1=1,10)"); assertEquals(7, ptgs.length); - assertTrue("IF Attr set correctly", (ptgs[3] instanceof AttrPtg)); + assertTrue((ptgs[3] instanceof AttrPtg), "IF Attr set correctly"); AttrPtg ifFunc = (AttrPtg)ptgs[3]; - assertTrue("It is not an if", ifFunc.isOptimizedIf()); + assertTrue(ifFunc.isOptimizedIf(), "It is not an if"); - assertTrue("Single Value is not an IntPtg", (ptgs[4] instanceof IntPtg)); + assertTrue((ptgs[4] instanceof IntPtg), "Single Value is not an IntPtg"); IntPtg intPtg = (IntPtg)ptgs[4]; - assertEquals("Result", (short)10, intPtg.getValue()); + assertEquals((short)10, intPtg.getValue(), "Result"); - assertTrue("Ptg is not a Variable Function", (ptgs[6] instanceof FuncVarPtg)); + assertTrue((ptgs[6] instanceof FuncVarPtg), "Ptg is not a Variable Function"); FuncVarPtg funcPtg = (FuncVarPtg)ptgs[6]; - assertEquals("Arguments", 2, funcPtg.getNumberOfOperands()); + assertEquals(2, funcPtg.getNumberOfOperands(), "Arguments"); } } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java Thu Dec 24 18:42:29 2020 @@ -17,11 +17,11 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -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.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.ddf.EscherChildAnchorRecord; import org.apache.poi.ddf.EscherClientAnchorRecord; @@ -39,7 +39,7 @@ import org.apache.poi.hssf.usermodel.HSS import org.apache.poi.hssf.usermodel.HSSFTestHelper; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TestHSSFAnchor { @@ -326,10 +326,10 @@ public class TestHSSFAnchor { @Test public void testNullReferenceIsFalse() { HSSFClientAnchor clientAnchor = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7); - assertNotNull("Passing null to equals should return false", clientAnchor); + assertNotNull(clientAnchor, "Passing null to equals should return false"); HSSFChildAnchor childAnchor = new HSSFChildAnchor(0, 1, 2, 3); - assertNotNull("Passing null to equals should return false", childAnchor); + assertNotNull(childAnchor, "Passing null to equals should return false"); } @Test Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java Thu Dec 24 18:42:29 2020 @@ -17,12 +17,12 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Collections; @@ -44,7 +44,7 @@ import org.apache.poi.hssf.record.SupBoo import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.formula.ptg.NameXPtg; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link LinkTable} Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestOperandClassTransformer.java Thu Dec 24 18:42:29 2020 @@ -17,10 +17,10 @@ package org.apache.poi.hssf.model; -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.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 org.apache.poi.ss.formula.eval.BlankEval; import org.apache.poi.ss.formula.eval.ErrorEval; @@ -31,8 +31,8 @@ import org.apache.poi.ss.formula.functio import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg; import org.apache.poi.ss.formula.ptg.FuncVarPtg; import org.apache.poi.ss.formula.ptg.Ptg; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * Tests specific formula examples in <tt>OperandClassTransformer</tt>. @@ -41,7 +41,7 @@ public final class TestOperandClassTrans private static Ptg[] parseFormula(String formula) { Ptg[] result = HSSFFormulaParser.parse(formula, null); - assertNotNull("Ptg array should not be null", result); + assertNotNull(result, "Ptg array should not be null"); return result; } @@ -79,7 +79,7 @@ public final class TestOperandClassTrans * This test has been added but disabled in order to document this issue. */ @Test - @Ignore + @Disabled public void testIndexPi1() { String formula = "INDEX(PI(),1)"; Ptg[] ptgs = parseFormula(formula); @@ -144,7 +144,7 @@ public final class TestOperandClassTrans private void confirmTokenClass(Ptg[] ptgs, int i, byte operandClass) { Ptg ptg = ptgs[i]; - assertFalse("ptg[" + i + "] is a base token", ptg.isBaseToken()); + assertFalse(ptg.isBaseToken(), "ptg[" + i + "] is a base token"); assertEquals(operandClass, ptg.getPtgClass()); } } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java Thu Dec 24 18:42:29 2020 @@ -17,12 +17,13 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +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.stream.Stream; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.usermodel.FormulaExtractor; @@ -34,19 +35,16 @@ import org.apache.poi.poifs.filesystem.P import org.apache.poi.ss.formula.ptg.AttrPtg; import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.usermodel.CellType; -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; /** * Tests 'operand class' transformation performed by * <tt>OperandClassTransformer</tt> by comparing its results with those * directly produced by Excel (in a sample spreadsheet). */ -@RunWith(Parameterized.class) public final class TestRVA { private static final String NEW_LINE = System.getProperty("line.separator"); @@ -54,25 +52,19 @@ public final class TestRVA { private static HSSFWorkbook workbook; - @Parameter(value = 0) - public HSSFCell formulaCell; - @Parameter(value = 1) - public String formula; - - @AfterClass + @AfterAll public static void closeResource() throws Exception { workbook.close(); poifs.close(); } - @Parameters(name="{1}") - public static Collection<Object[]> data() throws Exception { + public static Stream<Arguments> data() throws Exception { poifs = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("testRVA.xls"), true); workbook = new HSSFWorkbook(poifs); HSSFSheet sheet = workbook.getSheetAt(0); - List<Object[]> data = new ArrayList<>(); - + List<Arguments> data = new ArrayList<>(); + for (int rowIdx = 0; true; rowIdx++) { HSSFRow row = sheet.getRow(rowIdx); if (row == null) { @@ -84,29 +76,29 @@ public final class TestRVA { } String formula = cell.getCellFormula(); - data.add(new Object[]{cell,formula}); + data.add(Arguments.of(cell,formula)); } - - return data; + + return data.stream(); } - - @Test - public void confirmCell() { + + @ParameterizedTest + @MethodSource("data") + public void confirmCell(HSSFCell formulaCell, String formula) { Ptg[] excelPtgs = FormulaExtractor.getPtgs(formulaCell); Ptg[] poiPtgs = HSSFFormulaParser.parse(formula, workbook); int nExcelTokens = excelPtgs.length; int nPoiTokens = poiPtgs.length; if (nExcelTokens != nPoiTokens) { - if (nExcelTokens == nPoiTokens + 1 && excelPtgs[0].getClass() == AttrPtg.class) { - // compensate for missing tAttrVolatile, which belongs in any formula - // involving OFFSET() et al. POI currently does not insert where required - Ptg[] temp = new Ptg[nExcelTokens]; - temp[0] = excelPtgs[0]; - System.arraycopy(poiPtgs, 0, temp, 1, nPoiTokens); - poiPtgs = temp; - } else { - fail("Expected " + nExcelTokens + " tokens but got " + nPoiTokens); - } + assertTrue(nExcelTokens == nPoiTokens + 1 && excelPtgs[0].getClass() == AttrPtg.class, + "Expected " + nExcelTokens + " tokens but got " + nPoiTokens); + + // compensate for missing tAttrVolatile, which belongs in any formula + // involving OFFSET() et al. POI currently does not insert where required + Ptg[] temp = new Ptg[nExcelTokens]; + temp[0] = excelPtgs[0]; + System.arraycopy(poiPtgs, 0, temp, 1, nPoiTokens); + poiPtgs = temp; } boolean hasMismatch = false; StringBuilder sb = new StringBuilder(); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRowBlocksReader.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRowBlocksReader.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRowBlocksReader.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRowBlocksReader.java Thu Dec 24 18:42:29 2020 @@ -17,10 +17,11 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.Arrays; @@ -31,7 +32,7 @@ import org.apache.poi.hssf.record.Unknow import org.apache.poi.hssf.record.WindowTwoRecord; import org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord; import org.apache.poi.util.LocaleUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link RowBlocksReader} @@ -51,10 +52,9 @@ public final class TestRowBlocksReader { }; RecordStream rs = new RecordStream(Arrays.asList(inRecs), 0); RowBlocksReader rbr = new RowBlocksReader(rs); - if (rs.peekNextClass() == WindowTwoRecord.class) { - // Should have stopped at the SXVIEW record - fail("Identified bug 46280b"); - } + assertNotEquals(WindowTwoRecord.class, rs.peekNextClass(), + "Should have stopped at the SXVIEW record - Identified bug 46280b"); + RecordStream rbStream = rbr.getPlainRecordStream(); assertEquals(inRecs[0], rbStream.getNext()); assertEquals(inRecs[1], rbStream.getNext()); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheet.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheet.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheet.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheet.java Thu Dec 24 18:42:29 2020 @@ -17,12 +17,13 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.ArrayList; import java.util.Arrays; @@ -44,7 +45,7 @@ import org.apache.poi.ss.SpreadsheetVers import org.apache.poi.ss.formula.FormulaShifter; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit test for the {@link InternalSheet} class. @@ -112,7 +113,7 @@ public final class TestSheet { for (int n = 0; n < regionsToAdd; n++) { int index = sheet.addMergedRegion(0, (short) 0, 1, (short) 1); - assertEquals("Merged region index expected to be " + n + " got " + index, index, n); + assertEquals(index, n, "Merged region index expected to be " + n + " got " + index); } //test all the regions were indeed added @@ -127,23 +128,16 @@ public final class TestSheet { if ((regionsToAdd % 1027) != 0) { recordsExpected++; } - assertEquals("The " + regionsToAdd + " merged regions should have been spread out over " - + recordsExpected + " records, not " + recordsAdded, recordsAdded, recordsExpected); + assertEquals(recordsAdded, recordsExpected, + "The " + regionsToAdd + " merged regions should have been spread out over " + + recordsExpected + " records, not " + recordsAdded); // Check we can't add one with invalid date - try { - sheet.addMergedRegion(10, (short)10, 9, (short)12); - fail("Expected an exception to occur"); - } catch(IllegalArgumentException e) { - // occurs during successful test - assertEquals("The 'to' row (9) must not be less than the 'from' row (10)", e.getMessage()); - } - try { - sheet.addMergedRegion(10, (short)10, 12, (short)9); - fail("Expected an exception to occur"); - } catch(IllegalArgumentException e) { - // occurs during successful test - assertEquals("The 'to' col (9) must not be less than the 'from' col (10)", e.getMessage()); - } + IllegalArgumentException e; + e = assertThrows(IllegalArgumentException.class, () -> sheet.addMergedRegion(10, (short)10, 9, (short)12)); + assertEquals("The 'to' row (9) must not be less than the 'from' row (10)", e.getMessage()); + + e = assertThrows(IllegalArgumentException.class, () -> sheet.addMergedRegion(10, (short)10, 12, (short)9)); + assertEquals("The 'to' col (9) must not be less than the 'from' col (10)", e.getMessage()); } @Test @@ -162,12 +156,12 @@ public final class TestSheet { { sheet.removeMergedRegion(0); //assert they have been deleted - assertEquals("Num of regions", regionsToAdd - n - 1, sheet.getNumMergedRegions()); + assertEquals(regionsToAdd - n - 1, sheet.getNumMergedRegions(), "Num of regions"); } // merge records are removed from within the MergedCellsTable, // so the sheet record count should not change - assertEquals("Sheet Records", nSheetRecords, sheet.getRecords().size()); + assertEquals(nSheetRecords, sheet.getRecords().size(), "Sheet Records"); } /** @@ -199,7 +193,7 @@ public final class TestSheet { //stub object to throw off list INDEX operations sheet.removeMergedRegion(0); - assertEquals("Should be no more merged regions", 0, sheet.getNumMergedRegions()); + assertEquals(0, sheet.getNumMergedRegions(), "Should be no more merged regions"); } // @Test @@ -233,7 +227,7 @@ public final class TestSheet { records.add(EOFRecord.instance); InternalSheet sheet = createSheet(records); - assertNotNull("Row [2] was skipped", sheet.getRow(2)); + assertNotNull(sheet.getRow(2), "Row [2] was skipped"); } /** @@ -249,21 +243,21 @@ public final class TestSheet { PageSettingsBlock sheet = worksheet.getPageSettings(); sheet.setRowBreak(0, colFrom, colTo); - assertTrue("no row break at 0", sheet.isRowBroken(0)); - assertEquals("1 row break available", 1, sheet.getNumRowBreaks()); + assertTrue(sheet.isRowBroken(0), "no row break at 0"); + assertEquals(1, sheet.getNumRowBreaks(), "1 row break available"); sheet.setRowBreak(0, colFrom, colTo); sheet.setRowBreak(0, colFrom, colTo); - assertTrue("no row break at 0", sheet.isRowBroken(0)); - assertEquals("1 row break available", 1, sheet.getNumRowBreaks()); + assertTrue(sheet.isRowBroken(0), "no row break at 0"); + assertEquals(1, sheet.getNumRowBreaks(), "1 row break available"); sheet.setRowBreak(10, colFrom, colTo); sheet.setRowBreak(11, colFrom, colTo); - assertTrue("no row break at 10", sheet.isRowBroken(10)); - assertTrue("no row break at 11", sheet.isRowBroken(11)); - assertEquals("3 row break available", 3, sheet.getNumRowBreaks()); + assertTrue(sheet.isRowBroken(10), "no row break at 10"); + assertTrue(sheet.isRowBroken(11), "no row break at 11"); + assertEquals(3, sheet.getNumRowBreaks(), "3 row break available"); boolean is10 = false; @@ -272,24 +266,24 @@ public final class TestSheet { int[] rowBreaks = sheet.getRowBreaks(); for (int main : rowBreaks) { - if (main != 0 && main != 10 && main != 11) fail("Invalid page break"); + assertTrue(main == 0 || main == 10 || main == 11, "Invalid page break"); if (main == 0) is0 = true; - if (main == 10) is10= true; + if (main == 10) is10 = true; if (main == 11) is11 = true; } - assertTrue("one of the breaks didnt make it", is0 && is10 && is11); + assertTrue(is0 && is10 && is11, "one of the breaks didnt make it"); sheet.removeRowBreak(11); - assertFalse("row should be removed", sheet.isRowBroken(11)); + assertFalse(sheet.isRowBroken(11), "row should be removed"); sheet.removeRowBreak(0); - assertFalse("row should be removed", sheet.isRowBroken(0)); + assertFalse(sheet.isRowBroken(0), "row should be removed"); sheet.removeRowBreak(10); - assertFalse("row should be removed", sheet.isRowBroken(10)); + assertFalse(sheet.isRowBroken(10), "row should be removed"); - assertEquals("no more breaks", 0, sheet.getNumRowBreaks()); + assertEquals(0, sheet.getNumRowBreaks(), "no more breaks"); } /** @@ -305,22 +299,22 @@ public final class TestSheet { PageSettingsBlock sheet = worksheet.getPageSettings(); sheet.setColumnBreak((short)0, rowFrom, rowTo); - assertTrue("no col break at 0", sheet.isColumnBroken(0)); - assertEquals("1 col break available", 1, sheet.getNumColumnBreaks()); + assertTrue(sheet.isColumnBroken(0), "no col break at 0"); + assertEquals(1, sheet.getNumColumnBreaks(), "1 col break available"); sheet.setColumnBreak((short)0, rowFrom, rowTo); - assertTrue("no col break at 0", sheet.isColumnBroken(0)); - assertEquals("1 col break available", 1, sheet.getNumColumnBreaks()); + assertTrue(sheet.isColumnBroken(0), "no col break at 0"); + assertEquals(1, sheet.getNumColumnBreaks(), "1 col break available"); sheet.setColumnBreak((short)1, rowFrom, rowTo); sheet.setColumnBreak((short)10, rowFrom, rowTo); sheet.setColumnBreak((short)15, rowFrom, rowTo); - assertTrue("no col break at 1", sheet.isColumnBroken(1)); - assertTrue("no col break at 10", sheet.isColumnBroken(10)); - assertTrue("no col break at 15", sheet.isColumnBroken(15)); - assertEquals("4 col break available", 4, sheet.getNumColumnBreaks()); + assertTrue(sheet.isColumnBroken(1), "no col break at 1"); + assertTrue(sheet.isColumnBroken(10), "no col break at 10"); + assertTrue(sheet.isColumnBroken(15), "no col break at 15"); + assertEquals(4, sheet.getNumColumnBreaks(), "4 col break available"); boolean is10 = false; boolean is0 = false; @@ -329,28 +323,28 @@ public final class TestSheet { int[] colBreaks = sheet.getColumnBreaks(); for (int main : colBreaks) { - if (main != 0 && main != 1 && main != 10 && main != 15) fail("Invalid page break"); + assertTrue(main == 0 || main == 1 || main == 10 || main == 15, "Invalid page break"); if (main == 0) is0 = true; if (main == 1) is1 = true; if (main == 10) is10= true; if (main == 15) is15 = true; } - assertTrue("one of the breaks didnt make it", is0 && is1 && is10 && is15); + assertTrue(is0 && is1 && is10 && is15, "one of the breaks didnt make it"); sheet.removeColumnBreak(15); - assertFalse("column break should not be there", sheet.isColumnBroken(15)); + assertFalse(sheet.isColumnBroken(15), "column break should not be there"); sheet.removeColumnBreak(0); - assertFalse("column break should not be there", sheet.isColumnBroken(0)); + assertFalse(sheet.isColumnBroken(0), "column break should not be there"); sheet.removeColumnBreak(1); - assertFalse("column break should not be there", sheet.isColumnBroken(1)); + assertFalse(sheet.isColumnBroken(1), "column break should not be there"); sheet.removeColumnBreak(10); - assertFalse("column break should not be there", sheet.isColumnBroken(10)); + assertFalse(sheet.isColumnBroken(10), "column break should not be there"); - assertEquals("no more breaks", 0, sheet.getNumColumnBreaks()); + assertEquals(0, sheet.getNumColumnBreaks(), "no more breaks"); } /** @@ -447,7 +441,7 @@ public final class TestSheet { sheet.visitContainedRecords(r -> { int estimatedSize = r.getRecordSize(); int serializedSize = r.serialize(0, buf); - assertEquals("serialized size mismatch for record (" + r.getClass().getName() + ")", estimatedSize, serializedSize); + assertEquals(estimatedSize, serializedSize, "serialized size mismatch for record (" + r.getClass().getName() + ")"); totalSize[0] += estimatedSize; }, 0); assertEquals(90, totalSize[0]); @@ -540,17 +534,13 @@ public final class TestSheet { @Test public void testMisplacedMergedCellsRecords_bug45699() throws Exception { - HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex45698-22488.xls"); - - HSSFSheet sheet = wb.getSheetAt(0); - HSSFRow row = sheet.getRow(3); - HSSFCell cell = row.getCell(4); - if (cell == null) { - fail("Identified bug 45699"); + try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex45698-22488.xls")) { + HSSFSheet sheet = wb.getSheetAt(0); + HSSFRow row = sheet.getRow(3); + HSSFCell cell = row.getCell(4); + assertNotNull(cell, "Identified bug 45699"); + assertEquals("Informations", cell.getRichStringCellValue().getString()); } - assertEquals("Informations", cell.getRichStringCellValue().getString()); - - wb.close(); } /** * In 3.1, setting margins between creating first row and first cell caused an exception. Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestSheetAdditional.java Thu Dec 24 18:42:29 2020 @@ -17,11 +17,11 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.poi.hssf.record.ColumnInfoRecord; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestSheetAdditional { @Test Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java Thu Dec 24 18:42:29 2020 @@ -17,12 +17,12 @@ package org.apache.poi.hssf.model; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; @@ -36,7 +36,7 @@ import org.apache.poi.ss.formula.functio import org.apache.poi.ss.formula.udf.AggregatingUDFFinder; import org.apache.poi.ss.formula.udf.DefaultUDFFinder; import org.apache.poi.ss.formula.udf.UDFFinder; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit test for the Workbook class. @@ -161,15 +161,13 @@ public final class TestWorkbook { InternalWorkbook iwb = TestHSSFWorkbook.getInternalWorkbook(wb); int oldRecordsCount = iwb.getNumRecords(); - //System.out.println("records count = " + oldRecordsCount); - assertEquals("records count", 68, oldRecordsCount); + assertEquals(68, oldRecordsCount, "records count"); WriteAccessRecord writeAccess = iwb.getWriteAccess(); assertNotNull(writeAccess); assertEquals(WriteAccessRecord.sid, writeAccess.getSid()); int newRecordsCount = iwb.getNumRecords(); - //System.out.println("records count after 'getWriteAccess' = " + newRecordsCount); - assertEquals("records count after getWriteAccess", oldRecordsCount, newRecordsCount); + assertEquals(oldRecordsCount, newRecordsCount, "records count after getWriteAccess"); } } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestArrayRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestArrayRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestArrayRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestArrayRecord.java Thu Dec 24 18:42:29 2020 @@ -17,8 +17,8 @@ package org.apache.poi.hssf.record; -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 org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.usermodel.HSSFSheet; @@ -31,7 +31,7 @@ import org.apache.poi.ss.formula.Formula import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestArrayRecord { Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestAutoFilterInfoRecord.java Thu Dec 24 18:42:29 2020 @@ -17,10 +17,10 @@ package org.apache.poi.hssf.record; -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 org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the AutoFilterInfoRecord class. Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java Thu Dec 24 18:42:29 2020 @@ -17,14 +17,14 @@ package org.apache.poi.hssf.record; -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.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Sheet; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestBOFRecord { @Test Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java Thu Dec 24 18:42:29 2020 @@ -17,13 +17,13 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertArrayEquals; -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.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link BoolErrRecord} Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestBoundSheetRecord.java Thu Dec 24 18:42:29 2020 @@ -17,16 +17,17 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertArrayEquals; -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.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests BoundSheetRecord. @@ -45,10 +46,10 @@ public final class TestBoundSheetRecord assertEquals(24, record.getRecordSize()); } - @Test(expected = IllegalArgumentException.class) + @Test public void testName() { BoundSheetRecord record = new BoundSheetRecord("1234567890223456789032345678904"); - record.setSheetname("s//*s"); + assertThrows(IllegalArgumentException.class, () -> record.setSheetname("s//*s")); } @Test Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java Thu Dec 24 18:42:29 2020 @@ -18,12 +18,12 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.ss.util.CellRangeAddress; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the serialization and deserialization of the {@link CFHeaderRecord} @@ -133,7 +133,7 @@ public final class TestCFHeaderRecord { CFHeaderRecord record = new CFHeaderRecord(TestcaseRecordInputStream.create(CFHeaderRecord.sid, recordData)); - assertEquals("#CFRULES", 3, record.getNumberOfConditionalFormats()); + assertEquals(3, record.getNumberOfConditionalFormats(), "#CFRULES"); assertTrue(record.getNeedRecalculation()); confirm(record.getEnclosingCellRange(), 0, 3, 0, 3); CellRangeAddress[] ranges = record.getCellRanges(); @@ -180,7 +180,7 @@ public final class TestCFHeaderRecord { // bug 44739b - invalid cell range (-25536, 2, -15536, 2) CFHeaderRecord record = new CFHeaderRecord(TestcaseRecordInputStream.create(CFHeaderRecord.sid, recordData)); - assertEquals("#CFRULES", 19, record.getNumberOfConditionalFormats()); + assertEquals(19, record.getNumberOfConditionalFormats(), "#CFRULES"); assertFalse(record.getNeedRecalculation()); confirm(record.getEnclosingCellRange(), 0, 65535, 0, 255); CellRangeAddress[] ranges = record.getCellRanges(); @@ -194,9 +194,9 @@ public final class TestCFHeaderRecord { } private static void confirm(CellRangeAddress cr, int expFirstRow, int expLastRow, int expFirstCol, int expLastColumn) { - assertEquals("first row", expFirstRow, cr.getFirstRow()); - assertEquals("last row", expLastRow, cr.getLastRow()); - assertEquals("first column", expFirstCol, cr.getFirstColumn()); - assertEquals("last column", expLastColumn, cr.getLastColumn()); + assertEquals(expFirstRow, cr.getFirstRow(), "first row"); + assertEquals(expLastRow, cr.getLastRow(), "last row"); + assertEquals(expFirstCol, cr.getFirstColumn(), "first column"); + assertEquals(expLastColumn, cr.getLastColumn(), "last column"); } } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCFRuleRecord.java Thu Dec 24 18:42:29 2020 @@ -18,12 +18,12 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -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.assertSame; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.util.Arrays; @@ -42,7 +42,7 @@ import org.apache.poi.ss.formula.ptg.Ref import org.apache.poi.ss.usermodel.ConditionalFormattingThreshold.RangeType; import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet; import org.apache.poi.util.LittleEndian; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the serialization and deserialization of the TestCFRuleRecord @@ -387,8 +387,9 @@ public final class TestCFRuleRecord { assertEquals(3, LittleEndian.getShort(data, 8)); int flags = LittleEndian.getInt(data, 10); - assertEquals("unused flags should be 111", 0x00380000, flags & 0x00380000); - assertEquals("undocumented flags should be 0000", 0, flags & 0x03C00000); // Otherwise Excel gets unhappy + assertEquals(0x00380000, flags & 0x00380000, "unused flags should be 111"); + // Otherwise Excel gets unhappy + assertEquals(0, flags & 0x03C00000, "undocumented flags should be 0000"); // check all remaining flag bits (some are not well understood yet) assertEquals(0x203FFFFF, flags); } @@ -415,7 +416,7 @@ public final class TestCFRuleRecord { CFRuleRecord rr = new CFRuleRecord(is); Ptg[] ptgs = rr.getParsedExpression1(); assertEquals(3, ptgs.length); - assertFalse("Identified bug 45234", ptgs[0] instanceof RefPtg); + assertFalse(ptgs[0] instanceof RefPtg, "Identified bug 45234"); assertEquals(RefNPtg.class, ptgs[0].getClass()); RefNPtg refNPtg = (RefNPtg) ptgs[0]; assertTrue(refNPtg.isColRelative()); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java Thu Dec 24 18:42:29 2020 @@ -17,12 +17,12 @@ package org.apache.poi.hssf.record; -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 org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link ColumnInfoRecord} Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java Thu Dec 24 18:42:29 2020 @@ -19,11 +19,11 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the serialization and deserialization of the {@link CommonObjectDataSubRecord} Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java Thu Dec 24 18:42:29 2020 @@ -19,17 +19,17 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertArrayEquals; -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.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; import org.apache.poi.util.LittleEndianOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Unit tests for DConRefRecord class. @@ -214,7 +214,7 @@ public class TestDConRefRecord { d.serialize(o); o.flush(); - assertArrayEquals(message, data, bos.toByteArray()); + assertArrayEquals(data, bos.toByteArray(), message); } /** @@ -241,14 +241,14 @@ public class TestDConRefRecord { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1)); int expResult = data1.length; int result = instance.getDataSize(); - assertEquals("single byte external reference, volume type path data size", expResult, result); + assertEquals(expResult, result, "single byte external reference, volume type path data size"); instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data2)); - assertEquals("double byte self reference data size", data2.length, instance.getDataSize()); + assertEquals(data2.length, instance.getDataSize(), "double byte self reference data size"); instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data3)); - assertEquals("single byte self reference data size", data3.length, instance.getDataSize()); + assertEquals(data3.length, instance.getDataSize(), "single byte self reference data size"); instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data4)); - assertEquals("double byte external reference, UNC volume type path data size", data4.length, - instance.getDataSize()); + assertEquals(data4.length, instance.getDataSize(), + "double byte external reference, UNC volume type path data size"); } /** @@ -259,7 +259,7 @@ public class TestDConRefRecord { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1)); short expResult = 81; short result = instance.getSid(); - assertEquals("SID", expResult, result); + assertEquals(expResult, result, "SID"); } /** @@ -271,7 +271,7 @@ public class TestDConRefRecord { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1)); byte[] expResult = Arrays.copyOfRange(data1, 9, data1.length); byte[] result = instance.getPath(); - assertArrayEquals("get path", expResult, result); + assertArrayEquals(expResult, result, "get path"); } /** @@ -280,8 +280,8 @@ public class TestDConRefRecord { @Test public void testIsExternalRef() { DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1)); - assertTrue("external reference", instance.isExternalRef()); + assertTrue(instance.isExternalRef(), "external reference"); instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data2)); - assertFalse("internal reference", instance.isExternalRef()); + assertFalse(instance.isExternalRef(), "internal reference"); } } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDVALRecord.java Thu Dec 24 18:42:29 2020 @@ -17,13 +17,13 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.io.ByteArrayInputStream; import org.apache.poi.util.LittleEndian; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestDVALRecord { @Test @@ -45,7 +45,7 @@ public final class TestDVALRecord { assertEquals(56, dv.getHorizontalPos()); assertEquals(57, dv.getVerticalPos()); assertEquals(58, dv.getObjectID()); - assertNotEquals("Identified bug 44510",0, dv.getDVRecNo()); + assertNotEquals(0, dv.getDVRecNo(), "Identified bug 44510"); assertEquals(59, dv.getDVRecNo()); } } Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingGroupRecord.java Thu Dec 24 18:42:29 2020 @@ -18,12 +18,12 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.cut; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.poi.ddf.EscherContainerRecord; import org.apache.poi.ddf.EscherSpRecord; import org.apache.poi.util.HexDump; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestDrawingGroupRecord { private static final int MAX_RECORD_SIZE = 8228; Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java Thu Dec 24 18:42:29 2020 @@ -17,9 +17,9 @@ package org.apache.poi.hssf.record; -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.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -27,7 +27,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestDrawingRecord { Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEmbeddedObjectRefSubRecord.java Thu Dec 24 18:42:29 2020 @@ -18,11 +18,11 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -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 org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the serialization and deserialization of the TestEmbeddedObjectRefSubRecord Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEndSubRecord.java Thu Dec 24 18:42:29 2020 @@ -18,9 +18,9 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the serialization and deserialization of the EndSubRecord Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestEscherAggregate.java Thu Dec 24 18:42:29 2020 @@ -17,7 +17,7 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; @@ -27,7 +27,7 @@ import org.apache.poi.ddf.EscherContaine import org.apache.poi.ddf.EscherSpRecord; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the EscherAggregate class. Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java Thu Dec 24 18:42:29 2020 @@ -19,12 +19,12 @@ package org.apache.poi.hssf.record; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import org.apache.poi.poifs.storage.RawDataUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestExtSSTRecord { Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExtendedFormatRecord.java Thu Dec 24 18:42:29 2020 @@ -18,9 +18,9 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -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 TestExtendedFormatRecord { Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java Thu Dec 24 18:42:29 2020 @@ -18,15 +18,15 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.util.HexDump; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; public final class TestExternalNameRecord { @@ -64,7 +64,7 @@ public final class TestExternalNameRecor @Test public void testBasicSize() { ExternalNameRecord enr = createSimpleENR(dataFDS); - assertNotEquals("Identified bug 44695",13, enr.getRecordSize()); + assertNotEquals(13, enr.getRecordSize(), "Identified bug 44695"); assertEquals(17, enr.getRecordSize()); assertNotNull(enr.serialize()); Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFeatRecord.java Thu Dec 24 18:42:29 2020 @@ -17,11 +17,11 @@ package org.apache.poi.hssf.record; -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.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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; @@ -32,7 +32,7 @@ import org.apache.poi.hssf.record.common import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFTestHelper; import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for <tt>FeatRecord</tt> Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java?rev=1884783&r1=1884782&r2=1884783&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java (original) +++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFontRecord.java Thu Dec 24 18:42:29 2020 @@ -19,13 +19,13 @@ package org.apache.poi.hssf.record; import static org.apache.poi.hssf.record.TestcaseRecordInputStream.confirmRecordEncoding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.apache.poi.util.HexRead; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the serialization and deserialization of the {@link FontRecord} @@ -111,7 +111,7 @@ public final class TestFontRecord { byte [] recordBytes = other.serialize(); assertEquals(recordBytes.length - 4, data.length); for (int i = 0; i < data.length; i++) - assertEquals("At offset " + i, data[i], recordBytes[i+4]); + assertEquals(data[i], recordBytes[i+4], "At offset " + i); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org