From: Dominik Stadler Date: Mon, 5 Jan 2015 14:39:51 +0000 (+0000) Subject: Add reproducing testcase for Bug 57294 X-Git-Tag: REL_3_12_BETA1~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7d0c19328bf1b996eef24533e8ef51b8158da75;p=poi.git Add reproducing testcase for Bug 57294 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1649536 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java index 4c1e6c563a..cb29db710e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java @@ -29,6 +29,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -211,4 +212,32 @@ public final class TestUnfixedBugs extends TestCase { wb.removeSheetAt(sn); } } + + // When this is fixed, the test case should go to BaseTestXCell with + // adjustments to use _testDataProvider to also verify this for XSSF + public void testBug57294() throws IOException { + Workbook wb = SXSSFITestDataProvider.instance.createWorkbook(); + + Sheet sheet = wb.createSheet(); + Row row = sheet.createRow(0); + Cell cell = row.createCell(0); + + RichTextString str = new XSSFRichTextString("Test rich text string"); + str.applyFont(2, 4, (short)0); + assertEquals(3, str.numFormattingRuns()); + cell.setCellValue(str); + + Workbook wbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb); + wb.close(); + + // re-read after serializing and reading back + Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(0); + assertNotNull(cellBack); + RichTextString strBack = cellBack.getRichStringCellValue(); + assertNotNull(strBack); + assertEquals(3, strBack.numFormattingRuns()); + assertEquals(0, strBack.getIndexOfFormattingRun(0)); + assertEquals(2, strBack.getIndexOfFormattingRun(1)); + assertEquals(4, strBack.getIndexOfFormattingRun(2)); + } }