poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1706742 [1/2] - in /poi/trunk/src: java/org/apache/poi/hpsf/ java/org/apache/poi/poifs/dev/ java/org/apache/poi/sl/usermodel/ ooxml/testcases/org/apache/poi/xssf/streaming/ ooxml/testcases/org/apache/poi/xssf/usermodel/ scratchpad/src/org/...
Date Mon, 05 Oct 2015 00:28:55 GMT
Author: kiwiwings
Date: Mon Oct  5 00:28:54 2015
New Revision: 1706742

URL: http://svn.apache.org/viewvc?rev=1706742&view=rev
Log:
fixed sonar issues and eclipse warnings

Modified:
    poi/trunk/src/java/org/apache/poi/hpsf/MutableSection.java
    poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSViewer.java
    poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestFormulaEvaluator.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java

Modified: poi/trunk/src/java/org/apache/poi/hpsf/MutableSection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/MutableSection.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/MutableSection.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/MutableSection.java Mon Oct  5 00:28:54 2015
@@ -514,8 +514,9 @@ public class MutableSection extends Sect
             {
                 /* Write the dictionary item in Unicode. */
                 int sLength = value.length() + 1;
-                if (sLength % 2 == 1)
+                if ((sLength & 1) == 1) {
                     sLength++;
+                }
                 length += TypeWriter.writeUIntToStream(out, key.longValue());
                 length += TypeWriter.writeUIntToStream(out, sLength);
                 final byte[] ca = CodePageUtil.getBytesInCodePage(value, codepage);

Modified: poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSViewer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSViewer.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSViewer.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSViewer.java Mon Oct  5 00:28:54 2015
@@ -21,7 +21,6 @@ package org.apache.poi.poifs.dev;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
@@ -41,10 +40,8 @@ public class POIFSViewer
      * @param args the names of the files to be displayed
      */
 
-    public static void main(final String args[])
-    {
-        if (args.length < 0)
-        {
+    public static void main(final String args[]) {
+        if (args.length == 0) {
             System.err.println("Must specify at least one file to view");
             System.exit(1);
         }
@@ -56,16 +53,12 @@ public class POIFSViewer
         }
     }
 
-    private static void viewFile(final String filename,
-                                 final boolean printName)
-    {
-        if (printName)
-        {
+    private static void viewFile(String filename, boolean printName) {
+        if (printName) {
             StringBuffer flowerbox = new StringBuffer();
 
             flowerbox.append(".");
-            for (int j = 0; j < filename.length(); j++)
-            {
+            for (int j = 0; j < filename.length(); j++) {
                 flowerbox.append("-");
             }
             flowerbox.append(".");
@@ -73,21 +66,14 @@ public class POIFSViewer
             System.out.println("|" + filename + "|");
             System.out.println(flowerbox);
         }
-        try
-        {
-            POIFSViewable fs      =
-                new NPOIFSFileSystem(new File(filename));
-            List<String>  strings = POIFSViewEngine.inspectViewable(fs, true,
-                                        0, "  ");
-            Iterator<String> iter = strings.iterator();
-
-            while (iter.hasNext())
-            {
-                System.out.print(iter.next());
+        try {
+            NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(filename));
+            List<String> strings = POIFSViewEngine.inspectViewable(fs, true, 0, "  ");
+            for (String s : strings) {
+                System.out.print(s);
             }
-        }
-        catch (IOException e)
-        {
+            fs.close();
+        } catch (IOException e) {
             System.out.println(e.getMessage());
         }
     }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java Mon Oct  5 00:28:54 2015
@@ -66,11 +66,17 @@ public interface TextRun {
 	
 	
     /**
+     * Returns the font size which is either set directly on this text run or
+     * given from the slide layout
+     * 
      * @return font size in points or null if font size is not set.
      */
 	Double getFontSize();
 
     /**
+     * Sets the font size directly on this text run, if null is given, the
+     * font size defaults to the values given from the slide layout
+     * 
      * @param fontSize font size in points, if null the underlying fontsize will be unset
      */
 	void setFontSize(Double fontSize);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java Mon Oct  5 00:28:54 2015
@@ -52,7 +52,7 @@ public class TestSXSSFSheet extends Base
      */
     @Override
     @Test
-    public void cloneSheet() {
+    public void cloneSheet() throws IOException {
         thrown.expect(RuntimeException.class);
         thrown.expectMessage("NotImplemented");
         super.cloneSheet();
@@ -60,7 +60,7 @@ public class TestSXSSFSheet extends Base
 
     @Override
     @Test
-    public void cloneSheetMultipleTimes() {
+    public void cloneSheetMultipleTimes() throws IOException {
         thrown.expect(RuntimeException.class);
         thrown.expectMessage("NotImplemented");
         super.cloneSheetMultipleTimes();
@@ -71,7 +71,7 @@ public class TestSXSSFSheet extends Base
      */
     @Override
     @Test
-    public void shiftMerged(){
+    public void shiftMerged() throws IOException {
         thrown.expect(RuntimeException.class);
         thrown.expectMessage("NotImplemented");
         super.shiftMerged();
@@ -84,7 +84,7 @@ public class TestSXSSFSheet extends Base
      */
     @Override
     @Test
-    public void bug35084(){
+    public void bug35084() throws IOException {
         thrown.expect(RuntimeException.class);
         thrown.expectMessage("NotImplemented");
         super.bug35084();
@@ -146,11 +146,12 @@ public class TestSXSSFSheet extends Base
             sheet.createRow(2);
         } finally {
             wb.close();
+            template.close();
         }
     }
 
-    @Test
-    public void createRowAfterLastRow() {
+    @Test(expected=IllegalArgumentException.class)
+    public void createRowAfterLastRow() throws IOException {
         createRowAfterLastRow(SpreadsheetVersion.EXCEL2007);
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java Mon Oct  5 00:28:54 2015
@@ -18,9 +18,15 @@
  */
 package org.apache.poi.xssf.usermodel;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
 import org.apache.poi.ss.usermodel.BaseTestConditionalFormatting;
 import org.apache.poi.ss.usermodel.Color;
 import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.junit.Test;
 
 /**
  * XSSF-specific Conditional Formatting tests
@@ -40,11 +46,13 @@ public class TestXSSFConditionalFormatti
         }
     }
 
-    public void testRead(){
+    @Test
+    public void testRead() throws IOException {
         testRead("WithConditionalFormatting.xlsx");
     }
     
-    public void testReadOffice2007() {
+    @Test
+    public void testReadOffice2007() throws IOException {
         testReadOffice2007("NewStyleConditionalFormattings.xlsx");
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java Mon Oct  5 00:28:54 2015
@@ -17,6 +17,8 @@
 
 package org.apache.poi.xssf.usermodel;
 
+import static org.junit.Assert.*;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -33,6 +35,8 @@ import org.apache.poi.ss.usermodel.Workb
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Ignore;
+import org.junit.Test;
 
 public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
 
@@ -40,11 +44,13 @@ public final class TestXSSFFormulaEvalua
         super(XSSFITestDataProvider.instance);
     }
 
-    public void testSharedFormulas(){
+    @Test
+    public void testSharedFormulas() throws IOException {
         baseTestSharedFormulas("shared_formulas.xlsx");
     }
 
-    public void testSharedFormulas_evaluateInCell(){
+    @Test
+    public void testSharedFormulas_evaluateInCell() throws IOException {
         XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.openSampleWorkbook("49872.xlsx");
         FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
         XSSFSheet sheet = wb.getSheetAt(0);
@@ -59,20 +65,23 @@ public final class TestXSSFFormulaEvalua
 
         // get B3 and evaluate it in the cell
         XSSFCell b3 = sheet.getRow(2).getCell(1);
-        assertEquals(result, evaluator.evaluateInCell(b3).getNumericCellValue());
+        assertEquals(result, evaluator.evaluateInCell(b3).getNumericCellValue(), 0);
 
         //at this point the master formula is gone, but we are still able to evaluate dependent cells
         XSSFCell c3 = sheet.getRow(2).getCell(2);
-        assertEquals(result, evaluator.evaluateInCell(c3).getNumericCellValue());
+        assertEquals(result, evaluator.evaluateInCell(c3).getNumericCellValue(), 0);
 
         XSSFCell d3 = sheet.getRow(2).getCell(3);
-        assertEquals(result, evaluator.evaluateInCell(d3).getNumericCellValue());
+        assertEquals(result, evaluator.evaluateInCell(d3).getNumericCellValue(), 0);
+        
+        wb.close();
     }
 
     /**
      * Evaluation of cell references with column indexes greater than 255. See bugzilla 50096
      */
-    public void testEvaluateColumnGreaterThan255() {
+    @Test
+    public void testEvaluateColumnGreaterThan255() throws IOException {
         XSSFWorkbook wb = (XSSFWorkbook) _testDataProvider.openSampleWorkbook("50096.xlsx");
         XSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
 
@@ -95,8 +104,10 @@ public final class TestXSSFFormulaEvalua
             CellValue cv_noformula = evaluator.evaluate(cell_noformula);
             CellValue cv_formula = evaluator.evaluate(cell_formula);
             assertEquals("Wrong evaluation result in " + ref_formula.formatAsString(),
-                    cv_noformula.getNumberValue(), cv_formula.getNumberValue());
+                    cv_noformula.getNumberValue(), cv_formula.getNumberValue(), 0);
         }
+        
+        wb.close();
     }
     
     /**
@@ -104,6 +115,7 @@ public final class TestXSSFFormulaEvalua
      *  formulas that refer to cells and named ranges in multiple other
      *  workbooks, both HSSF and XSSF ones
      */
+    @Test
     public void testReferencesToOtherWorkbooks() throws Exception {
         XSSFWorkbook wb = (XSSFWorkbook) _testDataProvider.openSampleWorkbook("ref2-56737.xlsx");
         XSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -120,7 +132,7 @@ public final class TestXSSFFormulaEvalua
         
         assertEquals("Hello!", cXSLX_cell.getStringCellValue());
         assertEquals("Test A1", cXSLX_sNR.getStringCellValue());
-        assertEquals(142.0, cXSLX_gNR.getNumericCellValue());
+        assertEquals(142.0, cXSLX_gNR.getNumericCellValue(), 0);
         
         // References to a .xls file
         Row rXSL = s.getRow(4);
@@ -133,7 +145,7 @@ public final class TestXSSFFormulaEvalua
         
         assertEquals("Hello!", cXSL_cell.getStringCellValue());
         assertEquals("Test A1", cXSL_sNR.getStringCellValue());
-        assertEquals(142.0, cXSL_gNR.getNumericCellValue());
+        assertEquals(142.0, cXSL_gNR.getNumericCellValue(), 0);
         
         // Try to evaluate without references, won't work
         // (At least, not unit we fix bug #56752 that is)
@@ -213,6 +225,8 @@ public final class TestXSSFFormulaEvalua
         } finally {
         	alt.close();
         }
+        
+        wb.close();
     }
     
     /**
@@ -222,7 +236,9 @@ public final class TestXSSFFormulaEvalua
      * TODO Add the support then add a unit test
      * See bug #56752
      */
-    public void TODOtestCachedReferencesToOtherWorkbooks() throws Exception {
+    @Test
+    @Ignore
+    public void testCachedReferencesToOtherWorkbooks() throws Exception {
         // TODO
     }
     
@@ -233,12 +249,12 @@ public final class TestXSSFFormulaEvalua
      * This test, based on common test files for HSSF and XSSF, checks
      *  that we can correctly evaluate these
      */
+    @Test
     public void testMultiSheetReferencesHSSFandXSSF() throws Exception {
-        Workbook[] wbs = new Workbook[] {
-                HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls"),
-                XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx")
-        };
-        for (Workbook wb : wbs) {
+        Workbook wb1 = HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls");
+        Workbook wb2 = XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx");
+
+        for (Workbook wb : new Workbook[] {wb1,wb2}) {
             FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
             Sheet s1 = wb.getSheetAt(0);
 
@@ -288,7 +304,11 @@ public final class TestXSSFFormulaEvalua
             assertEquals("COUNTA(Sheet1:Sheet3!E1)", countA_3F.getCellFormula());
             assertEquals("3.0", evaluator.evaluate(countA_3F).formatAsString());
         }
+        
+        wb2.close();
+        wb1.close();
     }
+    
     /**
      * A handful of functions (such as SUM, COUNTA, MIN) support
      *  multi-sheet areas (eg Sheet1:Sheet3!A1:B2 = Cell A1 to Cell B2,
@@ -296,12 +316,12 @@ public final class TestXSSFFormulaEvalua
      * This test, based on common test files for HSSF and XSSF, checks
      *  that we can correctly evaluate these
      */
-    public void testMultiSheetAreasHSSFandXSSF() throws Exception {
-        Workbook[] wbs = new Workbook[] {
-                HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls"),
-                XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx")
-        };
-        for (Workbook wb : wbs) {
+    @Test
+    public void testMultiSheetAreasHSSFandXSSF() throws IOException {
+        Workbook wb1 = HSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xls");
+        Workbook wb2 = XSSFTestDataSamples.openSampleWorkbook("55906-MultiSheetRefs.xlsx");
+
+        for (Workbook wb : new Workbook[]{wb1,wb2}) {
             FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
             Sheet s1 = wb.getSheetAt(0);
 
@@ -334,8 +354,12 @@ public final class TestXSSFFormulaEvalua
             assertEquals("COUNT(Sheet1:Sheet3!$A$1:$B$2)", countFA.getCellFormula());
             assertEquals("4.0", evaluator.evaluate(countFA).formatAsString());
         }
+        
+        wb2.close();
+        wb1.close();
     }
     
+    @Test
     public void testMultisheetFormulaEval() throws IOException {
     	XSSFWorkbook wb = new XSSFWorkbook();
     	try {
@@ -376,15 +400,16 @@ public final class TestXSSFFormulaEvalua
     		wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
     		
     		cell = sheet1.getRow(1).getCell(0);
-    		assertEquals(3.0, cell.getNumericCellValue());
+    		assertEquals(3.0, cell.getNumericCellValue(), 0);
     		
     		cell = sheet1.getRow(2).getCell(0);
-    		assertEquals(4.0, cell.getNumericCellValue());
+    		assertEquals(4.0, cell.getNumericCellValue(), 0);
     	} finally {
     	    wb.close();
     	}
 	}
 
+    @Test
     public void testBug55843() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -397,12 +422,10 @@ public final class TestXSSFFormulaEvalua
             XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
             cellA2.setCellFormula("IF(B1=0,\"\",((ROW()-ROW(A$1))*12))");
             CellValue evaluate = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluate);
             assertEquals("12.0", evaluate.formatAsString());
 
             cellA2.setCellFormula("IF(NOT(B1=0),((ROW()-ROW(A$1))*12),\"\")");
             CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluateN);
             
             assertEquals(evaluate.toString(), evaluateN.toString());
             assertEquals("12.0", evaluateN.formatAsString());
@@ -411,6 +434,7 @@ public final class TestXSSFFormulaEvalua
         }
     }
     
+    @Test
     public void testBug55843a() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -423,12 +447,10 @@ public final class TestXSSFFormulaEvalua
             XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
             cellA2.setCellFormula("IF(B1=0,\"\",((ROW(A$1))))");
             CellValue evaluate = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluate);
             assertEquals("1.0", evaluate.formatAsString());
 
             cellA2.setCellFormula("IF(NOT(B1=0),((ROW(A$1))),\"\")");
             CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluateN);
             
             assertEquals(evaluate.toString(), evaluateN.toString());
             assertEquals("1.0", evaluateN.formatAsString());
@@ -437,6 +459,7 @@ public final class TestXSSFFormulaEvalua
         }
     }    
 
+    @Test
     public void testBug55843b() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -450,12 +473,10 @@ public final class TestXSSFFormulaEvalua
 
             cellA2.setCellFormula("IF(B1=0,\"\",((ROW())))");
             CellValue evaluate = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluate);
             assertEquals("2.0", evaluate.formatAsString());
             
             cellA2.setCellFormula("IF(NOT(B1=0),((ROW())),\"\")");
             CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluateN);
             
             assertEquals(evaluate.toString(), evaluateN.toString());
             assertEquals("2.0", evaluateN.formatAsString());
@@ -464,6 +485,7 @@ public final class TestXSSFFormulaEvalua
         }
     }
     
+    @Test
     public void testBug55843c() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -477,13 +499,13 @@ public final class TestXSSFFormulaEvalua
             
             cellA2.setCellFormula("IF(NOT(B1=0),((ROW())))");
             CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluateN);
             assertEquals("2.0", evaluateN.formatAsString());
         } finally {
             wb.close();
         }
     }
     
+    @Test
     public void testBug55843d() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -497,13 +519,13 @@ public final class TestXSSFFormulaEvalua
             
             cellA2.setCellFormula("IF(NOT(B1=0),((ROW())),\"\")");
             CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluateN);
             assertEquals("2.0", evaluateN.formatAsString());
         } finally {
             wb.close();
         }
     }
 
