integerSpecials.addAll(specials.subList(0, integerEnd()));
if (exponent == null) {
- StringBuffer fmtBuf = new StringBuffer("%");
+ StringBuilder fmtBuf = new StringBuilder("%");
int integerPartWidth = calculateIntegerPartWidth();
int totalWidth = integerPartWidth + fractionPartWidth;
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) {
// 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();
}
// 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();
}
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
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());
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;
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));
* 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;
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) {
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;
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();
}
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
p.setBulletFont("Calibri");
assertEquals("Calibri", p.getBulletFont());
- assertEquals(null, p.getBulletFontColor());
+ assertNull(p.getBulletFontColor());
p.setBulletFontColor(Color.red);
assertTrue(sameColor(Color.red, p.getBulletFontColor()));
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);
}
}
pivotTable.addColumnLabel(DataConsolidateFunction.SUM, columnIndex);
CTPivotTableDefinition defintion = pivotTable.getCTPivotTableDefinition();
- assertEquals(defintion.getColFields(), null);
+ assertNull(defintion.getColFields());
}
/**
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;
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());
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());
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());
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());
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;
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
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());
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;
sheet.addValidationData(validation);
final List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
- assertEquals(true, dataValidations.get(0).getCtDdataValidation().getAllowBlank());
+ assertTrue(dataValidations.get(0).getCtDdataValidation().getAllowBlank());
}
}
sheet.addValidationData(validation);
final List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
- assertEquals(false, dataValidations.get(0).getCtDdataValidation().getAllowBlank());
+ assertFalse(dataValidations.get(0).getCtDdataValidation().getAllowBlank());
}
}
sheet.addValidationData(validation);
final List<XSSFDataValidation> dataValidations = sheet.getDataValidations();
- assertEquals(true, dataValidations.get(0).getCtDdataValidation().getAllowBlank());
+ assertTrue(dataValidations.get(0).getCtDdataValidation().getAllowBlank());
}
}
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());
}
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} ,
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")
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");
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
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
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(
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());
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;
}
try (XSSFWorkbook wb2 = (XSSFWorkbook) WorkbookFactory.create(file)) {
- assertTrue(wb2.getPivotTables().size() == 1);
+ assertEquals(1, wb2.getPivotTables().size());
}
assertTrue(file.delete());
try (XSSFWorkbook wb2 = (XSSFWorkbook) WorkbookFactory.create(file)) {
setPivotData(wb2);
- assertTrue(wb2.getPivotTables().size() == 2);
+ assertEquals(2, wb2.getPivotTables().size());
}
assertTrue(file.delete());
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());
wb.close();
}
+ @SuppressWarnings("deprecation")
@Test
public void testBug56957CloseWorkbook() throws Exception {
File file = TempFile.createTempFile("TestBug56957_", ".xlsx");
}
@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;
/**
* See bug #61700
- * @throws Exception
*/
@Test
public void testWorkbookForceFormulaRecalculation() throws Exception {
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;
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);
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;
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);
}
* 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);
}
}
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());
}
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());
}
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");
package org.apache.poi.hpbf;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
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();
}
//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();
}
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 {
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 {
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
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());
}
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());
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());
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());
// 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());
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());
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());
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());
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;
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();
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());
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;
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());
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)) {
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 {
// 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));
}
}
assertEquals(0, p.getLfoMac());
assertEquals(0, p2.getLfoMac());
- assertTrue(p.equals(p2));
+ assertEquals(p, p2);
//noinspection ObjectEqualsNull
- assertFalse(p.equals(null));
+ assertNotEquals(null, p);
p.add(new LFO(new byte[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 0), new LFOData());
assertEquals(1, p.getLfoMac());
- assertFalse(p.equals(p2));
+ assertNotEquals(p, p2);
p2.add(new LFO(new byte[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 0), new LFOData());
assertEquals(1, p2.getLfoMac());
- assertTrue(p.equals(p2));
+ assertEquals(p, p2);
}
}
\ No newline at end of file
{
CHPX oldNode = oldTextRuns.get(x);
CHPX newNode = newTextRuns.get(x);
- assertTrue(oldNode.equals(newNode));
+ assertEquals(oldNode, newNode);
}
}
package org.apache.poi.hwpf.model;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
FontTable newFontTable = new FontTable(newTableStream, 0, newTableStream.length);
- assertTrue(_fontTable.equals(newFontTable));
+ assertEquals(_fontTable, newFontTable);
}
PAPX oldNode = oldTextRuns.get( x );
PAPX newNode = newTextRuns.get( x );
- assertTrue( oldNode.equals( newNode ) );
+ assertEquals(oldNode, newNode);
}
_hWPFDocFixture.tearDown();
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;
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();
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}
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}
{
bExceptionOccurred = true;
}
- Assert.assertTrue(bExceptionOccurred);
+ assertTrue(bExceptionOccurred);
bExceptionOccurred = false;
try
{
bExceptionOccurred = true;
}
- Assert.assertTrue(bExceptionOccurred);
+ assertTrue(bExceptionOccurred);
// These should work without throwing an Exception
bExceptionOccurred = false;
{
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}"
);
}
HSSFEventFactory f = new HSSFEventFactory();
assertEquals(0, l.countSeen);
- assertEquals(null, l.lastRecordSeen);
+ assertNull(l.lastRecordSeen);
POIFSFileSystem fs = openSample();
short res = f.abortableProcessWorkbookEvents(req, fs);
HSSFEventFactory f = new HSSFEventFactory();
assertEquals(0, l.countSeen);
- assertEquals(null, l.lastRecordSeen);
+ assertNull(l.lastRecordSeen);
POIFSFileSystem fs = openSample();
short res = f.abortableProcessWorkbookEvents(req, fs);
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]));
}
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;
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);
}
}
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();
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();
}
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();
}
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();
}
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();
}
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();
}
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());
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();
}
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();
}
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
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);
}
}
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
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 {
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);
}
}
Ptg[] ptgs = parseFormula("TRUE");
assertEquals(1, ptgs.length);
BoolPtg flag = (BoolPtg) ptgs[0];
- assertEquals(true, flag.getValue());
+ assertTrue(flag.getValue());
}
@Test
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*/
*/
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());
}
StringPtg n = (StringPtg) ptgs[4];
- assertEquals(true, flag.getValue());
+ assertTrue(flag.getValue());
assertEquals("Y", y.getValue());
assertEquals("N", n.getValue());
assertEquals("IF", funif.toFormulaString());
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(){
container.addChildRecord(escher);
HSSFClientAnchor anchor = (HSSFClientAnchor) HSSFAnchor.createAnchorFromEscher(container);
+ assertNotNull(anchor);
assertEquals(anchor.getCol1(), 11);
assertEquals(escher.getCol1(), 11);
assertEquals(anchor.getCol2(), 12);
container.addChildRecord(escher);
HSSFChildAnchor anchor = (HSSFChildAnchor) HSSFAnchor.createAnchorFromEscher(container);
+ assertNotNull(anchor);
assertEquals(anchor.getDx1(), 15);
assertEquals(escher.getDx1(), 15);
assertEquals(anchor.getDx2(), 16);
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(){
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(){
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);
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());
}
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();
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);
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());
}
assertFalse(hasMore);
assertTrue(ber.isBoolean());
- assertEquals(true, ber.getBooleanValue());
+ assertTrue(ber.getBooleanValue());
// Check that the record re-serializes correctly
byte[] outData = ber.serialize();
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());
}
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());
}
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());
}
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());
import junit.framework.TestCase;
import org.apache.poi.util.LittleEndianOutputStream;
+import static org.junit.Assert.assertArrayEquals;
+
/**
* Unit tests for DConRefRecord class.
*
/**
* 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
{
/**
* test read-constructor-then-serialize for a double-byte external reference 'UNC-Volume' style
* string
- * <p>
- * @throws IOException
*/
public void testReadWriteDBExtRefUncVol() throws IOException
{
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
{
/**
* test read-constructor-then-serialize for a single-byte self-reference style string
- * <p>
- * @throws IOException
*/
public void testReadWriteSBSelfRef() throws IOException
{
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);
}
/**
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);
}
}
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());
}
}
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() {
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;
in.nextRecord();
SSTRecord result = new SSTRecord(in);
assertEquals(0, in.remaining());
- assertTrue(!in.hasNextRecord());
+ assertFalse(in.hasNextRecord());
return result;
}
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);
}
}
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;
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);
}
/**
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());
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() );
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() );
}
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() );
}
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() );
}
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() );
}
assertEquals( 0, record.getSeriesIndex());
assertEquals( 0, record.getSeriesNumber());
assertEquals( 0, record.getFormatFlags());
- assertEquals( false, record.isUseExcel4Colors() );
+ assertFalse(record.isUseExcel4Colors());
assertEquals( 12, record.getRecordSize() );
}
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() );
}
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());
}
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() );
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,
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() );
}
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() );
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() );
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());
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() );
}
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();
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);
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());
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());
HSSFRow r = s.getRow(0);
HSSFCellStyle cs = r.getCell(0).getCellStyle();
- assertEquals(true, cs.getShrinkToFit());
+ assertTrue(cs.getShrinkToFit());
// New file
HSSFWorkbook wbOrig = new HSSFWorkbook();
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());
}
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;
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());
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();
}
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());
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();
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();
}
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]);
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();
}
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();
}
}
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());
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;
} catch (NumberFormatException e) {
fail("Identified bug 44508");
}
- assertEquals(true, cell.getBooleanCellValue());
+ assertTrue(cell.getBooleanCellValue());
wb.close();
}
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;
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();
}
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());
}
}
}
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)) {
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());
}
}
//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();
}
//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);
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());
}
}
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());
}
/**
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();
}
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();
}
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();
}
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();
}
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();
}
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();
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;
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());
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;
assertEquals(comment.getRow(), 4);
comment.setVisible(false);
- assertEquals(comment.isVisible(), false);
+ assertFalse(comment.isVisible());
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
sh = wbBack.getSheetAt(0);
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");
assertEquals("poi2", comment.getAuthor());
assertEquals(comment.getColumn(), 32);
assertEquals(comment.getRow(), 42);
- assertEquals(comment.isVisible(), true);
+ assertTrue(comment.isVisible());
wb.close();
wbBack.close();
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;
// 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();
// 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 +
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());
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;
Iterator<POIFSReaderListener> listeners =
registry.getListeners(path, name).iterator();
- assertTrue(!listeners.hasNext());
+ assertFalse(listeners.hasNext());
}
}
}
if (k == n)
{
- assertTrue(!listeners.iterator().hasNext());
+ assertFalse(listeners.iterator().hasNext());
}
else
{
{
if (j == k)
{
- assertTrue(!registeredListeners
- .contains(this.listeners[ j ]));
+ assertFalse(registeredListeners
+ .contains(this.listeners[j]));
}
else
{
assertEquals(property2.getName(), node.getName());
// verify behavior of isDocumentEntry
- assertTrue(!node.isDocumentEntry());
+ assertFalse(node.isDocumentEntry());
// verify behavior of getParent
assertEquals(parent, node.getParent());
assertEquals(2, count);
// verify behavior of isEmpty
- assertTrue(!node.isEmpty());
+ assertFalse(node.isEmpty());
// verify behavior of getEntryCount
assertEquals(2, node.getEntryCount());
assertEquals(property1.getName(), node.getName());
// verify behavior of isDocumentEntry
- assertTrue(!node.isDocumentEntry());
+ assertFalse(node.isDocumentEntry());
// verify behavior of getParent
assertNull(node.getParent());
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"));
}
else
{
- assertTrue("" + j + "," + k + "," + m + "," + n,
- !d1.equals(d2));
+ assertFalse(d1.equals(d2));
}
}
}
}
else
{
- assertTrue("" + j + "," + k + "," + m + "," + n,
- !(d1.equals(d2)));
+ assertFalse(d1.equals(d2));
}
}
}
new DocumentDescriptor(builtUpPaths[ k ],
names[ n ]);
- assertTrue("" + j + "," + k + "," + m + "," + n,
- !(d1.equals(d2)));
+ assertFalse(d1.equals(d2));
}
}
}
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
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()));
Iterator<Entry> i = d.getEntries();
assertEquals(dirA, i.next());
assertEquals(dirB, i.next());
- assertEquals(null, i.next());
+ assertNull(i.next());
// Filter more
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());
i = d.getEntries();
assertEquals(dirB, i.next());
- assertEquals(null, i.next());
+ assertNull(i.next());
// Filter everything
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());
}
i = d.getEntries();
- assertEquals(null, i.next());
+ assertNull(i.next());
}
@Test
// 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)
}
else
{
- assertTrue(j + "<>" + k,
- !(fullPaths[ j ].equals(builtUpPaths[ k ])));
+ assertFalse(fullPaths[j].equals(builtUpPaths[k]));
}
}
}
{
for (int j = 0; j < badPaths.length; j++)
{
- assertTrue(j + "<>" + k,
- !(fullPaths[ k ].equals(badPaths[ j ])));
+ assertFalse(fullPaths[k].equals(badPaths[j]));
}
}
}
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;
if (index != -1)
{
- assertTrue("found index " + index + " twice",
- !found[ index - 1 ]);
+ assertFalse(found[index - 1]);
found[ index - 1 ] = true;
total_found++;
}
if (index != -1)
{
- assertTrue("found index " + index + " twice",
- !found[ index - 1 ]);
+ assertFalse(found[index - 1]);
found[ index - 1 ] = true;
total_found++;
}
// as expected
}
assertTrue(_property.deleteChild(p1));
- assertTrue(!_property.deleteChild(p1));
+ assertFalse(_property.deleteChild(p1));
_property.addChild(new LocalProperty(1));
}
_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));
}
}
assertEquals(index, property.getIndex());
assertEquals(name, property.getName());
- assertTrue(!property.getChildren().hasNext());
+ assertFalse(property.getChildren().hasNext());
}
}
if (size >= 4096)
{
- assertTrue(!property.shouldUseSmallBlocks());
+ assertFalse(property.shouldUseSmallBlocks());
}
else
{
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;
}
assertEquals(index, property.getIndex());
assertEquals(name, property.getName());
- assertTrue(!property.getChildren().hasNext());
+ assertFalse(property.getChildren().hasNext());
assertEquals(property.getStorageClsid().toString(), sClsId);
}
}
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;
}
// 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
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;
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();
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));
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;
* 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());
}
CellValue cellValue = evaluateWithCycles(wb, testCell);
- assertTrue(cellValue.getCellType() == CellType.NUMERIC);
+ assertSame(cellValue.getCellType(), CellType.NUMERIC);
assertEquals(2, cellValue.getNumberValue(), 0);
wb.close();
}
import java.io.InputStream;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
cv = fe.evaluate(row.getCell(1));
assertEquals(CellType.BOOLEAN, cv.getCellType());
- assertEquals(true, cv.getBooleanValue());
+ assertTrue(cv.getBooleanValue());
wb.close();
}
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;
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());
}
}
private static void confirmError(ValueEval arg) {
ValueEval eval = invokeT(arg);
- assertSame(arg, eval);
+ assertSame(arg, eval);
}
@Test
confirmString(eval, "");
eval = invokeTWithReference(ErrorEval.NAME_INVALID);
- assertSame(eval, ErrorEval.NAME_INVALID);
+ assertSame(eval, ErrorEval.NAME_INVALID);
}
@Test
assertNotNull("Cells in the second column have comments", sheet.getCellComment(new CellAddress(rownum, 1)));
assertEquals("Yegor Kozlov", comment.getAuthor());
- assertTrue("cells in the second column should have non-empty notes",
- !comment.getString().getString().isEmpty());
+ assertFalse(comment.getString().getString().isEmpty());
assertEquals(rownum, comment.getRow());
assertEquals(cell.getColumnIndex(), comment.getColumn());
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.poi.ss.usermodel.helpers.ColumnShifter;
public void testShiftLeft() {
try {
columnShifter.shiftColumns(1, 2, -3);
- assertTrue("Shift to negative indices should throw exception", false);
+ fail("Shift to negative indices should throw exception");
}
catch(IllegalStateException e){
assertTrue(true);
assertEquals(ConditionType.CELL_VALUE_IS, cr.getConditionType());
assertEquals(ComparisonOperator.GT, cr.getComparisonOperation());
assertEquals("0", cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula2());
// When it matches:
// Sets the font colour to dark green
// Sets the background colour to lighter green
private void assertDataBar(ConditionalFormattingRule cr, String color) {
assertEquals(ConditionType.DATA_BAR, cr.getConditionType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
- assertEquals(null, cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula1());
+ assertNull(cr.getFormula2());
DataBarFormatting databar = cr.getDataBarFormatting();
assertNotNull(databar);
- assertEquals(false, databar.isIconOnly());
- assertEquals(true, databar.isLeftToRight());
+ assertFalse(databar.isIconOnly());
+ assertTrue(databar.isLeftToRight());
assertEquals(0, databar.getWidthMin());
assertEquals(100, databar.getWidthMax());
ConditionalFormattingThreshold th;
th = databar.getMinThreshold();
assertEquals(RangeType.MIN, th.getRangeType());
- assertEquals(null, th.getValue());
- assertEquals(null, th.getFormula());
+ assertNull(th.getValue());
+ assertNull(th.getFormula());
th = databar.getMaxThreshold();
assertEquals(RangeType.MAX, th.getRangeType());
- assertEquals(null, th.getValue());
- assertEquals(null, th.getFormula());
+ assertNull(th.getValue());
+ assertNull(th.getFormula());
}
private void assertIconSetPercentages(ConditionalFormatting cf, IconSet iconset, Double...vals) {
private void assertIconSetPercentages(ConditionalFormattingRule cr, IconSet iconset, Double...vals) {
assertEquals(ConditionType.ICON_SET, cr.getConditionType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
- assertEquals(null, cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula1());
+ assertNull(cr.getFormula2());
IconMultiStateFormatting icon = cr.getMultiStateFormatting();
assertNotNull(icon);
assertEquals(iconset, icon.getIconSet());
- assertEquals(false, icon.isIconOnly());
- assertEquals(false, icon.isReversed());
+ assertFalse(icon.isIconOnly());
+ assertFalse(icon.isReversed());
assertNotNull(icon.getThresholds());
assertEquals(vals.length, icon.getThresholds().length);
ConditionalFormattingThreshold th = icon.getThresholds()[i];
assertEquals(RangeType.PERCENT, th.getRangeType());
assertEquals(v, th.getValue());
- assertEquals(null, th.getFormula());
+ assertNull(th.getFormula());
}
}
private void assertColorScale(ConditionalFormattingRule cr, String... colors) {
assertEquals(ConditionType.COLOR_SCALE, cr.getConditionType());
assertEquals(ComparisonOperator.NO_COMPARISON, cr.getComparisonOperation());
- assertEquals(null, cr.getFormula1());
- assertEquals(null, cr.getFormula2());
+ assertNull(cr.getFormula1());
+ assertNull(cr.getFormula2());
ColorScaleFormatting color = cr.getColorScaleFormatting();
assertNotNull(color);
assertEquals(RangeType.PERCENTILE, th.getRangeType());
assertEquals(steps*i, th.getValue().intValue());
}
- assertEquals(null, th.getFormula());
+ assertNull(th.getFormula());
}
// Colors should match
assertEquals(IconSet.GYRB_4_TRAFFIC_LIGHTS, iconFmt.getIconSet());
assertEquals(4, iconFmt.getThresholds().length);
- assertEquals(false, iconFmt.isIconOnly());
- assertEquals(false, iconFmt.isReversed());
+ assertFalse(iconFmt.isIconOnly());
+ assertFalse(iconFmt.isReversed());
iconFmt.setIconOnly(true);
iconFmt.getThresholds()[0].setRangeType(RangeType.MIN);
assertEquals(IconSet.GYRB_4_TRAFFIC_LIGHTS, iconFmt.getIconSet());
assertEquals(4, iconFmt.getThresholds().length);
- assertEquals(true, iconFmt.isIconOnly());
- assertEquals(false, iconFmt.isReversed());
+ assertTrue(iconFmt.isIconOnly());
+ assertFalse(iconFmt.isReversed());
assertEquals(RangeType.MIN, iconFmt.getThresholds()[0].getRangeType());
assertEquals(RangeType.NUMBER, iconFmt.getThresholds()[1].getRangeType());
assertEquals(RangeType.PERCENT,iconFmt.getThresholds()[2].getRangeType());
assertEquals(RangeType.MAX, iconFmt.getThresholds()[3].getRangeType());
- assertEquals(null, iconFmt.getThresholds()[0].getValue());
+ assertNull(iconFmt.getThresholds()[0].getValue());
assertEquals(10d, iconFmt.getThresholds()[1].getValue(), 0);
assertEquals(75d, iconFmt.getThresholds()[2].getValue(), 0);
- assertEquals(null, iconFmt.getThresholds()[3].getValue());
+ assertNull(iconFmt.getThresholds()[3].getValue());
wb2.close();
}
assertEquals(RangeType.MIN, clrFmt.getThresholds()[0].getRangeType());
assertEquals(RangeType.NUMBER, clrFmt.getThresholds()[1].getRangeType());
assertEquals(RangeType.MAX, clrFmt.getThresholds()[2].getRangeType());
- assertEquals(null, clrFmt.getThresholds()[0].getValue());
+ assertNull(clrFmt.getThresholds()[0].getValue());
assertEquals(10d, clrFmt.getThresholds()[1].getValue(), 0);
- assertEquals(null, clrFmt.getThresholds()[2].getValue());
+ assertNull(clrFmt.getThresholds()[2].getValue());
wb2.close();
}
ConditionalFormattingRule rule1 =
sheetCF.createConditionalFormattingRule(color);
DataBarFormatting dbFmt = rule1.getDataBarFormatting();
-
- assertEquals(false, dbFmt.isIconOnly());
- assertEquals(true, dbFmt.isLeftToRight());
+
+ assertFalse(dbFmt.isIconOnly());
+ assertTrue(dbFmt.isLeftToRight());
assertEquals(0, dbFmt.getWidthMin());
assertEquals(100, dbFmt.getWidthMax());
assertColour(colorHex, dbFmt.getColor());
rule1 = cf.getRule(0);
dbFmt = rule1.getDataBarFormatting();
assertEquals(ConditionType.DATA_BAR, rule1.getConditionType());
-
- assertEquals(false, dbFmt.isIconOnly());
- assertEquals(true, dbFmt.isLeftToRight());
+
+ assertFalse(dbFmt.isIconOnly());
+ assertTrue(dbFmt.isLeftToRight());
assertEquals(0, dbFmt.getWidthMin());
assertEquals(100, dbFmt.getWidthMax());
assertColour(colorHex, dbFmt.getColor());
assertEquals(RangeType.MIN, dbFmt.getMinThreshold().getRangeType());
assertEquals(RangeType.MAX, dbFmt.getMaxThreshold().getRangeType());
- assertEquals(null, dbFmt.getMinThreshold().getValue());
- assertEquals(null, dbFmt.getMaxThreshold().getValue());
+ assertNull(dbFmt.getMinThreshold().getValue());
+ assertNull(dbFmt.getMaxThreshold().getValue());
wb2.close();
}
assertNotNull(wb3.getFontAt(font2Idx));
assertEquals(15, wb3.getFontAt(font2Idx).getFontHeightInPoints());
- assertEquals(true, wb3.getFontAt(font2Idx).getItalic());
+ assertTrue(wb3.getFontAt(font2Idx).getItalic());
wb3.close();
}
assertEquals(nf, wb.getFontAt(nfIdx));
assertEquals(wb.getFontAt(nfIdx), wb.getFontAt(nfIdx));
- assertTrue(wb.getFontAt(0) != wb.getFontAt(nfIdx));
+ assertNotSame(wb.getFontAt(0), wb.getFontAt(nfIdx));
// Find it now
assertNotNull(
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import org.apache.poi.ss.util.NumberComparisonExamples.ComparisonExample;
double a = 0.06-0.01;
double b = 0.05;
//noinspection ConstantConditions
- assertFalse(a == b);
+ assertNotEquals(a, b, 0.0);
assertEquals(0, NumberComparer.compare(a, b));
}
double a = 1+1.0028-0.9973;
double b = 1.0055;
//noinspection ConstantConditions
- assertFalse(a == b);
+ assertNotEquals(a, b, 0.0);
assertEquals(0, NumberComparer.compare(a, b));
}
}
public void testIsSet() {
- assertTrue(!bf_multi.isSet(0));
+ assertFalse(bf_multi.isSet(0));
for (int j = 0x80; j <= 0x3F80; j += 0x80)
{
assertTrue(bf_multi.isSet(j));
}
- assertTrue(!bf_single.isSet(0));
+ assertFalse(bf_single.isSet(0));
assertTrue(bf_single.isSet(0x4000));
}
public void testIsAllSet() {
for (int j = 0; j < 0x3F80; j += 0x80)
{
- assertTrue(!bf_multi.isAllSet(j));
+ assertFalse(bf_multi.isAllSet(j));
}
assertTrue(bf_multi.isAllSet(0x3F80));
- assertTrue(!bf_single.isAllSet(0));
+ assertFalse(bf_single.isAllSet(0));
assertTrue(bf_single.isAllSet(0x4000));
}
byte clearedBit = BitFieldFactory.getInstance(0x40).setByteBoolean(( byte ) -63,
false);
- assertEquals(false, BitFieldFactory.getInstance(0x40).isSet(clearedBit));
+ assertFalse(BitFieldFactory.getInstance(0x40).isSet(clearedBit));
}
public void testClear() {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
assertEquals(list, list);
//noinspection ObjectEqualsNull
- assertFalse(list.equals(null));
+ assertNotEquals(null, list);
IntList list2 = new IntList(200);
assertEquals(list, list2);
list.add(1);
list2.add(1);
list2.add(0);
- assertFalse(list.equals(list2));
+ assertNotEquals(list, list2);
list2.removeValue(1);
list2.add(1);
assertEquals(list, list2);
assertEquals(list2, list);
assertEquals(list.hashCode(), list2.hashCode());
list2.add(2);
- assertFalse(list.equals(list2));
- assertFalse(list2.equals(list));
+ assertNotEquals(list, list2);
+ assertNotEquals(list2, list);
}
@Test
int[] a4 = list.toArray(aShort);
int[] a5 = list.toArray(aLong);
- assertTrue(a4 != aShort);
- assertTrue(a5 != aLong);
+ assertNotSame(a4, aShort);
+ assertNotSame(a5, aLong);
assertEquals(a4.length, list.size());
for (int j = 0; j < 1000; j++)
{
package org.apache.poi.util;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
// Should be able to create two tempfiles with same prefix and suffix
File file1 = TempFile.createTempFile("TestTempFile", ".tst");
File file2 = TempFile.createTempFile("TestTempFile", ".tst");
- assertFalse(file1.equals(file2));
+ assertNotEquals(file1, file2);
assertNotNull(file2);
assertTrue(file2.delete());
assertNotNull(file1);