Browse Source

Let IntelliJ simplify some assertions

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871591 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_4_1_2
Dominik Stadler 4 years ago
parent
commit
5e394a5e10
100 changed files with 564 additions and 555 deletions
  1. 2
    3
      src/java/org/apache/poi/ss/format/CellNumberFormatter.java
  2. 4
    6
      src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
  3. 2
    2
      src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java
  4. 2
    2
      src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
  5. 16
    14
      src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java
  6. 3
    4
      src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java
  7. 1
    1
      src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
  8. 8
    8
      src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java
  9. 1
    1
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java
  10. 13
    12
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
  11. 5
    3
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
  12. 5
    3
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
  13. 3
    3
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
  14. 10
    14
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
  15. 1
    1
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
  16. 8
    5
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
  17. 2
    1
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
  18. 15
    13
      src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
  19. 1
    1
      src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
  20. 1
    1
      src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
  21. 2
    2
      src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java
  22. 2
    1
      src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java
  23. 2
    2
      src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java
  24. 4
    4
      src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java
  25. 3
    3
      src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java
  26. 3
    3
      src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
  27. 1
    1
      src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java
  28. 39
    39
      src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java
  29. 8
    8
      src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java
  30. 4
    3
      src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java
  31. 3
    2
      src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java
  32. 7
    7
      src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestMAPIProperty.java
  33. 4
    4
      src/scratchpad/testcases/org/apache/poi/hwpf/model/PlfLfoTest.java
  34. 1
    1
      src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java
  35. 2
    1
      src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
  36. 1
    1
      src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
  37. 26
    25
      src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java
  38. 23
    18
      src/testcases/org/apache/poi/hpsf/basic/TestClassID.java
  39. 2
    2
      src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java
  40. 2
    2
      src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java
  41. 13
    14
      src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
  42. 19
    18
      src/testcases/org/apache/poi/hssf/model/TestEscherRecordFactory.java
  43. 4
    4
      src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
  44. 1
    1
      src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java
  45. 1
    1
      src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java
  46. 32
    21
      src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java
  47. 2
    2
      src/testcases/org/apache/poi/hssf/model/TestLinkTable.java
  48. 4
    4
      src/testcases/org/apache/poi/hssf/model/TestSheet.java
  49. 1
    1
      src/testcases/org/apache/poi/hssf/model/TestWorkbook.java
  50. 1
    1
      src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java
  51. 7
    7
      src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java
  52. 2
    2
      src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java
  53. 4
    4
      src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java
  54. 4
    10
      src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java
  55. 1
    1
      src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java
  56. 2
    2
      src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
  57. 3
    3
      src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java
  58. 3
    2
      src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java
  59. 2
    1
      src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java
  60. 2
    2
      src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java
  61. 3
    3
      src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java
  62. 8
    8
      src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java
  63. 4
    4
      src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java
  64. 3
    3
      src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java
  65. 4
    4
      src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java
  66. 1
    1
      src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java
  67. 2
    2
      src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java
  68. 6
    6
      src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java
  69. 2
    2
      src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java
  70. 1
    1
      src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java
  71. 6
    6
      src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java
  72. 5
    5
      src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java
  73. 12
    12
      src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java
  74. 3
    3
      src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java
  75. 9
    9
      src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java
  76. 13
    13
      src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
  77. 27
    25
      src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java
  78. 1
    1
      src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java
  79. 2
    1
      src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
  80. 23
    44
      src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
  81. 2
    1
      src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
  82. 5
    3
      src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
  83. 3
    2
      src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
  84. 1
    1
      src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java
  85. 5
    4
      src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java
  86. 5
    5
      src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
  87. 3
    6
      src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java
  88. 27
    27
      src/testcases/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java
  89. 2
    4
      src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
  90. 7
    8
      src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java
  91. 1
    1
      src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
  92. 2
    1
      src/testcases/org/apache/poi/poifs/property/TestRootProperty.java
  93. 2
    1
      src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java
  94. 3
    2
      src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java
  95. 1
    1
      src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java
  96. 3
    2
      src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java
  97. 2
    1
      src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
  98. 3
    2
      src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java
  99. 2
    2
      src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java
  100. 0
    0
      src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java

+ 2
- 3
src/java/org/apache/poi/ss/format/CellNumberFormatter.java View File

@@ -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) {

+ 4
- 6
src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java View File

@@ -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();
}


+ 2
- 2
src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java View File

@@ -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

+ 2
- 2
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java View File

@@ -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());

+ 16
- 14
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java View File

@@ -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) {

+ 3
- 4
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java View File

@@ -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

+ 1
- 1
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java View File

@@ -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()));


+ 8
- 8
src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java View File

@@ -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);
}
}


