diff options
author | Dominik Stadler <centic@apache.org> | 2019-12-15 14:53:46 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2019-12-15 14:53:46 +0000 |
commit | 5e394a5e10bc986f4caa2d4f29d4ffa088581cbf (patch) | |
tree | 0a5b70fe699af700697c31e3daeff022a24e27bb /src | |
parent | 1a5cec89d8d36f2a7cd5643b221befd57fa515b7 (diff) | |
download | poi-5e394a5e10bc986f4caa2d4f29d4ffa088581cbf.tar.gz poi-5e394a5e10bc986f4caa2d4f29d4ffa088581cbf.zip |
Let IntelliJ simplify some assertions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871591 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
107 files changed, 620 insertions, 608 deletions
diff --git a/src/java/org/apache/poi/ss/format/CellNumberFormatter.java b/src/java/org/apache/poi/ss/format/CellNumberFormatter.java index 7a3070a542..a7e7666758 100644 --- a/src/java/org/apache/poi/ss/format/CellNumberFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellNumberFormatter.java @@ -232,7 +232,7 @@ public class CellNumberFormatter extends CellFormatter { integerSpecials.addAll(specials.subList(0, integerEnd())); if (exponent == null) { - StringBuffer fmtBuf = new StringBuffer("%"); + StringBuilder fmtBuf = new StringBuilder("%"); int integerPartWidth = calculateIntegerPartWidth(); int totalWidth = integerPartWidth + fractionPartWidth; @@ -789,12 +789,11 @@ public class CellNumberFormatter extends CellFormatter { digit++; --pos; } - StringBuffer extraLeadingDigits = new StringBuffer(); if (pos >= 0) { // We ran out of places to put digits before we ran out of digits; put this aside so we can add it later // pos was decremented at the end of the loop above when the iterator was at its end ++pos; - extraLeadingDigits = new StringBuffer(result.substring(0, pos)); + StringBuffer extraLeadingDigits = new StringBuffer(result.substring(0, pos)); if (showGroupingSeparator) { while (pos > 0) { if (digit > 0 && digit % 3 == 0) { diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java index 9e1f00ead6..08081e711b 100644 --- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java +++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java @@ -85,9 +85,8 @@ public class TestPackagingURIHelper extends TestCase { // Relative part name PackagePartName relativeName = PackagingURIHelper.createPartName( "media/image1.gif", partBase); - assertTrue("The part name must be equal to " - + partNameToValid.getName(), partNameToValid - .equals(relativeName)); + assertEquals("The part name must be equal to " + + partNameToValid.getName(), partNameToValid, relativeName); pkg.revert(); } @@ -106,9 +105,8 @@ public class TestPackagingURIHelper extends TestCase { // Relative part name PackagePartName relativeName = PackagingURIHelper.createPartName( new URI("media/image1.gif"), partBase); - assertTrue("The part name must be equal to " - + partNameToValid.getName(), partNameToValid - .equals(relativeName)); + assertEquals("The part name must be equal to " + + partNameToValid.getName(), partNameToValid, relativeName); pkg.revert(); } diff --git a/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java b/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java index 47d71ff613..2b517448d6 100644 --- a/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java +++ b/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java @@ -31,11 +31,11 @@ public class CombinedIteratorTest { Iterator<String> iter = iterable.iterator(); for (String element : expected) { - Assert.assertEquals(true, iter.hasNext()); + Assert.assertTrue(iter.hasNext()); Assert.assertEquals(element, iter.next()); } - Assert.assertEquals(false, iter.hasNext()); + Assert.assertFalse(iter.hasNext()); } @Test diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java index 7e7d708ced..9c83ae9253 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java @@ -265,13 +265,13 @@ public class TestXSLFAutoShape { assertFalse(rPr.isSetB()); r.setBold(true); assertTrue(r.isBold()); - assertEquals(true, rPr.getB()); + assertTrue(rPr.getB()); assertFalse(r.isItalic()); assertFalse(rPr.isSetI()); r.setItalic(true); assertTrue(r.isItalic()); - assertEquals(true, rPr.getI()); + assertTrue(rPr.getI()); assertFalse(r.isUnderlined()); assertFalse(rPr.isSetU()); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java index 412520aede..493a0b89df 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java @@ -21,6 +21,8 @@ package org.apache.poi.xslf.usermodel; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -188,7 +190,7 @@ public class TestXSLFChart { XDDFChartData firstSeries = data.get(0); assertNotNull(firstSeries); if (firstSeries instanceof XDDFScatterChartData) { - assertEquals(null, firstSeries.getCategoryAxis()); + assertNull(firstSeries.getCategoryAxis()); assertEquals(2, firstSeries.getValueAxes().size()); checkAxisOperations(firstSeries.getValueAxes().get(0)); checkAxisOperations(firstSeries.getValueAxes().get(1)); @@ -219,10 +221,10 @@ public class TestXSLFChart { * According to interface, 0.0 should be returned for * uninitialized double properties. */ - assertTrue(layout.getX() == 0.0); - assertTrue(layout.getY() == 0.0); - assertTrue(layout.getWidthRatio() == 0.0); - assertTrue(layout.getHeightRatio() == 0.0); + assertEquals(0.0, layout.getX(), 0.0); + assertEquals(0.0, layout.getY(), 0.0); + assertEquals(0.0, layout.getWidthRatio(), 0.0); + assertEquals(0.0, layout.getHeightRatio(), 0.0); final double newRatio = 1.1; final double newCoordinate = 0.3; @@ -230,31 +232,31 @@ public class TestXSLFChart { final LayoutTarget nonDefaultTarget = LayoutTarget.OUTER; layout.setWidthRatio(newRatio); - assertTrue(layout.getWidthRatio() == newRatio); + assertEquals(layout.getWidthRatio(), newRatio, 0.0); layout.setHeightRatio(newRatio); - assertTrue(layout.getHeightRatio() == newRatio); + assertEquals(layout.getHeightRatio(), newRatio, 0.0); layout.setX(newCoordinate); - assertTrue(layout.getX() == newCoordinate); + assertEquals(layout.getX(), newCoordinate, 0.0); layout.setY(newCoordinate); - assertTrue(layout.getY() == newCoordinate); + assertEquals(layout.getY(), newCoordinate, 0.0); layout.setXMode(nonDefaultMode); - assertTrue(layout.getXMode() == nonDefaultMode); + assertSame(layout.getXMode(), nonDefaultMode); layout.setYMode(nonDefaultMode); - assertTrue(layout.getYMode() == nonDefaultMode); + assertSame(layout.getYMode(), nonDefaultMode); layout.setWidthMode(nonDefaultMode); - assertTrue(layout.getWidthMode() == nonDefaultMode); + assertSame(layout.getWidthMode(), nonDefaultMode); layout.setHeightMode(nonDefaultMode); - assertTrue(layout.getHeightMode() == nonDefaultMode); + assertSame(layout.getHeightMode(), nonDefaultMode); layout.setTarget(nonDefaultTarget); - assertTrue(layout.getTarget() == nonDefaultTarget); + assertSame(layout.getTarget(), nonDefaultTarget); } private void checkAxisOperations(XDDFValueAxis axis) { diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java index c80fafef18..315a8f561c 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java @@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -177,8 +178,7 @@ public class TestXSLFPictureShape { XSLFTextBox tb1 = group.createTextBox(); XSLFTextBox tb2 = group.createTextBox(); - assertFalse("We should have different names now, but had: " + tb1.getShapeName() + " for both", - tb1.getShapeName().equals(tb2.getShapeName())); + assertNotEquals("We should have different names now, but had: " + tb1.getShapeName() + " for both", tb1.getShapeName(), tb2.getShapeName()); XMLSlideShow pptCopy = new XMLSlideShow(); @@ -216,8 +216,7 @@ public class TestXSLFPictureShape { } private void differentShapeName(XSLFShape shape1, XSLFShape shape2) { - assertFalse("We should have different names now, but had: " + shape1.getShapeName() + " for both", - shape1.getShapeName().equals(shape2.getShapeName())); + assertNotEquals("We should have different names now, but had: " + shape1.getShapeName() + " for both", shape1.getShapeName(), shape2.getShapeName()); } @Test diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java index ba26fb8e95..2cb7c412ce 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java @@ -283,7 +283,7 @@ public class TestXSLFTextParagraph { p.setBulletFont("Calibri"); assertEquals("Calibri", p.getBulletFont()); - assertEquals(null, p.getBulletFontColor()); + assertNull(p.getBulletFontColor()); p.setBulletFontColor(Color.red); assertTrue(sameColor(Color.red, p.getBulletFontColor())); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java index e93239d940..6ba55c0692 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java @@ -75,14 +75,14 @@ public class TestXSSFImportFromXML { XSSFSheet sheet = wb.getSheetAt(0); XSSFRow row = sheet.getRow(0); - assertTrue(row.getCell(0).getStringCellValue().equals(name)); - assertTrue(row.getCell(1).getStringCellValue().equals(teacher)); - assertTrue(row.getCell(2).getStringCellValue().equals(tutor)); - assertTrue(row.getCell(3).getStringCellValue().equals(cdl)); - assertTrue(row.getCell(4).getStringCellValue().equals(duration)); - assertTrue(row.getCell(5).getStringCellValue().equals(topic)); - assertTrue(row.getCell(6).getStringCellValue().equals(project)); - assertTrue(row.getCell(7).getStringCellValue().equals(credits)); + assertEquals(row.getCell(0).getStringCellValue(), name); + assertEquals(row.getCell(1).getStringCellValue(), teacher); + assertEquals(row.getCell(2).getStringCellValue(), tutor); + assertEquals(row.getCell(3).getStringCellValue(), cdl); + assertEquals(row.getCell(4).getStringCellValue(), duration); + assertEquals(row.getCell(5).getStringCellValue(), topic); + assertEquals(row.getCell(6).getStringCellValue(), project); + assertEquals(row.getCell(7).getStringCellValue(), credits); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java index fb83269f4a..dcb793cf9f 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java @@ -101,7 +101,7 @@ public abstract class BaseTestXSSFPivotTable { pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnIndex); CTPivotTableDefinition defintion = pivotTable.getCTPivotTableDefinition(); - assertEquals(defintion.getColFields(), null); + assertNull(defintion.getColFields()); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java index abd769aed7..8d068ca678 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java @@ -18,6 +18,7 @@ package org.apache.poi.xssf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -129,17 +130,17 @@ public class TestXSSFColGrouping { assertEquals(0, cols.getColArray(0).getOutlineLevel()); assertEquals(2, cols.getColArray(0).getMin()); // 1 based assertEquals(2, cols.getColArray(0).getMax()); // 1 based - assertEquals(true, cols.getColArray(0).getCustomWidth()); + assertTrue(cols.getColArray(0).getCustomWidth()); assertEquals(1, cols.getColArray(1).getOutlineLevel()); assertEquals(3, cols.getColArray(1).getMin()); // 1 based assertEquals(4, cols.getColArray(1).getMax()); // 1 based - assertEquals(true, cols.getColArray(1).getCustomWidth()); + assertTrue(cols.getColArray(1).getCustomWidth()); assertEquals(0, cols.getColArray(2).getOutlineLevel()); assertEquals(5, cols.getColArray(2).getMin()); // 1 based assertEquals(5, cols.getColArray(2).getMax()); // 1 based - assertEquals(true, cols.getColArray(2).getCustomWidth()); + assertTrue(cols.getColArray(2).getCustomWidth()); assertEquals(3, cols.sizeOfColArray()); @@ -177,17 +178,17 @@ public class TestXSSFColGrouping { assertEquals(1, cols.getColArray(0).getOutlineLevel()); assertEquals(2, cols.getColArray(0).getMin()); // 1 based assertEquals(2, cols.getColArray(0).getMax()); // 1 based - assertEquals(false, cols.getColArray(0).getCustomWidth()); + assertFalse(cols.getColArray(0).getCustomWidth()); assertEquals(1, cols.getColArray(1).getOutlineLevel()); assertEquals(3, cols.getColArray(1).getMin()); // 1 based assertEquals(5, cols.getColArray(1).getMax()); // 1 based - assertEquals(true, cols.getColArray(1).getCustomWidth()); + assertTrue(cols.getColArray(1).getCustomWidth()); assertEquals(1, cols.getColArray(2).getOutlineLevel()); assertEquals(6, cols.getColArray(2).getMin()); // 1 based assertEquals(6, cols.getColArray(2).getMax()); // 1 based - assertEquals(false, cols.getColArray(2).getCustomWidth()); + assertFalse(cols.getColArray(2).getCustomWidth()); assertEquals(3, cols.sizeOfColArray()); @@ -225,17 +226,17 @@ public class TestXSSFColGrouping { assertEquals(0, cols.getColArray(0).getOutlineLevel()); assertEquals(3, cols.getColArray(0).getMin()); // 1 based assertEquals(3, cols.getColArray(0).getMax()); // 1 based - assertEquals(true, cols.getColArray(0).getCustomWidth()); + assertTrue(cols.getColArray(0).getCustomWidth()); assertEquals(1, cols.getColArray(1).getOutlineLevel()); assertEquals(4, cols.getColArray(1).getMin()); // 1 based assertEquals(5, cols.getColArray(1).getMax()); // 1 based - assertEquals(true, cols.getColArray(1).getCustomWidth()); + assertTrue(cols.getColArray(1).getCustomWidth()); assertEquals(1, cols.getColArray(2).getOutlineLevel()); assertEquals(6, cols.getColArray(2).getMin()); // 1 based assertEquals(6, cols.getColArray(2).getMax()); // 1 based - assertEquals(false, cols.getColArray(2).getCustomWidth()); + assertFalse(cols.getColArray(2).getCustomWidth()); assertEquals(3, cols.sizeOfColArray()); @@ -274,17 +275,17 @@ public class TestXSSFColGrouping { assertEquals(1, cols.getColArray(0).getOutlineLevel()); assertEquals(2, cols.getColArray(0).getMin()); // 1 based assertEquals(2, cols.getColArray(0).getMax()); // 1 based - assertEquals(false, cols.getColArray(0).getCustomWidth()); + assertFalse(cols.getColArray(0).getCustomWidth()); assertEquals(1, cols.getColArray(1).getOutlineLevel()); assertEquals(3, cols.getColArray(1).getMin()); // 1 based assertEquals(4, cols.getColArray(1).getMax()); // 1 based - assertEquals(true, cols.getColArray(1).getCustomWidth()); + assertTrue(cols.getColArray(1).getCustomWidth()); assertEquals(0, cols.getColArray(2).getOutlineLevel()); assertEquals(5, cols.getColArray(2).getMin()); // 1 based assertEquals(5, cols.getColArray(2).getMax()); // 1 based - assertEquals(true, cols.getColArray(2).getCustomWidth()); + assertTrue(cols.getColArray(2).getCustomWidth()); assertEquals(3, cols.sizeOfColArray()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java index d8d7554d47..c11879b71b 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java @@ -19,9 +19,11 @@ package org.apache.poi.xssf.usermodel; import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_SPREADSHEETML; 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.Assert.fail; import java.io.FileOutputStream; @@ -77,11 +79,11 @@ public final class TestXSSFComment extends BaseTestCellComment { CTShape vmlShape = CTShape.Factory.newInstance(); XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape); - assertEquals(null, comment.getString()); + assertNull(comment.getString()); assertEquals(0, comment.getRow()); assertEquals(0, comment.getColumn()); assertEquals("", comment.getAuthor()); - assertEquals(false, comment.isVisible()); + assertFalse(comment.isVisible()); } @Test @@ -168,7 +170,7 @@ public final class TestXSSFComment extends BaseTestCellComment { assertSame(comment.getString(), richText); //check that the rich text is set in the comment CTRPrElt rPr = richText.getCTRst().getRArray(0).getRPr(); - assertEquals(true, rPr.getIArray(0).getVal()); + assertTrue(rPr.getIArray(0).getVal()); assertEquals(8.5, rPr.getSzArray(0).getVal(), 0); assertEquals(IndexedColors.BLUE_GREY.getIndex(), rPr.getColorArray(0).getIndexed()); assertEquals("Tahoma", rPr.getRFontArray(0).getVal()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java index 0394f6fdd2..8a6e791b45 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java @@ -17,6 +17,8 @@ package org.apache.poi.xssf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.math.BigDecimal; @@ -323,7 +325,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation { sheet.addValidationData(validation); final List<XSSFDataValidation> dataValidations = sheet.getDataValidations(); - assertEquals(true, dataValidations.get(0).getCtDdataValidation().getAllowBlank()); + assertTrue(dataValidations.get(0).getCtDdataValidation().getAllowBlank()); } } @@ -338,7 +340,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation { sheet.addValidationData(validation); final List<XSSFDataValidation> dataValidations = sheet.getDataValidations(); - assertEquals(false, dataValidations.get(0).getCtDdataValidation().getAllowBlank()); + assertFalse(dataValidations.get(0).getCtDdataValidation().getAllowBlank()); } } @@ -353,7 +355,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation { sheet.addValidationData(validation); final List<XSSFDataValidation> dataValidations = sheet.getDataValidations(); - assertEquals(true, dataValidations.get(0).getCtDdataValidation().getAllowBlank()); + assertTrue(dataValidations.get(0).getCtDdataValidation().getAllowBlank()); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java index 714202e599..aacd1c18db 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java @@ -210,7 +210,7 @@ public class TestXSSFDrawing { XSSFShape sh1 = shapes1.get(i); XSSFShape sh2 = shapes2.get(i); - assertTrue(sh1.getClass() == sh2.getClass()); + assertSame(sh1.getClass(), sh2.getClass()); assertEquals(sh1.getShapeProperties().toString(), sh2.getShapeProperties().toString()); } @@ -246,8 +246,8 @@ public class TestXSSFDrawing { assertEquals(1, pr.sizeOfRArray()); CTTextCharacterProperties rPr = pr.getRArray(0).getRPr(); - assertEquals(true, rPr.getB()); - assertEquals(true, rPr.getI()); + assertTrue(rPr.getB()); + assertTrue(rPr.getI()); assertEquals(STTextUnderlineType.SNG, rPr.getU()); assertArrayEquals( new byte[]{0, (byte)128, (byte)128} , diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java index f55621ccbd..7186034e4b 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java @@ -72,12 +72,12 @@ public final class TestXSSFFont extends BaseTestFont{ bool.setVal(false); ctFont.setBArray(0,bool); XSSFFont xssfFont=new XSSFFont(ctFont); - assertEquals(false, xssfFont.getBold()); + assertFalse(xssfFont.getBold()); xssfFont.setBold(true); assertEquals(ctFont.sizeOfBArray(),1); - assertEquals(true, ctFont.getBArray(0).getVal()); + assertTrue(ctFont.getBArray(0).getVal()); } @SuppressWarnings("deprecation") @@ -105,7 +105,7 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(FontCharset.ARABIC.getValue(), xssfFont.getCharSet()); // This one isn't allowed - assertEquals(null, FontCharset.valueOf(9999)); + assertNull(FontCharset.valueOf(9999)); try { xssfFont.setCharSet(9999); fail("Shouldn't be able to set an invalid charset"); @@ -153,12 +153,12 @@ public final class TestXSSFFont extends BaseTestFont{ ctFont.setIArray(0,bool); XSSFFont xssfFont=new XSSFFont(ctFont); - assertEquals(false, xssfFont.getItalic()); + assertFalse(xssfFont.getItalic()); xssfFont.setItalic(true); assertEquals(ctFont.sizeOfIArray(),1); - assertEquals(true, ctFont.getIArray(0).getVal()); - assertEquals(true,ctFont.getIArray(0).getVal()); + assertTrue(ctFont.getIArray(0).getVal()); + assertTrue(ctFont.getIArray(0).getVal()); } @Test @@ -169,12 +169,12 @@ public final class TestXSSFFont extends BaseTestFont{ ctFont.setStrikeArray(0,bool); XSSFFont xssfFont=new XSSFFont(ctFont); - assertEquals(false, xssfFont.getStrikeout()); + assertFalse(xssfFont.getStrikeout()); xssfFont.setStrikeout(true); assertEquals(ctFont.sizeOfStrikeArray(),1); - assertEquals(true, ctFont.getStrikeArray(0).getVal()); - assertEquals(true,ctFont.getStrikeArray(0).getVal()); + assertTrue(ctFont.getStrikeArray(0).getVal()); + assertTrue(ctFont.getStrikeArray(0).getVal()); } @Test @@ -399,11 +399,7 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(2, wb.getNumberOfFonts()); assertEquals(nf, wb.getFontAt(1)); - assertTrue( - wb.getFontAt(0) - != - wb.getFontAt(1) - ); + assertNotSame(wb.getFontAt(0), wb.getFontAt(1)); // Find it now assertNotNull( diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java index edaa974a2c..885b3d55c7 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java @@ -75,7 +75,7 @@ public final class TestXSSFPicture extends BaseTestPicture { assertEquals(AnchorType.DONT_MOVE_AND_RESIZE, anchor.getAnchorType()); XSSFPicture shape = drawing.createPicture(anchor, jpegIdx); - assertTrue(anchor.equals(shape.getAnchor())); + assertEquals(anchor, shape.getAnchor()); assertNotNull(shape.getPictureData()); assertArrayEquals(jpegData, shape.getPictureData().getData()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index 67da55b3a5..a6e5ec4e2d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -48,6 +48,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackagePartName; +import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.openxml4j.opc.PackageRelationshipCollection; import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.internal.FileHelper; @@ -802,7 +803,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { } try (XSSFWorkbook wb2 = (XSSFWorkbook) WorkbookFactory.create(file)) { - assertTrue(wb2.getPivotTables().size() == 1); + assertEquals(1, wb2.getPivotTables().size()); } assertTrue(file.delete()); @@ -822,7 +823,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { try (XSSFWorkbook wb2 = (XSSFWorkbook) WorkbookFactory.create(file)) { setPivotData(wb2); - assertTrue(wb2.getPivotTables().size() == 2); + assertEquals(2, wb2.getPivotTables().size()); } assertTrue(file.delete()); @@ -890,7 +891,9 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { assertTrue(wbPart.hasRelationships()); final PackageRelationshipCollection relationships = wbPart.getRelationships().getRelationships(XSSFRelation.VBA_MACROS.getRelation()); assertEquals(1, relationships.size()); - assertEquals(XSSFRelation.VBA_MACROS.getDefaultFileName(), relationships.getRelationship(0).getTargetURI().toString()); + PackageRelationship relationship = relationships.getRelationship(0); + assertNotNull(relationship); + assertEquals(XSSFRelation.VBA_MACROS.getDefaultFileName(), relationship.getTargetURI().toString()); PackagePart vbaPart = pkg.getPart(PackagingURIHelper.createPartName(XSSFRelation.VBA_MACROS.getDefaultFileName())); assertNotNull(vbaPart); assertFalse(vbaPart.isRelationshipPart()); @@ -984,6 +987,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { wb.close(); } + @SuppressWarnings("deprecation") @Test public void testBug56957CloseWorkbook() throws Exception { File file = TempFile.createTempFile("TestBug56957_", ".xlsx"); @@ -1027,7 +1031,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { } @Test - public void closeDoesNotModifyWorkbook() throws IOException, InvalidFormatException { + public void closeDoesNotModifyWorkbook() throws IOException { final String filename = "SampleSS.xlsx"; final File file = POIDataSamples.getSpreadSheetInstance().getFile(filename); Workbook wb; @@ -1146,7 +1150,6 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { /** * See bug #61700 - * @throws Exception */ @Test public void testWorkbookForceFormulaRecalculation() throws Exception { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java index f85f44d22a..d0388175e1 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java @@ -19,6 +19,7 @@ package org.apache.poi.xssf.usermodel.charts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -139,7 +140,7 @@ public class TestXSSFChartTitle { XSSFRichTextString originalTitle = chart.getTitleText(); assertNotNull(originalTitle); final String myTitle = "My chart title"; - assertFalse(myTitle.equals(originalTitle.toString())); + assertNotEquals(myTitle, originalTitle.toString()); chart.setTitleText(myTitle); XSSFRichTextString queryTitle = chart.getTitleText(); assertNotNull(queryTitle); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java index 85ac30f30f..6cfe2f14a0 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java @@ -17,7 +17,9 @@ package org.apache.poi.xssf.usermodel.charts; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -68,31 +70,31 @@ public final class TestXSSFManualLayout { final LayoutTarget nonDefaultTarget = LayoutTarget.OUTER; layout.setWidthRatio(newRatio); - assertTrue(layout.getWidthRatio() == newRatio); + assertEquals(layout.getWidthRatio(), newRatio, 0.0); layout.setHeightRatio(newRatio); - assertTrue(layout.getHeightRatio() == newRatio); + assertEquals(layout.getHeightRatio(), newRatio, 0.0); layout.setX(newCoordinate); - assertTrue(layout.getX() == newCoordinate); + assertEquals(layout.getX(), newCoordinate, 0.0); layout.setY(newCoordinate); - assertTrue(layout.getY() == newCoordinate); + assertEquals(layout.getY(), newCoordinate, 0.0); layout.setXMode(nonDefaultMode); - assertTrue(layout.getXMode() == nonDefaultMode); + assertSame(layout.getXMode(), nonDefaultMode); layout.setYMode(nonDefaultMode); - assertTrue(layout.getYMode() == nonDefaultMode); + assertSame(layout.getYMode(), nonDefaultMode); layout.setWidthMode(nonDefaultMode); - assertTrue(layout.getWidthMode() == nonDefaultMode); + assertSame(layout.getWidthMode(), nonDefaultMode); layout.setHeightMode(nonDefaultMode); - assertTrue(layout.getHeightMode() == nonDefaultMode); + assertSame(layout.getHeightMode(), nonDefaultMode); layout.setTarget(nonDefaultTarget); - assertTrue(layout.getTarget() == nonDefaultTarget); + assertSame(layout.getTarget(), nonDefaultTarget); } @@ -111,9 +113,9 @@ public final class TestXSSFManualLayout { * According to interface, 0.0 should be returned for * uninitialized double properties. */ - assertTrue(layout.getX() == 0.0); - assertTrue(layout.getY() == 0.0); - assertTrue(layout.getWidthRatio() == 0.0); - assertTrue(layout.getHeightRatio() == 0.0); + assertEquals(0.0, layout.getX(), 0.0); + assertEquals(0.0, layout.getY(), 0.0); + assertEquals(0.0, layout.getWidthRatio(), 0.0); + assertEquals(0.0, layout.getHeightRatio(), 0.0); } } diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java index 0bc0fed736..addfbcb6a9 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java @@ -94,7 +94,7 @@ public class TestXWPFEndnote { XWPFRun r2 = testP2.getRuns().get(0); assertNotNull("Expected a run in testP2", r2); - assertTrue("Found an endnote reference in testP2", r2.getCTR().getEndnoteRefList().size() == 0); + assertEquals("Found an endnote reference in testP2", 0, r2.getCTR().getEndnoteRefList().size()); } diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java index b875644cb5..143a3ad2ad 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java @@ -94,7 +94,7 @@ public class TestXWPFFootnote { XWPFRun r2 = testP2.getRuns().get(0); assertNotNull("Expected a run in testP2", r2); - assertTrue("Found a footnote reference in testP2", r2.getCTR().getFootnoteRefList().size() == 0); + assertEquals("Found a footnote reference in testP2", 0, r2.getCTR().getFootnoteRefList().size()); } diff --git a/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java b/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java index 1bf0fa117b..903742c6c8 100644 --- a/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java +++ b/src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java @@ -236,8 +236,8 @@ public final class TestHMEFMessage { if (attr.getProperty().id == 0xe28) hasE28 = true; if (attr.getProperty().id == 0xe29) hasE29 = true; } - assertEquals(true, hasE28); - assertEquals(true, hasE29); + assertTrue(hasE28); + assertTrue(hasE29); // Ensure we can fetch those as custom ones MAPIProperty propE28 = MAPIProperty.createCustom(0xe28, Types.ASCII_STRING, "Custom E28"); diff --git a/src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java b/src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java index ff290d711d..acb5a740f7 100644 --- a/src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java +++ b/src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java @@ -17,6 +17,7 @@ package org.apache.poi.hpbf; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -52,7 +53,7 @@ public final class TestHPBFDocument { assertTrue(doc.getMainContents().getData().length > 0); assertTrue(doc.getQuillContents().getData().length > 0); assertTrue(doc.getEscherStm().getData().length > 0); - assertTrue(doc.getEscherDelayStm().getData().length == 0); + assertEquals(0, doc.getEscherDelayStm().getData().length); doc.close(); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java index 66795b5f1a..f51930ed54 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java @@ -83,9 +83,9 @@ public final class TestHeadersFooters //the first slide uses per-slide headers / footers HeadersFooters hd2 = slide.get(1).getHeadersFooters(); - assertEquals(true, hd2.isFooterVisible()); + assertTrue(hd2.isFooterVisible()); assertEquals("per-slide footer", hd2.getFooterText()); - assertEquals(true, hd2.isUserDateVisible()); + assertTrue(hd2.isUserDateVisible()); assertEquals("custom date format", hd2.getDateTimeText()); ppt.close(); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java index 40f4cd787f..82ec7bec51 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java @@ -60,10 +60,10 @@ public final class TestDocumentAtom extends TestCase { } public void testBooleans() { DocumentAtom da = new DocumentAtom(data_a, 0, data_a.length); - assertEquals(false, da.getSaveWithFonts()); - assertEquals(false, da.getOmitTitlePlace()); - assertEquals(false, da.getRightToLeft()); - assertEquals(true, da.getShowComments()); + assertFalse(da.getSaveWithFonts()); + assertFalse(da.getOmitTitlePlace()); + assertFalse(da.getRightToLeft()); + assertTrue(da.getShowComments()); } public void testWrite() throws Exception { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java index fc207ea3ca..796fb6eb2c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java @@ -38,9 +38,9 @@ public final class TestNotesAtom extends TestCase { public void testFlags() { NotesAtom na = new NotesAtom(data_a, 0, data_a.length); assertEquals(0x80000000, na.getSlideID()); - assertEquals(false, na.getFollowMasterObjects()); - assertEquals(false, na.getFollowMasterScheme()); - assertEquals(false, na.getFollowMasterBackground()); + assertFalse(na.getFollowMasterObjects()); + assertFalse(na.getFollowMasterScheme()); + assertFalse(na.getFollowMasterBackground()); } public void testWrite() throws Exception { diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java index 3e2fc49b14..7915346673 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java @@ -57,9 +57,9 @@ public final class TestSlideAtom { assertEquals(256, sa.getNotesID()); // Check the flags - assertEquals(true, sa.getFollowMasterObjects()); - assertEquals(true, sa.getFollowMasterScheme()); - assertEquals(true, sa.getFollowMasterBackground()); + assertTrue(sa.getFollowMasterObjects()); + assertTrue(sa.getFollowMasterScheme()); + assertTrue(sa.getFollowMasterBackground()); } @Test diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java index 87d8a17502..19d99c4569 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java @@ -39,7 +39,7 @@ public final class TestSlidePersistAtom extends TestCase { public void testFlags() { SlidePersistAtom spa = new SlidePersistAtom(data_a, 0, data_a.length); assertEquals(4, spa.getRefID() ); - assertEquals(true, spa.getHasShapesOtherThanPlaceholders() ); + assertTrue(spa.getHasShapesOtherThanPlaceholders()); assertEquals(2, spa.getNumPlaceholderTexts() ); assertEquals(256, spa.getSlideIdentifier()); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java index 0927d37edd..f9290e18fd 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java @@ -226,7 +226,7 @@ public final class TestStyleTextPropAtom { assertEquals(2,b_ch_1.getTextPropList().size()); TextProp tp_1_1 = b_ch_1.getTextPropList().get(0); TextProp tp_1_2 = b_ch_1.getTextPropList().get(1); - assertEquals(true, tp_1_1 instanceof CharFlagsTextProp); + assertTrue(tp_1_1 instanceof CharFlagsTextProp); assertEquals("font.size", tp_1_2.getName()); assertEquals(20, tp_1_2.getValue()); @@ -235,7 +235,7 @@ public final class TestStyleTextPropAtom { TextProp tp_2_1 = b_ch_2.getTextPropList().get(0); TextProp tp_2_2 = b_ch_2.getTextPropList().get(1); TextProp tp_2_3 = b_ch_2.getTextPropList().get(2); - assertEquals(true, tp_2_1 instanceof CharFlagsTextProp); + assertTrue(tp_2_1 instanceof CharFlagsTextProp); assertEquals("font.size", tp_2_2.getName()); assertEquals("font.color", tp_2_3.getName()); assertEquals(20, tp_2_2.getValue()); @@ -253,7 +253,7 @@ public final class TestStyleTextPropAtom { TextProp tp_4_1 = b_ch_4.getTextPropList().get(0); TextProp tp_4_2 = b_ch_4.getTextPropList().get(1); TextProp tp_4_3 = b_ch_4.getTextPropList().get(2); - assertEquals(true, tp_4_1 instanceof CharFlagsTextProp); + assertTrue(tp_4_1 instanceof CharFlagsTextProp); assertEquals("font.index", tp_4_2.getName()); assertEquals("font.size", tp_4_3.getName()); assertEquals(24, tp_4_3.getValue()); @@ -317,42 +317,42 @@ public final class TestStyleTextPropAtom { // 1st is bold CharFlagsTextProp cf_1_1 = (CharFlagsTextProp)b_ch_1.getTextPropList().get(0); - assertEquals(true,cf_1_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); - assertEquals(false,cf_1_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); + assertTrue(cf_1_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); + assertFalse(cf_1_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); // 2nd is italic CharFlagsTextProp cf_2_1 = (CharFlagsTextProp)b_ch_2.getTextPropList().get(0); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); - assertEquals(true,cf_2_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); - assertEquals(false,cf_2_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); + assertTrue(cf_2_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); + assertFalse(cf_2_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); // 3rd is normal, so lacks a CharFlagsTextProp assertFalse(b_ch_3.getTextPropList().get(0) instanceof CharFlagsTextProp); // 4th is underlined CharFlagsTextProp cf_4_1 = (CharFlagsTextProp)b_ch_4.getTextPropList().get(0); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); - assertEquals(true,cf_4_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); + assertTrue(cf_4_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); // The value for this should be 4 assertEquals(0x0004, cf_4_1.getValue()); @@ -362,15 +362,15 @@ public final class TestStyleTextPropAtom { cf_4_1.setSubValue(true, CharFlagsTextProp.ITALIC_IDX); cf_4_1.setSubValue(false, CharFlagsTextProp.UNDERLINE_IDX); - assertEquals(true,cf_4_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); - assertEquals(true,cf_4_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); - assertEquals(false,cf_4_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); + assertTrue(cf_4_1.getSubValue(CharFlagsTextProp.BOLD_IDX)); + assertTrue(cf_4_1.getSubValue(CharFlagsTextProp.ITALIC_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_1_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.ENABLE_NUMBERING_2_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.RELIEF_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.RESET_NUMBERING_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.SHADOW_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.STRIKETHROUGH_IDX)); + assertFalse(cf_4_1.getSubValue(CharFlagsTextProp.UNDERLINE_IDX)); // The value should now be 3 assertEquals(0x0003, cf_4_1.getValue()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java index b21f216577..31778e6ba3 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java @@ -58,12 +58,12 @@ public final class TestNumberedList { final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes(); assertNotNull(autoNumbers); assertEquals(4, autoNumbers.length); - assertTrue(4 == autoNumbers[0].getAutoNumberStartNumber()); + assertEquals(4, (short) autoNumbers[0].getAutoNumberStartNumber()); assertNull(autoNumbers[1].getAutoNumberStartNumber()); - assertTrue(3 == autoNumbers[2].getAutoNumberStartNumber()); - assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbers[0].getAutoNumberScheme()); + assertEquals(3, (short) autoNumbers[2].getAutoNumberStartNumber()); + assertSame(AutoNumberingScheme.arabicPeriod, autoNumbers[0].getAutoNumberScheme()); assertNull(autoNumbers[1].getAutoNumberScheme()); - assertTrue(AutoNumberingScheme.alphaLcParenRight == autoNumbers[2].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.alphaLcParenRight, autoNumbers[2].getAutoNumberScheme()); List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs(); assertEquals(2, textParass.size()); @@ -100,12 +100,12 @@ public final class TestNumberedList { final TextPFException9[] autoNumbers = numberedListInfo.getAutoNumberTypes(); assertNotNull(autoNumbers); assertEquals(4, autoNumbers.length); - assertTrue(9 == autoNumbers[0].getAutoNumberStartNumber()); + assertEquals(9, (short) autoNumbers[0].getAutoNumberStartNumber()); assertNull(autoNumbers[1].getAutoNumberStartNumber()); - assertTrue(3 == autoNumbers[2].getAutoNumberStartNumber()); - assertTrue(AutoNumberingScheme.arabicParenRight == autoNumbers[0].getAutoNumberScheme()); + assertEquals(3, (short) autoNumbers[2].getAutoNumberStartNumber()); + assertSame(AutoNumberingScheme.arabicParenRight, autoNumbers[0].getAutoNumberScheme()); assertNull(autoNumbers[1].getAutoNumberScheme()); - assertTrue(AutoNumberingScheme.alphaUcPeriod == autoNumbers[2].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.alphaUcPeriod, autoNumbers[2].getAutoNumberScheme()); final List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs(); assertEquals(2, textParass.size()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java index 32ac8f4172..2ec650ea0c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java @@ -21,6 +21,7 @@ package org.apache.poi.hslf.usermodel; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -69,11 +70,11 @@ public final class TestNumberedList2 { final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox0.getAutoNumberTypes(); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber()); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used - assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox0[0].getAutoNumberScheme()); final TextPFException9[] autoNumbersOfTextBox1 = numberedListInfoForTextBox1.getAutoNumberTypes(); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox1[0].getfBulletHasAutoNumber()); assertEquals(Short.valueOf((short)6), autoNumbersOfTextBox1[0].getAutoNumberStartNumber());//Default value = 1 will be used - assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox1[0].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox1[0].getAutoNumberScheme()); List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs(); @@ -105,7 +106,7 @@ public final class TestNumberedList2 { final TextPFException9[] autoNumbersOfTextBox = numberedListInfoForTextBox.getAutoNumberTypes(); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getfBulletHasAutoNumber()); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());//Default value = 1 will be used - assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox[0].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox[0].getAutoNumberScheme()); List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs(); assertEquals(3, textParass.size()); diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java index 36832c69e7..f3a682ffe5 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java @@ -22,6 +22,7 @@ package org.apache.poi.hslf.usermodel; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -68,7 +69,7 @@ public final class TestNumberedList3 { final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox.getAutoNumberTypes(); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber()); assertEquals(Short.valueOf((short)1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());//Default value = 1 will be used - assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox0[0].getAutoNumberScheme()); final List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs(); assertEquals(3, textParass.size()); @@ -85,7 +86,7 @@ public final class TestNumberedList3 { assertEquals(1, autoNumbers.length); assertEquals(Short.valueOf((short)1), autoNumbers[0].getfBulletHasAutoNumber()); assertEquals(Short.valueOf((short)1), autoNumbers[0].getAutoNumberStartNumber());//Default value = 1 will be used - assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme()); + assertSame(AutoNumberingScheme.arabicPeriod, autoNumbersOfTextBox0[0].getAutoNumberScheme()); int chCovered = 0; for (HSLFTextParagraph htp : textParass.get(1)) { diff --git a/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestMAPIProperty.java b/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestMAPIProperty.java index 55369e8dcd..d44980a960 100644 --- a/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestMAPIProperty.java +++ b/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestMAPIProperty.java @@ -33,14 +33,14 @@ public final class TestMAPIProperty extends TestCase { public void testGetAll() throws Exception { Collection<MAPIProperty> all = MAPIProperty.getAll(); - assertEquals(true, all.contains(MAPIProperty.DISPLAY_NAME)); - assertEquals(true, all.contains(MAPIProperty.DISPLAY_CC)); + assertTrue(all.contains(MAPIProperty.DISPLAY_NAME)); + assertTrue(all.contains(MAPIProperty.DISPLAY_CC)); // Won't contain custom - assertEquals(false, all.contains(MAPIProperty.createCustom(1, Types.UNSPECIFIED, ""))); + assertFalse(all.contains(MAPIProperty.createCustom(1, Types.UNSPECIFIED, ""))); // Won't contain unknown - assertEquals(false, all.contains(MAPIProperty.UNKNOWN)); + assertFalse(all.contains(MAPIProperty.UNKNOWN)); } public void testCustom() throws Exception { @@ -55,8 +55,8 @@ public final class TestMAPIProperty extends TestCase { // Won't be in all list Collection<MAPIProperty> all = MAPIProperty.getAll(); - assertEquals(false, all.contains(c1)); - assertEquals(false, all.contains(c2a)); - assertEquals(false, all.contains(c2b)); + assertFalse(all.contains(c1)); + assertFalse(all.contains(c2a)); + assertFalse(all.contains(c2b)); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/PlfLfoTest.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/PlfLfoTest.java index b9dafae62a..bde4c7659e 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/PlfLfoTest.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/PlfLfoTest.java @@ -40,17 +40,17 @@ public class PlfLfoTest { assertEquals(0, p.getLfoMac()); assertEquals(0, p2.getLfoMac()); - assertTrue(p.equals(p2)); + assertEquals(p, p2); //noinspection ObjectEqualsNull - assertFalse(p.equals(null)); + assertNotEquals(null, p); p.add(new LFO(new byte[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 0), new LFOData()); assertEquals(1, p.getLfoMac()); - assertFalse(p.equals(p2)); + assertNotEquals(p, p2); p2.add(new LFO(new byte[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 0), new LFOData()); assertEquals(1, p2.getLfoMac()); - assertTrue(p.equals(p2)); + assertEquals(p, p2); } }
\ No newline at end of file diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java index 96ca5cc64c..b3aa64ab9c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java @@ -69,7 +69,7 @@ public final class TestCHPBinTable { CHPX oldNode = oldTextRuns.get(x); CHPX newNode = newTextRuns.get(x); - assertTrue(oldNode.equals(newNode)); + assertEquals(oldNode, newNode); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java index 860e568850..488e28f2d3 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java @@ -17,6 +17,7 @@ package org.apache.poi.hwpf.model; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -53,7 +54,7 @@ public final class TestFontTable { FontTable newFontTable = new FontTable(newTableStream, 0, newTableStream.length); - assertTrue(_fontTable.equals(newFontTable)); + assertEquals(_fontTable, newFontTable); } diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java index 1befadb5f4..bf2a196dc0 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java @@ -74,7 +74,7 @@ public final class TestPAPBinTable { PAPX oldNode = oldTextRuns.get( x ); PAPX newNode = newTextRuns.get( x ); - assertTrue( oldNode.equals( newNode ) ); + assertEquals(oldNode, newNode); } _hWPFDocFixture.tearDown(); diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java index fc6ac11bc1..8c829c0fff 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java @@ -18,6 +18,7 @@ package org.apache.poi.hwpf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -178,47 +179,47 @@ public final class TestPictures { p = r.getParagraph(0); assertEquals(2, p.numCharacterRuns()); assertEquals("I have lots of embedded files in me\r", p.text()); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(0))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(1))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(0))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(1))); p = r.getParagraph(1); assertEquals(5, p.numCharacterRuns()); assertEquals("\u0013 EMBED Excel.Sheet.8 \u0014\u0001\u0015\r", p.text()); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(0))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(1))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(2))); - assertEquals(true, pictureTable.hasPicture(p.getCharacterRun(3))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(4))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(0))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(1))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(2))); + assertTrue(pictureTable.hasPicture(p.getCharacterRun(3))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(4))); p = r.getParagraph(2); assertEquals(6, p.numCharacterRuns()); assertEquals("\u0013 EMBED Excel.Sheet.8 \u0014\u0001\u0015\r", p.text()); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(0))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(1))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(2))); - assertEquals(true, pictureTable.hasPicture(p.getCharacterRun(3))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(4))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(5))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(0))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(1))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(2))); + assertTrue(pictureTable.hasPicture(p.getCharacterRun(3))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(4))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(5))); p = r.getParagraph(3); assertEquals(6, p.numCharacterRuns()); assertEquals("\u0013 EMBED PowerPoint.Show.8 \u0014\u0001\u0015\r", p.text()); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(0))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(1))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(2))); - assertEquals(true, pictureTable.hasPicture(p.getCharacterRun(3))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(4))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(5))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(0))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(1))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(2))); + assertTrue(pictureTable.hasPicture(p.getCharacterRun(3))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(4))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(5))); p = r.getParagraph(4); assertEquals(6, p.numCharacterRuns()); assertEquals("\u0013 EMBED Word.Document.8 \\s \u0014\u0001\u0015\r", p.text()); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(0))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(1))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(2))); - assertEquals(true, pictureTable.hasPicture(p.getCharacterRun(3))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(4))); - assertEquals(false, pictureTable.hasPicture(p.getCharacterRun(5))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(0))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(1))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(2))); + assertTrue(pictureTable.hasPicture(p.getCharacterRun(3))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(4))); + assertFalse(pictureTable.hasPicture(p.getCharacterRun(5))); // Look at the pictures table List<Picture> pictures = pictureTable.getAllPictures(); diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java b/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java index ed79510f40..717f74fe6d 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestClassID.java @@ -19,26 +19,29 @@ package org.apache.poi.hpsf.basic; import java.util.Locale; -import junit.framework.Assert; -import junit.framework.TestCase; - import org.apache.poi.hpsf.ClassID; import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.SummaryInformation; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; /** * <p>Tests ClassID structure.</p> * * @author Michael Zalewski (zalewski@optonline.net) */ -public final class TestClassID extends TestCase { +public final class TestClassID { /** * Various tests of overridden .equals() */ - public void testEquals() - { + @Test + public void testEquals() { ClassID clsidTest1 = new ClassID( new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10} @@ -54,17 +57,18 @@ public final class TestClassID extends TestCase { 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x11 } , 0 ); - Assert.assertEquals(clsidTest1, clsidTest1); - Assert.assertEquals(clsidTest1, clsidTest2); - Assert.assertFalse(clsidTest1.equals(clsidTest3)); - Assert.assertFalse(clsidTest1.equals(null)); + assertEquals(clsidTest1, clsidTest1); + assertEquals(clsidTest1, clsidTest2); + assertNotEquals(clsidTest1, clsidTest3); + assertNotEquals(null, clsidTest1); } + /** * Try to write to a buffer that is too small. This should * throw an Exception */ - public void testWriteArrayStoreException() - { + @Test + public void testWriteArrayStoreException() { ClassID clsidTest = new ClassID( new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10} @@ -79,7 +83,7 @@ public final class TestClassID extends TestCase { { bExceptionOccurred = true; } - Assert.assertTrue(bExceptionOccurred); + assertTrue(bExceptionOccurred); bExceptionOccurred = false; try @@ -90,7 +94,7 @@ public final class TestClassID extends TestCase { { bExceptionOccurred = true; } - Assert.assertTrue(bExceptionOccurred); + assertTrue(bExceptionOccurred); // These should work without throwing an Exception bExceptionOccurred = false; @@ -103,21 +107,22 @@ public final class TestClassID extends TestCase { { bExceptionOccurred = true; } - Assert.assertFalse(bExceptionOccurred); + assertFalse(bExceptionOccurred); } + /** * <p>Tests the {@link PropertySet} methods. The test file has two * property set: the first one is a {@link SummaryInformation}, * the second one is a {@link DocumentSummaryInformation}.</p> */ - public void testClassID() - { + @Test + public void testClassID() { ClassID clsidTest = new ClassID( new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10} , 0 ); - Assert.assertEquals(clsidTest.toString().toUpperCase(Locale.ROOT), + assertEquals(clsidTest.toString().toUpperCase(Locale.ROOT), "{04030201-0605-0807-090A-0B0C0D0E0F10}" ); } diff --git a/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java b/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java index a4618aed47..18384de5d8 100644 --- a/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java +++ b/src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java @@ -55,7 +55,7 @@ public final class TestAbortableListener extends TestCase { HSSFEventFactory f = new HSSFEventFactory(); assertEquals(0, l.countSeen); - assertEquals(null, l.lastRecordSeen); + assertNull(l.lastRecordSeen); POIFSFileSystem fs = openSample(); short res = f.abortableProcessWorkbookEvents(req, fs); @@ -75,7 +75,7 @@ public final class TestAbortableListener extends TestCase { HSSFEventFactory f = new HSSFEventFactory(); assertEquals(0, l.countSeen); - assertEquals(null, l.lastRecordSeen); + assertNull(l.lastRecordSeen); POIFSFileSystem fs = openSample(); short res = f.abortableProcessWorkbookEvents(req, fs); diff --git a/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java b/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java index b3bf668804..eacfdd51bb 100644 --- a/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java +++ b/src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java @@ -92,8 +92,8 @@ public final class TestEventRecordFactory extends TestCase { byte[] bytes = bof.serialize(); Record[] records = RecordFactory.createRecord(TestcaseRecordInputStream.create(bytes)); - - assertTrue("record.length must be 1, was ="+records.length,records.length == 1); + + assertEquals("record.length must be 1, was =" + records.length, 1, records.length); assertTrue("record is the same", compareRec(bof,records[0])); } diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java index f051529b75..82b1409dbd 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java +++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java @@ -20,6 +20,7 @@ import static org.apache.poi.poifs.storage.RawDataUtil.decompress; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -149,8 +150,7 @@ public class TestDrawingAggregate { byte[] dgBytes2 = agg.serialize(); assertEquals("different size of raw data ande aggregate.serialize()", dgBytes1.length, dgBytes2.length); - assertTrue("raw drawing data ("+dgBytes1.length+" bytes) and aggregate.serialize() are different.", - Arrays.equals(dgBytes1, dgBytes2)); + assertArrayEquals("raw drawing data (" + dgBytes1.length + " bytes) and aggregate.serialize() are different.", dgBytes1, dgBytes2); } } @@ -164,8 +164,7 @@ public class TestDrawingAggregate { byte[] dgBytes1 = info1.getRawBytes(); byte[] dgBytes2 = info2.getRawBytes(); assertEquals("different size of drawing data before and after save", dgBytes1.length, dgBytes2.length); - assertTrue("drawing data ("+dgBytes1.length+" bytes) before and after save is different.", - Arrays.equals(dgBytes1, dgBytes2)); + assertArrayEquals("drawing data (" + dgBytes1.length + " bytes) before and after save is different.", dgBytes1, dgBytes2); } } wb2.close(); @@ -295,7 +294,7 @@ public class TestDrawingAggregate { agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid); byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb2.close(); } @@ -314,7 +313,7 @@ public class TestDrawingAggregate { EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid); byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb.close(); } @@ -338,7 +337,7 @@ public class TestDrawingAggregate { System.out.println("pos = " + i); } } - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb.close(); } @@ -401,7 +400,7 @@ public class TestDrawingAggregate { byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb.close(); } @@ -469,7 +468,7 @@ public class TestDrawingAggregate { byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb.close(); } @@ -490,7 +489,7 @@ public class TestDrawingAggregate { for (int i = 0; i < records.size(); i++) { RecordBase r1 = records.get(i); RecordBase r2 = records2.get(i); - assertTrue(r1.getClass() == r2.getClass()); + assertSame(r1.getClass(), r2.getClass()); assertEquals(r1.getRecordSize(), r2.getRecordSize()); if (r1 instanceof Record) { assertEquals(((Record) r1).getSid(), ((Record) r2).getSid()); @@ -555,7 +554,7 @@ public class TestDrawingAggregate { byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb.close(); } @@ -615,7 +614,7 @@ public class TestDrawingAggregate { byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); wb.close(); } @@ -768,7 +767,7 @@ public class TestDrawingAggregate { byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); } @Test @@ -941,6 +940,6 @@ public class TestDrawingAggregate { byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data brefpore and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data brefpore and after save is different", dgBytes, dgBytesAfterSave); } } diff --git a/src/testcases/org/apache/poi/hssf/model/TestEscherRecordFactory.java b/src/testcases/org/apache/poi/hssf/model/TestEscherRecordFactory.java index 7b1c2078c1..905641f0a3 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestEscherRecordFactory.java +++ b/src/testcases/org/apache/poi/hssf/model/TestEscherRecordFactory.java @@ -31,10 +31,11 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.Arrays; import java.util.List; import java.util.Random; +import static org.junit.Assert.assertArrayEquals; + /** * @author Evgeniy Berlog * @date 18.06.12 @@ -56,26 +57,26 @@ public class TestEscherRecordFactory extends TestCase{ public void testDetectContainer() { Random rnd = new Random(); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.DG_CONTAINER)); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.SOLVER_CONTAINER)); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.SP_CONTAINER)); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.DGG_CONTAINER)); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.BSTORE_CONTAINER)); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.SPGR_CONTAINER)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.DG_CONTAINER)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.SOLVER_CONTAINER)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.SP_CONTAINER)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.DGG_CONTAINER)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.BSTORE_CONTAINER)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x0, EscherContainerRecord.SPGR_CONTAINER)); for (Short i=EscherContainerRecord.DGG_CONTAINER; i<= EscherContainerRecord.SOLVER_CONTAINER; i++){ - assertEquals(true, DefaultEscherRecordFactory.isContainer(Integer.valueOf(rnd.nextInt(Short.MAX_VALUE)).shortValue(), i)); + assertTrue(DefaultEscherRecordFactory.isContainer(Integer.valueOf(rnd.nextInt(Short.MAX_VALUE)).shortValue(), i)); } - assertEquals(false, DefaultEscherRecordFactory.isContainer((short) 0x0, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER-1).shortValue())); - assertEquals(false, DefaultEscherRecordFactory.isContainer((short) 0x0, Integer.valueOf(EscherContainerRecord.SOLVER_CONTAINER+1).shortValue())); + assertFalse(DefaultEscherRecordFactory.isContainer((short) 0x0, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER - 1).shortValue())); + assertFalse(DefaultEscherRecordFactory.isContainer((short) 0x0, Integer.valueOf(EscherContainerRecord.SOLVER_CONTAINER + 1).shortValue())); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0x000F, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER-1).shortValue())); - assertEquals(true, DefaultEscherRecordFactory.isContainer((short) 0xFFFF, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER-1).shortValue())); - assertEquals(false, DefaultEscherRecordFactory.isContainer((short) 0x000C, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER-1).shortValue())); - assertEquals(false, DefaultEscherRecordFactory.isContainer((short) 0xCCCC, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER-1).shortValue())); - assertEquals(false, DefaultEscherRecordFactory.isContainer((short) 0x000F, EscherTextboxRecord.RECORD_ID)); - assertEquals(false, DefaultEscherRecordFactory.isContainer((short) 0xCCCC, EscherTextboxRecord.RECORD_ID)); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0x000F, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER - 1).shortValue())); + assertTrue(DefaultEscherRecordFactory.isContainer((short) 0xFFFF, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER - 1).shortValue())); + assertFalse(DefaultEscherRecordFactory.isContainer((short) 0x000C, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER - 1).shortValue())); + assertFalse(DefaultEscherRecordFactory.isContainer((short) 0xCCCC, Integer.valueOf(EscherContainerRecord.DGG_CONTAINER - 1).shortValue())); + assertFalse(DefaultEscherRecordFactory.isContainer((short) 0x000F, EscherTextboxRecord.RECORD_ID)); + assertFalse(DefaultEscherRecordFactory.isContainer((short) 0xCCCC, EscherTextboxRecord.RECORD_ID)); } public void testDgContainerMustBeRootOfHSSFSheetEscherRecords() throws IOException { @@ -88,12 +89,12 @@ public class TestEscherRecordFactory extends TestCase{ byte[] dgBytes = toByteArray(dgRecords); sh.getDrawingPatriarch(); EscherAggregate agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid); - assertEquals(true, agg.getEscherRecords().get(0) instanceof EscherContainerRecord); + assertTrue(agg.getEscherRecords().get(0) instanceof EscherContainerRecord); assertEquals(EscherContainerRecord.DG_CONTAINER, agg.getEscherRecords().get(0).getRecordId()); assertEquals((short) 0x0, agg.getEscherRecords().get(0).getOptions()); agg = (EscherAggregate) ish.findFirstRecordBySid(EscherAggregate.sid); byte[] dgBytesAfterSave = agg.serialize(); assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length); - assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave)); + assertArrayEquals("drawing data before and after save is different", dgBytes, dgBytesAfterSave); } } diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java index 349043b9c9..b95b700bfb 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java @@ -132,7 +132,7 @@ public final class TestFormulaParser { Ptg[] ptgs = parseFormula("TRUE"); assertEquals(1, ptgs.length); BoolPtg flag = (BoolPtg) ptgs[0]; - assertEquals(true, flag.getValue()); + assertTrue(flag.getValue()); } @Test @@ -300,18 +300,18 @@ public final class TestFormulaParser { String value = " hi "; Ptg[] ptgs = parseFormula("\"" + value + "\""); confirmTokenClasses(ptgs, StringPtg.class); - assertTrue("ptg0 contains exact value", ((StringPtg)ptgs[0]).getValue().equals(value)); + assertEquals("ptg0 contains exact value", ((StringPtg) ptgs[0]).getValue(), value); } @Test public void testLookupAndMatchFunctionArgs() { Ptg[] ptgs = parseFormula("lookup(A1, A3:A52, B3:B52)"); confirmTokenClasses(ptgs, RefPtg.class, AreaPtg.class, AreaPtg.class, FuncVarPtg.class); - assertTrue("ptg0 has Value class", ptgs[0].getPtgClass() == Ptg.CLASS_VALUE); + assertEquals("ptg0 has Value class", ptgs[0].getPtgClass(), Ptg.CLASS_VALUE); ptgs = parseFormula("match(A1, A3:A52)"); confirmTokenClasses(ptgs, RefPtg.class, AreaPtg.class, FuncVarPtg.class); - assertTrue("ptg0 has Value class", ptgs[0].getPtgClass() == Ptg.CLASS_VALUE); + assertEquals("ptg0 has Value class", ptgs[0].getPtgClass(), Ptg.CLASS_VALUE); } /** bug 33160*/ diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java index 53f5f4ac75..d7ab7aa48d 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java @@ -70,7 +70,7 @@ public final class TestFormulaParserEval extends TestCase { */ private static void confirmParseFormula(HSSFWorkbook workbook) { Ptg[] ptgs = HSSFFormulaParser.parse("SUM(testName)", workbook); - assertTrue("two tokens expected, got "+ptgs.length,ptgs.length == 2); + assertEquals("two tokens expected, got " + ptgs.length, 2, ptgs.length); assertEquals(NamePtg.class, ptgs[0].getClass()); assertEquals(AttrPtg.class, ptgs[1].getClass()); } diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java index a069190f5f..250263392e 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java @@ -198,7 +198,7 @@ public final class TestFormulaParserIf extends TestCase { StringPtg n = (StringPtg) ptgs[4]; - assertEquals(true, flag.getValue()); + assertTrue(flag.getValue()); assertEquals("Y", y.getValue()); assertEquals("N", n.getValue()); assertEquals("IF", funif.toFormulaString()); diff --git a/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java b/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java index c79b29928f..d05e1c8d0d 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java +++ b/src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java @@ -18,15 +18,24 @@ package org.apache.poi.hssf.model; import junit.framework.TestCase; -import org.apache.poi.ddf.*; +import org.apache.poi.ddf.EscherChildAnchorRecord; +import org.apache.poi.ddf.EscherClientAnchorRecord; +import org.apache.poi.ddf.EscherClientDataRecord; +import org.apache.poi.ddf.EscherContainerRecord; +import org.apache.poi.ddf.EscherOptRecord; +import org.apache.poi.ddf.EscherSpRecord; import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.usermodel.HSSFAnchor; +import org.apache.poi.hssf.usermodel.HSSFChildAnchor; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFSimpleShape; +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.Assert; -/** - * @author Evgeniy Berlog - * @date 12.06.12 - */ public class TestHSSFAnchor extends TestCase { public void testDefaultValues(){ @@ -100,6 +109,7 @@ public class TestHSSFAnchor extends TestCase { container.addChildRecord(escher); HSSFClientAnchor anchor = (HSSFClientAnchor) HSSFAnchor.createAnchorFromEscher(container); + assertNotNull(anchor); assertEquals(anchor.getCol1(), 11); assertEquals(escher.getCol1(), 11); assertEquals(anchor.getCol2(), 12); @@ -128,6 +138,7 @@ public class TestHSSFAnchor extends TestCase { container.addChildRecord(escher); HSSFChildAnchor anchor = (HSSFChildAnchor) HSSFAnchor.createAnchorFromEscher(container); + assertNotNull(anchor); assertEquals(anchor.getDx1(), 15); assertEquals(escher.getDx1(), 15); assertEquals(anchor.getDx2(), 16); @@ -153,7 +164,7 @@ public class TestHSSFAnchor extends TestCase { assertNotNull(HSSFTestHelper.getEscherAnchor(anchor)); assertNotNull(HSSFTestHelper.getEscherContainer(rectangle)); - assertTrue(HSSFTestHelper.getEscherAnchor(anchor).equals(HSSFTestHelper.getEscherContainer(rectangle).getChildById(EscherClientAnchorRecord.RECORD_ID))); + assertEquals(HSSFTestHelper.getEscherAnchor(anchor), HSSFTestHelper.getEscherContainer(rectangle).getChildById(EscherClientAnchorRecord.RECORD_ID)); } public void testClientAnchorFromEscher(){ @@ -298,24 +309,24 @@ public class TestHSSFAnchor extends TestCase { public void testNullReferenceIsFalse() { HSSFClientAnchor clientAnchor = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7); - assertFalse("Passing null to equals should return false", clientAnchor.equals(null)); + Assert.assertNotNull("Passing null to equals should return false", clientAnchor); HSSFChildAnchor childAnchor = new HSSFChildAnchor(0, 1, 2, 3); - assertFalse("Passing null to equals should return false", childAnchor.equals(null)); + assertNotNull("Passing null to equals should return false", childAnchor); } public void testEqualsIsReflexiveIsSymmetric() { HSSFClientAnchor clientAnchor1 = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7); HSSFClientAnchor clientAnchor2 = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7); - assertTrue(clientAnchor1.equals(clientAnchor2)); - assertTrue(clientAnchor1.equals(clientAnchor2)); + assertEquals(clientAnchor1, clientAnchor2); + assertEquals(clientAnchor1, clientAnchor2); HSSFChildAnchor childAnchor1 = new HSSFChildAnchor(0, 1, 2, 3); HSSFChildAnchor childAnchor2 = new HSSFChildAnchor(0, 1, 2, 3); - assertTrue(childAnchor1.equals(childAnchor2)); - assertTrue(childAnchor2.equals(childAnchor1)); + assertEquals(childAnchor1, childAnchor2); + assertEquals(childAnchor2, childAnchor1); } public void testEqualsValues(){ @@ -394,32 +405,32 @@ public class TestHSSFAnchor extends TestCase { public void testFlipped(){ HSSFChildAnchor child = new HSSFChildAnchor(2,2,1,1); - assertEquals(child.isHorizontallyFlipped(), true); - assertEquals(child.isVerticallyFlipped(), true); + assertTrue(child.isHorizontallyFlipped()); + assertTrue(child.isVerticallyFlipped()); assertEquals(child.getDx1(), 1); assertEquals(child.getDx2(), 2); assertEquals(child.getDy1(), 1); assertEquals(child.getDy2(), 2); child = new HSSFChildAnchor(3,3,4,4); - assertEquals(child.isHorizontallyFlipped(), false); - assertEquals(child.isVerticallyFlipped(), false); + assertFalse(child.isHorizontallyFlipped()); + assertFalse(child.isVerticallyFlipped()); assertEquals(child.getDx1(), 3); assertEquals(child.getDx2(), 4); assertEquals(child.getDy1(), 3); assertEquals(child.getDy2(), 4); HSSFClientAnchor client = new HSSFClientAnchor(1,1,1,1, (short)4,4,(short)3,3); - assertEquals(client.isVerticallyFlipped(), true); - assertEquals(client.isHorizontallyFlipped(), true); + assertTrue(client.isVerticallyFlipped()); + assertTrue(client.isHorizontallyFlipped()); assertEquals(client.getCol1(), 3); assertEquals(client.getCol2(), 4); assertEquals(client.getRow1(), 3); assertEquals(client.getRow2(), 4); client = new HSSFClientAnchor(1,1,1,1, (short)5,5,(short)6,6); - assertEquals(client.isVerticallyFlipped(), false); - assertEquals(client.isHorizontallyFlipped(), false); + assertFalse(client.isVerticallyFlipped()); + assertFalse(client.isHorizontallyFlipped()); assertEquals(client.getCol1(), 5); assertEquals(client.getCol2(), 6); assertEquals(client.getRow1(), 5); diff --git a/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java b/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java index fbd562b444..a6f8414a92 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java +++ b/src/testcases/org/apache/poi/hssf/model/TestLinkTable.java @@ -181,8 +181,8 @@ public final class TestLinkTable extends TestCase { assertNotNull(lt); assertEquals(2, commentRecords.size()); - assertTrue(recs[1] == commentRecords.get("name1")); //== is intentionally not .equals()! - assertTrue(recs[3] == commentRecords.get("name2")); //== is intentionally not .equals()! + assertSame(recs[1], commentRecords.get("name1")); //== is intentionally not .equals()! + assertSame(recs[3], commentRecords.get("name2")); //== is intentionally not .equals()! assertEquals(2, lt.getNumNames()); } diff --git a/src/testcases/org/apache/poi/hssf/model/TestSheet.java b/src/testcases/org/apache/poi/hssf/model/TestSheet.java index 7ebb8a401c..84d5e65015 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestSheet.java +++ b/src/testcases/org/apache/poi/hssf/model/TestSheet.java @@ -140,11 +140,11 @@ public final class TestSheet { for (int n = 0; n < regionsToAdd; n++) { int index = sheet.addMergedRegion(0, (short) 0, 1, (short) 1); - assertTrue("Merged region index expected to be " + n + " got " + index, index == n); + assertEquals("Merged region index expected to be " + n + " got " + index, index, n); } //test all the regions were indeed added - assertTrue(sheet.getNumMergedRegions() == regionsToAdd); + assertEquals(sheet.getNumMergedRegions(), regionsToAdd); //test that the regions were spread out over the appropriate number of records MergedCellListener mcListener = new MergedCellListener(); @@ -153,8 +153,8 @@ public final class TestSheet { int recordsExpected = regionsToAdd/1027; if ((regionsToAdd % 1027) != 0) recordsExpected++; - assertTrue("The " + regionsToAdd + " merged regions should have been spread out over " - + recordsExpected + " records, not " + recordsAdded, recordsAdded == recordsExpected); + assertEquals("The " + regionsToAdd + " merged regions should have been spread out over " + + recordsExpected + " records, not " + recordsAdded, recordsAdded, recordsExpected); // Check we can't add one with invalid date try { sheet.addMergedRegion(10, (short)10, 9, (short)12); diff --git a/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java index 558a5ec0ff..d3e99e510c 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/model/TestWorkbook.java @@ -140,7 +140,7 @@ public final class TestWorkbook { int countryPos = iwb.findFirstRecordLocBySid(CountryRecord.sid); assertTrue(countryPos != -1); // RecalcIdRecord is not present in new workbooks - assertEquals(null, iwb.findFirstRecordBySid(RecalcIdRecord.sid)); + assertNull(iwb.findFirstRecordBySid(RecalcIdRecord.sid)); RecalcIdRecord record = iwb.getRecalcId(); assertNotNull(record); assertSame(record, iwb.getRecalcId()); diff --git a/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java b/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java index 9223dc9967..7f34a1c5dc 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java @@ -70,7 +70,7 @@ public final class TestBoolErrRecord extends TestCase { } assertFalse(hasMore); assertTrue(ber.isBoolean()); - assertEquals(true, ber.getBooleanValue()); + assertTrue(ber.getBooleanValue()); // Check that the record re-serializes correctly byte[] outData = ber.serialize(); diff --git a/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java b/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java index 9c9b5486cf..57ae686b0c 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java @@ -45,17 +45,17 @@ public final class TestCFHeaderRecord extends TestCase { assertEquals(65535, enclosingCellRange.getLastRow()); assertEquals(0, enclosingCellRange.getFirstColumn()); assertEquals(6, enclosingCellRange.getLastColumn()); - - assertEquals(false, record.getNeedRecalculation()); + + assertFalse(record.getNeedRecalculation()); assertEquals(0, record.getID()); record.setNeedRecalculation(true); - assertEquals(true, record.getNeedRecalculation()); + assertTrue(record.getNeedRecalculation()); assertEquals(0, record.getID()); record.setID(7); record.setNeedRecalculation(false); - assertEquals(false, record.getNeedRecalculation()); + assertFalse(record.getNeedRecalculation()); assertEquals(7, record.getID()); } @@ -78,16 +78,16 @@ public final class TestCFHeaderRecord extends TestCase { assertEquals(0, enclosingCellRange.getFirstColumn()); assertEquals(6, enclosingCellRange.getLastColumn()); - assertEquals(false, record.getNeedRecalculation()); + assertFalse(record.getNeedRecalculation()); assertEquals(0, record.getID()); record.setNeedRecalculation(true); - assertEquals(true, record.getNeedRecalculation()); + assertTrue(record.getNeedRecalculation()); assertEquals(0, record.getID()); record.setID(7); record.setNeedRecalculation(false); - assertEquals(false, record.getNeedRecalculation()); + assertFalse(record.getNeedRecalculation()); assertEquals(7, record.getID()); } diff --git a/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java b/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java index 8e5b482761..b2c56686fa 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java @@ -41,9 +41,9 @@ public final class TestColumnInfoRecord extends TestCase { assertEquals(155, cir.getLastColumn()); assertEquals(6599, cir.getColumnWidth()); assertEquals(15, cir.getXFIndex()); - assertEquals(true, cir.getHidden()); + assertTrue(cir.getHidden()); assertEquals(3, cir.getOutlineLevel()); - assertEquals(true, cir.getCollapsed()); + assertTrue(cir.getCollapsed()); assertArrayEquals(data, cir.serialize()); } diff --git a/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java index 7ff8623852..5f0ac2e4e9 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java @@ -42,10 +42,10 @@ public final class TestCommonObjectDataSubRecord extends TestCase { assertEquals( CommonObjectDataSubRecord.OBJECT_TYPE_LIST_BOX, record.getObjectType()); assertEquals((short) 1, record.getObjectId()); assertEquals((short) 1, record.getOption()); - assertEquals(true, record.isLocked()); - assertEquals(false, record.isPrintable()); - assertEquals(false, record.isAutofill()); - assertEquals(false, record.isAutoline()); + assertTrue(record.isLocked()); + assertFalse(record.isPrintable()); + assertFalse(record.isAutofill()); + assertFalse(record.isAutoline()); assertEquals(24593, record.getReserved1()); assertEquals(218103808, record.getReserved2()); assertEquals(294, record.getReserved3()); diff --git a/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java b/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java index 98f4d86920..5962e78767 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java @@ -25,6 +25,8 @@ import java.util.Arrays; import junit.framework.TestCase; import org.apache.poi.util.LittleEndianOutputStream; +import static org.junit.Assert.assertArrayEquals; + /** * Unit tests for DConRefRecord class. * @@ -184,7 +186,6 @@ public class TestDConRefRecord extends TestCase /** * test read-constructor-then-serialize for a single-byte external reference strings of * various flavours. This uses the RecordInputStream constructor. - * @throws IOException */ public void testReadWriteSBExtRef() throws IOException { @@ -210,8 +211,6 @@ public class TestDConRefRecord extends TestCase /** * test read-constructor-then-serialize for a double-byte external reference 'UNC-Volume' style * string - * <p> - * @throws IOException */ public void testReadWriteDBExtRefUncVol() throws IOException { @@ -227,14 +226,11 @@ public class TestDConRefRecord extends TestCase d.serialize(o); o.flush(); - assertTrue(message, Arrays.equals(data, - bos.toByteArray())); + assertArrayEquals(message, data, bos.toByteArray()); } /** * test read-constructor-then-serialize for a double-byte self-reference style string - * <p> - * @throws IOException */ public void testReadWriteDBSelfRef() throws IOException { @@ -243,8 +239,6 @@ public class TestDConRefRecord extends TestCase /** * test read-constructor-then-serialize for a single-byte self-reference style string - * <p> - * @throws IOException */ public void testReadWriteSBSelfRef() throws IOException { @@ -289,7 +283,7 @@ public class TestDConRefRecord extends TestCase DConRefRecord instance = new DConRefRecord(TestcaseRecordInputStream.create(81, data1)); byte[] expResult = Arrays.copyOfRange(data1, 9, data1.length); byte[] result = instance.getPath(); - assertTrue("get path", Arrays.equals(expResult, result)); + assertArrayEquals("get path", expResult, result); } /** diff --git a/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java b/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java index 7a126c57a9..228e728ae8 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java @@ -826,7 +826,7 @@ public final class TestExtSSTRecord extends TestCase { UnicodeString us1 = expected.getString(k); UnicodeString us2 = actual.getString(k); - assertTrue("String at idx=" + k, us1.equals(us2)); + assertEquals("String at idx=" + k, us1, us2); } } diff --git a/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java b/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java index e0d14b8da9..ab80faf510 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java @@ -187,7 +187,7 @@ public final class TestFormulaRecord extends TestCase { if (fr0.getCachedBooleanValue() && !fr1.getCachedBooleanValue()) { throw new AssertionFailedError("Identified bug 46479c"); } - assertEquals(false, fr0.getCachedBooleanValue()); - assertEquals(true, fr1.getCachedBooleanValue()); + assertFalse(fr0.getCachedBooleanValue()); + assertTrue(fr1.getCachedBooleanValue()); } } diff --git a/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java b/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java index fdc2fd779e..f002aa8ebc 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java @@ -52,9 +52,9 @@ public final class TestMergeCellsRecord extends TestCase { assertEquals("New Clone Row From doesnt match", mergeRegion.getFirstRow(), cloneRegion.getFirstRow()); assertEquals("New Clone Row To doesnt match", mergeRegion.getLastRow(), cloneRegion.getLastRow()); assertEquals("New Clone Col From doesnt match", mergeRegion.getFirstColumn(), cloneRegion.getFirstColumn()); - assertEquals("New Clone Col To doesnt match", mergeRegion.getLastColumn(), cloneRegion.getLastColumn()); - - assertFalse(merge.getAreaAt(0) == clone.getAreaAt(0)); + assertEquals("New Clone Col To doesnt match", mergeRegion.getLastColumn(), cloneRegion.getLastColumn()); + + assertNotSame(merge.getAreaAt(0), clone.getAreaAt(0)); } private static final RecordVisitor dummyRecordVisitor = new RecordVisitor() { diff --git a/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java index cd98ee0840..01f3ded891 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java @@ -19,6 +19,7 @@ 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.Assert.fail; @@ -82,7 +83,7 @@ public final class TestSSTRecord { in.nextRecord(); SSTRecord result = new SSTRecord(in); assertEquals(0, in.remaining()); - assertTrue(!in.hasNextRecord()); + assertFalse(in.hasNextRecord()); return result; } @@ -1468,7 +1469,7 @@ public final class TestSSTRecord { org.apache.poi.hssf.record.common.UnicodeString us1 = expected.getString(k); org.apache.poi.hssf.record.common.UnicodeString us2 = actual.getString(k); - assertTrue("String at idx=" + k, us1.equals(us2)); + assertEquals("String at idx=" + k, us1, us2); } } diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java index 3bced93f6d..750e5b9427 100644 --- a/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java +++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java @@ -19,6 +19,7 @@ package org.apache.poi.hssf.record.aggregates; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -59,7 +60,7 @@ public final class TestRowRecordsAggregate { assertNotNull(rr1); assertEquals("Row number is 1", 4, rr1.getRowNumber()); - assertTrue("Row record retrieved is identical ", rr1 == rr); + assertSame("Row record retrieved is identical ", rr1, rr); } /** diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java index c47a8b4f7e..1a1041cf7d 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java @@ -48,8 +48,8 @@ public final class TestAreaFormatRecord extends TestCase { assertEquals( 0x000000, record.getBackgroundColor()); assertEquals( 1, record.getPattern()); assertEquals( 1, record.getFormatFlags()); - assertEquals( true, record.isAutomatic() ); - assertEquals( false, record.isInvert() ); + assertTrue(record.isAutomatic()); + assertFalse(record.isInvert()); assertEquals( 0x4e, record.getForecolorIndex()); assertEquals( 0x4d, record.getBackcolorIndex()); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java index 2570d2e1c3..4d5f30e783 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java @@ -39,9 +39,9 @@ public final class TestAreaRecord extends TestCase { AreaRecord record = new AreaRecord(TestcaseRecordInputStream.create(0x101A, data)); assertEquals( 2, record.getFormatFlags()); - assertEquals( false, record.isStacked() ); - assertEquals( true, record.isDisplayAsPercentage() ); - assertEquals( false, record.isShadow() ); + assertFalse(record.isStacked()); + assertTrue(record.isDisplayAsPercentage()); + assertFalse(record.isShadow()); assertEquals( 6, record.getRecordSize() ); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java index 344bdee5d8..ebb5ba4637 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java @@ -49,14 +49,14 @@ public final class TestAxisOptionsRecord extends TestCase { assertEquals( 0, record.getBaseUnit()); assertEquals( 0, record.getCrossingPoint()); assertEquals( 239, record.getOptions()); - assertEquals( true, record.isDefaultMinimum() ); - assertEquals( true, record.isDefaultMaximum() ); - assertEquals( true, record.isDefaultMajor() ); - assertEquals( true, record.isDefaultMinorUnit() ); - assertEquals( false, record.isIsDate() ); - assertEquals( true, record.isDefaultBase() ); - assertEquals( true, record.isDefaultCross() ); - assertEquals( true, record.isDefaultDateSettings() ); + assertTrue(record.isDefaultMinimum()); + assertTrue(record.isDefaultMaximum()); + assertTrue(record.isDefaultMajor()); + assertTrue(record.isDefaultMinorUnit()); + assertFalse(record.isIsDate()); + assertTrue(record.isDefaultBase()); + assertTrue(record.isDefaultCross()); + assertTrue(record.isDefaultDateSettings()); assertEquals( 22, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java index 4781fe9418..90d2f81bb8 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java @@ -43,10 +43,10 @@ public final class TestBarRecord extends TestCase { assertEquals( 0, record.getBarSpace()); assertEquals( 0x96, record.getCategorySpace()); assertEquals( 0, record.getFormatFlags()); - assertEquals( false, record.isHorizontal() ); - assertEquals( false, record.isStacked() ); - assertEquals( false, record.isDisplayAsPercentage() ); - assertEquals( false, record.isShadow() ); + assertFalse(record.isHorizontal()); + assertFalse(record.isStacked()); + assertFalse(record.isDisplayAsPercentage()); + assertFalse(record.isShadow()); assertEquals( 10, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java index 948241dbb7..68f5333618 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java @@ -45,9 +45,9 @@ public final class TestCategorySeriesAxisRecord extends TestCase { assertEquals( 1, record.getLabelFrequency()); assertEquals( 1, record.getTickMarkFrequency()); assertEquals( 1, record.getOptions()); - assertEquals( true, record.isValueAxisCrossing() ); - assertEquals( false, record.isCrossesFarRight() ); - assertEquals( false, record.isReversed() ); + assertTrue(record.isValueAxisCrossing()); + assertFalse(record.isCrossesFarRight()); + assertFalse(record.isReversed()); assertEquals( 4 + 8, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java index 93b25ed95b..ce2f581b17 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java @@ -39,10 +39,10 @@ public final class TestDatRecord extends TestCase { DatRecord record = new DatRecord(TestcaseRecordInputStream.create(0x1063, data)); assertEquals( 0xD, record.getOptions()); - assertEquals( true, record.isHorizontalBorder() ); - assertEquals( false, record.isVerticalBorder() ); - assertEquals( true, record.isBorder() ); - assertEquals( true, record.isShowSeriesKey() ); + assertTrue(record.isHorizontalBorder()); + assertFalse(record.isVerticalBorder()); + assertTrue(record.isBorder()); + assertTrue(record.isShowSeriesKey()); assertEquals( 6, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java index c9958f5074..34a9534ff1 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java @@ -45,7 +45,7 @@ public final class TestDataFormatRecord extends TestCase { assertEquals( 0, record.getSeriesIndex()); assertEquals( 0, record.getSeriesNumber()); assertEquals( 0, record.getFormatFlags()); - assertEquals( false, record.isUseExcel4Colors() ); + assertFalse(record.isUseExcel4Colors()); assertEquals( 12, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java index da2a8a3189..512b46816d 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java @@ -41,8 +41,8 @@ public final class TestFrameRecord extends TestCase { FrameRecord record = new FrameRecord(TestcaseRecordInputStream.create(0x1032, data)); assertEquals( FrameRecord.BORDER_TYPE_REGULAR, record.getBorderType()); assertEquals( 2, record.getOptions()); - assertEquals( false, record.isAutoSize() ); - assertEquals( true, record.isAutoPosition() ); + assertFalse(record.isAutoSize()); + assertTrue(record.isAutoPosition()); assertEquals( 8, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java index a23d6741b6..3523a0b44b 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java @@ -50,12 +50,12 @@ public final class TestLegendRecord extends TestCase { assertEquals((byte) 0x1, record.getSpacing()); assertEquals((short) 0x1f, record.getOptions()); - assertEquals(true, record.isAutoPosition()); - assertEquals(true, record.isAutoSeries()); - assertEquals(true, record.isAutoXPositioning()); - assertEquals(true, record.isAutoYPositioning()); - assertEquals(true, record.isVertical()); - assertEquals(false, record.isDataTable()); + assertTrue(record.isAutoPosition()); + assertTrue(record.isAutoSeries()); + assertTrue(record.isAutoXPositioning()); + assertTrue(record.isAutoYPositioning()); + assertTrue(record.isVertical()); + assertFalse(record.isDataTable()); assertEquals(24, record.getRecordSize()); } diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java index 5b58b22561..f4230cdab3 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java @@ -45,8 +45,8 @@ public final class TestLineFormatRecord extends TestCase { assertEquals( 0, record.getLinePattern()); assertEquals( 0, record.getWeight()); assertEquals( 1, record.getFormat()); - assertEquals( true, record.isAuto() ); - assertEquals( false, record.isDrawTicks() ); + assertTrue(record.isAuto()); + assertFalse(record.isDrawTicks()); assertEquals( 0x4d, record.getColourPaletteIndex()); assertEquals( 16, record.getRecordSize() ); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java index 3fa87dcc87..02e9483928 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java @@ -162,7 +162,7 @@ recordid = 0x1051, size =8 assertEquals( LinkedDataRecord.LINK_TYPE_VALUES, record.getLinkType()); assertEquals( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET, record.getReferenceType()); assertEquals( 0, record.getOptions()); - assertEquals( false, record.isCustomNumberFormat() ); + assertFalse(record.isCustomNumberFormat()); assertEquals( 0, record.getIndexNumberFmtRecord()); Area3DPtg ptgExpected = new Area3DPtg(0, 7936, 0, 0, diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java index 9f0f1f1ead..9d0c52daee 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java @@ -38,12 +38,12 @@ public final class TestSeriesLabelsRecord extends TestCase { public void testLoad() { SeriesLabelsRecord record = new SeriesLabelsRecord(TestcaseRecordInputStream.create(0x100c, data)); assertEquals( 3, record.getFormatFlags()); - assertEquals( true, record.isShowActual() ); - assertEquals( true, record.isShowPercent() ); - assertEquals( false, record.isLabelAsPercentage() ); - assertEquals( false, record.isSmoothedLine() ); - assertEquals( false, record.isShowLabel() ); - assertEquals( false, record.isShowBubbleSizes() ); + assertTrue(record.isShowActual()); + assertTrue(record.isShowPercent()); + assertFalse(record.isLabelAsPercentage()); + assertFalse(record.isSmoothedLine()); + assertFalse(record.isShowLabel()); + assertFalse(record.isShowBubbleSizes()); assertEquals( 2+4, record.getRecordSize() ); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java index ba1415e4db..9c9059f8f5 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java @@ -45,11 +45,11 @@ public final class TestSheetPropertiesRecord extends TestCase { } assertEquals(0, in.remaining()); assertEquals( 10, record.getFlags()); - assertEquals( false, record.isChartTypeManuallyFormatted() ); - assertEquals( true, record.isPlotVisibleOnly() ); - assertEquals( false, record.isDoNotSizeWithWindow() ); - assertEquals( true, record.isDefaultPlotDimensions() ); - assertEquals( false, record.isAutoPlotArea() ); + assertFalse(record.isChartTypeManuallyFormatted()); + assertTrue(record.isPlotVisibleOnly()); + assertFalse(record.isDoNotSizeWithWindow()); + assertTrue(record.isDefaultPlotDimensions()); + assertFalse(record.isAutoPlotArea()); assertEquals( 0, record.getEmpty()); assertEquals( 8, record.getRecordSize() ); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java index 4214b0a370..cdca0f82b8 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java @@ -57,19 +57,19 @@ public final class TestTextRecord extends TestCase { assertEquals( 0, record.getWidth()); assertEquals( 0, record.getHeight()); assertEquals( 177, record.getOptions1()); - assertEquals( true, record.isAutoColor() ); - assertEquals( false, record.isShowKey() ); - assertEquals( false, record.isShowValue() ); - assertEquals( false, record.isVertical() ); - assertEquals( true, record.isAutoGeneratedText() ); - assertEquals( true, record.isGenerated() ); - assertEquals( false, record.isAutoLabelDeleted() ); - assertEquals( true, record.isAutoBackground() ); + assertTrue(record.isAutoColor()); + assertFalse(record.isShowKey()); + assertFalse(record.isShowValue()); + assertFalse(record.isVertical()); + assertTrue(record.isAutoGeneratedText()); + assertTrue(record.isGenerated()); + assertFalse(record.isAutoLabelDeleted()); + assertTrue(record.isAutoBackground()); assertEquals( TextRecord.ROTATION_NONE, record.getRotation() ); - assertEquals( false, record.isShowCategoryLabelAsPercentage() ); - assertEquals( false, record.isShowValueAsPercentage() ); - assertEquals( false, record.isShowBubbleSizes() ); - assertEquals( false, record.isShowLabel() ); + assertFalse(record.isShowCategoryLabelAsPercentage()); + assertFalse(record.isShowValueAsPercentage()); + assertFalse(record.isShowBubbleSizes()); + assertFalse(record.isShowLabel()); assertEquals( 77, record.getIndexOfColorValue()); assertEquals( 11088, record.getOptions2()); assertEquals( 0, record.getDataLabelPlacement() ); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java index 28d13178fc..0f2b1353bb 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java @@ -50,10 +50,10 @@ public final class TestTickRecord extends TestCase { assertEquals( (short)0, record.getZero1()); assertEquals( (short)0, record.getZero2()); assertEquals( (short)35, record.getOptions()); - assertEquals( true, record.isAutoTextColor() ); - assertEquals( true, record.isAutoTextBackground() ); + assertTrue(record.isAutoTextColor()); + assertTrue(record.isAutoTextBackground()); assertEquals( (short)0x0, record.getRotation() ); - assertEquals( true, record.isAutorotate() ); + assertTrue(record.isAutorotate()); assertEquals( (short)77, record.getTickColor()); assertEquals( (short)0x0, record.getZero3()); diff --git a/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java b/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java index d2a08df4a5..abd3badc44 100644 --- a/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java @@ -49,15 +49,15 @@ public final class TestValueRangeRecord extends TestCase { assertEquals( 0.0, record.getMinorIncrement(), 0.001); assertEquals( 0.0, record.getCategoryAxisCross(), 0.001); assertEquals( 0x011f, record.getOptions()); - assertEquals( true, record.isAutomaticMinimum() ); - assertEquals( true, record.isAutomaticMaximum() ); - assertEquals( true, record.isAutomaticMajor() ); - assertEquals( true, record.isAutomaticMinor() ); - assertEquals( true, record.isAutomaticCategoryCrossing() ); - assertEquals( false, record.isLogarithmicScale() ); - assertEquals( false, record.isValuesInReverse() ); - assertEquals( false, record.isCrossCategoryAxisAtMaximum() ); - assertEquals( true, record.isReserved() ); + assertTrue(record.isAutomaticMinimum()); + assertTrue(record.isAutomaticMaximum()); + assertTrue(record.isAutomaticMajor()); + assertTrue(record.isAutomaticMinor()); + assertTrue(record.isAutomaticCategoryCrossing()); + assertFalse(record.isLogarithmicScale()); + assertFalse(record.isValuesInReverse()); + assertFalse(record.isCrossCategoryAxisAtMaximum()); + assertTrue(record.isReserved()); assertEquals( 42+4, record.getRecordSize() ); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java index cbeb00223f..bd03399c28 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java @@ -152,8 +152,8 @@ public final class TestCellStyle extends TestCase { assertEquals(cs1.hashCode(), cs1.hashCode()); assertEquals(cs2.hashCode(), cs2.hashCode()); - assertTrue(cs1.equals(cs1)); - assertTrue(cs2.equals(cs2)); + assertEquals(cs1, cs1); + assertEquals(cs2, cs2); // Change cs1, hash will alter int hash1 = cs1.hashCode(); @@ -238,8 +238,8 @@ public final class TestCellStyle extends TestCase { assertEquals(18, orig.getDataFormat()); HSSFCellStyle clone = wb.createCellStyle(); - assertFalse(HorizontalAlignment.RIGHT == clone.getAlignment()); - assertFalse(fnt == clone.getFont(wb)); + assertNotSame(HorizontalAlignment.RIGHT, clone.getAlignment()); + assertNotSame(fnt, clone.getFont(wb)); assertFalse(18 == clone.getDataFormat()); clone.cloneStyleFrom(orig); @@ -280,9 +280,9 @@ public final class TestCellStyle extends TestCase { HSSFCellStyle clone = wbClone.createCellStyle(); assertEquals(4, wbClone.getNumberOfFonts()); - - assertFalse(HorizontalAlignment.RIGHT == clone.getAlignment()); - assertFalse("TestingFont" == clone.getFont(wbClone).getFontName()); + + assertNotSame(HorizontalAlignment.RIGHT, clone.getAlignment()); + assertNotSame("TestingFont", clone.getFont(wbClone).getFontName()); clone.cloneStyleFrom(orig); assertEquals(HorizontalAlignment.RIGHT, clone.getAlignment()); @@ -333,9 +333,9 @@ public final class TestCellStyle extends TestCase { assertNotNull(wb.getWorkbook().getStyleRecord(22)); // Now check the style names - assertEquals(null, cs1.getUserStyleName()); - assertEquals(null, cs2.getUserStyleName()); - assertEquals(null, cs3.getUserStyleName()); + assertNull(cs1.getUserStyleName()); + assertNull(cs2.getUserStyleName()); + assertNull(cs3.getUserStyleName()); assertEquals("style1", cs2.getParentStyle().getUserStyleName()); assertEquals("style2", cs3.getParentStyle().getUserStyleName()); @@ -394,7 +394,7 @@ public final class TestCellStyle extends TestCase { HSSFRow r = s.getRow(0); HSSFCellStyle cs = r.getCell(0).getCellStyle(); - assertEquals(true, cs.getShrinkToFit()); + assertTrue(cs.getShrinkToFit()); // New file HSSFWorkbook wbOrig = new HSSFWorkbook(); @@ -413,8 +413,8 @@ public final class TestCellStyle extends TestCase { wb = HSSFTestDataSamples.writeOutAndReadBack(wbOrig); s = wb.getSheetAt(0); r = s.getRow(0); - assertEquals(false, r.getCell(0).getCellStyle().getShrinkToFit()); - assertEquals(true, r.getCell(1).getCellStyle().getShrinkToFit()); + assertFalse(r.getCell(0).getCellStyle().getShrinkToFit()); + assertTrue(r.getCell(1).getCellStyle().getShrinkToFit()); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java b/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java index 13b7895ed2..e5ddcaa7f7 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java @@ -18,6 +18,8 @@ package org.apache.poi.hssf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -249,12 +251,12 @@ public final class TestDataValidation extends BaseTestDataValidation { assertEquals(3, address.getFirstColumn()); assertEquals(4, address.getLastColumn()); } - assertEquals(true, dv.getEmptyCellAllowed()); - assertEquals(false, dv.getSuppressDropDownArrow()); - assertEquals(true, dv.getShowErrorBox()); + assertTrue(dv.getEmptyCellAllowed()); + assertFalse(dv.getSuppressDropDownArrow()); + assertTrue(dv.getShowErrorBox()); assertEquals("error-title", dv.getErrorBoxTitle()); assertEquals("error-text", dv.getErrorBoxText()); - assertEquals(true, dv.getShowPromptBox()); + assertTrue(dv.getShowPromptBox()); assertEquals("prompt-title", dv.getPromptBoxTitle()); assertEquals("prompt-text", dv.getPromptBoxText()); @@ -288,8 +290,8 @@ public final class TestDataValidation extends BaseTestDataValidation { assertEquals(OperatorType.BETWEEN, c.getOperator()); assertEquals("A2", c.getFormula1()); assertEquals("A3", c.getFormula2()); - assertEquals(null, c.getValue1()); - assertEquals(null, c.getValue2()); + assertNull(c.getValue1()); + assertNull(c.getValue2()); wb.close(); } @@ -315,8 +317,8 @@ public final class TestDataValidation extends BaseTestDataValidation { DVConstraint c = dv.getConstraint(); assertEquals(ValidationType.INTEGER, c.getValidationType()); assertEquals(OperatorType.BETWEEN, c.getOperator()); - assertEquals(null, c.getFormula1()); - assertEquals(null, c.getFormula2()); + assertNull(c.getFormula1()); + assertNull(c.getFormula2()); assertEquals(new Double("100"), c.getValue1()); assertEquals(new Double("200"), c.getValue2()); @@ -345,8 +347,8 @@ public final class TestDataValidation extends BaseTestDataValidation { assertEquals(ValidationType.DECIMAL, c.getValidationType()); assertEquals(OperatorType.BETWEEN, c.getOperator()); assertEquals("A2", c.getFormula1()); - assertEquals(null, c.getFormula2()); - assertEquals(null, c.getValue1()); + assertNull(c.getFormula2()); + assertNull(c.getValue1()); assertEquals(new Double("200"), c.getValue2()); wb.close(); @@ -373,10 +375,10 @@ public final class TestDataValidation extends BaseTestDataValidation { DVConstraint c = dv.getConstraint(); assertEquals(ValidationType.DATE, c.getValidationType()); assertEquals(OperatorType.EQUAL, c.getOperator()); - assertEquals(null, c.getFormula1()); - assertEquals(null, c.getFormula2()); + assertNull(c.getFormula1()); + assertNull(c.getFormula2()); assertEquals(DateUtil.getExcelDate(DateUtil.parseYYYYMMDDDate("2014/10/25")), c.getValue1(), 0); - assertEquals(null, c.getValue2()); + assertNull(c.getValue2()); wb.close(); } @@ -400,14 +402,14 @@ public final class TestDataValidation extends BaseTestDataValidation { assertEquals(1, list.size()); HSSFDataValidation dv = list.get(0); - assertEquals(true, dv.getSuppressDropDownArrow()); + assertTrue(dv.getSuppressDropDownArrow()); DVConstraint c = dv.getConstraint(); assertEquals(ValidationType.LIST, c.getValidationType()); - assertEquals(null, c.getFormula1()); - assertEquals(null, c.getFormula2()); - assertEquals(null, c.getValue1()); - assertEquals(null, c.getValue2()); + assertNull(c.getFormula1()); + assertNull(c.getFormula2()); + assertNull(c.getValue1()); + assertNull(c.getValue2()); String[] values = c.getExplicitListValues(); assertEquals(3, values.length); assertEquals("aaa", values[0]); @@ -435,14 +437,14 @@ public final class TestDataValidation extends BaseTestDataValidation { assertEquals(1, list.size()); HSSFDataValidation dv = list.get(0); - assertEquals(true, dv.getSuppressDropDownArrow()); + assertTrue(dv.getSuppressDropDownArrow()); DVConstraint c = dv.getConstraint(); assertEquals(ValidationType.LIST, c.getValidationType()); assertEquals("A2", c.getFormula1()); - assertEquals(null, c.getFormula2()); - assertEquals(null, c.getValue1()); - assertEquals(null, c.getValue2()); + assertNull(c.getFormula2()); + assertNull(c.getValue1()); + assertNull(c.getValue2()); wb.close(); } @@ -467,9 +469,9 @@ public final class TestDataValidation extends BaseTestDataValidation { DVConstraint c = dv.getConstraint(); assertEquals(ValidationType.FORMULA, c.getValidationType()); assertEquals("A2:A3", c.getFormula1()); - assertEquals(null, c.getFormula2()); - assertEquals(null, c.getValue1()); - assertEquals(null, c.getValue2()); + assertNull(c.getFormula2()); + assertNull(c.getValue1()); + assertNull(c.getValue2()); wb.close(); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java index 130e0fd84b..e765936b01 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java @@ -140,7 +140,7 @@ public final class TestEscherGraphics2d { public void testDraw() { graphics.draw(new Line2D.Double(10,10,20,20)); HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0); - assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE); + assertEquals(s.getShapeType(), HSSFSimpleShape.OBJECT_TYPE_LINE); assertEquals(10, s.getAnchor().getDx1()); assertEquals(10, s.getAnchor().getDy1()); assertEquals(20, s.getAnchor().getDx2()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java index 60d0ccfdec..61103829af 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; @@ -265,7 +266,7 @@ public final class TestFormulaEvaluatorBugs { } catch (NumberFormatException e) { fail("Identified bug 44508"); } - assertEquals(true, cell.getBooleanCellValue()); + assertTrue(cell.getBooleanCellValue()); wb.close(); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java index 7cd88fe93b..1eea909b3c 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -66,7 +67,7 @@ public final class TestFormulas { r = s.getRow(1); c = r.getCell(1); - assertTrue("Formula is as expected",("1+1".equals(c.getCellFormula()))); + assertEquals("Formula is as expected", "1+1", c.getCellFormula()); wb2.close(); } @@ -209,10 +210,9 @@ public final class TestFormulas { for (int y = 1; y < 256 && y > 0; y=(short)(y+2)) { HSSFCell c = r.getCell(y); - assertTrue("got a formula",c.getCellFormula()!=null); + assertNotNull("got a formula", c.getCellFormula()); - assertTrue("loop Formula is as expected "+x+"."+y+operator+y+"."+x+"!="+c.getCellFormula(),( - (""+x+"."+y+operator+y+"."+x).equals(c.getCellFormula()) )); + assertEquals("loop Formula is as expected " + x + "." + y + operator + y + "." + x + "!=" + c.getCellFormula(), ("" + x + "." + y + operator + y + "." + x), c.getCellFormula()); } } } @@ -316,9 +316,7 @@ public final class TestFormulas { r = s.getRow(0); c = r.getCell(1); //get our minimum values - assertTrue("minval Formula is as expected A2"+operator+"A3 != "+c.getCellFormula(), - ( ("A2"+operator+"A3").equals(c.getCellFormula()) - )); + assertEquals("minval Formula is as expected A2" + operator + "A3 != " + c.getCellFormula(), ("A2" + operator + "A3"), c.getCellFormula()); for (int x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) { @@ -354,10 +352,7 @@ public final class TestFormulas { String ref2=cr.formatAsString(); - assertTrue("loop Formula is as expected "+ref+operator+ref2+"!="+c.getCellFormula(),( - (""+ref+operator+ref2).equals(c.getCellFormula()) - ) - ); + assertEquals("loop Formula is as expected " + ref + operator + ref2 + "!=" + c.getCellFormula(), ("" + ref + operator + ref2), c.getCellFormula()); } } @@ -391,7 +386,7 @@ public final class TestFormulas { //get our minimum values r = s.getRow(0); c = r.getCell(1); - assertTrue("minval Formula is as expected", formula.equals(c.getCellFormula())); + assertEquals("minval Formula is as expected", formula, c.getCellFormula()); wb2.close(); } @@ -446,9 +441,7 @@ public final class TestFormulas { //get our minimum values r = s.getRow(0); c = r.getCell(1); - assertTrue("minval Formula is as expected 1"+operator+"1 != "+c.getCellFormula(), - ( ("1"+operator+"1").equals(c.getCellFormula()) - )); + assertEquals("minval Formula is as expected 1" + operator + "1 != " + c.getCellFormula(), ("1" + operator + "1"), c.getCellFormula()); for (int x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) { r = s.getRow(x); @@ -457,10 +450,7 @@ public final class TestFormulas { c = r.getCell(y); - assertTrue("loop Formula is as expected "+x+operator+y+"!="+c.getCellFormula(),( - (""+x+operator+y).equals(c.getCellFormula()) - ) - ); + assertEquals("loop Formula is as expected " + x + operator + y + "!=" + c.getCellFormula(), ("" + x + operator + y), c.getCellFormula()); } } @@ -468,10 +458,7 @@ public final class TestFormulas { r = s.getRow(0); c = r.getCell(0); - assertTrue("maxval Formula is as expected",( - (""+Short.MAX_VALUE+operator+Short.MAX_VALUE).equals(c.getCellFormula()) - ) - ); + assertEquals("maxval Formula is as expected", ("" + Short.MAX_VALUE + operator + Short.MAX_VALUE), c.getCellFormula()); } /** @@ -496,9 +483,7 @@ public final class TestFormulas { r = s.getRow(0); c = r.getCell(0); - assertTrue("function ="+function+"(A2:A3)", - ( (function+"(A2:A3)").equals((function+"(A2:A3)")) ) - ); + assertEquals("function =" + function + "(A2:A3)", (function + "(A2:A3)"), (function + "(A2:A3)")); wb2.close(); } @@ -524,9 +509,7 @@ public final class TestFormulas { r = s.getRow(0); c = r.getCell(0); - assertTrue("function ="+function+"(A2,A3)", - ( (function+"(A2,A3)").equals(c.getCellFormula()) ) - ); + assertEquals("function =" + function + "(A2,A3)", (function + "(A2,A3)"), c.getCellFormula()); wb2.close(); } @@ -556,14 +539,10 @@ public final class TestFormulas { r = s.getRow(0); c = r.getCell(0); - assertTrue("function ="+function+"(A2:A4,B2:B4)", - ( (function+"(A2:A4,B2:B4)").equals(c.getCellFormula()) ) - ); + assertEquals("function =" + function + "(A2:A4,B2:B4)", (function + "(A2:A4,B2:B4)"), c.getCellFormula()); c=r.getCell(1); - assertTrue("function ="+function+"($A$2:$A4,B$2:B4)", - ( (function+"($A$2:$A4,B$2:B4)").equals(c.getCellFormula()) ) - ); + assertEquals("function =" + function + "($A$2:$A4,B$2:B4)", (function + "($A$2:$A4,B$2:B4)"), c.getCellFormula()); wb2.close(); } @@ -592,15 +571,15 @@ public final class TestFormulas { s = wb2.getSheetAt(0); r = s.getRow(0); c = r.getCell(0); - assertTrue("A3+A2", ("A3+A2").equals(c.getCellFormula())); + assertEquals("A3+A2", ("A3+A2"), c.getCellFormula()); c = r.getCell(1); - assertTrue("$A3+$A2", ("$A3+$A2").equals(c.getCellFormula())); + assertEquals("$A3+$A2", ("$A3+$A2"), c.getCellFormula()); c = r.getCell(2); - assertTrue("A$3+A$2", ("A$3+A$2").equals(c.getCellFormula())); + assertEquals("A$3+A$2", ("A$3+A$2"), c.getCellFormula()); c = r.getCell(3); - assertTrue("$A$3+$A$2", ("$A$3+$A$2").equals(c.getCellFormula())); + assertEquals("$A$3+$A$2", ("$A$3+$A$2"), c.getCellFormula()); c = r.getCell(4); - assertTrue("SUM($A$3,$A$2)", ("SUM($A$3,$A$2)").equals(c.getCellFormula())); + assertEquals("SUM($A$3,$A$2)", ("SUM($A$3,$A$2)"), c.getCellFormula()); wb2.close(); } @@ -626,9 +605,9 @@ public final class TestFormulas { s = wb2.getSheet("B"); r = s.getRow(0); c = r.getCell(0); - assertTrue("expected: AVERAGE(A!A1:B1) got: "+c.getCellFormula(), ("AVERAGE(A!A1:B1)").equals(c.getCellFormula())); + assertEquals("expected: AVERAGE(A!A1:B1) got: " + c.getCellFormula(), ("AVERAGE(A!A1:B1)"), c.getCellFormula()); c = r.getCell(1); - assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula())); + assertEquals("expected: A!A1+A!B1 got: " + c.getCellFormula(), ("A!A1+A!B1"), c.getCellFormula()); wb2.close(); } @@ -760,14 +739,14 @@ public final class TestFormulas { r = s.getRow(0); c = r.getCell(4); - assertTrue("expected: IF(A1=D1,\"A1\",\"B1\") got "+c.getCellFormula(), ("IF(A1=D1,\"A1\",\"B1\")").equals(c.getCellFormula())); + assertEquals("expected: IF(A1=D1,\"A1\",\"B1\") got " + c.getCellFormula(), ("IF(A1=D1,\"A1\",\"B1\")"), c.getCellFormula()); wb2.close(); wb1 = openSample("IfFormulaTest.xls"); s = wb1.getSheetAt(0); r = s.getRow(3); c = r.getCell(0); - assertTrue("expected: IF(A3=A1,\"A1\",\"A2\") got "+c.getCellFormula(), ("IF(A3=A1,\"A1\",\"A2\")").equals(c.getCellFormula())); + assertEquals("expected: IF(A3=A1,\"A1\",\"A2\") got " + c.getCellFormula(), ("IF(A3=A1,\"A1\",\"A2\")"), c.getCellFormula()); //c = r.getCell((short)1); //assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula())); wb1.close(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index aac0747579..f6e5afbd81 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; @@ -377,7 +378,7 @@ public final class TestHSSFCell extends BaseTestCell { if (isPresent) { assertEquals(StringRecord.class, recs[index++].getClass()); } else { - assertFalse(StringRecord.class == recs[index].getClass()); + assertNotSame(StringRecord.class, recs[index].getClass()); } Record dbcr = recs[index]; assertEquals(DBCellRecord.class, dbcr.getClass()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java index 74e7765056..62ecf00a4f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java @@ -19,8 +19,10 @@ package org.apache.poi.hssf.usermodel; import static org.apache.poi.poifs.storage.RawDataUtil.decompress; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -332,7 +334,7 @@ public final class TestHSSFComment extends BaseTestCellComment { assertEquals(comment.getRow(), 4); comment.setVisible(false); - assertEquals(comment.isVisible(), false); + assertFalse(comment.isVisible()); HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb); sh = wbBack.getSheetAt(0); @@ -344,7 +346,7 @@ public final class TestHSSFComment extends BaseTestCellComment { assertEquals("poi", comment.getAuthor()); assertEquals(comment.getColumn(), 3); assertEquals(comment.getRow(), 4); - assertEquals(comment.isVisible(), false); + assertFalse(comment.isVisible()); comment.setString(new HSSFRichTextString("comment12")); comment.setAuthor("poi2"); @@ -361,7 +363,7 @@ public final class TestHSSFComment extends BaseTestCellComment { assertEquals("poi2", comment.getAuthor()); assertEquals(comment.getColumn(), 32); assertEquals(comment.getRow(), 42); - assertEquals(comment.isVisible(), true); + assertTrue(comment.isVisible()); wb.close(); wbBack.close(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java index ed72f82a8f..7ee4525989 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.text.DecimalFormat; @@ -240,7 +241,7 @@ public final class TestHSSFDataFormatter { // should not be equal to "555.555" assertTrue( DateUtil.isCellDateFormatted(cell) ); - assertTrue( ! "555.555".equals(fmtval)); + assertFalse("555.555".equals(fmtval)); String fmt = cell.getCellStyle().getDataFormatString(); @@ -270,7 +271,7 @@ public final class TestHSSFDataFormatter { // should not be equal to "555.47431" assertTrue( DateUtil.isCellDateFormatted(cell) ); - assertTrue( ! "555.47431".equals(fmtval)); + assertFalse("555.47431".equals(fmtval)); // check we found the time properly assertTrue("Format came out incorrect - " + fmt + " - found " + fmtval + diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java index 9338dfa652..758b0fe10f 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java @@ -107,7 +107,7 @@ public final class TestHSSFPalette { assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPattern()); assertEquals(FillPatternType.NO_FILL, cellA.getCellStyle().getFillPatternEnum()); assertEquals("0:0:0", p.getColor((short)64).getHexString()); - assertEquals(null, p.getColor((short)32767)); + assertNull(p.getColor((short) 32767)); // Red assertEquals("I'm red", cellB.getStringCellValue()); diff --git a/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java b/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java index 7b88fbc650..9a87b3fe7f 100644 --- a/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java +++ b/src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java @@ -18,6 +18,7 @@ package org.apache.poi.poifs.eventfilesystem; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.HashSet; @@ -67,7 +68,7 @@ public final class TestPOIFSReaderRegistry { Iterator<POIFSReaderListener> listeners = registry.getListeners(path, name).iterator(); - assertTrue(!listeners.hasNext()); + assertFalse(listeners.hasNext()); } } } @@ -102,7 +103,7 @@ public final class TestPOIFSReaderRegistry { if (k == n) { - assertTrue(!listeners.iterator().hasNext()); + assertFalse(listeners.iterator().hasNext()); } else { @@ -118,8 +119,8 @@ public final class TestPOIFSReaderRegistry { { if (j == k) { - assertTrue(!registeredListeners - .contains(this.listeners[ j ])); + assertFalse(registeredListeners + .contains(this.listeners[j])); } else { diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java index 41d1a340f0..366bc4387e 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java @@ -86,7 +86,7 @@ public final class TestDirectoryNode extends TestCase { assertEquals(property2.getName(), node.getName()); // verify behavior of isDocumentEntry - assertTrue(!node.isDocumentEntry()); + assertFalse(node.isDocumentEntry()); // verify behavior of getParent assertEquals(parent, node.getParent()); @@ -117,7 +117,7 @@ public final class TestDirectoryNode extends TestCase { assertEquals(2, count); // verify behavior of isEmpty - assertTrue(!node.isEmpty()); + assertFalse(node.isEmpty()); // verify behavior of getEntryCount assertEquals(2, node.getEntryCount()); @@ -145,7 +145,7 @@ public final class TestDirectoryNode extends TestCase { assertEquals(property1.getName(), node.getName()); // verify behavior of isDocumentEntry - assertTrue(!node.isDocumentEntry()); + assertFalse(node.isDocumentEntry()); // verify behavior of getParent assertNull(node.getParent()); @@ -202,14 +202,14 @@ public final class TestDirectoryNode extends TestCase { DirectoryEntry root = fs.getRoot(); // verify cannot rename the root directory - assertTrue(!root.renameTo("foo")); + assertFalse(root.renameTo("foo")); DirectoryEntry dir = fs.createDirectory("myDir"); assertTrue(dir.renameTo("foo")); assertEquals("foo", dir.getName()); DirectoryEntry dir2 = fs.createDirectory("myDir"); - assertTrue(!dir2.renameTo("foo")); + assertFalse(dir2.renameTo("foo")); assertEquals("myDir", dir2.getName()); assertTrue(dir.renameTo("FirstDir")); assertTrue(dir2.renameTo("foo")); diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java index 9b69b1a2cb..8a6e7da480 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java @@ -60,8 +60,7 @@ public final class TestDocumentDescriptor extends TestCase { } else { - assertTrue("" + j + "," + k + "," + m + "," + n, - !d1.equals(d2)); + assertFalse(d1.equals(d2)); } } } @@ -126,8 +125,7 @@ public final class TestDocumentDescriptor extends TestCase { } else { - assertTrue("" + j + "," + k + "," + m + "," + n, - !(d1.equals(d2))); + assertFalse(d1.equals(d2)); } } } @@ -165,8 +163,7 @@ public final class TestDocumentDescriptor extends TestCase { new DocumentDescriptor(builtUpPaths[ k ], names[ n ]); - assertTrue("" + j + "," + k + "," + m + "," + n, - !(d1.equals(d2))); + assertFalse(d1.equals(d2)); } } } diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java b/src/testcases/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java index 9494fcfcc6..b1fa580f75 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java @@ -59,20 +59,20 @@ public final class TestFilteringDirectoryNode { assertEquals(3, d.getEntryCount()); assertEquals(dirA.getName(), d.getEntry(dirA.getName()).getName()); - assertEquals(true, d.getEntry(dirA.getName()).isDirectoryEntry()); - assertEquals(false, d.getEntry(dirA.getName()).isDocumentEntry()); + assertTrue(d.getEntry(dirA.getName()).isDirectoryEntry()); + assertFalse(d.getEntry(dirA.getName()).isDocumentEntry()); - assertEquals(true, d.getEntry(dirB.getName()).isDirectoryEntry()); - assertEquals(false, d.getEntry(dirB.getName()).isDocumentEntry()); + assertTrue(d.getEntry(dirB.getName()).isDirectoryEntry()); + assertFalse(d.getEntry(dirB.getName()).isDocumentEntry()); - assertEquals(false, d.getEntry(eRoot.getName()).isDirectoryEntry()); - assertEquals(true, d.getEntry(eRoot.getName()).isDocumentEntry()); + assertFalse(d.getEntry(eRoot.getName()).isDirectoryEntry()); + assertTrue(d.getEntry(eRoot.getName()).isDocumentEntry()); Iterator<Entry> i = d.getEntries(); assertEquals(dirA, i.next()); assertEquals(dirB, i.next()); assertEquals(eRoot, i.next()); - assertEquals(null, i.next()); + assertNull(i.next()); } @Test @@ -81,9 +81,9 @@ public final class TestFilteringDirectoryNode { FilteringDirectoryNode d = new FilteringDirectoryNode(fs.getRoot(), excl); assertEquals(2, d.getEntryCount()); - assertEquals(true, d.hasEntry(dirA.getName())); - assertEquals(true, d.hasEntry(dirB.getName())); - assertEquals(false, d.hasEntry(eRoot.getName())); + assertTrue(d.hasEntry(dirA.getName())); + assertTrue(d.hasEntry(dirB.getName())); + assertFalse(d.hasEntry(eRoot.getName())); assertEquals(dirA, d.getEntry(dirA.getName())); assertEquals(dirB, d.getEntry(dirB.getName())); @@ -96,7 +96,7 @@ public final class TestFilteringDirectoryNode { Iterator<Entry> i = d.getEntries(); assertEquals(dirA, i.next()); assertEquals(dirB, i.next()); - assertEquals(null, i.next()); + assertNull(i.next()); // Filter more @@ -104,9 +104,9 @@ public final class TestFilteringDirectoryNode { d = new FilteringDirectoryNode(fs.getRoot(), excl); assertEquals(1, d.getEntryCount()); - assertEquals(false, d.hasEntry(dirA.getName())); - assertEquals(true, d.hasEntry(dirB.getName())); - assertEquals(false, d.hasEntry(eRoot.getName())); + assertFalse(d.hasEntry(dirA.getName())); + assertTrue(d.hasEntry(dirB.getName())); + assertFalse(d.hasEntry(eRoot.getName())); try { d.getEntry(dirA.getName()); @@ -122,7 +122,7 @@ public final class TestFilteringDirectoryNode { i = d.getEntries(); assertEquals(dirB, i.next()); - assertEquals(null, i.next()); + assertNull(i.next()); // Filter everything @@ -130,9 +130,9 @@ public final class TestFilteringDirectoryNode { d = new FilteringDirectoryNode(fs.getRoot(), excl); assertEquals(0, d.getEntryCount()); - assertEquals(false, d.hasEntry(dirA.getName())); - assertEquals(false, d.hasEntry(dirB.getName())); - assertEquals(false, d.hasEntry(eRoot.getName())); + assertFalse(d.hasEntry(dirA.getName())); + assertFalse(d.hasEntry(dirB.getName())); + assertFalse(d.hasEntry(eRoot.getName())); try { d.getEntry(dirA.getName()); @@ -151,7 +151,7 @@ public final class TestFilteringDirectoryNode { } i = d.getEntries(); - assertEquals(null, i.next()); + assertNull(i.next()); } @Test @@ -166,20 +166,20 @@ public final class TestFilteringDirectoryNode { // Check main assertEquals(2, d.getEntryCount()); - assertEquals(true, d.hasEntry(dirA.getName())); - assertEquals(true, d.hasEntry(dirB.getName())); - assertEquals(false, d.hasEntry(eRoot.getName())); + assertTrue(d.hasEntry(dirA.getName())); + assertTrue(d.hasEntry(dirB.getName())); + assertFalse(d.hasEntry(eRoot.getName())); // Check filtering down - assertEquals(true, d.getEntry(dirA.getName()) instanceof FilteringDirectoryNode); - assertEquals(false, d.getEntry(dirB.getName()) instanceof FilteringDirectoryNode); + assertTrue(d.getEntry(dirA.getName()) instanceof FilteringDirectoryNode); + assertFalse(d.getEntry(dirB.getName()) instanceof FilteringDirectoryNode); DirectoryEntry fdA = (DirectoryEntry) d.getEntry(dirA.getName()); - assertEquals(false, fdA.hasEntry(eA.getName())); - assertEquals(true, fdA.hasEntry(dirAA.getName())); + assertFalse(fdA.hasEntry(eA.getName())); + assertTrue(fdA.hasEntry(dirAA.getName())); DirectoryEntry fdAA = (DirectoryEntry) fdA.getEntry(dirAA.getName()); - assertEquals(true, fdAA.hasEntry(eAA.getName())); + assertTrue(fdAA.hasEntry(eAA.getName())); } @Test(expected = IllegalArgumentException.class) diff --git a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java index aec1f20d6e..cc91dd602a 100644 --- a/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java +++ b/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java @@ -271,8 +271,7 @@ public final class TestPOIFSDocumentPath extends TestCase { } else { - assertTrue(j + "<>" + k, - !(fullPaths[ j ].equals(builtUpPaths[ k ]))); + assertFalse(fullPaths[j].equals(builtUpPaths[k])); } } } @@ -297,8 +296,7 @@ public final class TestPOIFSDocumentPath extends TestCase { { for (int j = 0; j < badPaths.length; j++) { - assertTrue(j + "<>" + k, - !(fullPaths[ k ].equals(badPaths[ j ]))); + assertFalse(fullPaths[k].equals(badPaths[j])); } } } diff --git a/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java b/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java index 2d94aba13a..c14c5dd17f 100644 --- a/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java +++ b/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java @@ -18,6 +18,7 @@ package org.apache.poi.poifs.property; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -129,8 +130,7 @@ public final class TestDirectoryProperty { if (index != -1) { - assertTrue("found index " + index + " twice", - !found[ index - 1 ]); + assertFalse(found[index - 1]); found[ index - 1 ] = true; total_found++; } @@ -143,8 +143,7 @@ public final class TestDirectoryProperty { if (index != -1) { - assertTrue("found index " + index + " twice", - !found[ index - 1 ]); + assertFalse(found[index - 1]); found[ index - 1 ] = true; total_found++; } @@ -246,7 +245,7 @@ public final class TestDirectoryProperty { // as expected } assertTrue(_property.deleteChild(p1)); - assertTrue(!_property.deleteChild(p1)); + assertFalse(_property.deleteChild(p1)); _property.addChild(new LocalProperty(1)); } @@ -259,12 +258,12 @@ public final class TestDirectoryProperty { _property.addChild(p1); assertTrue(_property.changeName(p1, "foobar")); assertEquals("foobar", p1.getName()); - assertTrue(!_property.changeName(p1, "foobar")); + assertFalse(_property.changeName(p1, "foobar")); assertEquals("foobar", p1.getName()); Property p2 = new LocalProperty(1); _property.addChild(p2); - assertTrue(!_property.changeName(p1, originalName)); + assertFalse(_property.changeName(p1, originalName)); assertTrue(_property.changeName(p2, "foo")); assertTrue(_property.changeName(p1, originalName)); } @@ -299,6 +298,6 @@ public final class TestDirectoryProperty { } assertEquals(index, property.getIndex()); assertEquals(name, property.getName()); - assertTrue(!property.getChildren().hasNext()); + assertFalse(property.getChildren().hasNext()); } } diff --git a/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java b/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java index d4442e859a..61b230d4ff 100644 --- a/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java +++ b/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java @@ -100,7 +100,7 @@ public final class TestDocumentProperty extends TestCase { if (size >= 4096) { - assertTrue(!property.shouldUseSmallBlocks()); + assertFalse(property.shouldUseSmallBlocks()); } else { diff --git a/src/testcases/org/apache/poi/poifs/property/TestRootProperty.java b/src/testcases/org/apache/poi/poifs/property/TestRootProperty.java index 27708a4b61..5553bb7b10 100644 --- a/src/testcases/org/apache/poi/poifs/property/TestRootProperty.java +++ b/src/testcases/org/apache/poi/poifs/property/TestRootProperty.java @@ -18,6 +18,7 @@ package org.apache.poi.poifs.property; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -131,7 +132,7 @@ public final class TestRootProperty { } assertEquals(index, property.getIndex()); assertEquals(name, property.getName()); - assertTrue(!property.getChildren().hasNext()); + assertFalse(property.getChildren().hasNext()); assertEquals(property.getStorageClsid().toString(), sClsId); } } diff --git a/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java b/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java index 371188edb6..fe7b087c2c 100644 --- a/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java +++ b/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java @@ -20,6 +20,7 @@ package org.apache.poi.sl.draw.geom; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.awt.geom.Path2D; @@ -52,7 +53,7 @@ public class TestPresetGeometries { } // we get the same instance on further calls - assertTrue(shapes == PresetGeometries.getInstance()); + assertSame(shapes, PresetGeometries.getInstance()); } // helper methods to adjust list of presets for other tests 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)); } diff --git a/src/testcases/org/apache/poi/util/TestBitField.java b/src/testcases/org/apache/poi/util/TestBitField.java index a5c953a435..1070f1389f 100644 --- a/src/testcases/org/apache/poi/util/TestBitField.java +++ b/src/testcases/org/apache/poi/util/TestBitField.java @@ -60,22 +60,22 @@ public final class TestBitField extends TestCase { } public void testIsSet() { - assertTrue(!bf_multi.isSet(0)); + assertFalse(bf_multi.isSet(0)); for (int j = 0x80; j <= 0x3F80; j += 0x80) { assertTrue(bf_multi.isSet(j)); } - assertTrue(!bf_single.isSet(0)); + assertFalse(bf_single.isSet(0)); assertTrue(bf_single.isSet(0x4000)); } public void testIsAllSet() { for (int j = 0; j < 0x3F80; j += 0x80) { - assertTrue(!bf_multi.isAllSet(j)); + assertFalse(bf_multi.isAllSet(j)); } assertTrue(bf_multi.isAllSet(0x3F80)); - assertTrue(!bf_single.isAllSet(0)); + assertFalse(bf_single.isAllSet(0)); assertTrue(bf_single.isAllSet(0x4000)); } @@ -148,7 +148,7 @@ public final class TestBitField extends TestCase { byte clearedBit = BitFieldFactory.getInstance(0x40).setByteBoolean(( byte ) -63, false); - assertEquals(false, BitFieldFactory.getInstance(0x40).isSet(clearedBit)); + assertFalse(BitFieldFactory.getInstance(0x40).isSet(clearedBit)); } public void testClear() { diff --git a/src/testcases/org/apache/poi/util/TestIntList.java b/src/testcases/org/apache/poi/util/TestIntList.java index 7f5f721f50..25d427d361 100644 --- a/src/testcases/org/apache/poi/util/TestIntList.java +++ b/src/testcases/org/apache/poi/util/TestIntList.java @@ -21,6 +21,8 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -279,7 +281,7 @@ public final class TestIntList { assertEquals(list, list); //noinspection ObjectEqualsNull - assertFalse(list.equals(null)); + assertNotEquals(null, list); IntList list2 = new IntList(200); assertEquals(list, list2); @@ -289,15 +291,15 @@ public final class TestIntList { list.add(1); list2.add(1); list2.add(0); - assertFalse(list.equals(list2)); + assertNotEquals(list, list2); list2.removeValue(1); list2.add(1); assertEquals(list, list2); assertEquals(list2, list); assertEquals(list.hashCode(), list2.hashCode()); list2.add(2); - assertFalse(list.equals(list2)); - assertFalse(list2.equals(list)); + assertNotEquals(list, list2); + assertNotEquals(list2, list); } @Test @@ -604,8 +606,8 @@ public final class TestIntList { int[] a4 = list.toArray(aShort); int[] a5 = list.toArray(aLong); - assertTrue(a4 != aShort); - assertTrue(a5 != aLong); + assertNotSame(a4, aShort); + assertNotSame(a5, aLong); assertEquals(a4.length, list.size()); for (int j = 0; j < 1000; j++) { diff --git a/src/testcases/org/apache/poi/util/TestTempFile.java b/src/testcases/org/apache/poi/util/TestTempFile.java index 020081073a..47fa72dbe8 100644 --- a/src/testcases/org/apache/poi/util/TestTempFile.java +++ b/src/testcases/org/apache/poi/util/TestTempFile.java @@ -17,7 +17,7 @@ package org.apache.poi.util; 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; @@ -140,7 +140,7 @@ public class TestTempFile { // Should be able to create two tempfiles with same prefix and suffix File file1 = TempFile.createTempFile("TestTempFile", ".tst"); File file2 = TempFile.createTempFile("TestTempFile", ".tst"); - assertFalse(file1.equals(file2)); + assertNotEquals(file1, file2); assertNotNull(file2); assertTrue(file2.delete()); assertNotNull(file1); |