aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java5
-rw-r--r--src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java2
-rw-r--r--src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java5
-rw-r--r--src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java3
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java5
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java4
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java3
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java3
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java66
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java4
-rw-r--r--src/testcases/org/apache/poi/ss/util/TestNumberComparer.java5
11 files changed, 55 insertions, 50 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java b/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java
index e2e8fc9e45..d71d955bbc 100644
--- a/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java
+++ b/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java
@@ -17,6 +17,7 @@
package org.apache.poi.ss.formula;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -150,12 +151,12 @@ public abstract class BaseTestExternalFunctions {
Cell cell2 = sh.getRow(2).getCell(1);
assertEquals("ISODD(2)", cell2.getCellFormula());
- assertEquals(false, evaluator.evaluate(cell2).getBooleanValue());
+ assertFalse(evaluator.evaluate(cell2).getBooleanValue());
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell2));
Cell cell3 = sh.getRow(3).getCell(1);
assertEquals("ISEVEN(2)", cell3.getCellFormula());
- assertEquals(true, evaluator.evaluate(cell3).getBooleanValue());
+ assertTrue(evaluator.evaluate(cell3).getBooleanValue());
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell3));
wb.close();
diff --git a/src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java b/src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java
index e40100d5b9..1abe548430 100644
--- a/src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java
+++ b/src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java
@@ -45,7 +45,7 @@ public class TestPlainCellCache extends TestCase {
Loc sameLoc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
assertEquals(loc.hashCode(), sameLoc.hashCode());
- assertTrue(loc.equals(sameLoc));
+ assertEquals(loc, sameLoc);
assertNull(cache.get(loc));
PlainValueCellCacheEntry entry = new PlainValueCellCacheEntry(new NumberEval(0));
diff --git a/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java b/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java
index 4c0223afd7..21fdce4bfd 100644
--- a/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java
+++ b/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java
@@ -18,6 +18,7 @@ package org.apache.poi.ss.formula.eval;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -66,7 +67,7 @@ public abstract class BaseTestCircularReferences {
* Makes sure that the specified evaluated cell value represents a circular reference error.
*/
private static void confirmCycleErrorCode(CellValue cellValue) {
- assertTrue(cellValue.getCellType() == CellType.ERROR);
+ assertSame(cellValue.getCellType(), CellType.ERROR);
assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cellValue.getErrorValue());
}
@@ -96,7 +97,7 @@ public abstract class BaseTestCircularReferences {
CellValue cellValue = evaluateWithCycles(wb, testCell);
- assertTrue(cellValue.getCellType() == CellType.NUMERIC);
+ assertSame(cellValue.getCellType(), CellType.NUMERIC);
assertEquals(2, cellValue.getNumberValue(), 0);
wb.close();
}
diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
index 565f756d08..db2a20c1e2 100644
--- a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
+++ b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.InputStream;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
@@ -111,7 +112,7 @@ public final class TestFormulaBugs {
cv = fe.evaluate(row.getCell(1));
assertEquals(CellType.BOOLEAN, cv.getCellType());
- assertEquals(true, cv.getBooleanValue());
+ assertTrue(cv.getBooleanValue());
wb.close();
}
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java b/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java
index 29d82c1e5b..5d142c8ec6 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java
@@ -18,6 +18,7 @@
package org.apache.poi.ss.formula.functions;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
@@ -51,12 +52,12 @@ public final class TestIsBlank {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
CellValue result = fe.evaluate(cell);
assertEquals(CellType.BOOLEAN, result.getCellType());
- assertEquals(true, result.getBooleanValue());
+ assertTrue(result.getBooleanValue());
cell.setCellFormula("isblank(D7:D7)");
result = fe.evaluate(cell);
assertEquals(CellType.BOOLEAN, result.getCellType());
- assertEquals(true, result.getBooleanValue());
+ assertTrue(result.getBooleanValue());
}
}
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java b/src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java
index a099b7ff44..a89a213091 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java
@@ -76,7 +76,7 @@ public final class TestTFunc {
private static void confirmError(ValueEval arg) {
ValueEval eval = invokeT(arg);
- assertSame(arg, eval);
+ assertSame(arg, eval);
}
@Test
@@ -119,7 +119,7 @@ public final class TestTFunc {
confirmString(eval, "");
eval = invokeTWithReference(ErrorEval.NAME_INVALID);
- assertSame(eval, ErrorEval.NAME_INVALID);
+ assertSame(eval, ErrorEval.NAME_INVALID);
}
@Test
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
index f19f1ac562..852c989009 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
@@ -169,8 +169,7 @@ public abstract class BaseTestCellComment {
assertNotNull("Cells in the second column have comments", sheet.getCellComment(new CellAddress(rownum, 1)));
assertEquals("Yegor Kozlov", comment.getAuthor());
- assertTrue("cells in the second column should have non-empty notes",
- !comment.getString().getString().isEmpty());
+ assertFalse(comment.getString().getString().isEmpty());
assertEquals(rownum, comment.getRow());
assertEquals(cell.getColumnIndex(), comment.getColumn());
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java
index 0b7aef693e..b0944ee27e 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestColumnShifting.java
@@ -23,6 +23,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.poi.ss.usermodel.helpers.ColumnShifter;
@@ -77,7 +78,7 @@ public abstract class BaseTestColumnShifting {
public void testShiftLeft() {
try {
columnShifter.shiftColumns(1, 2, -3);
- assertTrue("Shift to negative indices should throw exception", false);
+ fail("Shift to negative indices should throw exception");
}
catch(IllegalStateException e){
assertTrue(true);
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
index 6bdeccddf7..0399c964ed 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
@@ -610,7 +610,7 @@ public abstract class BaseTestConditionalFormatting {
assertEquals(ConditionType.CELL_VALUE_IS, cr.getConditionType());
assertEquals(ComparisonOperator.GT, cr.getComparisonOperation());
assertEquals("0", cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula2());
// When it matches:
// Sets the font colour to dark green
// Sets the background colour to lighter green
@@ -791,13 +791,13 @@ public abstract class BaseTestConditionalFormatting {
private void assertDataBar(ConditionalFormattingRule cr, String color) {
assertEquals(ConditionType.DATA_BAR, cr.getConditionType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
- assertEquals(null, cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula1());
+ assertNull(cr.getFormula2());
DataBarFormatting databar = cr.getDataBarFormatting();
assertNotNull(databar);
- assertEquals(false, databar.isIconOnly());
- assertEquals(true, databar.isLeftToRight());
+ assertFalse(databar.isIconOnly());
+ assertTrue(databar.isLeftToRight());
assertEquals(0, databar.getWidthMin());
assertEquals(100, databar.getWidthMax());
@@ -806,12 +806,12 @@ public abstract class BaseTestConditionalFormatting {
ConditionalFormattingThreshold th;
th = databar.getMinThreshold();
assertEquals(RangeType.MIN, th.getRangeType());
- assertEquals(null, th.getValue());
- assertEquals(null, th.getFormula());
+ assertNull(th.getValue());
+ assertNull(th.getFormula());
th = databar.getMaxThreshold();
assertEquals(RangeType.MAX, th.getRangeType());
- assertEquals(null, th.getValue());
- assertEquals(null, th.getFormula());
+ assertNull(th.getValue());
+ assertNull(th.getFormula());
}
private void assertIconSetPercentages(ConditionalFormatting cf, IconSet iconset, Double...vals) {
@@ -822,14 +822,14 @@ public abstract class BaseTestConditionalFormatting {
private void assertIconSetPercentages(ConditionalFormattingRule cr, IconSet iconset, Double...vals) {
assertEquals(ConditionType.ICON_SET, cr.getConditionType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
- assertEquals(null, cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula1());
+ assertNull(cr.getFormula2());
IconMultiStateFormatting icon = cr.getMultiStateFormatting();
assertNotNull(icon);
assertEquals(iconset, icon.getIconSet());
- assertEquals(false, icon.isIconOnly());
- assertEquals(false, icon.isReversed());
+ assertFalse(icon.isIconOnly());
+ assertFalse(icon.isReversed());
assertNotNull(icon.getThresholds());
assertEquals(vals.length, icon.getThresholds().length);
@@ -838,7 +838,7 @@ public abstract class BaseTestConditionalFormatting {
ConditionalFormattingThreshold th = icon.getThresholds()[i];
assertEquals(RangeType.PERCENT, th.getRangeType());
assertEquals(v, th.getValue());
- assertEquals(null, th.getFormula());
+ assertNull(th.getFormula());
}
}
@@ -850,8 +850,8 @@ public abstract class BaseTestConditionalFormatting {
private void assertColorScale(ConditionalFormattingRule cr, String... colors) {
assertEquals(ConditionType.COLOR_SCALE, cr.getConditionType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
- assertEquals(null, cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula1());
+ assertNull(cr.getFormula2());
ColorScaleFormatting color = cr.getColorScaleFormatting();
assertNotNull(color);
@@ -873,7 +873,7 @@ public abstract class BaseTestConditionalFormatting {
assertEquals(RangeType.PERCENTILE, th.getRangeType());
assertEquals(steps*i, th.getValue().intValue());
}
- assertEquals(null, th.getFormula());
+ assertNull(th.getFormula());
}
// Colors should match
@@ -1107,8 +1107,8 @@ public abstract class BaseTestConditionalFormatting {
assertEquals(IconSet.GYRB_4_TRAFFIC_LIGHTS, iconFmt.getIconSet());
assertEquals(4, iconFmt.getThresholds().length);
- assertEquals(false, iconFmt.isIconOnly());
- assertEquals(false, iconFmt.isReversed());
+ assertFalse(iconFmt.isIconOnly());
+ assertFalse(iconFmt.isReversed());
iconFmt.setIconOnly(true);
iconFmt.getThresholds()[0].setRangeType(RangeType.MIN);
@@ -1136,17 +1136,17 @@ public abstract class BaseTestConditionalFormatting {
assertEquals(IconSet.GYRB_4_TRAFFIC_LIGHTS, iconFmt.getIconSet());
assertEquals(4, iconFmt.getThresholds().length);
- assertEquals(true, iconFmt.isIconOnly());
- assertEquals(false, iconFmt.isReversed());
+ assertTrue(iconFmt.isIconOnly());
+ assertFalse(iconFmt.isReversed());
assertEquals(RangeType.MIN, iconFmt.getThresholds()[0].getRangeType());
assertEquals(RangeType.NUMBER, iconFmt.getThresholds()[1].getRangeType());
assertEquals(RangeType.PERCENT,iconFmt.getThresholds()[2].getRangeType());
assertEquals(RangeType.MAX, iconFmt.getThresholds()[3].getRangeType());
- assertEquals(null, iconFmt.getThresholds()[0].getValue());
+ assertNull(iconFmt.getThresholds()[0].getValue());
assertEquals(10d, iconFmt.getThresholds()[1].getValue(), 0);
assertEquals(75d, iconFmt.getThresholds()[2].getValue(), 0);
- assertEquals(null, iconFmt.getThresholds()[3].getValue());
+ assertNull(iconFmt.getThresholds()[3].getValue());
wb2.close();
}
@@ -1193,9 +1193,9 @@ public abstract class BaseTestConditionalFormatting {
assertEquals(RangeType.MIN, clrFmt.getThresholds()[0].getRangeType());
assertEquals(RangeType.NUMBER, clrFmt.getThresholds()[1].getRangeType());
assertEquals(RangeType.MAX, clrFmt.getThresholds()[2].getRangeType());
- assertEquals(null, clrFmt.getThresholds()[0].getValue());
+ assertNull(clrFmt.getThresholds()[0].getValue());
assertEquals(10d, clrFmt.getThresholds()[1].getValue(), 0);
- assertEquals(null, clrFmt.getThresholds()[2].getValue());
+ assertNull(clrFmt.getThresholds()[2].getValue());
wb2.close();
}
@@ -1212,9 +1212,9 @@ public abstract class BaseTestConditionalFormatting {
ConditionalFormattingRule rule1 =
sheetCF.createConditionalFormattingRule(color);
DataBarFormatting dbFmt = rule1.getDataBarFormatting();
-
- assertEquals(false, dbFmt.isIconOnly());
- assertEquals(true, dbFmt.isLeftToRight());
+
+ assertFalse(dbFmt.isIconOnly());
+ assertTrue(dbFmt.isLeftToRight());
assertEquals(0, dbFmt.getWidthMin());
assertEquals(100, dbFmt.getWidthMax());
assertColour(colorHex, dbFmt.getColor());
@@ -1237,17 +1237,17 @@ public abstract class BaseTestConditionalFormatting {
rule1 = cf.getRule(0);
dbFmt = rule1.getDataBarFormatting();
assertEquals(ConditionType.DATA_BAR, rule1.getConditionType());
-
- assertEquals(false, dbFmt.isIconOnly());
- assertEquals(true, dbFmt.isLeftToRight());
+
+ assertFalse(dbFmt.isIconOnly());
+ assertTrue(dbFmt.isLeftToRight());
assertEquals(0, dbFmt.getWidthMin());
assertEquals(100, dbFmt.getWidthMax());
assertColour(colorHex, dbFmt.getColor());
assertEquals(RangeType.MIN, dbFmt.getMinThreshold().getRangeType());
assertEquals(RangeType.MAX, dbFmt.getMaxThreshold().getRangeType());
- assertEquals(null, dbFmt.getMinThreshold().getValue());
- assertEquals(null, dbFmt.getMaxThreshold().getValue());
+ assertNull(dbFmt.getMinThreshold().getValue());
+ assertNull(dbFmt.getMaxThreshold().getValue());
wb2.close();
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java
index bd8c74032b..89594af0f9 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestFont.java
@@ -140,7 +140,7 @@ public abstract class BaseTestFont {
assertNotNull(wb3.getFontAt(font2Idx));
assertEquals(15, wb3.getFontAt(font2Idx).getFontHeightInPoints());
- assertEquals(true, wb3.getFontAt(font2Idx).getItalic());
+ assertTrue(wb3.getFontAt(font2Idx).getItalic());
wb3.close();
}
@@ -195,7 +195,7 @@ public abstract class BaseTestFont {
assertEquals(nf, wb.getFontAt(nfIdx));
assertEquals(wb.getFontAt(nfIdx), wb.getFontAt(nfIdx));
- assertTrue(wb.getFontAt(0) != wb.getFontAt(nfIdx));
+ assertNotSame(wb.getFontAt(0), wb.getFontAt(nfIdx));
// Find it now
assertNotNull(
diff --git a/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java b/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java
index b48ebee5a7..206194fccc 100644
--- a/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java
+++ b/src/testcases/org/apache/poi/ss/util/TestNumberComparer.java
@@ -19,6 +19,7 @@ package org.apache.poi.ss.util;
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 org.apache.poi.ss.util.NumberComparisonExamples.ComparisonExample;
@@ -74,7 +75,7 @@ public final class TestNumberComparer {
double a = 0.06-0.01;
double b = 0.05;
//noinspection ConstantConditions
- assertFalse(a == b);
+ assertNotEquals(a, b, 0.0);
assertEquals(0, NumberComparer.compare(a, b));
}
@@ -86,7 +87,7 @@ public final class TestNumberComparer {
double a = 1+1.0028-0.9973;
double b = 1.0055;
//noinspection ConstantConditions
- assertFalse(a == b);
+ assertNotEquals(a, b, 0.0);
assertEquals(0, NumberComparer.compare(a, b));
}