+    @Test
     public void testBug55843e() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -517,13 +539,13 @@ public final class TestXSSFFormulaEvalua
 
             cellA2.setCellFormula("IF(B1=0,\"\",((ROW())))");
             CellValue evaluate = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluate);
             assertEquals("2.0", evaluate.formatAsString());
         } finally {
             wb.close();
         }
     }
     
+    @Test
     public void testBug55843f() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         try {
@@ -537,13 +559,13 @@ public final class TestXSSFFormulaEvalua
 
             cellA2.setCellFormula("IF(B1=0,\"\",IF(B1=10,3,4))");
             CellValue evaluate = formulaEvaluator.evaluate(cellA2);
-            System.out.println(evaluate);
             assertEquals("3.0", evaluate.formatAsString());
         } finally {
             wb.close();
         }
     }    
 
+    @Test
     public void testBug56655() throws IOException {
         Workbook wb =  new XSSFWorkbook();
         Sheet sheet = wb.createSheet();
@@ -561,6 +583,7 @@ public final class TestXSSFFormulaEvalua
         wb.close();
     }
 
+    @Test
     public void testBug56655a() throws IOException {
         Workbook wb =  new XSSFWorkbook();
         Sheet sheet = wb.createSheet();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Mon Oct  5 00:28:54 2015
@@ -17,11 +17,15 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertTrue;
 import static org.apache.poi.xssf.XSSFTestDataSamples.openSampleWorkbook;
 import static org.apache.poi.xssf.XSSFTestDataSamples.writeOutAndReadBack;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -51,7 +55,18 @@ import org.apache.poi.xssf.model.StylesT
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
 import org.junit.Test;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
 
 
 @SuppressWarnings("resource")
@@ -69,18 +84,18 @@ public final class TestXSSFSheet extends
     }
 
     @Test
