diff options
author | Nick Burch <nick@apache.org> | 2011-03-04 21:09:02 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2011-03-04 21:09:02 +0000 |
commit | 5805f3b66001219a382427f995b323fcba40d700 (patch) | |
tree | dc60ff6091c3c8094ed9c2faacdd6ba898590658 /src/testcases | |
parent | cb54849561ea3c1f99d11097de97370f0309554f (diff) | |
download | poi-5805f3b66001219a382427f995b323fcba40d700.tar.gz poi-5805f3b66001219a382427f995b323fcba40d700.zip |
Add a unit test for bug #50833
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1078135 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index ae54b4aaac..2725528e86 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -22,7 +22,10 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; import junit.framework.AssertionFailedError; @@ -43,7 +46,6 @@ import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Name; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -1983,4 +1985,38 @@ if(1==2) { assertEquals("35", df.formatCellValue(r18.getCell(2))); assertEquals("123", df.formatCellValue(r18.getCell(3))); } + + /** + * A protected sheet with comments, when written out by + * POI, ends up upsetting excel. + * TODO Identify the cause and add extra asserts for + * the bit excel cares about + */ + public void test50833() throws Exception { + HSSFWorkbook wb = openSample("50833.xls"); + HSSFSheet s = wb.getSheetAt(0); + assertEquals("Sheet1", s.getSheetName()); + assertEquals(false, s.getProtect()); + + HSSFCell c = s.getRow(0).getCell(0); + assertEquals("test cell value", c.getRichStringCellValue().getString()); + + HSSFComment cmt = c.getCellComment(); + assertNotNull(cmt); + assertEquals("Robert Lawrence", cmt.getAuthor()); + assertEquals("Robert Lawrence:\ntest comment", cmt.getString().getString()); + + // Reload + wb = writeOutAndReadBack(wb); + s = wb.getSheetAt(0); + c = s.getRow(0).getCell(0); + + // Re-check the comment + cmt = c.getCellComment(); + assertNotNull(cmt); + assertEquals("Robert Lawrence", cmt.getAuthor()); + assertEquals("Robert Lawrence:\ntest comment", cmt.getString().getString()); + + // TODO Identify what excel doesn't like, and check for that + } } |