}
public String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("[SUPBOOK ");
if(isExternalReferences()) {
sum += StringUtil.getEncodedSize(field_2_encoded_url);
- for(int i=0; i<field_3_sheet_names.length; i++) {
- sum += StringUtil.getEncodedSize(field_3_sheet_names[i]);
+ for (String field_3_sheet_name : field_3_sheet_names) {
+ sum += StringUtil.getEncodedSize(field_3_sheet_name);
}
return sum;
}
if(isExternalReferences()) {
StringUtil.writeUnicodeString(out, field_2_encoded_url);
- for(int i=0; i<field_3_sheet_names.length; i++) {
- StringUtil.writeUnicodeString(out, field_3_sheet_names[i]);
+ for (String field_3_sheet_name : field_3_sheet_names) {
+ StringUtil.writeUnicodeString(out, field_3_sheet_name);
}
} else {
int field2val = _isAddInFunctions ? TAG_ADD_IN_FUNCTIONS : TAG_INTERNAL_REFERENCES;
package org.apache.poi.openxml4j.opc.compliance;
+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 static org.junit.Assert.fail;
try {
uri = new URI(s);
} catch (URISyntaxException e) {
- assertTrue(s.equals("[Content_Types].xml"));
+ assertEquals("[Content_Types].xml", s);
continue;
}
assertFalse("This part name SHOULD NOT be valid: " + s,
for (int i = 0; i < partName1.length || i < partName2.length; ++i) {
PackagePartName p1 = PackagingURIHelper.createPartName(partName1[i]);
PackagePartName p2 = PackagingURIHelper.createPartName(partName2[i]);
- assertTrue(p1.equals(p2));
- assertTrue(p1.compareTo(p2) == 0);
- assertTrue(p1.hashCode() == p2.hashCode());
+ assertEquals(p1, p2);
+ assertEquals(0, p1.compareTo(p2));
+ assertEquals(p1.hashCode(), p2.hashCode());
}
}
for (int i = 0; i < partName1.length || i < partName2.length; ++i) {
PackagePartName p1 = PackagingURIHelper.createPartName(partName1[i]);
PackagePartName p2 = PackagingURIHelper.createPartName(partName2[i]);
- assertFalse(p1.equals(p2));
- assertFalse(p1.compareTo(p2) == 0);
- assertFalse(p1.hashCode() == p2.hashCode());
+ assertNotEquals(p1, p2);
+ assertNotEquals(0, p1.compareTo(p2));
+ assertNotEquals(p1.hashCode(), p2.hashCode());
}
}
}
// Column 1 has a font with regular colours
XSSFCell cr = r.getCell(1);
- XSSFFont fr = wb.getFontAt(cr.getCellStyle().getFontIndex());
+ XSSFFont fr = wb.getFontAt(cr.getCellStyle().getFontIndexAsInt());
XSSFColor colr = fr.getXSSFColor();
// No theme, has colours
assertEquals(0, colr.getTheme());
// Column 0 has a font with colours from a theme
XSSFCell ct = r.getCell(0);
- XSSFFont ft = wb.getFontAt(ct.getCellStyle().getFontIndex());
+ XSSFFont ft = wb.getFontAt(ct.getCellStyle().getFontIndexAsInt());
XSSFColor colt = ft.getXSSFColor();
// Has a theme, which has the colours on it
assertEquals(9, colt.getTheme());
wb.createSheet("Sheet1");
name.setNameName("test");
name.setRefersToFormula("Sheet1!$B$3");
- if (name.getRefersToFormula().equals("Sheet1!B3")) {
+ if ("Sheet1!B3".equals(name.getRefersToFormula())) {
fail("Identified bug 46174");
}
assertEquals("Sheet1!$B$3", name.getRefersToFormula());
NameRecord record = new NameRecord();
assertEquals(0, record.getExternSheetNumber());
- record.setNameDefinition(new Ptg[] {});
+ record.setNameDefinition(Ptg.EMPTY_PTG_ARRAY);
assertEquals(0, record.getExternSheetNumber());
record.setNameDefinition(new Ptg[] {new NamePtg(1)});
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.record.NameRecord;
-import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.BaseTestNamedRange;
-import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellRangeAddress;
import org.junit.Test;
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
HSSFName nm = wb2.getNameAt(wb2.getNameIndex("RangeTest"));
- assertTrue("Name is "+nm.getNameName(),"RangeTest".equals(nm.getNameName()));
+ assertEquals("Name is " + nm.getNameName(), "RangeTest", nm.getNameName());
assertEquals(wb2.getSheetName(0)+"!$D$4:$E$8", nm.getRefersToFormula());
wb2.close();
wb1.close();
import org.apache.poi.hpsf.SummaryInformation;
import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.apache.poi.poifs.filesystem.Entry;
-import org.junit.BeforeClass;
import org.junit.Test;
/**
// Read the Excel file and verify its content
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
Name nm1 = wb2.getName("RangeTest1");
- assertTrue("Name is "+nm1.getNameName(),"RangeTest1".equals(nm1.getNameName()));
- assertTrue("Reference is "+nm1.getRefersToFormula(),(wb2.getSheetName(0)+"!$A$1:$L$41").equals(nm1.getRefersToFormula()));
+ assertEquals("Name is " + nm1.getNameName(), "RangeTest1", nm1.getNameName());
+ assertEquals("Reference is " + nm1.getRefersToFormula(), (wb2.getSheetName(0) + "!$A$1:$L$41"), nm1.getRefersToFormula());
Name nm2 = wb2.getName("RangeTest2");
- assertTrue("Name is "+nm2.getNameName(),"RangeTest2".equals(nm2.getNameName()));
- assertTrue("Reference is "+nm2.getRefersToFormula(),(wb2.getSheetName(1)+"!$A$1:$O$21").equals(nm2.getRefersToFormula()));
+ assertEquals("Name is " + nm2.getNameName(), "RangeTest2", nm2.getNameName());
+ assertEquals("Reference is " + nm2.getRefersToFormula(), (wb2.getSheetName(1) + "!$A$1:$O$21"), nm2.getRefersToFormula());
wb2.close();
wb1.close();
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
Name nm =wb2.getName("RangeTest");
- assertTrue("Name is "+nm.getNameName(),"RangeTest".equals(nm.getNameName()));
- assertTrue("Reference is "+nm.getRefersToFormula(),(wb2.getSheetName(0)+"!$D$4:$E$8").equals(nm.getRefersToFormula()));
+ assertEquals("Name is " + nm.getNameName(), "RangeTest", nm.getNameName());
+ assertEquals("Reference is " + nm.getRefersToFormula(), (wb2.getSheetName(0) + "!$D$4:$E$8"), nm.getRefersToFormula());
nm = wb2.getName("AnotherTest");
- assertTrue("Name is "+nm.getNameName(),"AnotherTest".equals(nm.getNameName()));
- assertTrue("Reference is "+nm.getRefersToFormula(),newNamedRange2.getRefersToFormula().equals(nm.getRefersToFormula()));
+ assertEquals("Name is " + nm.getNameName(), "AnotherTest", nm.getNameName());
+ assertEquals("Reference is " + nm.getRefersToFormula(), newNamedRange2.getRefersToFormula(), nm.getRefersToFormula());
wb2.close();
wb1.close();
}
@Test
- public void testInvalid() throws IOException {
+ public void testInvalid() {
Workbook wb = _testDataProvider.createWorkbook();
Name name = wb.createName();