Streamline assertion-usage in some tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1830296 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d219fe085a
commit
2574fd2d3d
@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel;
|
|||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@ -349,7 +350,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
// Look at the low level xml elements
|
// Look at the low level xml elements
|
||||||
assertEquals(2, cs.getCoreXf().getFillId());
|
assertEquals(2, cs.getCoreXf().getFillId());
|
||||||
assertEquals(0, cs.getCoreXf().getXfId());
|
assertEquals(0, cs.getCoreXf().getXfId());
|
||||||
assertEquals(true, cs.getCoreXf().getApplyFill());
|
assertTrue(cs.getCoreXf().getApplyFill());
|
||||||
|
|
||||||
XSSFCellFill fg = wb.getStylesSource().getFillAt(2);
|
XSSFCellFill fg = wb.getStylesSource().getFillAt(2);
|
||||||
assertNotNull(fg.getFillForegroundColor());
|
assertNotNull(fg.getFillForegroundColor());
|
||||||
@ -366,8 +367,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
assertEquals("FFFF0000", cs.getFillForegroundColorColor().getARGBHex());
|
assertEquals("FFFF0000", cs.getFillForegroundColorColor().getARGBHex());
|
||||||
|
|
||||||
assertEquals(64, cs.getFillBackgroundColor());
|
assertEquals(64, cs.getFillBackgroundColor());
|
||||||
assertEquals(null, cs.getFillBackgroundXSSFColor().getARGBHex());
|
assertNull(cs.getFillBackgroundXSSFColor().getARGBHex());
|
||||||
assertEquals(null, cs.getFillBackgroundColorColor().getARGBHex());
|
assertNull(cs.getFillBackgroundColorColor().getARGBHex());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
@ -471,7 +472,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
);
|
);
|
||||||
assertEquals(" with spaces ", c.getRichStringCellValue().toString());
|
assertEquals(" with spaces ", c.getRichStringCellValue().toString());
|
||||||
assertEquals(0, c.getRichStringCellValue().getCTRst().sizeOfRArray());
|
assertEquals(0, c.getRichStringCellValue().getCTRst().sizeOfRArray());
|
||||||
assertEquals(true, c.getRichStringCellValue().getCTRst().isSetT());
|
assertTrue(c.getRichStringCellValue().getCTRst().isSetT());
|
||||||
// Should have the preserve set
|
// Should have the preserve set
|
||||||
assertEquals(
|
assertEquals(
|
||||||
1,
|
1,
|
||||||
@ -490,7 +491,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
c = r.getCell(0);
|
c = r.getCell(0);
|
||||||
assertEquals(" with spaces ", c.getRichStringCellValue().toString());
|
assertEquals(" with spaces ", c.getRichStringCellValue().toString());
|
||||||
assertEquals(0, c.getRichStringCellValue().getCTRst().sizeOfRArray());
|
assertEquals(0, c.getRichStringCellValue().getCTRst().sizeOfRArray());
|
||||||
assertEquals(true, c.getRichStringCellValue().getCTRst().isSetT());
|
assertTrue(c.getRichStringCellValue().getCTRst().isSetT());
|
||||||
|
|
||||||
// Change the string
|
// Change the string
|
||||||
c.setCellValue(
|
c.setCellValue(
|
||||||
@ -1069,36 +1070,36 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
// No print settings before repeating
|
// No print settings before repeating
|
||||||
XSSFSheet s1 = wb1.createSheet();
|
XSSFSheet s1 = wb1.createSheet();
|
||||||
assertEquals(false, s1.getCTWorksheet().isSetPageSetup());
|
assertFalse(s1.getCTWorksheet().isSetPageSetup());
|
||||||
assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
|
assertTrue(s1.getCTWorksheet().isSetPageMargins());
|
||||||
s1.setRepeatingColumns(cra);
|
s1.setRepeatingColumns(cra);
|
||||||
s1.setRepeatingRows(cra);
|
s1.setRepeatingRows(cra);
|
||||||
|
|
||||||
assertEquals(true, s1.getCTWorksheet().isSetPageSetup());
|
assertTrue(s1.getCTWorksheet().isSetPageSetup());
|
||||||
assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
|
assertTrue(s1.getCTWorksheet().isSetPageMargins());
|
||||||
|
|
||||||
PrintSetup ps1 = s1.getPrintSetup();
|
PrintSetup ps1 = s1.getPrintSetup();
|
||||||
assertEquals(false, ps1.getValidSettings());
|
assertFalse(ps1.getValidSettings());
|
||||||
assertEquals(false, ps1.getLandscape());
|
assertFalse(ps1.getLandscape());
|
||||||
|
|
||||||
|
|
||||||
// Had valid print settings before repeating
|
// Had valid print settings before repeating
|
||||||
XSSFSheet s2 = wb2.createSheet();
|
XSSFSheet s2 = wb2.createSheet();
|
||||||
PrintSetup ps2 = s2.getPrintSetup();
|
PrintSetup ps2 = s2.getPrintSetup();
|
||||||
assertEquals(true, s2.getCTWorksheet().isSetPageSetup());
|
assertTrue(s2.getCTWorksheet().isSetPageSetup());
|
||||||
assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
|
assertTrue(s2.getCTWorksheet().isSetPageMargins());
|
||||||
|
|
||||||
ps2.setLandscape(false);
|
ps2.setLandscape(false);
|
||||||
assertEquals(true, ps2.getValidSettings());
|
assertTrue(ps2.getValidSettings());
|
||||||
assertEquals(false, ps2.getLandscape());
|
assertFalse(ps2.getLandscape());
|
||||||
s2.setRepeatingColumns(cra);
|
s2.setRepeatingColumns(cra);
|
||||||
s2.setRepeatingRows(cra);
|
s2.setRepeatingRows(cra);
|
||||||
|
|
||||||
ps2 = s2.getPrintSetup();
|
ps2 = s2.getPrintSetup();
|
||||||
assertEquals(true, s2.getCTWorksheet().isSetPageSetup());
|
assertTrue(s2.getCTWorksheet().isSetPageSetup());
|
||||||
assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
|
assertTrue(s2.getCTWorksheet().isSetPageMargins());
|
||||||
assertEquals(true, ps2.getValidSettings());
|
assertTrue(ps2.getValidSettings());
|
||||||
assertEquals(false, ps2.getLandscape());
|
assertFalse(ps2.getLandscape());
|
||||||
|
|
||||||
wb1.close();
|
wb1.close();
|
||||||
wb2.close();
|
wb2.close();
|
||||||
@ -1887,9 +1888,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
// Check the core properties - will be found but empty, due
|
// Check the core properties - will be found but empty, due
|
||||||
// to the expansion being too much to be considered valid
|
// to the expansion being too much to be considered valid
|
||||||
POIXMLProperties props = new POIXMLProperties(pkg);
|
POIXMLProperties props = new POIXMLProperties(pkg);
|
||||||
assertEquals(null, props.getCoreProperties().getTitle());
|
assertNull(props.getCoreProperties().getTitle());
|
||||||
assertEquals(null, props.getCoreProperties().getSubject());
|
assertNull(props.getCoreProperties().getSubject());
|
||||||
assertEquals(null, props.getCoreProperties().getDescription());
|
assertNull(props.getCoreProperties().getDescription());
|
||||||
|
|
||||||
// Now check the spreadsheet itself
|
// Now check the spreadsheet itself
|
||||||
try {
|
try {
|
||||||
@ -2546,11 +2547,11 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
private void checkCellsAreGone(CalculationChain chain) {
|
private void checkCellsAreGone(CalculationChain chain) {
|
||||||
for (CTCalcCell calc : chain.getCTCalcChain().getCList()) {
|
for (CTCalcCell calc : chain.getCTCalcChain().getCList()) {
|
||||||
// A2 to A6 should be gone
|
// A2 to A6 should be gone
|
||||||
assertFalse(calc.getR().equals("A2"));
|
assertNotEquals("A2", calc.getR());
|
||||||
assertFalse(calc.getR().equals("A3"));
|
assertNotEquals("A3", calc.getR());
|
||||||
assertFalse(calc.getR().equals("A4"));
|
assertNotEquals("A4", calc.getR());
|
||||||
assertFalse(calc.getR().equals("A5"));
|
assertNotEquals("A5", calc.getR());
|
||||||
assertFalse(calc.getR().equals("A6"));
|
assertNotEquals("A6", calc.getR());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2830,7 +2831,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
Cell cell = row.getCell(cellNum);
|
Cell cell = row.getCell(cellNum);
|
||||||
String fmtCellValue = formatter.formatCellValue(cell);
|
String fmtCellValue = formatter.formatCellValue(cell);
|
||||||
assertNotNull(fmtCellValue);
|
assertNotNull(fmtCellValue);
|
||||||
assertFalse(fmtCellValue.equals("0"));
|
assertNotEquals("0", fmtCellValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3001,14 +3002,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
assertTrue("Last row num: " + sheet.getLastRowNum(), sheet.getLastRowNum() > 20);
|
assertTrue("Last row num: " + sheet.getLastRowNum(), sheet.getLastRowNum() > 20);
|
||||||
assertEquals("Checked", sheet.getRow(0).getCell(0).getStringCellValue());
|
assertEquals("Checked", sheet.getRow(0).getCell(0).getStringCellValue());
|
||||||
assertEquals("Checked", sheet.getRow(9).getCell(2).getStringCellValue());
|
assertEquals("Checked", sheet.getRow(9).getCell(2).getStringCellValue());
|
||||||
assertEquals(false, sheet.getRow(70).getCell(8).getBooleanCellValue());
|
assertFalse(sheet.getRow(70).getCell(8).getBooleanCellValue());
|
||||||
assertEquals(71, sheet.getPhysicalNumberOfRows());
|
assertEquals(71, sheet.getPhysicalNumberOfRows());
|
||||||
assertEquals(70, sheet.getLastRowNum());
|
assertEquals(70, sheet.getLastRowNum());
|
||||||
assertEquals(70, sheet.getRow(sheet.getLastRowNum()).getRowNum());
|
assertEquals(70, sheet.getRow(sheet.getLastRowNum()).getRowNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWorkdayFunction() throws IOException {
|
public void testWorkdayFunction() {
|
||||||
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("59106.xlsx");
|
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("59106.xlsx");
|
||||||
XSSFSheet sheet = workbook.getSheet("Test");
|
XSSFSheet sheet = workbook.getSheet("Test");
|
||||||
Row row = sheet.getRow(1);
|
Row row = sheet.getRow(1);
|
||||||
@ -3063,7 +3064,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
* part with a part number)
|
* part with a part number)
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void drawingNumbersAlreadyTaken_60255() throws Exception {
|
public void drawingNumbersAlreadyTaken_60255() {
|
||||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("60255_extra_drawingparts.xlsx");
|
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("60255_extra_drawingparts.xlsx");
|
||||||
assertEquals(4, wb.getNumberOfSheets());
|
assertEquals(4, wb.getNumberOfSheets());
|
||||||
|
|
||||||
@ -3262,7 +3263,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
* TODO Get this to actually reproduce the bug...
|
* TODO Get this to actually reproduce the bug...
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void test62108() throws IOException {
|
public void test62108() {
|
||||||
XSSFWorkbook wb = new XSSFWorkbook();
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
XSSFSheet sheet = wb.createSheet();
|
XSSFSheet sheet = wb.createSheet();
|
||||||
XSSFRow row = sheet.createRow(0);
|
XSSFRow row = sheet.createRow(0);
|
||||||
|
@ -21,6 +21,7 @@ import static org.apache.poi.POITestCase.assertContains;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.Assert.assertSame;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@ -570,8 +571,8 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
HSSFWorkbook wb = openSample("35564.xls");
|
HSSFWorkbook wb = openSample("35564.xls");
|
||||||
|
|
||||||
HSSFSheet sheet = wb.getSheetAt(0);
|
HSSFSheet sheet = wb.getSheetAt(0);
|
||||||
assertEquals(false, sheet.isGridsPrinted());
|
assertFalse(sheet.isGridsPrinted());
|
||||||
assertEquals(false, sheet.getProtect());
|
assertFalse(sheet.getProtect());
|
||||||
|
|
||||||
writeOutAndReadBack(wb).close();
|
writeOutAndReadBack(wb).close();
|
||||||
|
|
||||||
@ -1042,11 +1043,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
wb.getFontAt(2),
|
wb.getFontAt(2),
|
||||||
wb.getFontAt(2)
|
wb.getFontAt(2)
|
||||||
);
|
);
|
||||||
assertTrue(
|
assertNotSame(wb.getFontAt(0), wb.getFontAt(2));
|
||||||
wb.getFontAt(0)
|
|
||||||
!=
|
|
||||||
wb.getFontAt(2)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Look for a new font we have
|
// Look for a new font we have
|
||||||
// yet to add
|
// yet to add
|
||||||
@ -1727,10 +1724,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
UnicodeString withoutExt = wb1.getWorkbook().getSSTString(31);
|
UnicodeString withoutExt = wb1.getWorkbook().getSSTString(31);
|
||||||
|
|
||||||
assertEquals("O:Alloc:Qty", withExt.getString());
|
assertEquals("O:Alloc:Qty", withExt.getString());
|
||||||
assertTrue((withExt.getOptionFlags() & 0x0004) == 0x0004);
|
assertEquals(0x0004, (withExt.getOptionFlags() & 0x0004));
|
||||||
|
|
||||||
assertEquals("RT", withoutExt.getString());
|
assertEquals("RT", withoutExt.getString());
|
||||||
assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000);
|
assertEquals(0x0000, (withoutExt.getOptionFlags() & 0x0004));
|
||||||
|
|
||||||
// Something about continues...
|
// Something about continues...
|
||||||
|
|
||||||
@ -1745,10 +1742,10 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
withoutExt = wb2.getWorkbook().getSSTString(31);
|
withoutExt = wb2.getWorkbook().getSSTString(31);
|
||||||
|
|
||||||
assertEquals("O:Alloc:Qty", withExt.getString());
|
assertEquals("O:Alloc:Qty", withExt.getString());
|
||||||
assertTrue((withExt.getOptionFlags() & 0x0004) == 0x0004);
|
assertEquals(0x0004, (withExt.getOptionFlags() & 0x0004));
|
||||||
|
|
||||||
assertEquals("RT", withoutExt.getString());
|
assertEquals("RT", withoutExt.getString());
|
||||||
assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000);
|
assertEquals(0x0000, (withoutExt.getOptionFlags() & 0x0004));
|
||||||
wb2.close();
|
wb2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2215,7 +2212,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
HSSFWorkbook wb1 = openSample("50833.xls");
|
HSSFWorkbook wb1 = openSample("50833.xls");
|
||||||
HSSFSheet s = wb1.getSheetAt(0);
|
HSSFSheet s = wb1.getSheetAt(0);
|
||||||
assertEquals("Sheet1", s.getSheetName());
|
assertEquals("Sheet1", s.getSheetName());
|
||||||
assertEquals(false, s.getProtect());
|
assertFalse(s.getProtect());
|
||||||
|
|
||||||
HSSFCell c = s.getRow(0).getCell(0);
|
HSSFCell c = s.getRow(0).getCell(0);
|
||||||
assertEquals("test cell value", c.getRichStringCellValue().getString());
|
assertEquals("test cell value", c.getRichStringCellValue().getString());
|
||||||
|
Loading…
Reference in New Issue
Block a user