-    public void getSetMargin() {
+    public void getSetMargin() throws IOException {
         baseTestGetSetMargin(new double[]{0.7, 0.7, 0.75, 0.75, 0.3, 0.3});
     }
 
     @Test
-    public void existingHeaderFooter() {
-        XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx");
+    public void existingHeaderFooter() throws IOException {
+        XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx");
         XSSFOddHeader hdr;
         XSSFOddFooter ftr;
 
         // Sheet 1 has a header with center and right text
-        XSSFSheet s1 = workbook.getSheetAt(0);
+        XSSFSheet s1 = wb1.getSheetAt(0);
         assertNotNull(s1.getHeader());
         assertNotNull(s1.getFooter());
         hdr = (XSSFOddHeader) s1.getHeader();
@@ -98,7 +113,7 @@ public final class TestXSSFSheet extends
         assertEquals("", ftr.getRight());
 
         // Sheet 2 has a footer, but it's empty
-        XSSFSheet s2 = workbook.getSheetAt(1);
+        XSSFSheet s2 = wb1.getSheetAt(1);
         assertNotNull(s2.getHeader());
         assertNotNull(s2.getFooter());
         hdr = (XSSFOddHeader) s2.getHeader();
@@ -116,10 +131,11 @@ public final class TestXSSFSheet extends
         assertEquals("", ftr.getRight());
 
         // Save and reload
-        XSSFWorkbook wb = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
+        wb1.close();
 
-        hdr = (XSSFOddHeader) wb.getSheetAt(0).getHeader();
-        ftr = (XSSFOddFooter) wb.getSheetAt(0).getFooter();
+        hdr = (XSSFOddHeader) wb2.getSheetAt(0).getHeader();
+        ftr = (XSSFOddFooter) wb2.getSheetAt(0).getFooter();
 
         assertEquals("", hdr.getLeft());
         assertEquals("testdoc", hdr.getCenter());
@@ -128,10 +144,12 @@ public final class TestXSSFSheet extends
         assertEquals("", ftr.getLeft());
         assertEquals("", ftr.getCenter());
         assertEquals("", ftr.getRight());
+        
+        wb2.close();
     }
 
     @Test
-    public void getAllHeadersFooters() {
+    public void getAllHeadersFooters() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertNotNull(sheet.getOddFooter());
@@ -168,10 +186,12 @@ public final class TestXSSFSheet extends
         // Defaults are odd
         assertEquals("odd footer left", sheet.getFooter().getLeft());
         assertEquals("odd header center", sheet.getHeader().getCenter());
+        
+        workbook.close();
     }
 
     @Test
-    public void autoSizeColumn() {
+    public void autoSizeColumn() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet("Sheet 1");
         sheet.createRow(0).createCell(13).setCellValue("test");
@@ -181,11 +201,12 @@ public final class TestXSSFSheet extends
         ColumnHelper columnHelper = sheet.getColumnHelper();
         CTCol col = columnHelper.getColumn(13, false);
         assertTrue(col.getBestFit());
+        workbook.close();
     }
 
 
     @Test
-    public void setCellComment() {
+    public void setCellComment() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
 
@@ -200,20 +221,21 @@ public final class TestXSSFSheet extends
         assertEquals("A1", ctComments.getCommentList().getCommentArray(0).getRef());
         comment.setAuthor("test A1 author");
         assertEquals("test A1 author", comments.getAuthor((int) ctComments.getCommentList().getCommentArray(0).getAuthorId()));
+        workbook.close();
     }
 
     @Test
-    public void getActiveCell() {
+    public void getActiveCell() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
         sheet.setActiveCell("R5");
 
         assertEquals("R5", sheet.getActiveCell());
-
+        workbook.close();
     }
 
     @Test
-    public void createFreezePane_XSSF() {
+    public void createFreezePane_XSSF() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
         CTWorksheet ctWorksheet = sheet.getCTWorksheet();
@@ -228,10 +250,12 @@ public final class TestXSSFSheet extends
         sheet.createSplitPane(4, 8, 12, 12, 1);
         assertEquals(8.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit(), 0.0);
         assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
+        
+        workbook.close();
     }
 
     @Test
-    public void removeMergedRegion_lowlevel() {
+    public void removeMergedRegion_lowlevel() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
         CTWorksheet ctWorksheet = sheet.getCTWorksheet();
@@ -263,10 +287,11 @@ public final class TestXSSFSheet extends
         sheet.removeMergedRegions(rmIdx);
         assertEquals("A1:B2", ctWorksheet.getMergeCells().getMergeCellArray(0).getRef());
         assertEquals("E5:F6", ctWorksheet.getMergeCells().getMergeCellArray(1).getRef());
+        workbook.close();
     }
 
     @Test
-    public void setDefaultColumnStyle() {
+    public void setDefaultColumnStyle() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
         CTWorksheet ctWorksheet = sheet.getCTWorksheet();
@@ -288,12 +313,13 @@ public final class TestXSSFSheet extends
 
         sheet.setDefaultColumnStyle(3, cellStyle);
         assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle());
+        workbook.close();
     }
 
 
     @Test
     @SuppressWarnings("deprecation")
-    public void groupUngroupColumn() {
+    public void groupUngroupColumn() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
 
@@ -334,10 +360,12 @@ public final class TestXSSFSheet extends
         colArray = cols.getColArray();
         assertEquals(4, colArray.length);
         assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
+        
+        workbook.close();
     }
 
     @Test
-    public void groupUngroupRow() {
+    public void groupUngroupRow() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
 
@@ -369,10 +397,12 @@ public final class TestXSSFSheet extends
         assertEquals(3, sheet.getPhysicalNumberOfRows());
 
         assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
+        
+        workbook.close();
     }
 
-    @Test
-    public void setZoom() {
+    @Test(expected=IllegalArgumentException.class)
+    public void setZoom() throws IOException {
         XSSFWorkbook workBook = new XSSFWorkbook();
         XSSFSheet sheet1 = workBook.createSheet("new sheet");
         sheet1.setZoom(3, 4);   // 75 percent magnification
@@ -383,11 +413,11 @@ public final class TestXSSFSheet extends
         zoom = sheet1.getCTWorksheet().getSheetViews().getSheetViewArray(0).getZoomScale();
         assertEquals(zoom, 200);
 
+        // Valid scale values range from 10 to 400
         try {
             sheet1.setZoom(500);
-            fail("Expecting exception");
-        } catch (IllegalArgumentException e) {
-            assertEquals("Valid scale values range from 10 to 400", e.getMessage());
+        } finally {
+            workBook.close();
         }
     }
 
@@ -398,7 +428,7 @@ public final class TestXSSFSheet extends
      *  better should really review this!
      */
     @Test
-    public void setColumnGroupCollapsed(){
+    public void setColumnGroupCollapsed() throws IOException {
         Workbook wb = new XSSFWorkbook();
         XSSFSheet sheet1 =(XSSFSheet) wb.createSheet();
 
@@ -620,6 +650,8 @@ public final class TestXSSFSheet extends
         assertEquals(false,cols.getColArray(5).isSetCollapsed());
         assertEquals(14, cols.getColArray(5).getMin()); // 1 based
         assertEquals(14, cols.getColArray(5).getMax()); // 1 based
+        
+        wb.close();
     }
 
     /**
@@ -629,7 +661,7 @@ public final class TestXSSFSheet extends
      *  better should really review this!
      */
     @Test
-    public void setRowGroupCollapsed(){
+    public void setRowGroupCollapsed() throws IOException {
         Workbook wb = new XSSFWorkbook();
         XSSFSheet sheet1 = (XSSFSheet)wb.createSheet();
 
@@ -638,75 +670,77 @@ public final class TestXSSFSheet extends
         sheet1.groupRow( 16, 19 );
 
         assertEquals(14,sheet1.getPhysicalNumberOfRows());
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(7).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(9).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(14).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(7).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(7).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(9).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(9).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(14).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(14).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetHidden());
 
         //collapsed
         sheet1.setRowGroupCollapsed( 7, true );
 
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(7).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(7).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(9).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(9).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(14).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(14).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetHidden());
 
         //expanded
         sheet1.setRowGroupCollapsed( 7, false );
 
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(7).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(7).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(9).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(9).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(14).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(14).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetHidden());
 
 
         // Save and re-load
         wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
         sheet1 = (XSSFSheet)wb.getSheetAt(0);
 
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
-        assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
-        assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(6).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(7).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(7).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(9).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(9).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(14).getCTRow().isSetCollapsed());
+        assertTrue (sheet1.getRow(14).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(16).getCTRow().isSetHidden());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetCollapsed());
+        assertFalse(sheet1.getRow(18).getCTRow().isSetHidden());
+        
+        wb.close();
     }
 
     /**
      * Get / Set column width and check the actual values of the underlying XML beans
      */
     @Test
