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

svn commit: r1755463 [3/3] - in /poi/branches/hssf_cryptoapi: ./ maven/ sonar/main/ src/java/org/apache/poi/hssf/record/aggregates/ src/java/org/apache/poi/hssf/usermodel/ src/java/org/apache/poi/poifs/crypt/ src/java/org/apache/poi/ss/formula/ src/jav...

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java Mon Aug  8 01:14:36 2016
@@ -27,6 +27,7 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.eval.ErrorEval;
+import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
@@ -105,6 +106,7 @@ public final class TestIndirect {
 
         // non-error cases
         confirm(feA, c, "INDIRECT(\"C2\")", 23);
+        confirm(feA, c, "INDIRECT(\"C2\", TRUE)", 23);
         confirm(feA, c, "INDIRECT(\"$C2\")", 23);
         confirm(feA, c, "INDIRECT(\"C$2\")", 23);
         confirm(feA, c, "SUM(INDIRECT(\"Sheet2!B1:C3\"))", 351); // area ref
@@ -149,7 +151,7 @@ public final class TestIndirect {
 //            confirm(feA, c, "INDIRECT(\"Sheet1!A65537\")", ErrorEval.REF_INVALID); // bad row
 //        }
         confirm(feA, c, "INDIRECT(\"Sheet1!A 1\")", ErrorEval.REF_INVALID); // space in cell ref
-        
+
         wbA.close();
     }
 
@@ -203,4 +205,9 @@ public final class TestIndirect {
                     + "' but got '" + cv.formatAsString() + "'.");
         }
     }
+
+    @Test
+    public void testInvalidInput() {
+        assertEquals(ErrorEval.VALUE_INVALID, Indirect.instance.evaluate(new ValueEval[] {}, null));
+    }
 }

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestSubtotal.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestSubtotal.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestSubtotal.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/formula/functions/TestSubtotal.java Mon Aug  8 01:14:36 2016
@@ -20,9 +20,8 @@ package org.apache.poi.ss.formula.functi
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.formula.eval.AreaEval;
-import org.apache.poi.ss.formula.eval.NumberEval;
-import org.apache.poi.ss.formula.eval.ValueEval;
+import org.apache.poi.ss.formula.FormulaParseException;
+import org.apache.poi.ss.formula.eval.*;
 
 import junit.framework.TestCase;
 import org.apache.poi.ss.usermodel.*;
