You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/07/10 11:37:22 UTC

svn commit: r1752079 - /poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java

Author: onealj
Date: Sun Jul 10 11:37:22 2016
New Revision: 1752079

URL: http://svn.apache.org/viewvc?rev=1752079&view=rev
Log:
add BaseTestCellUtil unit tests to cover setting cell style properties with an invalid value and using both valid Short and Enum values

Modified:
    poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java

Modified: poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java?rev=1752079&r1=1752078&r2=1752079&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java Sun Jul 10 11:37:22 2016
@@ -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 {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org