aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2019-01-11 19:30:44 +0000
committerDominik Stadler <centic@apache.org>2019-01-11 19:30:44 +0000
commita1a179729905b237dbdbfa96337357965d766fab (patch)
tree977265b14e4ac2925983855da74ae5769e883c39 /src/ooxml/testcases/org/apache
parent8b69fcc642981c773f5ac35264813b8d65e91cf2 (diff)
downloadpoi-a1a179729905b237dbdbfa96337357965d766fab.tar.gz
poi-a1a179729905b237dbdbfa96337357965d766fab.zip
Add one more test for bug 62828 and fix some IDE warnings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1851088 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java33
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java25
2 files changed, 31 insertions, 27 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
index b044e97c06..6e83a5e6e2 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
@@ -222,7 +222,7 @@ public final class TestXSSFCell extends BaseTestXCell {
assertEquals("a", cell.toString());
//Gnumeric produces spreadsheets without styles
//make sure we return null for that instead of throwing OutOfBounds
- assertEquals(null, cell.getCellStyle());
+ assertNull(cell.getCellStyle());
//try a numeric cell
cell = sh.getRow(1).getCell(0);
@@ -231,7 +231,7 @@ public final class TestXSSFCell extends BaseTestXCell {
assertEquals("1.0", cell.toString());
//Gnumeric produces spreadsheets without styles
//make sure we return null for that instead of throwing OutOfBounds
- assertEquals(null, cell.getCellStyle());
+ assertNull(cell.getCellStyle());
wb.close();
}
@@ -565,7 +565,7 @@ public final class TestXSSFCell extends BaseTestXCell {
// Old cell value should not have been overwritten
assertNotEquals(CellType.BLANK, destCell.getCellType());
assertEquals(CellType.BOOLEAN, destCell.getCellType());
- assertEquals(true, destCell.getBooleanCellValue());
+ assertTrue(destCell.getBooleanCellValue());
}
@Test
@@ -580,12 +580,7 @@ public final class TestXSSFCell extends BaseTestXCell {
srcCell.setHyperlink(link);
// Set link cell style (optional)
- CellStyle hlinkStyle = wb.createCellStyle();
- Font hlinkFont = wb.createFont();
- hlinkFont.setUnderline(Font.U_SINGLE);
- hlinkFont.setColor(IndexedColors.BLUE.getIndex());
- hlinkStyle.setFont(hlinkFont);
- srcCell.setCellStyle(hlinkStyle);
+ setLinkCellStyle(wb, srcCell);
// Copy hyperlink
final CellCopyPolicy policy = new CellCopyPolicy.Builder().copyHyperlink(true).mergeHyperlink(false).build();
@@ -604,7 +599,16 @@ public final class TestXSSFCell extends BaseTestXCell {
wb.close();
}
-
+
+ private void setLinkCellStyle(Workbook wb, XSSFCell srcCell) {
+ CellStyle hlinkStyle = wb.createCellStyle();
+ Font hlinkFont = wb.createFont();
+ hlinkFont.setUnderline(Font.U_SINGLE);
+ hlinkFont.setColor(IndexedColors.BLUE.getIndex());
+ hlinkStyle.setFont(hlinkFont);
+ srcCell.setCellStyle(hlinkStyle);
+ }
+
@Test
public final void testCopyCellFrom_CellCopyPolicy_mergeHyperlink() throws IOException {
setUp_testCopyCellFrom_CellCopyPolicy();
@@ -617,13 +621,8 @@ public final class TestXSSFCell extends BaseTestXCell {
destCell.setHyperlink(link);
// Set link cell style (optional)
- CellStyle hlinkStyle = wb.createCellStyle();
- Font hlinkFont = wb.createFont();
- hlinkFont.setUnderline(Font.U_SINGLE);
- hlinkFont.setColor(IndexedColors.BLUE.getIndex());
- hlinkStyle.setFont(hlinkFont);
- destCell.setCellStyle(hlinkStyle);
-
+ setLinkCellStyle(wb, destCell);
+
// Pre-condition assumptions. This test is broken if either of these fail.
assertSame("unit test assumes srcCell and destCell are on the same sheet",
srcCell.getSheet(), destCell.getSheet());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
index 85118916c8..6e54db73ca 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
@@ -113,7 +113,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
ftr = (XSSFOddFooter) s1.getFooter();
assertEquals("&Ctestdoc&Rtest phrase", hdr.getText());
- assertEquals(null, ftr.getText());
+ assertNull(ftr.getText());
assertEquals("", hdr.getLeft());
assertEquals("testdoc", hdr.getCenter());
@@ -130,7 +130,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
hdr = (XSSFOddHeader) s2.getHeader();
ftr = (XSSFOddFooter) s2.getFooter();
- assertEquals(null, hdr.getText());
+ assertNull(hdr.getText());
assertEquals("&L&F", ftr.getText());
assertEquals("", hdr.getLeft());
@@ -964,15 +964,15 @@ public final class TestXSSFSheet extends BaseTestXSheet {
//rows are sorted: {0, 1, 2}
assertEquals(4, xrow[0].sizeOfCArray());
assertEquals(1, xrow[0].getR());
- assertTrue(xrow[0].equals(row3.getCTRow()));
+ assertEquals(xrow[0], row3.getCTRow());
assertEquals(3, xrow[1].sizeOfCArray());
assertEquals(2, xrow[1].getR());
- assertTrue(xrow[1].equals(row2.getCTRow()));
+ assertEquals(xrow[1], row2.getCTRow());
assertEquals(2, xrow[2].sizeOfCArray());
assertEquals(3, xrow[2].getR());
- assertTrue(xrow[2].equals(row1.getCTRow()));
+ assertEquals(xrow[2], row1.getCTRow());
CTCell[] xcell = xrow[0].getCArray();
assertEquals("D1", xcell[0].getR());
@@ -1487,7 +1487,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// Boolean
cell = CellUtil.getCell(destRow, col++);
assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellType());
- assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue());
+ assertTrue("[Boolean] F7 cell value", cell.getBooleanCellValue());
// String
cell = CellUtil.getCell(destRow, col++);
@@ -1656,11 +1656,11 @@ public final class TestXSSFSheet extends BaseTestXSheet {
col++;
cell = CellUtil.getCell(destRow1, col);
assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellType());
- assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue());
+ assertTrue("[Boolean] F10 cell value", cell.getBooleanCellValue());
cell = CellUtil.getCell(destRow2, col);
assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellType());
- assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue());
+ assertFalse("[Boolean] F11 cell value", cell.getBooleanCellValue());
// String
col++;
@@ -1922,6 +1922,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// test regular-colored (non-indexed, ARGB) sheet
expected = XSSFColor.from(CTColor.Factory.newInstance(), wb.getStylesSource().getIndexedColors());
+ assertNotNull(expected);
expected.setARGBHex("FF7F2700");
assertEquals(expected, wb.getSheet("customOrange").getTabColor());
}
@@ -1931,7 +1932,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
* See bug #52425
*/
@Test
- public void testInsertCommentsToClonedSheet() {
+ public void testInsertCommentsToClonedSheet() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("52425.xlsx");
CreationHelper helper = wb.getCreationHelper();
Sheet sheet2 = wb.createSheet("Sheet 2");
@@ -1942,7 +1943,9 @@ public final class TestXSSFSheet extends BaseTestXSheet {
addComments(helper, sheet2);
// Adding Comment to cloned Sheet 3
addComments(helper, sheet3);
- }
+
+ wb.close();
+ }
private void addComments(CreationHelper helper, Sheet sheet) {
Drawing<?> drawing = sheet.createDrawingPatriarch();
@@ -1986,6 +1989,8 @@ public final class TestXSSFSheet extends BaseTestXSheet {
sheet.removeRow(sheet.getRow(commentCellAddress.getRow()));
assertEquals("There should not be any comments left!", 0, sheet.getCellComments().size());
+
+ wb.close();
}
@Test