This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
The following commit(s) were added to refs/heads/trunk by this push:
new 945806f670 assertInstanceOf (#1088)
945806f670 is described below
commit 945806f6702e69dad0e0b4586ad7d0e02f29eb04
Author: PJ Fanning <[email protected]>
AuthorDate: Tue May 26 09:09:33 2026 +0100
assertInstanceOf (#1088)
---
.../poi/xssf/usermodel/TestXSSFFormulaParser.java | 81 +++++++++++-----------
.../apache/poi/xwpf/usermodel/TestXWPFEndnote.java | 2 +-
.../poi/xwpf/usermodel/TestXWPFFootnote.java | 2 +-
.../org/apache/poi/hpsf/basic/TestMetaDataIPI.java | 26 +++----
.../apache/poi/hssf/model/TestFormulaParserIf.java | 2 +-
.../record/aggregates/TestRowRecordsAggregate.java | 11 +--
.../aggregates/TestValueRecordsAggregate.java | 11 +--
.../poi/ss/formula/SheetRangeEvaluatorTest.java | 10 +--
.../poi/ss/formula/functions/TestSumifs.java | 8 +--
9 files changed, 67 insertions(+), 86 deletions(-)
diff --git
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
index 269516c0fd..7cfb3233b3 100644
---
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
+++
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
@@ -82,20 +82,20 @@ public final class TestXSSFFormulaParser {
ptgs = parse(fpb, "ABC10");
assertEquals(1, ptgs.length);
- assertTrue(ptgs[0] instanceof RefPtg, "Had " + Arrays.toString(ptgs));
+ assertInstanceOf(RefPtg.class, ptgs[0], "Had " +
Arrays.toString(ptgs));
ptgs = parse(fpb, "A500000");
assertEquals(1, ptgs.length);
- assertTrue(ptgs[0] instanceof RefPtg, "Had " + Arrays.toString(ptgs));
+ assertInstanceOf(RefPtg.class, ptgs[0], "Had " +
Arrays.toString(ptgs));
ptgs = parse(fpb, "ABC500000");
assertEquals(1, ptgs.length);
- assertTrue(ptgs[0] instanceof RefPtg, "Had " + Arrays.toString(ptgs));
+ assertInstanceOf(RefPtg.class, ptgs[0], "Had " +
Arrays.toString(ptgs));
//highest allowed rows and column (XFD and 0x100000)
ptgs = parse(fpb, "XFD1048576");
assertEquals(1, ptgs.length);
- assertTrue(ptgs[0] instanceof RefPtg, "Had " + Arrays.toString(ptgs));
+ assertInstanceOf(RefPtg.class, ptgs[0], "Had " +
Arrays.toString(ptgs));
//column greater than XFD
@@ -110,34 +110,33 @@ public final class TestXSSFFormulaParser {
// Formula referencing one cell
ptgs = parse(fpb, "ISEVEN(A1)");
assertEquals(3, ptgs.length);
- assertEquals(NameXPxg.class, ptgs[0].getClass());
- assertEquals(RefPtg.class, ptgs[1].getClass());
- assertEquals(FuncVarPtg.class, ptgs[2].getClass());
+ assertInstanceOf(NameXPxg.class, ptgs[0]);
+ assertInstanceOf(RefPtg.class, ptgs[1]);
+ assertInstanceOf(FuncVarPtg.class, ptgs[2]);
assertEquals("ISEVEN", ptgs[0].toFormulaString());
assertEquals("A1", ptgs[1].toFormulaString());
assertEquals("#external#", ptgs[2].toFormulaString());
// Formula referencing an area
ptgs = parse(fpb, "SUM(A1:B3)");
- assertEquals(2, ptgs.length);
- assertEquals(AreaPtg.class, ptgs[0].getClass());
- assertEquals(AttrPtg.class, ptgs[1].getClass());
+ assertInstanceOf(AreaPtg.class, ptgs[0]);
+ assertInstanceOf(AttrPtg.class, ptgs[1]);
assertEquals("A1:B3", ptgs[0].toFormulaString());
assertEquals("SUM", ptgs[1].toFormulaString());
// Formula referencing one cell in a different sheet
ptgs = parse(fpb, "SUM(Sheet1!A1)");
assertEquals(2, ptgs.length);
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
- assertEquals(AttrPtg.class, ptgs[1].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
+ assertInstanceOf(AttrPtg.class, ptgs[1]);
assertEquals("Sheet1!A1", ptgs[0].toFormulaString());
assertEquals("SUM", ptgs[1].toFormulaString());
// Formula referencing an area in a different sheet
ptgs = parse(fpb, "SUM(Sheet1!A1:B3)");
assertEquals(2, ptgs.length);
- assertEquals(Area3DPxg.class,ptgs[0].getClass());
- assertEquals(AttrPtg.class, ptgs[1].getClass());
+ assertInstanceOf(Area3DPxg.class, ptgs[0]);
+ assertInstanceOf(AttrPtg.class, ptgs[1]);
assertEquals("Sheet1!A1:B3", ptgs[0].toFormulaString());
assertEquals("SUM", ptgs[1].toFormulaString());
@@ -174,7 +173,7 @@ public final class TestXSSFFormulaParser {
// were defined in a different workbook
ptgs = parse(fpb, "[0]!NR_Global_B2");
assertEquals(1, ptgs.length);
- assertEquals(NameXPxg.class, ptgs[0].getClass());
+ assertInstanceOf(NameXPxg.class, ptgs[0]);
assertEquals(0, ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertNull(((NameXPxg) ptgs[0]).getSheetName());
assertEquals("NR_Global_B2",((NameXPxg)ptgs[0]).getNameName());
@@ -193,7 +192,7 @@ public final class TestXSSFFormulaParser {
// Reference to a single cell in a different sheet
ptgs = parse(fpb, "Uses!A1");
assertEquals(1, ptgs.length);
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
assertEquals(-1, ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
assertEquals("Uses!A1", ptgs[0].toFormulaString());
@@ -201,7 +200,7 @@ public final class TestXSSFFormulaParser {
// Reference to a single cell in a different sheet, which needs quoting
ptgs = parse(fpb, "'Testing 47100'!A1");
assertEquals(1, ptgs.length);
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
assertEquals(-1, ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Testing 47100", ((Ref3DPxg)ptgs[0]).getSheetName());
assertEquals("A1", ((Ref3DPxg)ptgs[0]).format2DRefAsString());
@@ -210,7 +209,7 @@ public final class TestXSSFFormulaParser {
// Reference to a sheet scoped named range from another sheet
ptgs = parse(fpb, "Defines!NR_To_A1");
assertEquals(1, ptgs.length);
- assertEquals(NameXPxg.class, ptgs[0].getClass());
+ assertInstanceOf(NameXPxg.class, ptgs[0]);
assertEquals(-1,
((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Defines", ((NameXPxg)ptgs[0]).getSheetName());
assertEquals("NR_To_A1",((NameXPxg)ptgs[0]).getNameName());
@@ -219,7 +218,7 @@ public final class TestXSSFFormulaParser {
// Reference to a workbook scoped named range
ptgs = parse(fpb, "NR_Global_B2");
assertEquals(1, ptgs.length);
- assertEquals(NamePtg.class, ptgs[0].getClass());
+ assertInstanceOf(NamePtg.class, ptgs[0]);
assertEquals("NR_Global_B2",((NamePtg)ptgs[0]).toFormulaString(fpb));
wb.close();
@@ -235,7 +234,7 @@ public final class TestXSSFFormulaParser {
// Reference to a single cell in a different workbook
ptgs = parse(fpb, "[1]Uses!$A$1");
assertEquals(1, ptgs.length);
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
assertEquals(1, ((Ref3DPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Uses",((Ref3DPxg)ptgs[0]).getSheetName());
assertEquals("$A$1",((Ref3DPxg)ptgs[0]).format2DRefAsString());
@@ -244,7 +243,7 @@ public final class TestXSSFFormulaParser {
// Reference to a sheet-scoped named range in a different workbook
ptgs = parse(fpb, "[1]Defines!NR_To_A1");
assertEquals(1, ptgs.length);
- assertEquals(NameXPxg.class, ptgs[0].getClass());
+ assertInstanceOf(NameXPxg.class, ptgs[0]);
assertEquals(1,
((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertEquals("Defines", ((NameXPxg)ptgs[0]).getSheetName());
assertEquals("NR_To_A1",((NameXPxg)ptgs[0]).getNameName());
@@ -253,7 +252,7 @@ public final class TestXSSFFormulaParser {
// Reference to a global named range in a different workbook
ptgs = parse(fpb, "[1]!NR_Global_B2");
assertEquals(1, ptgs.length);
- assertEquals(NameXPxg.class, ptgs[0].getClass());
+ assertInstanceOf(NameXPxg.class, ptgs[0]);
assertEquals(1, ((NameXPxg)ptgs[0]).getExternalWorkbookNumber());
assertNull(((NameXPxg) ptgs[0]).getSheetName());
assertEquals("NR_Global_B2",((NameXPxg)ptgs[0]).getNameName());
@@ -330,60 +329,60 @@ public final class TestXSSFFormulaParser {
ptgs = parse(fpb, "SUM(Sheet1:Sheet3!A1)");
assertEquals(2, ptgs.length);
if (wb instanceof HSSFWorkbook) {
- assertEquals(Ref3DPtg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPtg.class, ptgs[0]);
} else {
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
}
assertEquals("Sheet1:Sheet3!A1", toFormulaString(ptgs[0], fpb));
- assertEquals(AttrPtg.class, ptgs[1].getClass());
- assertEquals("SUM", toFormulaString(ptgs[1], fpb));
+ assertInstanceOf(AttrPtg.class, ptgs[1]);
+ assertEquals("SUM", toFormulaString(ptgs[1], fpb));
// MAX to one cell over 3 workbooks, absolute row reference
ptgs = parse(fpb, "MAX(Sheet1:Sheet3!A$1)");
assertEquals(2, ptgs.length);
if (wb instanceof HSSFWorkbook) {
- assertEquals(Ref3DPtg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPtg.class, ptgs[0]);
} else {
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
}
assertEquals("Sheet1:Sheet3!A$1", toFormulaString(ptgs[0], fpb));
- assertEquals(FuncVarPtg.class, ptgs[1].getClass());
- assertEquals("MAX", toFormulaString(ptgs[1], fpb));
+ assertInstanceOf(FuncVarPtg.class, ptgs[1]);
+ assertEquals("MAX", toFormulaString(ptgs[1], fpb));
// MIN to one cell over 3 workbooks, absolute reference
ptgs = parse(fpb, "MIN(Sheet1:Sheet3!$A$1)");
assertEquals(2, ptgs.length);
if (wb instanceof HSSFWorkbook) {
- assertEquals(Ref3DPtg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPtg.class, ptgs[0]);
} else {
- assertEquals(Ref3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Ref3DPxg.class, ptgs[0]);
}
assertEquals("Sheet1:Sheet3!$A$1", toFormulaString(ptgs[0], fpb));
- assertEquals(FuncVarPtg.class, ptgs[1].getClass());
+ assertInstanceOf(FuncVarPtg.class, ptgs[1]);
assertEquals("MIN", toFormulaString(ptgs[1], fpb));
// SUM to a range of cells over 3 workbooks
ptgs = parse(fpb, "SUM(Sheet1:Sheet3!A1:B2)");
assertEquals(2, ptgs.length);
if (wb instanceof HSSFWorkbook) {
- assertEquals(Area3DPtg.class, ptgs[0].getClass());
+ assertInstanceOf(Area3DPtg.class, ptgs[0]);
} else {
- assertEquals(Area3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Area3DPxg.class, ptgs[0]);
}
assertEquals("Sheet1:Sheet3!A1:B2", toFormulaString(ptgs[0], fpb));
- assertEquals(AttrPtg.class, ptgs[1].getClass());
+ assertInstanceOf(AttrPtg.class, ptgs[1]);
assertEquals("SUM", toFormulaString(ptgs[1], fpb));
// MIN to a range of cells over 3 workbooks, absolute reference
ptgs = parse(fpb, "MIN(Sheet1:Sheet3!$A$1:$B$2)");
assertEquals(2, ptgs.length);
if (wb instanceof HSSFWorkbook) {
- assertEquals(Area3DPtg.class, ptgs[0].getClass());
+ assertInstanceOf(Area3DPtg.class, ptgs[0]);
} else {
- assertEquals(Area3DPxg.class, ptgs[0].getClass());
+ assertInstanceOf(Area3DPxg.class, ptgs[0]);
}
assertEquals("Sheet1:Sheet3!$A$1:$B$2", toFormulaString(ptgs[0],
fpb));
- assertEquals(FuncVarPtg.class, ptgs[1].getClass());
+ assertInstanceOf(FuncVarPtg.class, ptgs[1]);
assertEquals("MIN", toFormulaString(ptgs[1], fpb));
// Check we can round-trip - try to set a new one to a new single
cell
@@ -479,8 +478,8 @@ public final class TestXSSFFormulaParser {
ptgs = parse(fpb, "(ABC10 )");
assertEquals(2, ptgs.length, "Had: " + Arrays.toString(ptgs));
- assertTrue(ptgs[0] instanceof RefPtg, "Had " +
Arrays.toString(ptgs));
- assertTrue(ptgs[1] instanceof ParenthesisPtg, "Had " +
Arrays.toString(ptgs));
+ assertInstanceOf(RefPtg.class, ptgs[0], "Had " +
Arrays.toString(ptgs));
+ assertInstanceOf(ParenthesisPtg.class, ptgs[1], "Had " +
Arrays.toString(ptgs));
}
}
diff --git
a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
index e375d710fb..f9a6bcd65c 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
@@ -119,7 +119,7 @@ class TestXWPFEndnote {
assertEquals(3, endnote.getBodyElements().size(), "Expected 3 body
elements");
IBodyElement testP1 = endnote.getBodyElements().get(0);
- assertTrue(testP1 instanceof XWPFParagraph, "Expected a paragraph, got
" + testP1.getClass().getSimpleName());
+ assertInstanceOf(XWPFParagraph.class, testP1, "Expected a paragraph,
got " + testP1.getClass().getSimpleName());
XWPFRun r1 = ((XWPFParagraph)testP1).getRuns().get(0);
assertNotNull(r1);
assertTrue(r1.getCTR().getEndnoteRefList().size() > 0, "No footnote
reference in testP1");
diff --git
a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
index 9d8e563326..3916f2e7b6 100644
---
a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
+++
b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
@@ -119,7 +119,7 @@ class TestXWPFFootnote {
assertEquals(3, footnote.getBodyElements().size(), "Expected 3 body
elements");
IBodyElement testP1 = footnote.getBodyElements().get(0);
- assertTrue(testP1 instanceof XWPFParagraph, "Expected a paragraph, got
" + testP1.getClass().getSimpleName());
+ assertInstanceOf(XWPFParagraph.class, testP1, "Expected a paragraph,
got " + testP1.getClass().getSimpleName());
XWPFRun r1 = ((XWPFParagraph)testP1).getRuns().get(0);
assertNotNull(r1);
assertTrue(r1.getCTR().getFootnoteRefList().size() > 0, "No footnote
reference in testP1");
diff --git a/poi/src/test/java/org/apache/poi/hpsf/basic/TestMetaDataIPI.java
b/poi/src/test/java/org/apache/poi/hpsf/basic/TestMetaDataIPI.java
index 0f7d88939d..8486c15318 100644
--- a/poi/src/test/java/org/apache/poi/hpsf/basic/TestMetaDataIPI.java
+++ b/poi/src/test/java/org/apache/poi/hpsf/basic/TestMetaDataIPI.java
@@ -17,12 +17,6 @@
package org.apache.poi.hpsf.basic;
-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;
import java.io.InputStream;
import java.util.Date;
@@ -40,6 +34,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Basing on:
src/examples/src/org/apache/poi/hpsf/examples/ModifyDocumentSummaryInformation.java
* This class tests reading and writing of meta data. No actual document is
created. All information
@@ -506,15 +502,15 @@ final class TestMetaDataIPI {
assertEquals("a String", s, "string");
- assertTrue(customProperties.get("string") instanceof String);
- assertTrue(customProperties.get("boolean") instanceof Boolean);
- assertTrue(customProperties.get("int") instanceof Integer);
- assertTrue(customProperties.get("negint") instanceof Integer);
- assertTrue(customProperties.get("long") instanceof Long);
- assertTrue(customProperties.get("neglong") instanceof Long);
- assertTrue(customProperties.get("double") instanceof Double);
- assertTrue(customProperties.get("negdouble") instanceof Double);
- assertTrue(customProperties.get("date") instanceof Date);
+ assertInstanceOf(String.class, customProperties.get("string"));
+ assertInstanceOf(Boolean.class, customProperties.get("boolean"));
+ assertInstanceOf(Integer.class, customProperties.get("int"));
+ assertInstanceOf(Integer.class, customProperties.get("negint"));
+ assertInstanceOf(Long.class, customProperties.get("long"));
+ assertInstanceOf(Long.class, customProperties.get("neglong"));
+ assertInstanceOf(Double.class, customProperties.get("double"));
+ assertInstanceOf(Double.class, customProperties.get("negdouble"));
+ assertInstanceOf(Date.class, customProperties.get("date"));
}
diff --git
a/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParserIf.java
b/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParserIf.java
index fe88c73139..8c82c42661 100644
--- a/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParserIf.java
+++ b/poi/src/test/java/org/apache/poi/hssf/model/TestFormulaParserIf.java
@@ -50,7 +50,7 @@ final class TestFormulaParserIf {
private static void confirmAttrData(Ptg[] ptgs, int i, int expectedData) {
Ptg ptg = ptgs[i];
- assertTrue(ptg instanceof AttrPtg, "Token[" + i + "] was not AttrPtg
as expected");
+ assertInstanceOf(AttrPtg.class, ptg, "Token[" + i + "] was not AttrPtg
as expected");
AttrPtg attrPtg = (AttrPtg) ptg;
assertEquals(expectedData, attrPtg.getData());
}
diff --git
a/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java
b/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java
index 8137ff8b25..a035bc10c7 100644
---
a/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java
+++
b/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java
@@ -17,12 +17,6 @@
package org.apache.poi.hssf.record.aggregates;
-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 static org.junit.jupiter.api.Assertions.fail;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -44,6 +38,8 @@ import org.apache.poi.hssf.util.CellRangeAddress8Bit;
import org.apache.poi.util.LocaleUtil;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Tests for {@link RowRecordsAggregate}
*/
@@ -109,8 +105,7 @@ final class TestRowRecordsAggregate {
if (rec.getClass() == shfClass) {
result++;
Record prevRec = recs.get(i-1);
- assertTrue(prevRec instanceof FormulaRecord,
- "Bad record order at index " + i + ": Formula record
expected but got (" + prevRec.getClass().getName() + ")");
+ assertInstanceOf(FormulaRecord.class, prevRec, "Bad record
order at index " + i + ": Formula record expected but got (" +
prevRec.getClass().getName() + ")");
verifySharedFormula((FormulaRecord) prevRec, rec);
}
}
diff --git
a/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
b/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
index 2c765cbc8c..da9d4c02e6 100644
---
a/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
+++
b/poi/src/test/java/org/apache/poi/hssf/record/aggregates/TestValueRecordsAggregate.java
@@ -17,13 +17,6 @@
package org.apache.poi.hssf.record.aggregates;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-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.assertTrue;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -48,6 +41,8 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.util.HexRead;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Tests for {@link ValueRecordsAggregate}
*/
@@ -81,7 +76,7 @@ final class TestValueRecordsAggregate {
CellValueRecordInterface record = cvrs.get(0);
assertNotNull( record, "Row contains a value" );
- assertTrue( ( record instanceof FormulaRecordAggregate ), "First
record is a FormulaRecordsAggregate");
+ assertInstanceOf(FormulaRecordAggregate.class, record, "First record
is a FormulaRecordsAggregate");
}
private void constructValueRecord(List<org.apache.poi.hssf.record.Record>
records) {
diff --git
a/poi/src/test/java/org/apache/poi/ss/formula/SheetRangeEvaluatorTest.java
b/poi/src/test/java/org/apache/poi/ss/formula/SheetRangeEvaluatorTest.java
index 621eb311e2..da974a5771 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/SheetRangeEvaluatorTest.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/SheetRangeEvaluatorTest.java
@@ -17,11 +17,6 @@
package org.apache.poi.ss.formula;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-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.hssf.usermodel.HSSFEvaluationWorkbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.SpreadsheetVersion;
@@ -30,6 +25,8 @@ import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.usermodel.Sheet;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
class SheetRangeEvaluatorTest {
@Test
public void testConstruct() {
@@ -96,8 +93,7 @@ class SheetRangeEvaluatorTest {
public void testGetEval() {
SheetRangeEvaluator eval = createWithTwoSheets();
ValueEval valueEval = eval.getEvalForCell(1, 0, 0);
- assertTrue(valueEval instanceof BlankEval,
- "Had: " + valueEval);
+ assertInstanceOf(BlankEval.class, valueEval, "Had: " + valueEval);
}
@Test
diff --git
a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java
b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java
index 28eb3bf951..629b89c148 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestSumifs.java
@@ -302,7 +302,7 @@ final class TestSumifs {
};
ValueEval result = invokeSumifs(args);
- assertTrue(result instanceof ErrorEval, "Expect to have an error when
an input is an invalid value, but had: " + result.getClass());
+ assertInstanceOf(ErrorEval.class, result, "Expect to have an error
when an input is an invalid value, but had: " + result.getClass());
args = new ValueEval[]{
EvalFactory.createAreaEval("A2:A9", a2a9),
@@ -311,7 +311,7 @@ final class TestSumifs {
};
result = invokeSumifs(args);
- assertTrue(result instanceof ErrorEval, "Expect to have an error when
an input is an invalid value, but had: " + result.getClass());
+ assertInstanceOf(ErrorEval.class, result, "Expect to have an error
when an input is an invalid value, but had: " + result.getClass());
}
@Test
@@ -335,7 +335,7 @@ final class TestSumifs {
};
ValueEval result = invokeSumifs(args);
- assertTrue(result instanceof ErrorEval, "Expect to have an error when
an input is an invalid value, but had: " + result.getClass());
+ assertInstanceOf(ErrorEval.class, result, "Expect to have an error
when an input is an invalid value, but had: " + result.getClass());
assertEquals(ErrorEval.VALUE_INVALID, result);
}
@@ -360,7 +360,7 @@ final class TestSumifs {
};
ValueEval result = invokeSumifs(args);
- assertTrue(result instanceof ErrorEval, "Expect to have an error when
an input is an invalid value, but had: " + result.getClass());
+ assertInstanceOf(ErrorEval.class, result, "Expect to have an error
when an input is an invalid value, but had: " + result.getClass());
assertEquals(ErrorEval.NAME_INVALID, result);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]