]> source.dussan.org Git - poi.git/commitdiff
Add unit tests which verify that the issues from bug 48962 and 50755 do not occur...
authorDominik Stadler <centic@apache.org>
Thu, 3 Sep 2015 20:45:55 +0000 (20:45 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 3 Sep 2015 20:45:55 +0000 (20:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1701131 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
test-data/spreadsheet/48962.xlsx [new file with mode: 0644]
test-data/spreadsheet/50755_workday_formula_example.xlsx [new file with mode: 0644]

index c36d8f7d3e76206e3b86d620d56a49bac6c45cac..6b4170ddb83febf7ee1c6720cbe250f5a9714bf3 100644 (file)
@@ -29,6 +29,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
@@ -2529,4 +2530,45 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
         FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
         assertEquals(expectedResultOrNull, eval.evaluate(intF).formatAsString());
     }
+
+    @Test
+    public void test48962() {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("48962.xlsx");
+        Sheet sh = wb.getSheetAt(0);
+        Row row = sh.getRow(1);
+        Cell cell = row.getCell(0);
+        
+        CellStyle style = cell.getCellStyle();
+        assertNotNull(style);
+        
+        // color index
+        assertEquals(64, style.getFillBackgroundColor());
+        XSSFColor color = ((XSSFCellStyle)style).getFillBackgroundXSSFColor();
+        assertNotNull(color);
+        
+        // indexed color
+        assertEquals(64, color.getIndexed());
+        assertEquals(64, color.getIndex());
+        
+        // not an RGB color
+        assertFalse(color.isRGB());
+        assertNull(color.getRGB());        
+    }
+    
+    @Test
+    public void test50755_workday_formula_example() {
+        Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50755_workday_formula_example.xlsx");
+        Sheet sheet = wb.getSheet("Sheet1");
+        for(Row aRow : sheet) {
+            Cell cell = aRow.getCell(1);
+            if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+                String formula = cell.getCellFormula();
+                //System.out.println("formula: " + formula);
+                assertNotNull(formula);
+                assertTrue(formula.contains("WORKDAY"));
+            } else {
+                assertNotNull(cell.toString());
+            }
+        }
+    }
 }
diff --git a/test-data/spreadsheet/48962.xlsx b/test-data/spreadsheet/48962.xlsx
new file mode 100644 (file)
index 0000000..7d14f77
Binary files /dev/null and b/test-data/spreadsheet/48962.xlsx differ
diff --git a/test-data/spreadsheet/50755_workday_formula_example.xlsx b/test-data/spreadsheet/50755_workday_formula_example.xlsx
new file mode 100644 (file)
index 0000000..c3ad479
Binary files /dev/null and b/test-data/spreadsheet/50755_workday_formula_example.xlsx differ