-    public void columnWidth_lowlevel() {
+    public void columnWidth_lowlevel() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet("Sheet 1");
         sheet.setColumnWidth(1, 22 * 256);
@@ -746,13 +780,15 @@ public final class TestXSSFSheet extends
         assertEquals(4, col.getMax());
         assertEquals(33.0, col.getWidth(), 0.0);
         assertTrue(col.getCustomWidth());
+        
+        workbook.close();
     }
 
     /**
      * Setting width of a column included in a column span
      */
     @Test
-    public void bug47862() {
+    public void bug47862() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47862.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
         CTCols cols = sheet.getCTWorksheet().getColsArray(0);
@@ -803,13 +839,15 @@ public final class TestXSSFSheet extends
             assertEquals(cw[i]*256, sheet.getColumnWidth(i));
             assertEquals(cw[i], cols.getColArray(i).getWidth(), 0.0);
         }
+        
+        wb.close();
     }
 
     /**
      * Hiding a column included in a column span
      */
     @Test
-    public void bug47804() {
+    public void bug47804() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47804.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
         CTCols cols = sheet.getCTWorksheet().getColsArray(0);
@@ -874,10 +912,12 @@ public final class TestXSSFSheet extends
         assertFalse(sheet.isColumnHidden(3));
         assertFalse(sheet.isColumnHidden(4));
         assertFalse(sheet.isColumnHidden(5));
+        
+        wb.close();
     }
 
     @Test
