aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2019-12-15 14:53:46 +0000
committerDominik Stadler <centic@apache.org>2019-12-15 14:53:46 +0000
commit5e394a5e10bc986f4caa2d4f29d4ffa088581cbf (patch)
tree0a5b70fe699af700697c31e3daeff022a24e27bb /src/ooxml/testcases/org
parent1a5cec89d8d36f2a7cd5643b221befd57fa515b7 (diff)
downloadpoi-5e394a5e10bc986f4caa2d4f29d4ffa088581cbf.tar.gz
poi-5e394a5e10bc986f4caa2d4f29d4ffa088581cbf.zip
Let IntelliJ simplify some assertions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871591 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org')
-rw-r--r--src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java4
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java4
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java30
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java16
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java25
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java24
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java13
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java28
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java2
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java2
19 files changed, 101 insertions, 95 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
index 9e1f00ead6..08081e711b 100644
--- a/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
+++ b/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
@@ -85,9 +85,8 @@ public class TestPackagingURIHelper extends TestCase {
// Relative part name
PackagePartName relativeName = PackagingURIHelper.createPartName(
"media/image1.gif", partBase);
- assertTrue("The part name must be equal to "
- + partNameToValid.getName(), partNameToValid
- .equals(relativeName));
+ assertEquals("The part name must be equal to "
+ + partNameToValid.getName(), partNameToValid, relativeName);
pkg.revert();
}
@@ -106,9 +105,8 @@ public class TestPackagingURIHelper extends TestCase {
// Relative part name
PackagePartName relativeName = PackagingURIHelper.createPartName(
new URI("media/image1.gif"), partBase);
- assertTrue("The part name must be equal to "
- + partNameToValid.getName(), partNameToValid
- .equals(relativeName));
+ assertEquals("The part name must be equal to "
+ + partNameToValid.getName(), partNameToValid, relativeName);
pkg.revert();
}
diff --git a/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java b/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java
index 47d71ff613..2b517448d6 100644
--- a/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java
+++ b/src/ooxml/testcases/org/apache/poi/xdgf/usermodel/section/CombinedIteratorTest.java
@@ -31,11 +31,11 @@ public class CombinedIteratorTest {
Iterator<String> iter = iterable.iterator();
for (String element : expected) {
- Assert.assertEquals(true, iter.hasNext());
+ Assert.assertTrue(iter.hasNext());
Assert.assertEquals(element, iter.next());
}
- Assert.assertEquals(false, iter.hasNext());
+ Assert.assertFalse(iter.hasNext());
}
@Test
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
index 7e7d708ced..9c83ae9253 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
@@ -265,13 +265,13 @@ public class TestXSLFAutoShape {
assertFalse(rPr.isSetB());
r.setBold(true);
assertTrue(r.isBold());
- assertEquals(true, rPr.getB());
+ assertTrue(rPr.getB());
assertFalse(r.isItalic());
assertFalse(rPr.isSetI());
r.setItalic(true);
assertTrue(r.isItalic());
- assertEquals(true, rPr.getI());
+ assertTrue(rPr.getI());
assertFalse(r.isUnderlined());
assertFalse(rPr.isSetU());
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java
index 412520aede..493a0b89df 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFChart.java
@@ -21,6 +21,8 @@ package org.apache.poi.xslf.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -188,7 +190,7 @@ public class TestXSLFChart {
XDDFChartData firstSeries = data.get(0);
assertNotNull(firstSeries);
if (firstSeries instanceof XDDFScatterChartData) {
- assertEquals(null, firstSeries.getCategoryAxis());
+ assertNull(firstSeries.getCategoryAxis());
assertEquals(2, firstSeries.getValueAxes().size());
checkAxisOperations(firstSeries.getValueAxes().get(0));
checkAxisOperations(firstSeries.getValueAxes().get(1));
@@ -219,10 +221,10 @@ public class TestXSLFChart {
* According to interface, 0.0 should be returned for
* uninitialized double properties.
*/
- assertTrue(layout.getX() == 0.0);
- assertTrue(layout.getY() == 0.0);
- assertTrue(layout.getWidthRatio() == 0.0);
- assertTrue(layout.getHeightRatio() == 0.0);
+ assertEquals(0.0, layout.getX(), 0.0);
+ assertEquals(0.0, layout.getY(), 0.0);
+ assertEquals(0.0, layout.getWidthRatio(), 0.0);
+ assertEquals(0.0, layout.getHeightRatio(), 0.0);
final double newRatio = 1.1;
final double newCoordinate = 0.3;
@@ -230,31 +232,31 @@ public class TestXSLFChart {
final LayoutTarget nonDefaultTarget = LayoutTarget.OUTER;
layout.setWidthRatio(newRatio);
- assertTrue(layout.getWidthRatio() == newRatio);
+ assertEquals(layout.getWidthRatio(), newRatio, 0.0);
layout.setHeightRatio(newRatio);
- assertTrue(layout.getHeightRatio() == newRatio);
+ assertEquals(layout.getHeightRatio(), newRatio, 0.0);
layout.setX(newCoordinate);
- assertTrue(layout.getX() == newCoordinate);
+ assertEquals(layout.getX(), newCoordinate, 0.0);
layout.setY(newCoordinate);
- assertTrue(layout.getY() == newCoordinate);
+ assertEquals(layout.getY(), newCoordinate, 0.0);
layout.setXMode(nonDefaultMode);
- assertTrue(layout.getXMode() == nonDefaultMode);
+ assertSame(layout.getXMode(), nonDefaultMode);
layout.setYMode(nonDefaultMode);
- assertTrue(layout.getYMode() == nonDefaultMode);
+ assertSame(layout.getYMode(), nonDefaultMode);
layout.setWidthMode(nonDefaultMode);
- assertTrue(layout.getWidthMode() == nonDefaultMode);
+ assertSame(layout.getWidthMode(), nonDefaultMode);
layout.setHeightMode(nonDefaultMode);
- assertTrue(layout.getHeightMode() == nonDefaultMode);
+ assertSame(layout.getHeightMode(), nonDefaultMode);
layout.setTarget(nonDefaultTarget);
- assertTrue(layout.getTarget() == nonDefaultTarget);
+ assertSame(layout.getTarget(), nonDefaultTarget);
}
private void checkAxisOperations(XDDFValueAxis axis) {
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java
index c80fafef18..315a8f561c 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFPictureShape.java
@@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -177,8 +178,7 @@ public class TestXSLFPictureShape {
XSLFTextBox tb1 = group.createTextBox();
XSLFTextBox tb2 = group.createTextBox();
- assertFalse("We should have different names now, but had: " + tb1.getShapeName() + " for both",
- tb1.getShapeName().equals(tb2.getShapeName()));
+ assertNotEquals("We should have different names now, but had: " + tb1.getShapeName() + " for both", tb1.getShapeName(), tb2.getShapeName());
XMLSlideShow pptCopy = new XMLSlideShow();
@@ -216,8 +216,7 @@ public class TestXSLFPictureShape {
}
private void differentShapeName(XSLFShape shape1, XSLFShape shape2) {
- assertFalse("We should have different names now, but had: " + shape1.getShapeName() + " for both",
- shape1.getShapeName().equals(shape2.getShapeName()));
+ assertNotEquals("We should have different names now, but had: " + shape1.getShapeName() + " for both", shape1.getShapeName(), shape2.getShapeName());
}
@Test
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
index ba26fb8e95..2cb7c412ce 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
@@ -283,7 +283,7 @@ public class TestXSLFTextParagraph {
p.setBulletFont("Calibri");
assertEquals("Calibri", p.getBulletFont());
- assertEquals(null, p.getBulletFontColor());
+ assertNull(p.getBulletFontColor());
p.setBulletFontColor(Color.red);
assertTrue(sameColor(Color.red, p.getBulletFontColor()));
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java
index e93239d940..6ba55c0692 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFImportFromXML.java
@@ -75,14 +75,14 @@ public class TestXSSFImportFromXML {
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
- assertTrue(row.getCell(0).getStringCellValue().equals(name));
- assertTrue(row.getCell(1).getStringCellValue().equals(teacher));
- assertTrue(row.getCell(2).getStringCellValue().equals(tutor));
- assertTrue(row.getCell(3).getStringCellValue().equals(cdl));
- assertTrue(row.getCell(4).getStringCellValue().equals(duration));
- assertTrue(row.getCell(5).getStringCellValue().equals(topic));
- assertTrue(row.getCell(6).getStringCellValue().equals(project));
- assertTrue(row.getCell(7).getStringCellValue().equals(credits));
+ assertEquals(row.getCell(0).getStringCellValue(), name);
+ assertEquals(row.getCell(1).getStringCellValue(), teacher);
+ assertEquals(row.getCell(2).getStringCellValue(), tutor);
+ assertEquals(row.getCell(3).getStringCellValue(), cdl);
+ assertEquals(row.getCell(4).getStringCellValue(), duration);
+ assertEquals(row.getCell(5).getStringCellValue(), topic);
+ assertEquals(row.getCell(6).getStringCellValue(), project);
+ assertEquals(row.getCell(7).getStringCellValue(), credits);
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java
index fb83269f4a..dcb793cf9f 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/BaseTestXSSFPivotTable.java
@@ -101,7 +101,7 @@ public abstract class BaseTestXSSFPivotTable {
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnIndex);
CTPivotTableDefinition defintion = pivotTable.getCTPivotTableDefinition();
- assertEquals(defintion.getColFields(), null);
+ assertNull(defintion.getColFields());
}
/**
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
index abd769aed7..8d068ca678 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColGrouping.java
@@ -18,6 +18,7 @@
package org.apache.poi.xssf.usermodel;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -129,17 +130,17 @@ public class TestXSSFColGrouping {
assertEquals(0, cols.getColArray(0).getOutlineLevel());
assertEquals(2, cols.getColArray(0).getMin()); // 1 based
assertEquals(2, cols.getColArray(0).getMax()); // 1 based
- assertEquals(true, cols.getColArray(0).getCustomWidth());
+ assertTrue(cols.getColArray(0).getCustomWidth());
assertEquals(1, cols.getColArray(1).getOutlineLevel());
assertEquals(3, cols.getColArray(1).getMin()); // 1 based
assertEquals(4, cols.getColArray(1).getMax()); // 1 based
- assertEquals(true, cols.getColArray(1).getCustomWidth());
+ assertTrue(cols.getColArray(1).getCustomWidth());
assertEquals(0, cols.getColArray(2).getOutlineLevel());
assertEquals(5, cols.getColArray(2).getMin()); // 1 based
assertEquals(5, cols.getColArray(2).getMax()); // 1 based
- assertEquals(true, cols.getColArray(2).getCustomWidth());
+ assertTrue(cols.getColArray(2).getCustomWidth());
assertEquals(3, cols.sizeOfColArray());
@@ -177,17 +178,17 @@ public class TestXSSFColGrouping {
assertEquals(1, cols.getColArray(0).getOutlineLevel());
assertEquals(2, cols.getColArray(0).getMin()); // 1 based
assertEquals(2, cols.getColArray(0).getMax()); // 1 based
- assertEquals(false, cols.getColArray(0).getCustomWidth());
+ assertFalse(cols.getColArray(0).getCustomWidth());
assertEquals(1, cols.getColArray(1).getOutlineLevel());
assertEquals(3, cols.getColArray(1).getMin()); // 1 based
assertEquals(5, cols.getColArray(1).getMax()); // 1 based
- assertEquals(true, cols.getColArray(1).getCustomWidth());
+ assertTrue(cols.getColArray(1).getCustomWidth());
assertEquals(1, cols.getColArray(2).getOutlineLevel());
assertEquals(6, cols.getColArray(2).getMin()); // 1 based
assertEquals(6, cols.getColArray(2).getMax()); // 1 based
- assertEquals(false, cols.getColArray(2).getCustomWidth());
+ assertFalse(cols.getColArray(2).getCustomWidth());
assertEquals(3, cols.sizeOfColArray());
@@ -225,17 +226,17 @@ public class TestXSSFColGrouping {
assertEquals(0, cols.getColArray(0).getOutlineLevel());
assertEquals(3, cols.getColArray(0).getMin()); // 1 based
assertEquals(3, cols.getColArray(0).getMax()); // 1 based
- assertEquals(true, cols.getColArray(0).getCustomWidth());
+ assertTrue(cols.getColArray(0).getCustomWidth());
assertEquals(1, cols.getColArray(1).getOutlineLevel());
assertEquals(4, cols.getColArray(1).getMin()); // 1 based
assertEquals(5, cols.getColArray(1).getMax()); // 1 based
- assertEquals(true, cols.getColArray(1).getCustomWidth());
+ assertTrue(cols.getColArray(1).getCustomWidth());
assertEquals(1, cols.getColArray(2).getOutlineLevel());
assertEquals(6, cols.getColArray(2).getMin()); // 1 based
assertEquals(6, cols.getColArray(2).getMax()); // 1 based
- assertEquals(false, cols.getColArray(2).getCustomWidth());
+ assertFalse(cols.getColArray(2).getCustomWidth());
assertEquals(3, cols.sizeOfColArray());
@@ -274,17 +275,17 @@ public class TestXSSFColGrouping {
assertEquals(1, cols.getColArray(0).getOutlineLevel());
assertEquals(2, cols.getColArray(0).getMin()); // 1 based
assertEquals(2, cols.getColArray(0).getMax()); // 1 based
- assertEquals(false, cols.getColArray(0).getCustomWidth());
+ assertFalse(cols.getColArray(0).getCustomWidth());
assertEquals(1, cols.getColArray(1).getOutlineLevel());
assertEquals(3, cols.getColArray(1).getMin()); // 1 based
assertEquals(4, cols.getColArray(1).getMax()); // 1 based
- assertEquals(true, cols.getColArray(1).getCustomWidth());
+ assertTrue(cols.getColArray(1).getCustomWidth());
assertEquals(0, cols.getColArray(2).getOutlineLevel());
assertEquals(5, cols.getColArray(2).getMin()); // 1 based
assertEquals(5, cols.getColArray(2).getMax()); // 1 based
- assertEquals(true, cols.getColArray(2).getCustomWidth());
+ assertTrue(cols.getColArray(2).getCustomWidth());
assertEquals(3, cols.sizeOfColArray());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
index d8d7554d47..c11879b71b 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
@@ -19,9 +19,11 @@ package org.apache.poi.xssf.usermodel;
import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_SPREADSHEETML;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.FileOutputStream;
@@ -77,11 +79,11 @@ public final class TestXSSFComment extends BaseTestCellComment {
CTShape vmlShape = CTShape.Factory.newInstance();
XSSFComment comment = new XSSFComment(sheetComments, ctComment, vmlShape);
- assertEquals(null, comment.getString());
+ assertNull(comment.getString());
assertEquals(0, comment.getRow());
assertEquals(0, comment.getColumn());
assertEquals("", comment.getAuthor());
- assertEquals(false, comment.isVisible());
+ assertFalse(comment.isVisible());
}
@Test
@@ -168,7 +170,7 @@ public final class TestXSSFComment extends BaseTestCellComment {
assertSame(comment.getString(), richText);
//check that the rich text is set in the comment
CTRPrElt rPr = richText.getCTRst().getRArray(0).getRPr();
- assertEquals(true, rPr.getIArray(0).getVal());
+ assertTrue(rPr.getIArray(0).getVal());
assertEquals(8.5, rPr.getSzArray(0).getVal(), 0);
assertEquals(IndexedColors.BLUE_GREY.getIndex(), rPr.getColorArray(0).getIndexed());
assertEquals("Tahoma", rPr.getRFontArray(0).getVal());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
index 0394f6fdd2..8a6e791b45 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
@@ -17,6 +17,8 @@
package org.apache.poi.xssf.usermodel;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.math.BigDecimal;
@@ -323,7 +325,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
sheet.addValidationData(validation);
final List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
- assertEquals(true, dataValidations.get(0).getCtDdataValidation().getAllowBlank());
+ assertTrue(dataValidations.get(0).getCtDdataValidation().getAllowBlank());
}
}
@@ -338,7 +340,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
sheet.addValidationData(validation);
final List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
- assertEquals(false, dataValidations.get(0).getCtDdataValidation().getAllowBlank());
+ assertFalse(dataValidations.get(0).getCtDdataValidation().getAllowBlank());
}
}
@@ -353,7 +355,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
sheet.addValidationData(validation);
final List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
- assertEquals(true, dataValidations.get(0).getCtDdataValidation().getAllowBlank());
+ assertTrue(dataValidations.get(0).getCtDdataValidation().getAllowBlank());
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
index 714202e599..aacd1c18db 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
@@ -210,7 +210,7 @@ public class TestXSSFDrawing {
XSSFShape sh1 = shapes1.get(i);
XSSFShape sh2 = shapes2.get(i);
- assertTrue(sh1.getClass() == sh2.getClass());
+ assertSame(sh1.getClass(), sh2.getClass());
assertEquals(sh1.getShapeProperties().toString(), sh2.getShapeProperties().toString());
}
@@ -246,8 +246,8 @@ public class TestXSSFDrawing {
assertEquals(1, pr.sizeOfRArray());
CTTextCharacterProperties rPr = pr.getRArray(0).getRPr();
- assertEquals(true, rPr.getB());
- assertEquals(true, rPr.getI());
+ assertTrue(rPr.getB());
+ assertTrue(rPr.getI());
assertEquals(STTextUnderlineType.SNG, rPr.getU());
assertArrayEquals(
new byte[]{0, (byte)128, (byte)128} ,
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
index f55621ccbd..7186034e4b 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
@@ -72,12 +72,12 @@ public final class TestXSSFFont extends BaseTestFont{
bool.setVal(false);
ctFont.setBArray(0,bool);
XSSFFont xssfFont=new XSSFFont(ctFont);
- assertEquals(false, xssfFont.getBold());
+ assertFalse(xssfFont.getBold());
xssfFont.setBold(true);
assertEquals(ctFont.sizeOfBArray(),1);
- assertEquals(true, ctFont.getBArray(0).getVal());
+ assertTrue(ctFont.getBArray(0).getVal());
}
@SuppressWarnings("deprecation")
@@ -105,7 +105,7 @@ public final class TestXSSFFont extends BaseTestFont{
assertEquals(FontCharset.ARABIC.getValue(), xssfFont.getCharSet());
// This one isn't allowed
- assertEquals(null, FontCharset.valueOf(9999));
+ assertNull(FontCharset.valueOf(9999));
try {
xssfFont.setCharSet(9999);
fail("Shouldn't be able to set an invalid charset");
@@ -153,12 +153,12 @@ public final class TestXSSFFont extends BaseTestFont{
ctFont.setIArray(0,bool);
XSSFFont xssfFont=new XSSFFont(ctFont);
- assertEquals(false, xssfFont.getItalic());
+ assertFalse(xssfFont.getItalic());
xssfFont.setItalic(true);
assertEquals(ctFont.sizeOfIArray(),1);
- assertEquals(true, ctFont.getIArray(0).getVal());
- assertEquals(true,ctFont.getIArray(0).getVal());
+ assertTrue(ctFont.getIArray(0).getVal());
+ assertTrue(ctFont.getIArray(0).getVal());
}
@Test
@@ -169,12 +169,12 @@ public final class TestXSSFFont extends BaseTestFont{
ctFont.setStrikeArray(0,bool);
XSSFFont xssfFont=new XSSFFont(ctFont);
- assertEquals(false, xssfFont.getStrikeout());
+ assertFalse(xssfFont.getStrikeout());
xssfFont.setStrikeout(true);
assertEquals(ctFont.sizeOfStrikeArray(),1);
- assertEquals(true, ctFont.getStrikeArray(0).getVal());
- assertEquals(true,ctFont.getStrikeArray(0).getVal());
+ assertTrue(ctFont.getStrikeArray(0).getVal());
+ assertTrue(ctFont.getStrikeArray(0).getVal());
}
@Test
@@ -399,11 +399,7 @@ public final class TestXSSFFont extends BaseTestFont{
assertEquals(2, wb.getNumberOfFonts());
assertEquals(nf, wb.getFontAt(1));
- assertTrue(
- wb.getFontAt(0)
- !=
- wb.getFontAt(1)
- );
+ assertNotSame(wb.getFontAt(0), wb.getFontAt(1));
// Find it now
assertNotNull(
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
index edaa974a2c..885b3d55c7 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPicture.java
@@ -75,7 +75,7 @@ public final class TestXSSFPicture extends BaseTestPicture {
assertEquals(AnchorType.DONT_MOVE_AND_RESIZE, anchor.getAnchorType());
XSSFPicture shape = drawing.createPicture(anchor, jpegIdx);
- assertTrue(anchor.equals(shape.getAnchor()));
+ assertEquals(anchor, shape.getAnchor());
assertNotNull(shape.getPictureData());
assertArrayEquals(jpegData, shape.getPictureData().getData());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index 67da55b3a5..a6e5ec4e2d 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -48,6 +48,7 @@ import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.openxml4j.opc.internal.FileHelper;
@@ -802,7 +803,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
}
try (XSSFWorkbook wb2 = (XSSFWorkbook) WorkbookFactory.create(file)) {
- assertTrue(wb2.getPivotTables().size() == 1);
+ assertEquals(1, wb2.getPivotTables().size());
}
assertTrue(file.delete());
@@ -822,7 +823,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
try (XSSFWorkbook wb2 = (XSSFWorkbook) WorkbookFactory.create(file)) {
setPivotData(wb2);
- assertTrue(wb2.getPivotTables().size() == 2);
+ assertEquals(2, wb2.getPivotTables().size());
}
assertTrue(file.delete());
@@ -890,7 +891,9 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
assertTrue(wbPart.hasRelationships());
final PackageRelationshipCollection relationships = wbPart.getRelationships().getRelationships(XSSFRelation.VBA_MACROS.getRelation());
assertEquals(1, relationships.size());
- assertEquals(XSSFRelation.VBA_MACROS.getDefaultFileName(), relationships.getRelationship(0).getTargetURI().toString());
+ PackageRelationship relationship = relationships.getRelationship(0);
+ assertNotNull(relationship);
+ assertEquals(XSSFRelation.VBA_MACROS.getDefaultFileName(), relationship.getTargetURI().toString());
PackagePart vbaPart = pkg.getPart(PackagingURIHelper.createPartName(XSSFRelation.VBA_MACROS.getDefaultFileName()));
assertNotNull(vbaPart);
assertFalse(vbaPart.isRelationshipPart());
@@ -984,6 +987,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
wb.close();
}
+ @SuppressWarnings("deprecation")
@Test
public void testBug56957CloseWorkbook() throws Exception {
File file = TempFile.createTempFile("TestBug56957_", ".xlsx");
@@ -1027,7 +1031,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
}
@Test
- public void closeDoesNotModifyWorkbook() throws IOException, InvalidFormatException {
+ public void closeDoesNotModifyWorkbook() throws IOException {
final String filename = "SampleSS.xlsx";
final File file = POIDataSamples.getSpreadSheetInstance().getFile(filename);
Workbook wb;
@@ -1146,7 +1150,6 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
/**
* See bug #61700
- * @throws Exception
*/
@Test
public void testWorkbookForceFormulaRecalculation() throws Exception {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
index f85f44d22a..d0388175e1 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
@@ -19,6 +19,7 @@ package org.apache.poi.xssf.usermodel.charts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -139,7 +140,7 @@ public class TestXSSFChartTitle {
XSSFRichTextString originalTitle = chart.getTitleText();
assertNotNull(originalTitle);
final String myTitle = "My chart title";
- assertFalse(myTitle.equals(originalTitle.toString()));
+ assertNotEquals(myTitle, originalTitle.toString());
chart.setTitleText(myTitle);
XSSFRichTextString queryTitle = chart.getTitleText();
assertNotNull(queryTitle);
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
index 85ac30f30f..6cfe2f14a0 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
@@ -17,7 +17,9 @@
package org.apache.poi.xssf.usermodel.charts;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -68,31 +70,31 @@ public final class TestXSSFManualLayout {
final LayoutTarget nonDefaultTarget = LayoutTarget.OUTER;
layout.setWidthRatio(newRatio);
- assertTrue(layout.getWidthRatio() == newRatio);
+ assertEquals(layout.getWidthRatio(), newRatio, 0.0);
layout.setHeightRatio(newRatio);
- assertTrue(layout.getHeightRatio() == newRatio);
+ assertEquals(layout.getHeightRatio(), newRatio, 0.0);
layout.setX(newCoordinate);
- assertTrue(layout.getX() == newCoordinate);
+ assertEquals(layout.getX(), newCoordinate, 0.0);
layout.setY(newCoordinate);
- assertTrue(layout.getY() == newCoordinate);
+ assertEquals(layout.getY(), newCoordinate, 0.0);
layout.setXMode(nonDefaultMode);
- assertTrue(layout.getXMode() == nonDefaultMode);
+ assertSame(layout.getXMode(), nonDefaultMode);
layout.setYMode(nonDefaultMode);
- assertTrue(layout.getYMode() == nonDefaultMode);
+ assertSame(layout.getYMode(), nonDefaultMode);
layout.setWidthMode(nonDefaultMode);
- assertTrue(layout.getWidthMode() == nonDefaultMode);
+ assertSame(layout.getWidthMode(), nonDefaultMode);
layout.setHeightMode(nonDefaultMode);
- assertTrue(layout.getHeightMode() == nonDefaultMode);
+ assertSame(layout.getHeightMode(), nonDefaultMode);
layout.setTarget(nonDefaultTarget);
- assertTrue(layout.getTarget() == nonDefaultTarget);
+ assertSame(layout.getTarget(), nonDefaultTarget);
}
@@ -111,9 +113,9 @@ public final class TestXSSFManualLayout {
* According to interface, 0.0 should be returned for
* uninitialized double properties.
*/
- assertTrue(layout.getX() == 0.0);
- assertTrue(layout.getY() == 0.0);
- assertTrue(layout.getWidthRatio() == 0.0);
- assertTrue(layout.getHeightRatio() == 0.0);
+ assertEquals(0.0, layout.getX(), 0.0);
+ assertEquals(0.0, layout.getY(), 0.0);
+ assertEquals(0.0, layout.getWidthRatio(), 0.0);
+ assertEquals(0.0, layout.getHeightRatio(), 0.0);
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
index 0bc0fed736..addfbcb6a9 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFEndnote.java
@@ -94,7 +94,7 @@ public class TestXWPFEndnote {
XWPFRun r2 = testP2.getRuns().get(0);
assertNotNull("Expected a run in testP2", r2);
- assertTrue("Found an endnote reference in testP2", r2.getCTR().getEndnoteRefList().size() == 0);
+ assertEquals("Found an endnote reference in testP2", 0, r2.getCTR().getEndnoteRefList().size());
}
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
index b875644cb5..143a3ad2ad 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnote.java
@@ -94,7 +94,7 @@ public class TestXWPFFootnote {
XWPFRun r2 = testP2.getRuns().get(0);
assertNotNull("Expected a run in testP2", r2);
- assertTrue("Found a footnote reference in testP2", r2.getCTR().getFootnoteRefList().size() == 0);
+ assertEquals("Found a footnote reference in testP2", 0, r2.getCTR().getFootnoteRefList().size());
}