+ 1
- 1
src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java View File

@@ -101,7 +101,7 @@ public abstract class BaseTestXSSFPivotTable {
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnIndex);
CTPivotTableDefinition defintion = pivotTable.getCTPivotTableDefinition();

assertEquals(defintion.getColFields(), null);
assertNull(defintion.getColFields());
}

/**

+ 13
- 12
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java View File

@@ -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());


+ 5
- 3
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java View File

@@ -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());

+ 5
- 3
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java View File

@@ -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());
}
}


+ 3
- 3
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java View File

@@ -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} ,

+ 10
- 14
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java View File

@@ -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(

+ 1
- 1
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java View File

@@ -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());


+ 8
- 5
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java View File

@@ -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 {

+ 2
- 1
src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java View File

@@ -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);

+ 15
- 13
src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java View File

@@ -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);
}
}

+ 1
- 1
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java View File

@@ -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());
}

+ 1
- 1
src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java View File

@@ -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());
}

+ 2
- 2
src/scratchpad/testcases/org/apache/poi/hmef/TestHMEFMessage.java View File

@@ -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");

+ 2
- 1
src/scratchpad/testcases/org/apache/poi/hpbf/TestHPBFDocument.java View File

@@ -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();
}

+ 2
- 2
src/scratchpad/testcases/org/apache/poi/hslf/model/TestHeadersFooters.java View File

@@ -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();

+ 4
- 4
src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentAtom.java View File

@@ -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 {

+ 3
- 3
src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java View File

@@ -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 {

+ 3
- 3
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java View File

@@ -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

+ 1
- 1
src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java View File

@@ -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());
}

+ 39
- 39
src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java View File

@@ -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());

+ 8
- 8
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList.java View File

@@ -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());

+ 4
- 3
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList2.java View File

@@ -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());

+ 3
- 2
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestNumberedList3.java View File

@@ -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)) {

+ 7
- 7
src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestMAPIProperty.java View File

@@ -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));
}
}

+ 4
- 4
src/scratchpad/testcases/org/apache/poi/hwpf/model/PlfLfoTest.java View File

@@ -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);
}
}

+ 1
- 1
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestCHPBinTable.java View File

@@ -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);
}

}

+ 2
- 1
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java View File

@@ -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);

}


+ 1
- 1
src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java View File

@@ -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();

+ 26
- 25
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.java View File

@@ -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();

+ 23
- 18
src/testcases/org/apache/poi/hpsf/basic/TestClassID.java View File

@@ -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}"
);
}

+ 2
- 2
src/testcases/org/apache/poi/hssf/eventmodel/TestAbortableListener.java View File

@@ -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);

+ 2
- 2
src/testcases/org/apache/poi/hssf/eventmodel/TestEventRecordFactory.java View File

@@ -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]));
}

+ 13
- 14
src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java View File

@@ -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);
}
}

+ 19
- 18
src/testcases/org/apache/poi/hssf/model/TestEscherRecordFactory.java View File

@@ -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);
}
}

+ 4
- 4
src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java View File

@@ -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*/

+ 1
- 1
src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java View File

@@ -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());
}

+ 1
- 1
src/testcases/org/apache/poi/hssf/model/TestFormulaParserIf.java View File

@@ -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());

+ 32
- 21
src/testcases/org/apache/poi/hssf/model/TestHSSFAnchor.java View File

@@ -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);

+ 2
- 2
src/testcases/org/apache/poi/hssf/model/TestLinkTable.java View File

@@ -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());
}

+ 4
- 4
src/testcases/org/apache/poi/hssf/model/TestSheet.java View File

@@ -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);

+ 1
- 1
src/testcases/org/apache/poi/hssf/model/TestWorkbook.java View File

@@ -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());

+ 1
- 1
src/testcases/org/apache/poi/hssf/record/TestBoolErrRecord.java View File

@@ -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();

+ 7
- 7
src/testcases/org/apache/poi/hssf/record/TestCFHeaderRecord.java View File

@@ -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());
}

+ 2
- 2
src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java View File

@@ -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());
}


+ 4
- 4
src/testcases/org/apache/poi/hssf/record/TestCommonObjectDataSubRecord.java View File

@@ -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());

+ 4
- 10
src/testcases/org/apache/poi/hssf/record/TestDConRefRecord.java View File

@@ -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);
}

