]> source.dussan.org Git - poi.git/commitdiff
Add reproducing testcase for Bug 57294
authorDominik Stadler <centic@apache.org>
Mon, 5 Jan 2015 14:39:51 +0000 (14:39 +0000)
committerDominik Stadler <centic@apache.org>
Mon, 5 Jan 2015 14:39:51 +0000 (14:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1649536 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java

index 4c1e6c563a3af1327216edc52ab42f3e254585f8..cb29db710e316e7ce62dfffe836309fafd91b788 100644 (file)
@@ -29,6 +29,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.Cell;\r
 import org.apache.poi.ss.usermodel.DataFormatter;\r
 import org.apache.poi.ss.usermodel.DateUtil;\r
+import org.apache.poi.ss.usermodel.RichTextString;\r
 import org.apache.poi.ss.usermodel.Row;\r
 import org.apache.poi.ss.usermodel.Sheet;\r
 import org.apache.poi.ss.usermodel.Workbook;\r
@@ -211,4 +212,32 @@ public final class TestUnfixedBugs extends TestCase {
             wb.removeSheetAt(sn);\r
         }\r
     }\r
+\r
+    // When this is fixed, the test case should go to BaseTestXCell with \r
+    // adjustments to use _testDataProvider to also verify this for XSSF\r
+    public void testBug57294() throws IOException {\r
+        Workbook wb = SXSSFITestDataProvider.instance.createWorkbook();\r
+        \r
+        Sheet sheet = wb.createSheet();\r
+        Row row = sheet.createRow(0);\r
+        Cell cell = row.createCell(0);\r
+        \r
+        RichTextString str = new XSSFRichTextString("Test rich text string");\r
+        str.applyFont(2, 4, (short)0);\r
+        assertEquals(3, str.numFormattingRuns());\r
+        cell.setCellValue(str);\r
+        \r
+        Workbook wbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);\r
+        wb.close();\r
+        \r
+        // re-read after serializing and reading back\r
+        Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(0);\r
+        assertNotNull(cellBack);\r
+        RichTextString strBack = cellBack.getRichStringCellValue();\r
+        assertNotNull(strBack);\r
+        assertEquals(3, strBack.numFormattingRuns());\r
+        assertEquals(0, strBack.getIndexOfFormattingRun(0));\r
+        assertEquals(2, strBack.getIndexOfFormattingRun(1));\r
+        assertEquals(4, strBack.getIndexOfFormattingRun(2));\r
+    }\r
 }\r