-    public void commentsTable() {
+    public void commentsTable() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet1 = workbook.createSheet();
         CommentsTable comment1 = sheet1.getCommentsTable(false);
@@ -910,6 +950,8 @@ public final class TestXSSFSheet extends
         assertNotNull(comment1);
         assertEquals("/xl/comments1.xml", comment1.getPackageRelationship().getTargetURI().toString());
         assertSame(comment1, sheet1.getCommentsTable(true));
+        
+        workbook.close();
     }
 
     /**
@@ -919,7 +961,7 @@ public final class TestXSSFSheet extends
     @Override
     @Test
     @SuppressWarnings("deprecation")
-    public void createRow() {
+    public void createRow() throws IOException {
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFSheet sheet = workbook.createSheet();
         CTWorksheet wsh = sheet.getCTWorksheet();
@@ -994,15 +1036,16 @@ public final class TestXSSFSheet extends
         assertEquals(2, xrow[2].sizeOfCArray());
         assertEquals(3, xrow[2].getR());
 
+        workbook.close();
     }
     
-    @Test
-    public void createRowAfterLastRow() {
+    @Test(expected=IllegalArgumentException.class)
+    public void createRowAfterLastRow() throws IOException {
         createRowAfterLastRow(SpreadsheetVersion.EXCEL2007);
     }
 
     @Test
-    public void setAutoFilter() {
+    public void setAutoFilter() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet("new sheet");
         sheet.setAutoFilter(CellRangeAddress.valueOf("A1:D100"));
@@ -1017,10 +1060,12 @@ public final class TestXSSFSheet extends
         assertEquals(true, nm.getCTName().getHidden());
         assertEquals("_xlnm._FilterDatabase", nm.getCTName().getName());
         assertEquals("'new sheet'!$A$1:$D$100", nm.getCTName().getStringValue());
+        
+        wb.close();
     }
 
     @Test
-    public void protectSheet_lowlevel() {
+    public void protectSheet_lowlevel() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection();
@@ -1038,10 +1083,12 @@ public final class TestXSSFSheet extends
 
         sheet.protectSheet(null);
         assertNull("protectSheet(null) should unset CTSheetProtection", sheet.getCTWorksheet().getSheetProtection());
+        
+        wb.close();
     }
 
     @Test
-    public void protectSheet_lowlevel_2013() {
+    public void protectSheet_lowlevel_2013() throws IOException {
         String password = "test";
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet xs = wb.createSheet();
@@ -1051,17 +1098,19 @@ public final class TestXSSFSheet extends
         
         wb = openSampleWorkbook("workbookProtection-sheet_password-2013.xlsx");
         assertTrue(wb.getSheetAt(0).validateSheetPassword("pwd"));
+        
+        wb.close();
     }
     
 
     @Test
-    public void bug49966() {
-        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49966.xlsx");
-        CalculationChain calcChain = wb.getCalculationChain();
-        assertNotNull(wb.getCalculationChain());
+    public void bug49966() throws IOException {
+        XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("49966.xlsx");
+        CalculationChain calcChain = wb1.getCalculationChain();
+        assertNotNull(wb1.getCalculationChain());
         assertEquals(3, calcChain.getCTCalcChain().sizeOfCArray());
 
-        XSSFSheet sheet = wb.getSheetAt(0);
+        XSSFSheet sheet = wb1.getSheetAt(0);
         XSSFRow row = sheet.getRow(0);
 
         sheet.removeRow(row);
@@ -1069,16 +1118,17 @@ public final class TestXSSFSheet extends
                 0, calcChain.getCTCalcChain().sizeOfCArray());
 
         //calcChain should be gone
-        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
-        assertNull(wb.getCalculationChain());
-
+        XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
+        wb1.close();
+        assertNull(wb2.getCalculationChain());
+        wb2.close();
     }
 
     /**
      * See bug #50829
      */
     @Test
-    public void tables() {
+    public void tables() throws IOException {
        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx");
        assertEquals(3, wb.getNumberOfSheets());
 
@@ -1100,15 +1150,16 @@ public final class TestXSSFSheet extends
        assertEquals(0, s2.getTables().size());
        XSSFSheet s3 = wb.getSheetAt(2);
        assertEquals(0, s3.getTables().size());
+       wb.close();
     }
 
     /**
      * Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr
      */
     @Test
-    public void setForceFormulaRecalculation() {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = workbook.createSheet("Sheet 1");
+    public void setForceFormulaRecalculation() throws IOException {
+        XSSFWorkbook wb1 = new XSSFWorkbook();
+        XSSFSheet sheet = wb1.createSheet("Sheet 1");
 
         assertFalse(sheet.getForceFormulaRecalculation());
         
@@ -1117,7 +1168,7 @@ public final class TestXSSFSheet extends
         assertEquals(true, sheet.getForceFormulaRecalculation());
 
         // calcMode="manual" is unset when forceFormulaRecalculation=true
-        CTCalcPr calcPr = workbook.getCTWorkbook().addNewCalcPr();
+        CTCalcPr calcPr = wb1.getCTWorkbook().addNewCalcPr();
         calcPr.setCalcMode(STCalcMode.MANUAL);
         sheet.setForceFormulaRecalculation(true);
         assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
@@ -1128,9 +1179,11 @@ public final class TestXSSFSheet extends
 
 
         // Save, re-load, and re-check
-        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-        sheet = workbook.getSheet("Sheet 1");
+        XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
+        wb1.close();
+        sheet = wb2.getSheet("Sheet 1");
         assertEquals(false, sheet.getForceFormulaRecalculation());
+        wb2.close();
     }
 
     @Test
@@ -1218,10 +1271,11 @@ public final class TestXSSFSheet extends
         }*/
         assertEquals("Sheet should contain 8 tables", 8, tables.size());
         assertNotNull("Sheet should contain a comments table", sheet.getCommentsTable(false));
+        wb.close();
     }
 
     @Test