@@ -75,7 +74,6 @@ public final class TestSubtotal extends
 	}
 
      public void testAvg(){
-
         Workbook wb = new HSSFWorkbook();
 
         FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
@@ -95,16 +93,18 @@ public final class TestSubtotal extends
         a6.setCellFormula("SUBTOTAL(1,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(1,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(1,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(2.0, a3.getNumericCellValue());
         assertEquals(8.0, a6.getNumericCellValue());
         assertEquals(3.0, a7.getNumericCellValue());
+        assertEquals(3.0, a8.getNumericCellValue());
     }
 
     public void testSum(){
-
         Workbook wb = new HSSFWorkbook();
 
         FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
@@ -124,12 +124,15 @@ public final class TestSubtotal extends
         a6.setCellFormula("SUBTOTAL(9,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(9,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(9,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(4.0, a3.getNumericCellValue());
         assertEquals(26.0, a6.getNumericCellValue());
         assertEquals(12.0, a7.getNumericCellValue());
+        assertEquals(12.0, a8.getNumericCellValue());
     }
 
     public void testCount(){
@@ -147,18 +150,21 @@ public final class TestSubtotal extends
         a3.setCellFormula("SUBTOTAL(2,B2:B3)");
         Cell a4 = sh.createRow(4).createCell(1);
         a4.setCellValue("POI");                  // A4 is string and not counted
-        Cell a5 = sh.createRow(5).createCell(1); // A5 is blank and not counted
+        /*Cell a5 =*/ sh.createRow(5).createCell(1); // A5 is blank and not counted
 
         Cell a6 = sh.createRow(6).createCell(1);
         a6.setCellFormula("SUBTOTAL(2,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(2,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(2,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(2.0, a3.getNumericCellValue());
         assertEquals(6.0, a6.getNumericCellValue());
         assertEquals(2.0, a7.getNumericCellValue());
+        assertEquals(2.0, a8.getNumericCellValue());
     }
 
     public void testCounta(){
@@ -176,18 +182,21 @@ public final class TestSubtotal extends
         a3.setCellFormula("SUBTOTAL(3,B2:B3)");
         Cell a4 = sh.createRow(4).createCell(1);
         a4.setCellValue("POI");                  // A4 is string and not counted
-        Cell a5 = sh.createRow(5).createCell(1); // A5 is blank and not counted
+        /*Cell a5 =*/ sh.createRow(5).createCell(1); // A5 is blank and not counted
 
         Cell a6 = sh.createRow(6).createCell(1);
         a6.setCellFormula("SUBTOTAL(3,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(3,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(3,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(2.0, a3.getNumericCellValue());
         assertEquals(8.0, a6.getNumericCellValue());
         assertEquals(3.0, a7.getNumericCellValue());
+        assertEquals(3.0, a8.getNumericCellValue());
     }
 
     public void testMax(){
@@ -211,12 +220,15 @@ public final class TestSubtotal extends
         a6.setCellFormula("SUBTOTAL(4,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(4,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(4,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(3.0, a3.getNumericCellValue());
         assertEquals(16.0, a6.getNumericCellValue());
         assertEquals(7.0, a7.getNumericCellValue());
+        assertEquals(7.0, a8.getNumericCellValue());
     }
 
     public void testMin(){
@@ -240,12 +252,15 @@ public final class TestSubtotal extends
         a6.setCellFormula("SUBTOTAL(5,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(5,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(5,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(1.0, a3.getNumericCellValue());
         assertEquals(4.0, a6.getNumericCellValue());
         assertEquals(1.0, a7.getNumericCellValue());
+        assertEquals(1.0, a8.getNumericCellValue());
     }
 
     public void testStdev(){
@@ -269,12 +284,15 @@ public final class TestSubtotal extends
         a6.setCellFormula("SUBTOTAL(7,B2:B6)*2 + 2");
         Cell a7 = sh.createRow(7).createCell(1);
         a7.setCellFormula("SUBTOTAL(7,B2:B7)");
+        Cell a8 = sh.createRow(8).createCell(1);
+        a8.setCellFormula("SUBTOTAL(7,B2,B3,B4,B5,B6,B7,B8)");
 
         fe.evaluateAll();
 
         assertEquals(1.41421, a3.getNumericCellValue(), 0.0001);
         assertEquals(7.65685, a6.getNumericCellValue(), 0.0001);
         assertEquals(2.82842, a7.getNumericCellValue(), 0.0001);
+        assertEquals(2.82842, a8.getNumericCellValue(), 0.0001);
     }
 
     public void test50209(){
@@ -328,4 +346,69 @@ public final class TestSubtotal extends
         confirmExpectedResult(evaluator, "SUBTOTAL(COUNT;B2:B8,C2:C8)", cellC2, 3.0);
         confirmExpectedResult(evaluator, "SUBTOTAL(COUNTA;B2:B8,C2:C8)", cellC3, 5.0);
     }
+
+    public void testUnimplemented(){
+        Workbook wb = new HSSFWorkbook();
+
+        FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
+
+        Sheet sh = wb.createSheet();
+        Cell a3 = sh.createRow(3).createCell(1);
+        a3.setCellFormula("SUBTOTAL(8,B2:B3)");
+
+        try {
+            fe.evaluateAll();
+            fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
+        } catch (NotImplementedException e) {
+            // expected here
+        }
+
+        a3.setCellFormula("SUBTOTAL(10,B2:B3)");
+
+        try {
+            fe.evaluateAll();
+            fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
+        } catch (NotImplementedException e) {
+            // expected here
+        }
+
+        a3.setCellFormula("SUBTOTAL(11,B2:B3)");
+
+        try {
+            fe.evaluateAll();
+            fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
+        } catch (NotImplementedException e) {
+            // expected here
+        }
+
+        a3.setCellFormula("SUBTOTAL(107,B2:B3)");
+
+        try {
+            fe.evaluateAll();
+            fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
+        } catch (NotImplementedException e) {
+            // expected here
+        }
+
+        a3.setCellFormula("SUBTOTAL(0,B2:B3)");
+        fe.evaluateAll();
+        assertEquals(FormulaError.VALUE.getCode(), a3.getErrorCellValue());
+
+        try {
+            a3.setCellFormula("SUBTOTAL(9)");
+            fail("Should catch an exception here");
+        } catch (FormulaParseException e) {
+            // expected here
+        }
+
+        try {
+            a3.setCellFormula("SUBTOTAL()");
+            fail("Should catch an exception here");
+        } catch (FormulaParseException e) {
+            // expected here
+        }
+
+        Subtotal subtotal = new Subtotal();
+        assertEquals(ErrorEval.VALUE_INVALID, subtotal.evaluate(new ValueEval[] {}, 0, 0));
+    }
 }

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Mon Aug  8 01:14:36 2016
@@ -33,9 +33,12 @@ import java.awt.font.FontRenderContext;
 import java.awt.font.TextAttribute;
 import java.awt.font.TextLayout;
 import java.awt.geom.Rectangle2D;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.text.AttributedString;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import static org.junit.Assert.*;
@@ -1606,4 +1609,78 @@ public abstract class BaseTestBugzillaIs
         assertNull("Sheet0 after write", wb2.getPrintArea(0)); // CURRENTLY FAILS with "Sheet0!$A$1:$C$6"
         assertEquals("Sheet1 after write", "Sheet1!$A$1:$A$1", wb2.getPrintArea(1));
     }
-}
+
+
+    @Test
+    public void test55384() throws Exception {
+        Workbook wb = _testDataProvider.createWorkbook();
+        try {
+            Sheet sh = wb.createSheet();
+            for (int rownum = 0; rownum < 10; rownum++) {
+                org.apache.poi.ss.usermodel.Row row = sh.createRow(rownum);
+                for (int cellnum = 0; cellnum < 3; cellnum++) {
+                    Cell cell = row.createCell(cellnum);
+                    cell.setCellValue(rownum + cellnum);
+                }
+            }
+            Row row = sh.createRow(10);
+            // setting no precalculated value works just fine.
+            Cell cell1 = row.createCell(0);
+            cell1.setCellFormula("SUM(A1:A10)");
+
+            // but setting a precalculated STRING value fails totally in SXSSF
+            Cell cell2 = row.createCell(1);
+            cell2.setCellFormula("SUM(B1:B10)");
+            cell2.setCellValue("55");
+
+            // setting a precalculated int value works as expected
+            Cell cell3 = row.createCell(2);
+            cell3.setCellFormula("SUM(C1:C10)");
+            cell3.setCellValue(65);
+
+            assertEquals(CellType.FORMULA, cell1.getCellTypeEnum());
+            assertEquals(CellType.FORMULA, cell2.getCellTypeEnum());
+            assertEquals(CellType.FORMULA, cell3.getCellTypeEnum());
+
+            assertEquals("SUM(A1:A10)", cell1.getCellFormula());
+            assertEquals("SUM(B1:B10)", cell2.getCellFormula());
+            assertEquals("SUM(C1:C10)", cell3.getCellFormula());
+
+            /*String name = wb.getClass().getCanonicalName();
+            String ext = (wb instanceof HSSFWorkbook) ? ".xls" : ".xlsx";
+            OutputStream output = new FileOutputStream("/tmp" + name + ext);
+            try {
+                wb.write(output);
+            } finally {
+                output.close();
+            }*/
+
+            Workbook wbBack = _testDataProvider.writeOutAndReadBack(wb);
+            checkFormulaPreevaluatedString(wbBack);
+            wbBack.close();
+        } finally {
+            wb.close();
+        }
+    }
+
+    private void checkFormulaPreevaluatedString(Workbook readFile) {
+        Sheet sheet = readFile.getSheetAt(0);
+        Row row = sheet.getRow(sheet.getLastRowNum());
+        assertEquals(10, row.getRowNum());
+
+        for (Cell cell : row) {
+            String cellValue = null;
+            switch (cell.getCellTypeEnum()) {
+                case STRING:
+                    cellValue = cell.getRichStringCellValue().getString();
+                    break;
+                case FORMULA:
+                    cellValue = cell.getCellFormula();
+                    break;
+            }
+            assertNotNull(cellValue);
+            cellValue = cellValue.isEmpty() ? null : cellValue;
+            assertNotNull(cellValue);
+        }
+    }
+}
\ No newline at end of file

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java Mon Aug  8 01:14:36 2016
@@ -201,11 +201,7 @@ public abstract class BaseTestNamedRange
             assertEquals("The sheet already contains this name: aaa", e.getMessage());
         }
 
-        int cnt = 0;
-        for (int i = 0; i < wb.getNumberOfNames(); i++) {
-            if("aaa".equals(wb.getNameAt(i).getNameName())) cnt++;
-        }
-        assertEquals(3, cnt);
+        assertEquals(3, wb.getNames("aaa").size());
         
         wb.close();
     }