/**

+ 1
- 1
src/testcases/org/apache/poi/hssf/record/TestExtSSTRecord.java View File

@@ -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);
}
}


+ 2
- 2
src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java View File

@@ -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());
}
}

+ 3
- 3
src/testcases/org/apache/poi/hssf/record/TestMergeCellsRecord.java View File

@@ -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() {

+ 3
- 2
src/testcases/org/apache/poi/hssf/record/TestSSTRecord.java View File

@@ -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);
}
}

+ 2
- 1
src/testcases/org/apache/poi/hssf/record/aggregates/TestRowRecordsAggregate.java View File

@@ -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);
}

/**

+ 2
- 2
src/testcases/org/apache/poi/hssf/record/chart/TestAreaFormatRecord.java View File

@@ -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());


+ 3
- 3
src/testcases/org/apache/poi/hssf/record/chart/TestAreaRecord.java View File

@@ -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() );

+ 8
- 8
src/testcases/org/apache/poi/hssf/record/chart/TestAxisOptionsRecord.java View File

@@ -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() );
}

+ 4
- 4
src/testcases/org/apache/poi/hssf/record/chart/TestBarRecord.java View File

@@ -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() );
}

+ 3
- 3
src/testcases/org/apache/poi/hssf/record/chart/TestCategorySeriesAxisRecord.java View File

@@ -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() );
}

+ 4
- 4
src/testcases/org/apache/poi/hssf/record/chart/TestDatRecord.java View File

@@ -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() );
}

+ 1
- 1
src/testcases/org/apache/poi/hssf/record/chart/TestDataFormatRecord.java View File

@@ -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() );
}

+ 2
- 2
src/testcases/org/apache/poi/hssf/record/chart/TestFrameRecord.java View File

@@ -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() );
}

+ 6
- 6
src/testcases/org/apache/poi/hssf/record/chart/TestLegendRecord.java View File

@@ -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());
}

+ 2
- 2
src/testcases/org/apache/poi/hssf/record/chart/TestLineFormatRecord.java View File

@@ -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() );

+ 1
- 1
src/testcases/org/apache/poi/hssf/record/chart/TestLinkedDataRecord.java View File

@@ -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,

+ 6
- 6
src/testcases/org/apache/poi/hssf/record/chart/TestSeriesLabelsRecord.java View File

@@ -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() );

+ 5
- 5
src/testcases/org/apache/poi/hssf/record/chart/TestSheetPropertiesRecord.java View File

@@ -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() );

+ 12
- 12
src/testcases/org/apache/poi/hssf/record/chart/TestTextRecord.java View File

@@ -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() );

+ 3
- 3
src/testcases/org/apache/poi/hssf/record/chart/TestTickRecord.java View File

@@ -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());


+ 9
- 9
src/testcases/org/apache/poi/hssf/record/chart/TestValueRangeRecord.java View File

@@ -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() );
}

+ 13
- 13
src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java View File

@@ -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());
}

+ 27
- 25
src/testcases/org/apache/poi/hssf/usermodel/TestDataValidation.java View File

@@ -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();
}
}

+ 1
- 1
src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java View File

@@ -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());

+ 2
- 1
src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java View File

@@ -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();
}

+ 23
- 44
src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java View File

@@ -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();

+ 2
- 1
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java View File

@@ -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());

+ 5
- 3
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java View File

@@ -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();

+ 3
- 2
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java View File

@@ -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 +

+ 1
- 1
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPalette.java View File

@@ -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());

+ 5
- 4
src/testcases/org/apache/poi/poifs/eventfilesystem/TestPOIFSReaderRegistry.java View File

@@ -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
{

+ 5
- 5
src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java View File

@@ -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"));

+ 3
- 6
src/testcases/org/apache/poi/poifs/filesystem/TestDocumentDescriptor.java View File

@@ -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));
}
}
}

+ 27
- 27
src/testcases/org/apache/poi/poifs/filesystem/TestFilteringDirectoryNode.java View File

@@ -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)

+ 2
- 4
src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java View File

@@ -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]));
}
}
}

+ 7
- 8
src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java View File

@@ -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());
}
}

+ 1
- 1
src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java View File

@@ -100,7 +100,7 @@ public final class TestDocumentProperty extends TestCase {

if (size >= 4096)
{
assertTrue(!property.shouldUseSmallBlocks());
assertFalse(property.shouldUseSmallBlocks());
}
else
{

+ 2
- 1
src/testcases/org/apache/poi/poifs/property/TestRootProperty.java View File

@@ -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);
}
}

+ 2
- 1
src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java View File

@@ -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

+ 3
- 2
src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java View File

@@ -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();

+ 1
- 1
src/testcases/org/apache/poi/ss/formula/TestPlainCellCache.java View File

@@ -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));

+ 3
- 2
src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java View File

@@ -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();
}

+ 2
- 1
src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java View File

@@ -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();
}

+ 3
- 2
src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java View File

@@ -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());
}
}

+ 2
- 2
src/testcases/org/apache/poi/ss/formula/functions/TestTFunc.java View File

@@ -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

+ 0
- 0
src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save