-    public void bug55723b(){
+    public void bug55723b() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         Sheet sheet = wb.createSheet();
 
@@ -1245,11 +1299,13 @@ public final class TestXSSFSheet extends
         name = wb.getBuiltInName(XSSFName.BUILTIN_FILTER_DB, 0);
         assertNotNull(name);
         assertEquals("Sheet0!$B:$C", name.getRefersToFormula());
+        
+        wb.close();
     }
 
     @Test(timeout=180000)
-    public void bug51585(){
-        XSSFTestDataSamples.openSampleWorkbook("51585.xlsx");
+    public void bug51585() throws IOException {
+        XSSFTestDataSamples.openSampleWorkbook("51585.xlsx").close();;
     }
 
     private XSSFWorkbook setupSheet(){
@@ -1279,7 +1335,7 @@ public final class TestXSSFSheet extends
     }
 
     @Test
-    public void testCreateTwoPivotTablesInOneSheet(){
+    public void testCreateTwoPivotTablesInOneSheet() throws IOException {
         XSSFWorkbook wb = setupSheet();
         XSSFSheet sheet = wb.getSheetAt(0);
 
@@ -1291,10 +1347,11 @@ public final class TestXSSFSheet extends
         XSSFPivotTable pivotTable2 = sheet.createPivotTable(new AreaReference("A1:B2"), new CellReference("L5"), sheet);
         assertNotNull(pivotTable2);
         assertTrue(wb.getPivotTables().size() > 1);
+        wb.close();
     }
 
     @Test
-    public void testCreateTwoPivotTablesInTwoSheets(){
+    public void testCreateTwoPivotTablesInTwoSheets() throws IOException {
         XSSFWorkbook wb = setupSheet();
         XSSFSheet sheet = wb.getSheetAt(0);
 
@@ -1308,10 +1365,11 @@ public final class TestXSSFSheet extends
         XSSFPivotTable pivotTable2 = sheet2.createPivotTable(new AreaReference("A1:B2"), new CellReference("H5"), sheet);
         assertNotNull(pivotTable2);
         assertTrue(wb.getPivotTables().size() > 1);
+        wb.close();
     }
 
     @Test
-    public void testCreatePivotTable(){
+    public void testCreatePivotTable() throws IOException {
         XSSFWorkbook wb = setupSheet();
         XSSFSheet sheet = wb.getSheetAt(0);
 
@@ -1320,10 +1378,11 @@ public final class TestXSSFSheet extends
         XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference("A1:B2"), new CellReference("H5"));
         assertNotNull(pivotTable);
         assertTrue(wb.getPivotTables().size() > 0);
+        wb.close();
     }
 
     @Test
-    public void testCreatePivotTableInOtherSheetThanDataSheet(){
+    public void testCreatePivotTableInOtherSheetThanDataSheet() throws IOException {
         XSSFWorkbook wb = setupSheet();
         XSSFSheet sheet1 = wb.getSheetAt(0);
         XSSFSheet sheet2 = wb.createSheet();
@@ -1335,10 +1394,11 @@ public final class TestXSSFSheet extends
         assertEquals(1, wb.getPivotTables().size());
         assertEquals(0, sheet1.getPivotTables().size());
         assertEquals(1, sheet2.getPivotTables().size());
+        wb.close();
     }
 
     @Test
-    public void testCreatePivotTableInOtherSheetThanDataSheetUsingAreaReference(){
+    public void testCreatePivotTableInOtherSheetThanDataSheetUsingAreaReference() throws IOException {
         XSSFWorkbook wb = setupSheet();
         XSSFSheet sheet = wb.getSheetAt(0);
         XSSFSheet sheet2 = wb.createSheet();
@@ -1346,47 +1406,41 @@ public final class TestXSSFSheet extends
         XSSFPivotTable pivotTable = sheet2.createPivotTable
                 (new AreaReference(sheet.getSheetName()+"!A$1:B$2"), new CellReference("H5"));
         assertEquals(0, pivotTable.getRowLabelColumns().size());
+        wb.close();
     }
 
-    @Test
-    public void testCreatePivotTableWithConflictingDataSheets(){
+    @Test(expected=IllegalArgumentException.class)
+    public void testCreatePivotTableWithConflictingDataSheets() throws IOException {
         XSSFWorkbook wb = setupSheet();
         XSSFSheet sheet = wb.getSheetAt(0);
         XSSFSheet sheet2 = wb.createSheet();
 
-        try {
-            sheet2.createPivotTable(new AreaReference(sheet.getSheetName()+"!A$1:B$2"), new CellReference("H5"), sheet2);
-        } catch(IllegalArgumentException e) {
-            return;
-        }
-        fail();
+        sheet2.createPivotTable(new AreaReference(sheet.getSheetName()+"!A$1:B$2"), new CellReference("H5"), sheet2);
     }
     
-    @Test
-    public void testReadFails() {
+    @Test(expected=POIXMLException.class)
+    public void testReadFails() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         
-        try {
-            sheet.onDocumentRead();
-            fail("Throws exception because we cannot read here");
-        } catch (POIXMLException e) {
-            // expected here
-        }
+        // Throws exception because we cannot read here
+        sheet.onDocumentRead();
     }
     
     @SuppressWarnings("deprecation")
     @Test
-    public void testCreateComment() {
+    public void testCreateComment() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         assertNotNull(sheet.createComment());
+        wb.close();
     }
 
     @Test
-    public void testNoMergedRegionsIsEmptyList() {
+    public void testNoMergedRegionsIsEmptyList() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         assertTrue(sheet.getMergedRegions().isEmpty());
+        wb.close();
     }
 }
\ No newline at end of file

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleDescription.java Mon Oct  5 00:28:54 2015
@@ -126,7 +126,7 @@ public final class StyleDescription impl
 
 
           // the upx will always start on a word boundary.
-          if(upxSize % 2 == 1)
+          if((upxSize & 1) == 1)
           {
               ++varOffset;
           }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/CharacterSprmUncompressor.java Mon Oct  5 00:28:54 2015
@@ -389,7 +389,7 @@ public final class CharacterSprmUncompre
 
         //byte hpsPos = (byte)((param & 0xff0000) >>> 8);
         byte hpsPos = (byte) ((operand & 0xff0000) >>> 16);
-        if (hpsPos != 0x80)
+        if (hpsPos != (byte)0x80)
         {
           newCHP.setHpsPos (hpsPos);
         }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFConditionalFormatting.java Mon Oct  5 00:28:54 2015
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.usermodel;
 
 
+import static org.junit.Assert.*;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
@@ -28,6 +29,7 @@ import org.apache.poi.ss.usermodel.Color
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.junit.Test;
 
 /**
  * HSSF-specific Conditional Formatting tests
@@ -51,18 +53,20 @@ public final class TestHSSFConditionalFo
         }
     }
 
-    public void testRead() {
+    @Test
+    public void testRead() throws IOException {
         testRead("WithConditionalFormatting.xls");
     }
     
-    public void testReadOffice2007() {
+    @Test
+    public void testReadOffice2007() throws IOException {
         testReadOffice2007("NewStyleConditionalFormattings.xls");
     }
 
+    @Test
     public void test53691() throws IOException {
         SheetConditionalFormatting cf;
-        final Workbook wb;
-        wb = HSSFITestDataProvider.instance.openSampleWorkbook("53691.xls");
+        final Workbook wb = HSSFITestDataProvider.instance.openSampleWorkbook("53691.xls");
         /*
         FileInputStream s = new FileInputStream("C:\\temp\\53691bbadfixed.xls");
         try {
@@ -101,6 +105,8 @@ public final class TestHSSFConditionalFo
         removeConditionalFormatting(sheet);        
         removeConditionalFormatting(wb.getSheetAt(0));        
         writeTemp53691(wb, "fgood");
+        
+        wb.close();
     }
     
     private void removeConditionalFormatting(Sheet sheet) {
@@ -110,18 +116,10 @@ public final class TestHSSFConditionalFo
         }
     }
 
-    private void writeTemp53691(Workbook wb, String suffix) throws FileNotFoundException,
-            IOException {
+    private void writeTemp53691(Workbook wb, String suffix) throws FileNotFoundException, IOException {
         // assert that we can write/read it in memory
         Workbook wbBack = HSSFITestDataProvider.instance.writeOutAndReadBack(wb);
         assertNotNull(wbBack);
-        
-        /* Just necessary for local testing... */
-        /*OutputStream out = new FileOutputStream("C:\\temp\\53691" + suffix + ".xls");
-        try {
-            wb.write(out);
-        } finally {
-            out.close();
-        }*/
+        wbBack.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java?rev=1706742&r1=1706741&r2=1706742&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java Mon Oct  5 00:28:54 2015
@@ -17,7 +17,10 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import junit.framework.AssertionFailedError;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -31,6 +34,7 @@ import org.apache.poi.ss.formula.eval.Va
 import org.apache.poi.ss.usermodel.BaseTestFormulaEvaluator;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellValue;
+import org.junit.Test;
 
 /**
  *
@@ -46,7 +50,8 @@ public final class TestHSSFFormulaEvalua
 	 * Test that the HSSFFormulaEvaluator can evaluate simple named ranges
 	 *  (single cells and rectangular areas)
 	 */
-	public void testEvaluateSimple() {
+    @Test
+	public void testEvaluateSimple() throws IOException {
 		HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("testNames.xls");
 		HSSFSheet sheet = wb.getSheetAt(0);
 		HSSFCell cell = sheet.getRow(8).getCell(0);
@@ -54,13 +59,15 @@ public final class TestHSSFFormulaEvalua
 		CellValue cv = fe.evaluate(cell);
 		assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
 		assertEquals(3.72, cv.getNumberValue(), 0.0);
+		wb.close();
 	}
 
 	/**
 	 * Test for bug due to attempt to convert a cached formula error result to a boolean
 	 */
+    @Test
 	@Override
-	public void testUpdateCachedFormulaResultFromErrorToNumber_bug46479() {
+	public void testUpdateCachedFormulaResultFromErrorToNumber_bug46479() throws IOException {
 
 		HSSFWorkbook wb = new HSSFWorkbook();
 		HSSFSheet sheet = wb.createSheet("Sheet1");
@@ -79,10 +86,12 @@ public final class TestHSSFFormulaEvalua
 			fe.evaluateInCell(cellB1);
 		} catch (IllegalStateException e) {
 			if (e.getMessage().equals("Cannot get a numeric value from a error formula cell")) {
-				throw new AssertionFailedError("Identified bug 46479a");
+				fail("Identified bug 46479a");
 			}
 		}
 		assertEquals(3.5, cellB1.getNumericCellValue(), 0.0);
+		
+		wb.close();
 	}
 
 	/**
@@ -92,7 +101,8 @@ public final class TestHSSFFormulaEvalua
 	 * which contained a simple area ref.  It is not clear what the 'complex' flag is used
 	 * for but POI should look elsewhere to decide whether it can evaluate the name.
 	 */
-	public void testDefinedNameWithComplexFlag_bug47048() {
+    @Test
+	public void testDefinedNameWithComplexFlag_bug47048() throws IOException {
 		// Mock up a spreadsheet to match the critical details of the sample
 		HSSFWorkbook wb = new HSSFWorkbook();
 		HSSFSheet sheet = wb.createSheet("Input");
@@ -118,16 +128,20 @@ public final class TestHSSFFormulaEvalua
 		CellValue value;
 		try {
 			value = hsf.evaluate(cellA1);
+
+	        assertEquals(Cell.CELL_TYPE_NUMERIC, value.getCellType());
+	        assertEquals(5.33, value.getNumberValue(), 0.0);
+	        
 		} catch (RuntimeException e) {
 			if (e.getMessage().equals("Don't now how to evalate name 'Is_Multicar_Vehicle'")) {
-				throw new AssertionFailedError("Identified bug 47048a");
+				fail("Identified bug 47048a");
 			}
 			throw e;
+		} finally {
+	        wb.close();
 		}
-
-		assertEquals(Cell.CELL_TYPE_NUMERIC, value.getCellType());
-		assertEquals(5.33, value.getNumberValue(), 0.0);
 	}
+    
 	private static final class EvalCountListener extends EvaluationListener {
 		private int _evalCount;
 		public EvalCountListener() {
@@ -145,7 +159,8 @@ public final class TestHSSFFormulaEvalua
 	/**
 	 * The HSSFFormula evaluator performance benefits greatly from caching of intermediate cell values
 	 */
-	public void testShortCircuitIfEvaluation() {
+	@Test
+	public void testShortCircuitIfEvaluation() throws IOException {
 
 		// Set up a simple IF() formula that has measurable evaluation cost for its operands.
 		HSSFWorkbook wb = new HSSFWorkbook();
@@ -166,23 +181,26 @@ public final class TestHSSFFormulaEvalua
 		int evalCount = evalListener.getEvalCount();
 		if (evalCount == 6) {
 			// Without short-circuit-if evaluation, evaluating cell 'A1' takes 3 extra evaluations (for D1,E1,F1)
-			throw new AssertionFailedError("Identifed bug 48195 - Formula evaluator should short-circuit IF() calculations.");
+			fail("Identifed bug 48195 - Formula evaluator should short-circuit IF() calculations.");
 		}
 		assertEquals(3, evalCount);
 		assertEquals(2.0, ((NumberEval)ve).getNumberValue(), 0D);
+		
+		wb.close();
 	}
 	
 	/**
 	 * Ensures that we can handle NameXPtgs in the formulas
 	 *  we parse.
 	 */
-	public void testXRefs() throws Exception {
-      HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
-      HSSFWorkbook wbData = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
+	@Test
+	public void testXRefs() throws IOException {
+      HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("XRefCalc.xls");
+      HSSFWorkbook wb2 = HSSFTestDataSamples.openSampleWorkbook("XRefCalcData.xls");
       Cell cell;
       
       // VLookup on a name in another file
-      cell = wb.getSheetAt(0).getRow(1).getCell(2);
+      cell = wb1.getSheetAt(0).getRow(1).getCell(2);
       assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
       assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
@@ -193,7 +211,7 @@ public final class TestHSSFFormulaEvalua
       
       
       // Simple reference to a name in another file
-      cell = wb.getSheetAt(0).getRow(1).getCell(4);
+      cell = wb1.getSheetAt(0).getRow(1).getCell(4);
       assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
       assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
@@ -203,37 +221,37 @@ public final class TestHSSFFormulaEvalua
       
       
       // Evaluate the cells
-      HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
+      HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb1);
       HSSFFormulaEvaluator.setupEnvironment(
             new String[] { "XRefCalc.xls", "XRefCalcData.xls" },
             new HSSFFormulaEvaluator[] {
                   eval,
-                  new HSSFFormulaEvaluator(wbData)
+                  new HSSFFormulaEvaluator(wb2)
             }
       );
       eval.evaluateFormulaCell(
-            wb.getSheetAt(0).getRow(1).getCell(2)
+            wb1.getSheetAt(0).getRow(1).getCell(2)
       );      
       eval.evaluateFormulaCell(
-            wb.getSheetAt(0).getRow(1).getCell(4)
+            wb1.getSheetAt(0).getRow(1).getCell(4)
       );      
       
 
       // Re-check VLOOKUP one
-      cell = wb.getSheetAt(0).getRow(1).getCell(2);
+      cell = wb1.getSheetAt(0).getRow(1).getCell(2);
       assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
       assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
       
       // Re-check ref one
-      cell = wb.getSheetAt(0).getRow(1).getCell(4);
+      cell = wb1.getSheetAt(0).getRow(1).getCell(4);
       assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
       assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
       
       
       // Add a formula that refers to one of the existing external workbooks
-      cell = wb.getSheetAt(0).getRow(1).createCell(40);
+      cell = wb1.getSheetAt(0).getRow(1).createCell(40);
       cell.setCellFormula("Cost*[XRefCalcData.xls]MarkupSheet!$B$1");
       
       // Check is was stored correctly
@@ -241,20 +259,20 @@ public final class TestHSSFFormulaEvalua
       
       // Check it evaluates correctly
       eval.evaluateFormulaCell(cell);
-      assertEquals(24.60*1.8, cell.getNumericCellValue());
+      assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
       
       
       // Try to add a formula for a new external workbook, won't be allowed to start
       try {
-          cell = wb.getSheetAt(0).getRow(1).createCell(42);
+          cell = wb1.getSheetAt(0).getRow(1).createCell(42);
           cell.setCellFormula("[alt.xls]Sheet0!$A$1");
           fail("New workbook not linked, shouldn't be able to add");
       } catch(Exception e) {}
       
       // Link our new workbook
-      HSSFWorkbook alt = new HSSFWorkbook();
-      alt.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
-      wb.linkExternalWorkbook("alt.xls", alt);
+      HSSFWorkbook wb3 = new HSSFWorkbook();
+      wb3.createSheet().createRow(0).createCell(0).setCellValue("In another workbook");
+      wb1.linkExternalWorkbook("alt.xls", wb3);
       
       // Now add a formula that refers to our new workbook
       cell.setCellFormula("[alt.xls]Sheet0!$A$1");
@@ -271,8 +289,8 @@ public final class TestHSSFFormulaEvalua
               new String[] { "XRefCalc.xls", "XRefCalcData.xls", "alt.xls" },
               new HSSFFormulaEvaluator[] {
                     eval,
-                    new HSSFFormulaEvaluator(wbData),
-                    new HSSFFormulaEvaluator(alt)
+                    new HSSFFormulaEvaluator(wb2),
+                    new HSSFFormulaEvaluator(wb3)
               }
       );
       eval.evaluateFormulaCell(cell);
@@ -280,31 +298,37 @@ public final class TestHSSFFormulaEvalua
       
       
       // Save and re-load
-      wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
-      eval = new HSSFFormulaEvaluator(wb);
+      HSSFWorkbook wb4 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
+      eval = new HSSFFormulaEvaluator(wb4);
       HSSFFormulaEvaluator.setupEnvironment(
               new String[] { "XRefCalc.xls", "XRefCalcData.xls", "alt.xls" },
               new HSSFFormulaEvaluator[] {
                     eval,
-                    new HSSFFormulaEvaluator(wbData),
-                    new HSSFFormulaEvaluator(alt)
+                    new HSSFFormulaEvaluator(wb2),
+                    new HSSFFormulaEvaluator(wb3)
               }
       );
       
       // Check the one referring to the previously existing workbook behaves
-      cell = wb.getSheetAt(0).getRow(1).getCell(40);
+      cell = wb4.getSheetAt(0).getRow(1).getCell(40);
       assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
       eval.evaluateFormulaCell(cell);
-      assertEquals(24.60*1.8, cell.getNumericCellValue());
+      assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
       
       // Now check the newly added reference
-      cell = wb.getSheetAt(0).getRow(1).getCell(42);
+      cell = wb4.getSheetAt(0).getRow(1).getCell(42);
       assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
       eval.evaluateFormulaCell(cell);
       assertEquals("In another workbook", cell.getStringCellValue());
+      
+      wb4.close();
+      wb3.close();
+      wb2.close();
+      wb1.close();
    }
 
-    public void testSharedFormulas(){
+	@Test
+    public void testSharedFormulas() throws IOException {
         baseTestSharedFormulas("shared_formulas.xls");
     }
 



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


Mime
View raw message