@@ -250,11 +246,11 @@ public abstract class BaseTestNamedRange
          // Write the workbook to a file
          // Read the Excel file and verify its content
          Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
-         Name nm1 = wb2.getNameAt(wb2.getNameIndex("RangeTest1"));
+         Name nm1 = wb2.getName("RangeTest1");
          assertTrue("Name is "+nm1.getNameName(),"RangeTest1".equals(nm1.getNameName()));
          assertTrue("Reference is "+nm1.getRefersToFormula(),(wb2.getSheetName(0)+"!$A$1:$L$41").equals(nm1.getRefersToFormula()));
 
-         Name nm2 = wb2.getNameAt(wb2.getNameIndex("RangeTest2"));
+         Name nm2 = wb2.getName("RangeTest2");
          assertTrue("Name is "+nm2.getNameName(),"RangeTest2".equals(nm2.getNameName()));
          assertTrue("Reference is "+nm2.getRefersToFormula(),(wb2.getSheetName(1)+"!$A$1:$O$21").equals(nm2.getRefersToFormula()));
          
@@ -466,11 +462,11 @@ public abstract class BaseTestNamedRange
         wb1.getNameAt(0);
 
         Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
-        Name nm =wb2.getNameAt(wb2.getNameIndex("RangeTest"));
+        Name nm =wb2.getName("RangeTest");
         assertTrue("Name is "+nm.getNameName(),"RangeTest".equals(nm.getNameName()));
         assertTrue("Reference is "+nm.getRefersToFormula(),(wb2.getSheetName(0)+"!$D$4:$E$8").equals(nm.getRefersToFormula()));
 
