From 8cc47c0d2aab1d080c133408b4eb2d03faa252c1 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Mon, 9 May 2016 01:27:31 +0000 Subject: [PATCH] =?utf8?q?add=20test=20case=20from=20Anders=20=C3=85berg?= =?utf8?q?=20for=20bug=2059442?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742862 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestXSSFBugs.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index d6e29d1293..942841bcc0 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Calendar; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -92,6 +93,7 @@ import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; +import org.apache.poi.ss.util.CellUtil; import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.TempFile; import org.apache.poi.xssf.XLSBUnsupportedException; @@ -3010,4 +3012,41 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { workbook.close(); } + + @Ignore("bug 59442") + @Test + public void testSetRGBBackgroundColor() throws IOException { + + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFCell cell = workbook.createSheet().createRow(0).createCell(0); + + XSSFColor color = new XSSFColor(java.awt.Color.RED); + XSSFCellStyle style = workbook.createCellStyle(); + style.setFillForegroundColor(color); + style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); + cell.setCellStyle(style); + + // Everything is fine at this point, cell is red + + Map properties = new HashMap(); + properties.put(CellUtil.BORDER_BOTTOM, CellStyle.BORDER_THIN); //or BorderStyle.THIN + CellUtil.setCellStyleProperties(cell, properties); + + // Now the cell is all black + XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor(); + assertNotNull(actual); + assertEquals(color.getARGBHex(), actual.getARGBHex()); + + XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(workbook); + workbook.close(); + XSSFCell ncell = nwb.getSheetAt(0).getRow(0).getCell(0); + XSSFColor ncolor = new XSSFColor(java.awt.Color.RED); + + // Now the cell is all black + XSSFColor nactual = ncell.getCellStyle().getFillBackgroundColorColor(); + assertNotNull(nactual); + assertEquals(ncolor.getARGBHex(), nactual.getARGBHex()); + + nwb.close(); + } } -- 2.39.5