From: Javen O'Neal Date: Sun, 10 Jul 2016 11:37:22 +0000 (+0000) Subject: add BaseTestCellUtil unit tests to cover setting cell style properties with an invali... X-Git-Tag: REL_3_15_BETA3~133 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8ff5dc84eaf5f531316d1e01304f5a839701b93;p=poi.git add BaseTestCellUtil unit tests to cover setting cell style properties with an invalid value and using both valid Short and Enum values git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752079 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java b/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java index cc299eb166..c519e165a8 100644 --- a/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java +++ b/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java @@ -74,6 +74,37 @@ public class BaseTestCellUtil { wb.close(); } + + @Test(expected=RuntimeException.class) + public void setCellStylePropertyWithInvalidValue() throws IOException { + Workbook wb = _testDataProvider.createWorkbook(); + Sheet s = wb.createSheet(); + Row r = s.createRow(0); + Cell c = r.createCell(0); + + // An invalid BorderStyle constant + CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 42); + + wb.close(); + } + + @Test() + public void setCellStylePropertyBorderWithShortAndEnum() throws IOException { + Workbook wb = _testDataProvider.createWorkbook(); + Sheet s = wb.createSheet(); + Row r = s.createRow(0); + Cell c = r.createCell(0); + + // A valid BorderStyle constant, as a Short + CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, BorderStyle.DASH_DOT.getCode()); + assertEquals(BorderStyle.DASH_DOT, c.getCellStyle().getBorderBottom()); + + // A valid BorderStyle constant, as an Enum + CellUtil.setCellStyleProperty(c, CellUtil.BORDER_TOP, BorderStyle.MEDIUM_DASH_DOT); + assertEquals(BorderStyle.MEDIUM_DASH_DOT, c.getCellStyle().getBorderTop()); + + wb.close(); + } @Test public void setCellStyleProperties() throws IOException {