-        nm = wb2.getNameAt(wb2.getNameIndex("AnotherTest"));
+        nm = wb2.getName("AnotherTest");
         assertTrue("Name is "+nm.getNameName(),"AnotherTest".equals(nm.getNameName()));
         assertTrue("Reference is "+nm.getRefersToFormula(),newNamedRange2.getRefersToFormula().equals(nm.getRefersToFormula()));
         
@@ -499,8 +495,7 @@ public abstract class BaseTestNamedRange
         namedCell.setRefersToFormula(reference);
 
         // retrieve the newly created named range
-        int namedCellIdx = wb.getNameIndex(cellName);
-        Name aNamedCell = wb.getNameAt(namedCellIdx);
+        Name aNamedCell = wb.getName(cellName);
         assertNotNull(aNamedCell);
 
         // retrieve the cell at the named range and test its contents
@@ -540,8 +535,7 @@ public abstract class BaseTestNamedRange
         namedCell.setRefersToFormula(reference);
 
         // retrieve the newly created named range
-        int namedCellIdx = wb.getNameIndex(cname);
-        Name aNamedCell = wb.getNameAt(namedCellIdx);
+        Name aNamedCell = wb.getName(cname);
         assertNotNull(aNamedCell);
 
         // retrieve the cell at the named range and test its contents

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java Mon Aug  8 01:14:36 2016
@@ -261,17 +261,17 @@ public abstract class BaseTestSheetShift
         name4.setSheetIndex(1);
 
         sheet1.shiftRows(0, 1, 2);  //shift down the top row on Sheet1.
-        name1 = wb.getNameAt(0);
+        name1 = wb.getName("name1");
         assertEquals("Sheet1!$A$3+Sheet1!$B$3", name1.getRefersToFormula());
 
-        name2 = wb.getNameAt(1);
+        name2 = wb.getName("name2");
         assertEquals("Sheet1!$A$3", name2.getRefersToFormula());
 
         //name3 and name4 refer to Sheet2 and should not be affected
-        name3 = wb.getNameAt(2);
+        name3 = wb.getName("name3");
         assertEquals("Sheet2!$A$1", name3.getRefersToFormula());
 
-        name4 = wb.getNameAt(3);
+        name4 = wb.getName("name4");
         assertEquals("A1", name4.getRefersToFormula());
         
         wb.close();

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java Mon Aug  8 01:14:36 2016
@@ -78,14 +78,16 @@ public class BaseTestCellUtil {
     @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);
+        try {
+            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();
+            // An invalid BorderStyle constant
+            CellUtil.setCellStyleProperty(c, CellUtil.BORDER_BOTTOM, 42);
+        } finally {
+            wb.close();
+        }
     }
     
     @Test()
