aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2025-04-21 08:51:02 +0000
committerDominik Stadler <centic@apache.org>2025-04-21 08:51:02 +0000
commit85aa74414c04741b85cf2873adf557003148cfa6 (patch)
tree9f1367b552941940d2b803bdb6de90cce84ec5d1
parent7c9a1ce89b0d90a9584e188837f1c9e7d40cbb69 (diff)
downloadpoi-85aa74414c04741b85cf2873adf557003148cfa6.tar.gz
poi-85aa74414c04741b85cf2873adf557003148cfa6.zip
Add test which populates cells with null string
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925187 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
index ceef38cd18..e42a662813 100644
--- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
+++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
@@ -1473,6 +1473,36 @@ public abstract class BaseTestCell {
verify(cell).setBlank();
}
+ @Test
+ protected void setCellNullString() throws IOException {
+ try (Workbook wb = _testDataProvider.createWorkbook()) {
+ Cell cell = getInstance(wb);
+
+ cell.setCellValue((String)null);
+
+ // setting string "null" leads to a BLANK cell
+ assertEquals(CellType.BLANK, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+ assertEquals("", cell.toString());
+
+ cell.setCellType(CellType.STRING);
+
+ // forcing to string type leads to STRING cell, but still empty strings
+ assertEquals(CellType.STRING, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+ assertEquals("", cell.toString());
+
+ try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb)) {
+ // read first sheet, first row, first cell
+ Cell cellBack = wb2.iterator().next().iterator().next().iterator().next();
+
+ assertEquals(CellType.STRING, cell.getCellType());
+ assertEquals("", cell.getStringCellValue());
+ assertEquals("", cell.toString());
+ }
+ }
+ }
+
private Cell getInstance(Workbook wb) {
return wb.createSheet().createRow(0).createCell(0);
}