diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java index c907d40..1a6c7d6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java @@ -67,15 +67,15 @@ ctBorderA = CTBorder.Factory.newInstance(); XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA); long borderId = stylesTable.putBorder(borderA); - assertEquals(1, borderId); + assertEquals(0, borderId); XSSFCellBorder borderB = new XSSFCellBorder(); - assertEquals(1, stylesTable.putBorder(borderB)); + assertEquals(0, stylesTable.putBorder(borderB)); ctFill = CTFill.Factory.newInstance(); XSSFCellFill fill = new XSSFCellFill(ctFill); long fillId = stylesTable.putFill(fill); - assertEquals(2, fillId); + assertEquals(0, fillId); ctFont = CTFont.Factory.newInstance(); XSSFFont font = new XSSFFont(ctFont); @@ -133,7 +133,10 @@ assertEquals(num, stylesTable.getBorders().size()); borderId = (int)cellStyle.getCoreXf().getBorderId(); ctBorder = stylesTable.getBorderAt(borderId).getCTBorder(); - assertFalse(ctBorder.isSetBottom()); + //none is not the same as "not set", therefore the following doesn't work any more + //assertFalse(ctBorder.isSetBottom()); + //replacement: + assertEquals(ctBorder.getBottom().getStyle(), STBorderStyle.NONE); } @Test @@ -168,7 +171,10 @@ assertEquals(num, stylesTable.getBorders().size()); borderId = (int)cellStyle.getCoreXf().getBorderId(); ctBorder = stylesTable.getBorderAt(borderId).getCTBorder(); - assertFalse(ctBorder.isSetRight()); + //none is not the same as "not set", therefore the following doesn't work any more + //assertFalse(ctBorder.isSetRight()); + //replacement: + assertEquals(ctBorder.getRight().getStyle(), STBorderStyle.NONE); } @Test @@ -203,7 +209,10 @@ assertEquals(num, stylesTable.getBorders().size()); borderId = (int)cellStyle.getCoreXf().getBorderId(); ctBorder = stylesTable.getBorderAt(borderId).getCTBorder(); - assertFalse(ctBorder.isSetLeft()); + //none is not the same as "not set", therefore the following doesn't work any more + //assertFalse(ctBorder.isSetLeft()); + //replacement: + assertEquals(ctBorder.getLeft().getStyle(), STBorderStyle.NONE); } @Test @@ -238,7 +247,10 @@ assertEquals(num, stylesTable.getBorders().size()); borderId = (int)cellStyle.getCoreXf().getBorderId(); ctBorder = stylesTable.getBorderAt(borderId).getCTBorder(); - assertFalse(ctBorder.isSetTop()); + //none is not the same as "not set", therefore the following doesn't work any more + //assertFalse(ctBorder.isSetTop()); + //replacement: + assertEquals(ctBorder.getTop().getStyle(), STBorderStyle.NONE); } private void testGetSetBorderXMLBean(BorderStyle border, STBorderStyle.Enum expected) { @@ -258,10 +270,14 @@ cellStyle.setBorderTop(BorderStyle.NONE); assertEquals(BorderStyle.NONE, cellStyle.getBorderTopEnum()); int borderId = (int)cellStyle.getCoreXf().getBorderId(); - assertTrue(borderId > 0); + // The default Style is already "none" + // Therefore the new style already exists as Id=0 + //assertTrue(borderId > 0); + // replacement: + assertTrue(borderId == 0); //check changes in the underlying xml bean CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder(); - assertNull(ctBorder.getTop()); + assertNotNull(ctBorder.getTop()); // no border style and STBorderStyle.NONE are equivalent // POI prefers to unset the border style than explicitly set it STBorderStyle.NONE } @@ -782,6 +798,8 @@ orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT); orig.setFont(fnt); orig.setDataFormat(fmt.getFormat("Test##")); + orig.setFillPattern(FillPatternType.SOLID_FOREGROUND); + orig.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex()); assertTrue(XSSFCellStyle.ALIGN_RIGHT == orig.getAlignment()); assertTrue(fnt == orig.getFont()); @@ -816,6 +834,8 @@ assertEquals("TestingFont", clone.getFont().getFontName()); assertEquals(fmtClone.getFormat("Test##"), clone.getDataFormat()); assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##")); + assertEquals(clone.getFillPatternEnum(), FillPatternType.SOLID_FOREGROUND); + assertEquals(clone.getFillForegroundColor(), IndexedColors.BRIGHT_GREEN.getIndex()); // Save it and re-check XSSFWorkbook wbReload = XSSFTestDataSamples.writeOutAndReadBack(wbClone); @@ -828,6 +848,8 @@ assertEquals("TestingFont", reload.getFont().getFontName()); assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat()); assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##")); + assertEquals(clone.getFillPatternEnum(), FillPatternType.SOLID_FOREGROUND); + assertEquals(clone.getFillForegroundColor(), IndexedColors.BRIGHT_GREEN.getIndex()); XSSFWorkbook wbOrig2 = XSSFTestDataSamples.writeOutAndReadBack(wbOrig); assertNotNull(wbOrig2);