aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2009-04-17 18:02:01 +0000
committerYegor Kozlov <yegor@apache.org>2009-04-17 18:02:01 +0000
commit9eff4e10b36d171ed5a33771066b779604897aff (patch)
tree33621cb83b0e84d70138f56fbb3ee5b4cbebd138 /src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
parent2ab0a58566226570ecbf55b7700cfb31d1e60a74 (diff)
downloadpoi-9eff4e10b36d171ed5a33771066b779604897aff.tar.gz
poi-9eff4e10b36d171ed5a33771066b779604897aff.zip
Fixed XSSFCell to preserve cell style when cell value is set to blank, also avoid NPE in XSSFCell.setCellType() when workbook does not have SST, see bugs 47026 and 47028
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@766103 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java')
-rwxr-xr-xsrc/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
index 5649c950e8..1a987c1ac8 100755
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
@@ -22,7 +22,6 @@ import java.util.Calendar;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.ss.ITestDataProvider;
/**
@@ -31,7 +30,7 @@ import org.apache.poi.ss.ITestDataProvider;
*/
public abstract class BaseTestCell extends TestCase {
- private final ITestDataProvider _testDataProvider;
+ protected final ITestDataProvider _testDataProvider;
/**
* @param testDataProvider an object that provides test data in HSSF / XSSF specific way
@@ -401,9 +400,23 @@ public abstract class BaseTestCell extends TestCase {
Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
cell.setCellFormula("B1&C1");
try {
- cell.setCellValue(new HSSFRichTextString("hello"));
+ cell.setCellValue(wb.getCreationHelper().createRichTextString("hello"));
} catch (ClassCastException e) {
throw new AssertionFailedError("Identified bug 44606");
}
}
+
+ /**
+ * Make sure that cell.setCellType(Cell.CELL_TYPE_BLANK) preserves the cell style
+ */
+ public void testSetBlank_bug47028() {
+ Workbook wb = _testDataProvider.createWorkbook();
+ CellStyle style = wb.createCellStyle();
+ Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
+ cell.setCellStyle(style);
+ int i1 = cell.getCellStyle().getIndex();
+ cell.setCellType(Cell.CELL_TYPE_BLANK);
+ int i2 = cell.getCellStyle().getIndex();
+ assertEquals(i1, i2);
+ }
}