@@ -352,10 +354,8 @@ public class BaseTestCellUtil {
             CellUtil.setFont(A1, font2);
             fail("setFont not allowed if font belongs to a different workbook");
         } catch (final IllegalArgumentException e) {
-            if (e.getMessage().startsWith("Font does not belong to this workbook")) {
-                // expected
-            }
-            else {
+            // one specific message is expected
+            if (!e.getMessage().startsWith("Font does not belong to this workbook")) {
                 throw e;
             }
         } finally {
@@ -371,7 +371,7 @@ public class BaseTestCellUtil {
      */
     // bug 55555
     @Test
-    public void setFillForegroundColorBeforeFillBackgroundColor() {
+    public void setFillForegroundColorBeforeFillBackgroundColor() throws IOException {
         Workbook wb1 = _testDataProvider.createWorkbook();
         Cell A1 = wb1.createSheet().createRow(0).createCell(0);
         Map<String, Object> properties = new HashMap<String, Object>();
@@ -386,13 +386,14 @@ public class BaseTestCellUtil {
         assertEquals("fill pattern", CellStyle.BRICKS, style.getFillPattern());
         assertEquals("fill foreground color", IndexedColors.BLUE, IndexedColors.fromInt(style.getFillForegroundColor()));
         assertEquals("fill background color", IndexedColors.RED, IndexedColors.fromInt(style.getFillBackgroundColor()));
+        wb1.close();
     }
     /**
      * bug 55555
      * @since POI 3.15 beta 3
      */
     @Test
-    public void setFillForegroundColorBeforeFillBackgroundColorEnum() {
+    public void setFillForegroundColorBeforeFillBackgroundColorEnum() throws IOException {
         Workbook wb1 = _testDataProvider.createWorkbook();
         Cell A1 = wb1.createSheet().createRow(0).createCell(0);
         Map<String, Object> properties = new HashMap<String, Object>();
@@ -407,5 +408,7 @@ public class BaseTestCellUtil {
         assertEquals("fill pattern", FillPatternType.BRICKS, style.getFillPatternEnum());
         assertEquals("fill foreground color", IndexedColors.BLUE, IndexedColors.fromInt(style.getFillForegroundColor()));
         assertEquals("fill background color", IndexedColors.RED, IndexedColors.fromInt(style.getFillBackgroundColor()));
+
+        wb1.close();
     }
 }

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/DummyPOILogger.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/DummyPOILogger.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/DummyPOILogger.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/DummyPOILogger.java Mon Aug  8 01:14:36 2016
@@ -30,16 +30,20 @@ public class DummyPOILogger extends POIL
 		logged = new ArrayList<String>();
 	}
 	
+    @Override
 	public boolean check(int level) {
 		return true;
 	}
 
+    @Override
 	public void initialize(String cat) {}
 
+    @Override
 	public void log(int level, Object obj1) {
 		logged.add(level + " - " + obj1);
 	}
 
+    @Override
 	public void log(int level, Object obj1, Throwable exception) {
 		logged.add(level + " - " + obj1 + " - " + exception);
 	}

Modified: poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/TestPOILogger.java
URL: http://svn.apache.org/viewvc/poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/TestPOILogger.java?rev=1755463&r1=1755462&r2=1755463&view=diff
==============================================================================
--- poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/TestPOILogger.java (original)
+++ poi/branches/hssf_cryptoapi/src/testcases/org/apache/poi/util/TestPOILogger.java Mon Aug  8 01:14:36 2016
@@ -26,10 +26,6 @@ import org.junit.Test;
 
 /**
  * Tests the log class.
- *
- * @author Glen Stampoultzis (glens at apache.org)
- * @author Marc Johnson (mjohnson at apache dot org)
- * @author Nicola Ken Barozzi (nicolaken at apache.org)
  */
 public final class TestPOILogger extends POILogger {
     private String lastLog = "";
@@ -61,20 +57,26 @@ public final class TestPOILogger extends
             POILogFactory._loggerClassName = oldLCN;
         }
     }
+    
+    // ---------- POI Logger methods implemented for testing ----------
 
+    @Override
     public void initialize(String cat) {
     }
 
+    @Override
     public void log(int level, Object obj1) {
         lastLog = (obj1 == null) ? "" : obj1.toString();
         lastEx = null;
     }
 
+    @Override
     public void log(int level, Object obj1, Throwable exception) {
         lastLog = (obj1 == null) ? "" : obj1.toString();
         lastEx = exception;
     }
 
+    @Override
     public boolean check(int level) {
         return true;
     }



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