]> source.dussan.org Git - poi.git/commitdiff
add BaseTestCellUtil unit tests to cover setting cell style properties with an invali...
authorJaven O'Neal <onealj@apache.org>
Sun, 10 Jul 2016 11:37:22 +0000 (11:37 +0000)
committerJaven O'Neal <onealj@apache.org>
Sun, 10 Jul 2016 11:37:22 +0000 (11:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1752079 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java

index cc299eb166424c773eb47db9ab839dba3ca333c7..c519e165a833c9fa9a0c41e64e699b300d992336 100644 (file)
@@ -74,6 +74,37 @@ public class BaseTestCellUtil {
 \r
         wb.close();\r
     }\r
+    \r
+    @Test(expected=RuntimeException.class)\r
+    public void setCellStylePropertyWithInvalidValue() throws IOException {\r
+        Workbook wb = _testDataProvider.createWorkbook();\r
+        Sheet s = wb.createSheet();\r
+        Row r = s.createRow(0);\r
+        Cell c = r.createCell(0);\r
+\r
+        // An invalid BorderStyle constant\r
+        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 42);\r
+        \r
+        wb.close();\r
+    }\r
+    \r
+    @Test()\r
+    public void setCellStylePropertyBorderWithShortAndEnum() throws IOException {\r
+        Workbook wb = _testDataProvider.createWorkbook();\r
+        Sheet s = wb.createSheet();\r
+        Row r = s.createRow(0);\r
+        Cell c = r.createCell(0);\r
+\r
+        // A valid BorderStyle constant, as a Short\r
+        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, BorderStyle.DASH_DOT.getCode());\r
+        assertEquals(BorderStyle.DASH_DOT, c.getCellStyle().getBorderBottom());\r
+        \r
+        // A valid BorderStyle constant, as an Enum\r
+        CellUtil.setCellStyleProperty(c, CellUtil.BORDER_TOP, BorderStyle.MEDIUM_DASH_DOT);\r
+        assertEquals(BorderStyle.MEDIUM_DASH_DOT, c.getCellStyle().getBorderTop());\r
+        \r
+        wb.close();\r
+    }\r
 \r
     @Test\r
     public void setCellStyleProperties() throws IOException {\r