aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-10-28 17:42:56 +0000
committerNick Burch <nick@apache.org>2015-10-28 17:42:56 +0000
commit8f0093e4648f0e9598d26847984eee060535f951 (patch)
treeaaf3542dc8f65fac07ad71a5687e1147be31dec6 /src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
parent974367ed1d3956415ab85244cbc20dfd47c22283 (diff)
downloadpoi-8f0093e4648f0e9598d26847984eee060535f951.tar.gz
poi-8f0093e4648f0e9598d26847984eee060535f951.zip
#58558 SXSSFCell.setCellValue((RichTextString)null) fixed to work like XSSF and HSSF, with common unit tests to verify this
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1711082 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
index 20451d6f35..9cdaf3d18d 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
@@ -767,7 +767,39 @@ public abstract class BaseTestCell {
wb1.close();
}
- private void checkUnicodeValues(Workbook wb) {
+ /**
+ * Setting a cell value of a null RichTextString should set
+ * the cell to Blank, test case for 58558
+ */
+ @Test
+ public void testSetCellValueNullRichTextString() throws IOException {
+ Workbook wb = _testDataProvider.createWorkbook();
+ Sheet sheet = wb.createSheet();
+ Cell cell = sheet.createRow(0).createCell(0);
+
+ RichTextString nullStr = null;
+ cell.setCellValue(nullStr);
+ assertEquals("", cell.getStringCellValue());
+ assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
+
+ cell = sheet.createRow(0).createCell(1);
+ cell.setCellValue(1.2d);
+ assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ cell.setCellValue(nullStr);
+ assertEquals("", cell.getStringCellValue());
+ assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
+
+ cell = sheet.createRow(0).createCell(1);
+ cell.setCellValue(wb.getCreationHelper().createRichTextString("Test"));
+ assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
+ cell.setCellValue(nullStr);
+ assertEquals("", cell.getStringCellValue());
+ assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
+
+ wb.close();
+ }
+
+ private void checkUnicodeValues(Workbook wb) {
assertEquals((wb instanceof HSSFWorkbook ? "row 0, cell 0 _x0046_ without changes" : "row 0, cell 0 F without changes"),
wb.getSheetAt(0).getRow(0).getCell(0).toString());
assertEquals((wb instanceof HSSFWorkbook ? "row 0, cell 1 _x005fx0046_ with changes" : "row 0, cell 1 _x005fx0046_ with changes"),