public void testGetFillForegroundColor() {
XSSFWorkbook wb = new XSSFWorkbook();
StylesTable styles = wb.getStylesSource();
assertEquals(1, wb.getNumCellStyles());
assertEquals(2, styles.getFills().size());
XSSFCellStyle defaultStyle = wb.getCellStyleAt((short)0);
assertEquals(IndexedColors.AUTOMATIC.getIndex(), defaultStyle.getFillForegroundColor());
assertEquals(null, defaultStyle.getFillForegroundXSSFColor());
assertEquals(CellStyle.NO_FILL, defaultStyle.getFillPattern());
XSSFCellStyle customStyle = wb.createCellStyle();
customStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
assertEquals(CellStyle.SOLID_FOREGROUND, customStyle.getFillPattern());
assertEquals(3, styles.getFills().size());
customStyle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
assertEquals(IndexedColors.BRIGHT_GREEN.getIndex(), customStyle.getFillForegroundColor());
assertEquals(4, styles.getFills().size());
for (int i = 0; i < 3; i++) {
XSSFCellStyle style = wb.createCellStyle();
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
assertEquals(CellStyle.SOLID_FOREGROUND, style.getFillPattern());
assertEquals(4, styles.getFills().size());
style.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
assertEquals(IndexedColors.BRIGHT_GREEN.getIndex(), style.getFillForegroundColor());
assertEquals(4, styles.getFills().size());
}
}