]> source.dussan.org Git - poi.git/commitdiff
Bug 56959: Add verification unit test to show that the bug cannot be reproduced
authorDominik Stadler <centic@apache.org>
Thu, 3 Sep 2015 20:46:32 +0000 (20:46 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 3 Sep 2015 20:46:32 +0000 (20:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1701135 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/usermodel/CellStyle.java
src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java

index 3e22bab10bc7b3bce6b971db1c186ebe4a5fae9a..0cae6536275688e2d709c545156b8abac6a74430 100644 (file)
@@ -254,7 +254,7 @@ public interface CellStyle {
 
     /**
      * set the font for this style
-     * @param font  a font object created or retreived from the Workbook object
+     * @param font  a font object created or retrieved from the Workbook object
      * @see Workbook#createFont()
      * @see Workbook#getFontAt(short)
      */
index bd874629f8d3715dfb9d430e83eafaccdfc6ee42..759363a29d2f42dae23362a046db3053c211f34b 100644 (file)
@@ -28,6 +28,7 @@ import junit.framework.TestCase;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -127,7 +128,7 @@ public final class TestCellStyle extends TestCase {
         assertEquals("FIRST ROW ", 0, s.getFirstRowNum());
     }
     
-    public void testHashEquals() {
+    public void testHashEquals() throws IOException {
         HSSFWorkbook     wb   = new HSSFWorkbook();
         HSSFSheet        s    = wb.createSheet();
         HSSFCellStyle    cs1  = wb.createCellStyle();
@@ -154,6 +155,8 @@ public final class TestCellStyle extends TestCase {
         int hash1 = cs1.hashCode();
         cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy"));
         assertFalse(hash1 == cs1.hashCode());
+        
+        wb.close();
     }
 
     /**
@@ -467,4 +470,43 @@ public final class TestCellStyle extends TestCase {
             throw threadB.getException();
         }
     }
+    
+    public void test56959() throws IOException {
+        Workbook wb = new HSSFWorkbook();
+        Sheet sheet = wb.createSheet("somesheet");
+        
+        Row row = sheet.createRow(0);
+        
+        // Create a new font and alter it.
+        Font font = wb.createFont();
+        font.setFontHeightInPoints((short)24);
+        font.setFontName("Courier New");
+        font.setItalic(true);
+        font.setStrikeout(true);
+        font.setColor(Font.COLOR_RED);
+        
+        CellStyle style = wb.createCellStyle();
+        style.setBorderBottom(CellStyle.BORDER_DOTTED);
+        style.setFont(font);
+        
+        Cell cell = row.createCell(0);
+        cell.setCellStyle(style);
+        cell.setCellValue("testtext");
+        
+        Cell newCell = row.createCell(1);
+        
+        newCell.setCellStyle(style);
+        newCell.setCellValue("2testtext2");
+
+        CellStyle newStyle = newCell.getCellStyle();
+        assertEquals(CellStyle.BORDER_DOTTED, newStyle.getBorderBottom());
+        assertEquals(Font.COLOR_RED, ((HSSFCellStyle)newStyle).getFont(wb).getColor());
+        
+//        OutputStream out = new FileOutputStream("/tmp/56959.xls");
+//        try {
+//            wb.write(out);
+//        } finally {
+//            out.close();
+//        }
+    }
 }