poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1778955 [1/2] - in /poi/trunk/src: examples/src/org/apache/poi/ss/examples/ examples/src/org/apache/poi/xssf/usermodel/examples/ integrationtest/org/apache/poi/stress/ java/org/apache/poi/hssf/extractor/ java/org/apache/poi/ss/usermodel/ o...
Date Sun, 15 Jan 2017 23:08:48 GMT
Author: kiwiwings
Date: Sun Jan 15 23:08:47 2017
New Revision: 1778955

URL: http://svn.apache.org/viewvc?rev=1778955&view=rev
Log:
fix eclipse warnings - close resources / type generics
cleanup sources - add parenthesis to statements

Modified:
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java
    poi/trunk/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java
    poi/trunk/src/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
    poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java
    poi/trunk/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java

Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java Sun Jan 15 23:08:47 2017
@@ -269,7 +269,7 @@ public class AddDimensionedImage {
      *                                            to the resizeBehaviour
      *                                            parameter.
      */
-    public void addImageToSheet(String cellNumber, Sheet sheet, Drawing drawing,
+    public void addImageToSheet(String cellNumber, Sheet sheet, Drawing<?> drawing,
             URL imageFile, double reqImageWidthMM, double reqImageHeightMM,
             int resizeBehaviour) throws IOException, IllegalArgumentException {
         // Convert the String into column and row indices then chain the
@@ -329,7 +329,7 @@ public class AddDimensionedImage {
      *                                            it is of a type that cannot
      *                                            currently be added to the worksheet.
      */
-    public void addImageToSheet(int colNumber, int rowNumber, Sheet sheet, Drawing drawing,
+    public void addImageToSheet(int colNumber, int rowNumber, Sheet sheet, Drawing<?> drawing,
             URL imageFile, double reqImageWidthMM, double reqImageHeightMM,
             int resizeBehaviour) throws IOException,
                                                      IllegalArgumentException {

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java Sun Jan 15 23:08:47 2017
@@ -16,13 +16,22 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel.examples;
 
-import org.apache.poi.ss.usermodel.*;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.RichTextString;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
-import java.io.IOException;
-import java.io.FileOutputStream;
-
 /**
  * Demonstrates how to work with excel cell comments.
  *
@@ -44,7 +53,7 @@ public class CellComments {
         Cell cell1 = sheet.createRow(3).createCell(5);
         cell1.setCellValue("F4");
 
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
 
         ClientAnchor anchor = factory.createClientAnchor();
 
@@ -63,7 +72,7 @@ public class CellComments {
         Font font = wb.createFont();
         font.setFontName("Arial");
         font.setFontHeightInPoints((short)14);
-        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        font.setBold(true);
         font.setColor(IndexedColors.RED.getIndex());
         str2.applyFont(font);
 

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java Sun Jan 15 23:08:47 2017
@@ -17,20 +17,23 @@
 
 package org.apache.poi.xssf.usermodel.examples;
 
-import org.apache.poi.xssf.usermodel.*;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.util.IOUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Picture;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.util.IOUtils;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
 /**
  * Demonstrates how to insert pictures in a SpreadsheetML document
- *
- * @author Yegor Kozlov
  */
 public class WorkingWithPictures {
     public static void main(String[] args) throws IOException {
@@ -50,7 +53,7 @@ public class WorkingWithPictures {
             Sheet sheet = wb.createSheet();
     
             //create drawing
-            Drawing drawing = sheet.createDrawingPatriarch();
+            Drawing<?> drawing = sheet.createDrawingPatriarch();
     
             //add a picture shape
             ClientAnchor anchor = helper.createClientAnchor();
@@ -63,7 +66,10 @@ public class WorkingWithPictures {
     
             //save workbook
             String file = "picture.xls";
-            if(wb instanceof XSSFWorkbook) file += "x"; // NOSONAR
+            if(wb instanceof XSSFWorkbook)
+             {
+                file += "x"; // NOSONAR
+            }
             OutputStream fileOut = new FileOutputStream(file);
             try {
                 wb.write(fileOut);

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/HDGFFileHandler.java Sun Jan 15 23:08:47 2017
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTru
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.poi.hdgf.HDGFDiagram;
@@ -32,7 +33,7 @@ import org.junit.Test;
 
 public class HDGFFileHandler extends POIFSFileHandler {
 	@Override
-	public void handleFile(InputStream stream) throws Exception {
+	public void handleFile(InputStream stream) throws IOException {
 	    POIFSFileSystem poifs = new POIFSFileSystem(stream);
 		HDGFDiagram diagram = new HDGFDiagram(poifs);
 		Stream[] topLevelStreams = diagram.getTopLevelStreams();
@@ -44,7 +45,7 @@ public class HDGFFileHandler extends POI
 		TrailerStream trailerStream = diagram.getTrailerStream();
 		assertNotNull(trailerStream);
 		assertTrue(trailerStream.getPointer().getLength() >= 0);
-		
+		diagram.close();
 		poifs.close();
 		
 		// writing is not yet implemented... handlePOIDocument(diagram);

Modified: poi/trunk/src/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/extractor/OldExcelExtractor.java Sun Jan 15 23:08:47 2017
@@ -161,7 +161,7 @@ public class OldExcelExtractor implement
         prepare();
     }
 
-    public static void main(String[] args) throws Exception {
+    public static void main(String[] args) throws IOException {
         if (args.length < 1) {
             System.err.println("Use:");
             System.err.println("   OldExcelExtractor <filename>");
@@ -173,8 +173,9 @@ public class OldExcelExtractor implement
     }
     
     private void prepare() {
-        if (! ris.hasNextRecord())
-            throw new IllegalArgumentException("File contains no records!"); 
+        if (! ris.hasNextRecord()) {
+            throw new IllegalArgumentException("File contains no records!");
+        } 
         ris.nextRecord();
         
         // Work out what version we're dealing with

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java Sun Jan 15 23:08:47 2017
@@ -19,11 +19,11 @@ package org.apache.poi.ss.usermodel;
 
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Map;
 
 import org.apache.poi.ss.formula.FormulaParseException;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.util.Internal;
 import org.apache.poi.util.Removal;
 
 /**
@@ -47,6 +47,7 @@ public interface Cell {
      * @see #getCellType()
      * @deprecated POI 3.15 beta 3. Use {@link CellType#NUMERIC} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     int CELL_TYPE_NUMERIC = 0; //CellType.NUMERIC.getCode();
 
@@ -56,6 +57,7 @@ public interface Cell {
      * @see #getCellType()
      * @deprecated POI 3.15 beta 3. Use {@link CellType#STRING} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     int CELL_TYPE_STRING = 1; //CellType.STRING.getCode();
 
@@ -65,6 +67,7 @@ public interface Cell {
      * @see #getCellType()
      * @deprecated POI 3.15 beta 3. Use {@link CellType#FORMULA} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     int CELL_TYPE_FORMULA = 2; //CellType.FORMULA.getCode();
 
@@ -74,6 +77,7 @@ public interface Cell {
      * @see #getCellType()
      * @deprecated POI 3.15 beta 3. Use {@link CellType#BLANK} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     int CELL_TYPE_BLANK = 3; //CellType.BLANK.getCode();
 
@@ -83,6 +87,7 @@ public interface Cell {
      * @see #getCellType()
      * @deprecated POI 3.15 beta 3. Use {@link CellType#BOOLEAN} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     int CELL_TYPE_BOOLEAN = 4; //CellType.BOOLEAN.getCode();
 
@@ -92,6 +97,7 @@ public interface Cell {
      * @see #getCellType()
      * @deprecated POI 3.15 beta 3. Use {@link CellType#ERROR} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     int CELL_TYPE_ERROR = 5; //CellType.ERROR.getCode();
 
@@ -143,6 +149,7 @@ public interface Cell {
      * @see CellType#ERROR
      * @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead.
      */
+    @Deprecated
     @Removal(version="4.0")
     void setCellType(int cellType);
     /**
@@ -169,6 +176,7 @@ public interface Cell {
      * @return the cell type
      * @deprecated POI 3.15. Will return a {@link CellType} enum in the future.
      */
+    @Deprecated
     int getCellType();
     
     /**
@@ -192,6 +200,7 @@ public interface Cell {
      * on the cached value of the formula
      * @deprecated 3.15. Will return a {@link CellType} enum in the future.
      */
+    @Deprecated
     int getCachedFormulaResultType();
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java Sun Jan 15 23:08:47 2017
@@ -972,7 +972,7 @@ public interface Sheet extends Iterable<
      *
      * @return a SpreadsheetML drawing
      */
-    Drawing getDrawingPatriarch();
+    Drawing<?> getDrawingPatriarch();
     
     /**
      * Creates the top-level drawing patriarch. 
@@ -982,7 +982,7 @@ public interface Sheet extends Iterable<
      *
      * @return  The new drawing patriarch.
      */
-    Drawing createDrawingPatriarch();
+    Drawing<?> createDrawingPatriarch();
 
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java Sun Jan 15 23:08:47 2017
@@ -33,7 +33,6 @@ import org.apache.poi.ss.usermodel.CellR
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.DataValidation;
 import org.apache.poi.ss.usermodel.DataValidationHelper;
-import org.apache.poi.ss.usermodel.Drawing;
 import org.apache.poi.ss.usermodel.Footer;
 import org.apache.poi.ss.usermodel.Header;
 import org.apache.poi.ss.usermodel.PrintSetup;
@@ -51,6 +50,7 @@ import org.apache.poi.util.Removal;
 import org.apache.poi.xssf.usermodel.XSSFColor;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 import org.apache.poi.xssf.usermodel.XSSFDataValidation;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
 import org.apache.poi.xssf.usermodel.XSSFHyperlink;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetFormatPr;
@@ -207,8 +207,9 @@ public class SXSSFSheet implements Sheet
     @Override
     public int getFirstRowNum()
     {
-        if(_writer.getNumberOfFlushedRows() > 0)
+        if(_writer.getNumberOfFlushedRows() > 0) {
             return _writer.getLowestIndexOfFlushedRows();
+        }
         return _rows.size() == 0 ? 0 : _rows.firstKey();
     }
 
@@ -875,6 +876,7 @@ public class SXSSFSheet implements Sheet
      * @param denominator   The denominator for the zoom magnification.
      * @deprecated 2015-11-23 (circa POI 3.14beta1). Use {@link #setZoom(int)} instead.
      */
+    @Deprecated
     @Removal(version="3.16")
     @Override
     public void setZoom(int numerator, int denominator)
@@ -1293,7 +1295,9 @@ public class SXSSFSheet implements Sheet
             int level = row.getOutlineLevel() + 1;
             row.setOutlineLevel(level);
 
-            if(level > outlineLevelRow) outlineLevelRow = level;
+            if(level > outlineLevelRow) {
+                outlineLevelRow = level;
+            }
         }
 
         setWorksheetOutlineLevelRow();
@@ -1328,7 +1332,9 @@ public class SXSSFSheet implements Sheet
         CTSheetFormatPr pr = ct.isSetSheetFormatPr() ?
             ct.getSheetFormatPr() :
             ct.addNewSheetFormatPr();
-        if(outlineLevelRow > 0) pr.setOutlineLevelRow((short)outlineLevelRow);
+        if(outlineLevelRow > 0) {
+            pr.setOutlineLevelRow((short)outlineLevelRow);
+        }
     }
 
     /**
@@ -1397,8 +1403,9 @@ public class SXSSFSheet implements Sheet
         }
         int currentRow = rowIndex;
         while (getRow(currentRow) != null) {
-            if (getRow(currentRow).getOutlineLevel() < level)
+            if (getRow(currentRow).getOutlineLevel() < level) {
                 return currentRow + 1;
+            }
             currentRow--;
         }
         return currentRow + 1;
@@ -1626,6 +1633,8 @@ public class SXSSFSheet implements Sheet
      * @return cell comment or <code>null</code> if not found
      * @deprecated as of 2015-11-23 (circa POI 3.14beta1). Use {@link #getCellComment(CellAddress)} instead.
      */
+    @Deprecated
+    @Removal(version="3.16")
     @Override
     public XSSFComment getCellComment(int row, int column)
     {
@@ -1691,7 +1700,7 @@ public class SXSSFSheet implements Sheet
      * {@inheritDoc}
      */
     @Override
-    public Drawing getDrawingPatriarch()
+    public XSSFDrawing getDrawingPatriarch()
     {
         return _sh.getDrawingPatriarch();
     }
@@ -1702,9 +1711,9 @@ public class SXSSFSheet implements Sheet
      * @return  The new drawing patriarch.
      */
     @Override
-    public Drawing createDrawingPatriarch()
+    public SXSSFDrawing createDrawingPatriarch()
     {
-        return new SXSSFDrawing((SXSSFWorkbook)getWorkbook(), _sh.createDrawingPatriarch());
+        return new SXSSFDrawing(getWorkbook(), _sh.createDrawingPatriarch());
     }
 
 
@@ -1868,8 +1877,12 @@ public class SXSSFSheet implements Sheet
      */
     public void flushRows(int remaining) throws IOException
     {
-        while(_rows.size() > remaining) flushOneRow();
-        if (remaining == 0) allFlushed = true;
+        while(_rows.size() > remaining) {
+            flushOneRow();
+        }
+        if (remaining == 0) {
+            allFlushed = true;
+        }
     }
 
     /**
@@ -1907,8 +1920,9 @@ public class SXSSFSheet implements Sheet
         for(Iterator<Map.Entry<Integer,SXSSFRow>> iter=_rows.entrySet().iterator();iter.hasNext();)
         {
             Map.Entry<Integer,SXSSFRow> entry=iter.next();
-            if(entry.getValue()==row)
+            if(entry.getValue()==row) {
                 return entry.getKey().intValue();
+            }
         }
         return -1;
     }
@@ -1918,7 +1932,9 @@ public class SXSSFSheet implements Sheet
      * @return true if the file was deleted, false if it wasn't.
      */
     boolean dispose() throws IOException {
-        if (!allFlushed) flushRows();
+        if (!allFlushed) {
+            flushRows();
+        }
         return _writer.dispose();
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCommentsTable.java Sun Jan 15 23:08:47 2017
@@ -144,7 +144,7 @@ public class TestCommentsTable {
         Cell c1r2s2 = r2s2.createCell(1);
         assertNull(c1r2s2.getCellComment());
 
-        Drawing dg = sheet2.createDrawingPatriarch();
+        Drawing<?> dg = sheet2.createDrawingPatriarch();
         Comment cc2 = dg.createCellComment(new XSSFClientAnchor());
         cc2.setAuthor("Also POI");
         cc2.setString(new XSSFRichTextString("A new comment"));
@@ -256,7 +256,7 @@ public class TestCommentsTable {
         // NOTE - only occurs if a comment is placed in A1 first
         Cell A1 = getCell(sheet, 0, 0);
         //Cell A1 = getCell(sheet, 2, 2);
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         setComment(sheet, A1, drawing, "for A1", helper, anchor);
         
         // find comment in A1 before we set the comment in B2
@@ -282,7 +282,7 @@ public class TestCommentsTable {
     
     // Set the comment on a sheet
     //
-    private static void setComment(Sheet sheet, Cell cell, Drawing drawing, String commentText, CreationHelper helper, ClientAnchor anchor) {
+    private static void setComment(Sheet sheet, Cell cell, Drawing<?> drawing, String commentText, CreationHelper helper, ClientAnchor anchor) {
         System.out.println("Setting col: " + cell.getColumnIndex() + " and row " + cell.getRowIndex());
         anchor.setCol1(cell.getColumnIndex());
         anchor.setCol2(cell.getColumnIndex());

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Sun Jan 15 23:08:47 2017
@@ -25,7 +25,14 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.HashMap;
@@ -57,6 +64,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.openxml4j.util.ZipSecureFile;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.SpreadsheetVersion;
 import org.apache.poi.ss.formula.WorkbookEvaluator;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.NumberEval;
@@ -1277,7 +1285,7 @@ public final class TestXSSFBugs extends
 
         // Try to add comments to Sheet 1
         CreationHelper factory = wb1.getCreationHelper();
-        Drawing drawing = sh1.createDrawingPatriarch();
+        Drawing<?> drawing = sh1.createDrawingPatriarch();
 
         ClientAnchor anchor = factory.createClientAnchor();
         anchor.setCol1(0);
@@ -1336,8 +1344,7 @@ public final class TestXSSFBugs extends
         Name name = wb.getName("Intekon.ProdCodes");
         assertEquals("'Abc,1'!$A$1:$A$2", name.getRefersToFormula());
 
-        @SuppressWarnings("deprecation")
-        AreaReference ref = new AreaReference(name.getRefersToFormula());
+        AreaReference ref = new AreaReference(name.getRefersToFormula(), SpreadsheetVersion.EXCEL2007);
         assertEquals(0, ref.getFirstCell().getRow());
         assertEquals(0, ref.getFirstCell().getCol());
         assertEquals(1, ref.getLastCell().getRow());
@@ -2312,7 +2319,7 @@ public final class TestXSSFBugs extends
             assertNotNull(orig);
 
             Sheet sheet = wb.cloneSheet(0);
-            Drawing drawing = sheet.createDrawingPatriarch();
+            Drawing<?> drawing = sheet.createDrawingPatriarch();
             for (XSSFShape shape : ((XSSFDrawing) drawing).getShapes()) {
                 if (shape instanceof XSSFPicture) {
                     XSSFPictureData pictureData = ((XSSFPicture) shape).getPictureData();
@@ -2991,7 +2998,7 @@ public final class TestXSSFBugs extends
         XSSFColor color = new XSSFColor(java.awt.Color.RED);
         XSSFCellStyle style = workbook.createCellStyle();
         style.setFillForegroundColor(color);
-        style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
+        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
         cell.setCellStyle(style);
 
         // Everything is fine at this point, cell is red

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFComment.java Sun Jan 15 23:08:47 2017
@@ -18,9 +18,15 @@
 package org.apache.poi.xssf.usermodel;
 
 import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_SPREADSHEETML;
-import static org.junit.Assert.*;
-
-import java.io.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
 
 import org.apache.poi.hssf.usermodel.HSSFRichTextString;
 import org.apache.poi.ss.usermodel.BaseTestCellComment;
@@ -48,9 +54,6 @@ import org.openxmlformats.schemas.spread
 
 import com.microsoft.schemas.vml.CTShape;
 
-/**
- * @author Yegor Kozlov
- */
 public final class TestXSSFComment extends BaseTestCellComment  {
 
     private static final String TEST_RICHTEXTSTRING = "test richtextstring";
@@ -274,7 +277,7 @@ public final class TestXSSFComment exten
 
             cell.setCellValue("F4");
 
-            Drawing drawing = sheet.createDrawingPatriarch();
+            Drawing<?> drawing = sheet.createDrawingPatriarch();
 
             CreationHelper factory = wb.getCreationHelper();
 

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=1778955&r1=1778954&r2=1778955&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 Sun Jan 15 23:08:47 2017
@@ -1955,7 +1955,7 @@ public final class TestXSSFSheet extends
 	}
     
     private void addComments(CreationHelper helper, Sheet sheet) {
-		Drawing drawing = sheet.createDrawingPatriarch();
+		Drawing<?> drawing = sheet.createDrawingPatriarch();
 
 		for (int i = 0; i < 2; i++) {
 			ClientAnchor anchor = helper.createClientAnchor();
@@ -1968,11 +1968,13 @@ public final class TestXSSFSheet extends
 			comment.setString(helper.createRichTextString("BugTesting"));
 
 			Row row = sheet.getRow(0 + i);
-			if (row == null)
-				row = sheet.createRow(0 + i);
+			if (row == null) {
+                row = sheet.createRow(0 + i);
+            }
 			Cell cell = row.getCell(0);
-			if (cell == null)
-				cell = row.createCell(0);
+			if (cell == null) {
+                cell = row.createCell(0);
+            }
 
 			cell.setCellComment(comment);
 		}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartLegend.java Sun Jan 15 23:08:47 2017
@@ -17,38 +17,47 @@
 
 package org.apache.poi.xssf.usermodel.charts;
 
-import junit.framework.TestCase;
-
-import org.apache.poi.ss.usermodel.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.Chart;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.charts.ChartLegend;
 import org.apache.poi.ss.usermodel.charts.LegendPosition;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
 
 /**
  * Tests ChartLegend
- *
- * @author Martin Andersson
- * @author Cedric dot Walter at gmail dot com
  */
-public final class TestXSSFChartLegend extends TestCase {
-
-	public void testLegendPositionAccessMethods() throws Exception {
+public final class TestXSSFChartLegend {
+    @Test
+	public void testLegendPositionAccessMethods() throws IOException {
 		Workbook wb = new XSSFWorkbook();
 		Sheet sheet = wb.createSheet();
-		Drawing drawing = sheet.createDrawingPatriarch();
+		Drawing<?> drawing = sheet.createDrawingPatriarch();
 		ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
 		Chart chart = drawing.createChart(anchor);
 		ChartLegend legend = chart.getOrCreateLegend();
 
 		legend.setPosition(LegendPosition.TOP_RIGHT);
 		assertEquals(LegendPosition.TOP_RIGHT, legend.getPosition());
+		
+		wb.close();
 	}
 
-    public void test_setOverlay_defaultChartLegend_expectOverlayInitialValueSetToFalse() {
+    @Test
+    public void test_setOverlay_defaultChartLegend_expectOverlayInitialValueSetToFalse() throws IOException {
         // Arrange
         Workbook wb = new XSSFWorkbook();
         Sheet sheet = wb.createSheet();
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
         Chart chart = drawing.createChart(anchor);
         ChartLegend legend = chart.getOrCreateLegend();
@@ -57,13 +66,16 @@ public final class TestXSSFChartLegend e
 
         // Assert
         assertFalse(legend.isOverlay());
+
+        wb.close();
     }
 
-	public void test_setOverlay_chartLegendSetToTrue_expectOverlayInitialValueSetToTrue() {
+    @Test
+    public void test_setOverlay_chartLegendSetToTrue_expectOverlayInitialValueSetToTrue() throws IOException {
         // Arrange
         Workbook wb = new XSSFWorkbook();
 		Sheet sheet = wb.createSheet();
-		Drawing drawing = sheet.createDrawingPatriarch();
+		Drawing<?> drawing = sheet.createDrawingPatriarch();
 		ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
 		Chart chart = drawing.createChart(anchor);
 		ChartLegend legend = chart.getOrCreateLegend();
@@ -73,5 +85,7 @@ public final class TestXSSFChartLegend e
 
         // Assert
         assertTrue(legend.isOverlay());
+
+        wb.close();
 	}
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java Sun Jan 15 23:08:47 2017
@@ -17,19 +17,43 @@
 
 package org.apache.poi.xssf.usermodel.charts;
 
-import junit.framework.TestCase;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.usermodel.charts.*;
-import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.usermodel.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
+import java.io.IOException;
 import java.util.List;
 
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Chart;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.charts.AxisCrosses;
+import org.apache.poi.ss.usermodel.charts.AxisPosition;
+import org.apache.poi.ss.usermodel.charts.ChartAxis;
+import org.apache.poi.ss.usermodel.charts.ChartDataSource;
+import org.apache.poi.ss.usermodel.charts.ChartLegend;
+import org.apache.poi.ss.usermodel.charts.DataSources;
+import org.apache.poi.ss.usermodel.charts.LegendPosition;
+import org.apache.poi.ss.usermodel.charts.LineChartData;
+import org.apache.poi.ss.usermodel.charts.ValueAxis;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.apache.poi.xssf.usermodel.XSSFDrawing;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
+
 /**
  * Test get/set chart title.
  */
-public class TestXSSFChartTitle extends TestCase {
+public class TestXSSFChartTitle {
     private Workbook createWorkbookWithChart() {
         Workbook wb = new XSSFWorkbook();
         Sheet sheet = wb.createSheet("linechart");
@@ -47,7 +71,7 @@ public class TestXSSFChartTitle extends
             }
         }
 
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15);
 
         Chart chart = drawing.createChart(anchor);
@@ -91,7 +115,8 @@ public class TestXSSFChartTitle extends
         return null;
     }
 
-    public void testNewChart() {
+    @Test
+    public void testNewChart() throws IOException {
         Workbook wb = createWorkbookWithChart();
         XSSFChart chart = getChartFromWorkbook(wb, "linechart");
         assertNotNull(chart);
@@ -101,9 +126,11 @@ public class TestXSSFChartTitle extends
         XSSFRichTextString queryTitle = chart.getTitle();
         assertNotNull(queryTitle);
         assertEquals(myTitle, queryTitle.toString());
+        wb.close();
     }
 
-    public void testExistingChartWithTitle() {
+    @Test
+    public void testExistingChartWithTitle() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
         XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
         assertNotNull(chart);
@@ -115,9 +142,11 @@ public class TestXSSFChartTitle extends
         XSSFRichTextString queryTitle = chart.getTitle();
         assertNotNull(queryTitle);
         assertEquals(myTitle, queryTitle.toString());
+        wb.close();
     }
 
-    public void testExistingChartNoTitle() {
+    @Test
+    public void testExistingChartNoTitle() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_noTitle.xlsx");
         XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
         assertNotNull(chart);
@@ -127,6 +156,6 @@ public class TestXSSFChartTitle extends
         XSSFRichTextString queryTitle = chart.getTitle();
         assertNotNull(queryTitle);
         assertEquals(myTitle, queryTitle.toString());
+        wb.close();
     }
-
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java Sun Jan 15 23:08:47 2017
@@ -16,7 +16,11 @@
 ==================================================================== */
 package org.apache.poi.xssf.usermodel.charts;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
 
 import org.apache.poi.ss.usermodel.Chart;
 import org.apache.poi.ss.usermodel.ClientAnchor;
@@ -32,21 +36,23 @@ import org.apache.poi.ss.usermodel.chart
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.SheetBuilder;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
 
 /**
  * Tests for XSSF Line Charts
  */
-public class TestXSSFLineChartData extends TestCase {
+public class TestXSSFLineChartData {
 
     private static final Object[][] plotData = {
             {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"},
             {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
     };
 
-    public void testOneSeriePlot() throws Exception {
+    @Test
+    public void testOneSeriePlot() throws IOException {
         Workbook wb = new XSSFWorkbook();
         Sheet sheet = new SheetBuilder(wb, plotData).build();
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
         Chart chart = drawing.createChart(anchor);
 
@@ -65,5 +71,6 @@ public class TestXSSFLineChartData exten
         assertTrue(lineChartData.getSeries().contains(series));
 
         chart.plot(lineChartData, bottomAxis, leftAxis);
+        wb.close();
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFManualLayout.java Sun Jan 15 23:08:47 2017
@@ -17,29 +17,57 @@
 
 package org.apache.poi.xssf.usermodel.charts;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import org.apache.poi.ss.usermodel.*;
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.Chart;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.usermodel.charts.ChartLegend;
-import org.apache.poi.ss.usermodel.charts.ManualLayout;
 import org.apache.poi.ss.usermodel.charts.LayoutMode;
 import org.apache.poi.ss.usermodel.charts.LayoutTarget;
-import org.apache.poi.xssf.usermodel.*;
-
-public final class TestXSSFManualLayout extends TestCase {
-	
+import org.apache.poi.ss.usermodel.charts.ManualLayout;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public final class TestXSSFManualLayout {
+
+    private Workbook wb;
+    private ManualLayout layout;
+    
+    @Before
+    public void createEmptyLayout() {
+        wb = new XSSFWorkbook();
+        Sheet sheet = wb.createSheet();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
+        ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+        Chart chart = drawing.createChart(anchor);
+        ChartLegend legend = chart.getOrCreateLegend();
+        layout = legend.getManualLayout();
+    }
+
+    @After
+    public void closeWB() throws IOException {
+        wb.close();
+    }
+    
 	/*
 	 * Accessor methods are not trivial. They use lazy underlying bean
 	 * initialization so there can be some errors (NPE, for example).
 	 */
-	public void testAccessorMethods() throws Exception {
+    @Test
+    public void testAccessorMethods() {
 		final double newRatio = 1.1;
 		final double newCoordinate = 0.3;
 		final LayoutMode nonDefaultMode = LayoutMode.FACTOR;
 		final LayoutTarget nonDefaultTarget = LayoutTarget.OUTER;
 
-		ManualLayout layout = getEmptyLayout();
-
 		layout.setWidthRatio(newRatio);
 		assertTrue(layout.getWidthRatio() == newRatio);
 
@@ -73,9 +101,8 @@ public final class TestXSSFManualLayout
 	 * Layout must have reasonable default values and must not throw
 	 * any exceptions.
 	 */
-	public void testDefaultValues() throws Exception {
-		ManualLayout layout = getEmptyLayout();
-		
+    @Test
+    public void testDefaultValues() {
 		assertNotNull(layout.getTarget());
 		assertNotNull(layout.getXMode());
 		assertNotNull(layout.getYMode());
@@ -90,14 +117,4 @@ public final class TestXSSFManualLayout
 		assertTrue(layout.getWidthRatio() == 0.0);
 		assertTrue(layout.getHeightRatio() == 0.0);
 	}
-
-	private ManualLayout getEmptyLayout() {
-		Workbook wb = new XSSFWorkbook();
-		Sheet sheet = wb.createSheet();
-		Drawing drawing = sheet.createDrawingPatriarch();
-		ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
-		Chart chart = drawing.createChart(anchor);
-		ChartLegend legend = chart.getOrCreateLegend();
-		return legend.getManualLayout();
-	}
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFScatterChartData.java Sun Jan 15 23:08:47 2017
@@ -17,7 +17,11 @@
 
 package org.apache.poi.xssf.usermodel.charts;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
 
 import org.apache.poi.ss.usermodel.Chart;
 import org.apache.poi.ss.usermodel.ClientAnchor;
@@ -33,21 +37,23 @@ import org.apache.poi.ss.usermodel.chart
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.SheetBuilder;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
 
 /**
  * Tests for XSSFScatterChartData.
  */
-public final class TestXSSFScatterChartData extends TestCase {
+public final class TestXSSFScatterChartData {
 
     private static final Object[][] plotData = {
             {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"},
             {  1,    2,   3,    4,    5,   6,    7,   8,    9,  10}
     };
 
-    public void testOneSeriePlot() throws Exception {
+    @Test
+    public void testOneSeriePlot() throws IOException {
         Workbook wb = new XSSFWorkbook();
         Sheet sheet = new SheetBuilder(wb, plotData).build();
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
         Chart chart = drawing.createChart(anchor);
 
@@ -66,5 +72,6 @@ public final class TestXSSFScatterChartD
         assertTrue(scatterChartData.getSeries().contains(series));
 
         chart.plot(scatterChartData, bottomAxis, leftAxis);
+        wb.close();
     }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java Sun Jan 15 23:08:47 2017
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTru
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
 
 import org.apache.poi.poifs.crypt.CryptoFunctions;
 import org.apache.poi.poifs.crypt.HashAlgorithm;
@@ -35,48 +36,53 @@ import org.junit.Test;
 public class TestDocumentProtection {
 
     @Test
-    public void testShouldReadEnforcementProperties() throws Exception {
+    public void testShouldReadEnforcementProperties() throws IOException {
 
         XWPFDocument documentWithoutDocumentProtectionTag = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
         assertFalse(documentWithoutDocumentProtectionTag.isEnforcedReadonlyProtection());
         assertFalse(documentWithoutDocumentProtectionTag.isEnforcedFillingFormsProtection());
         assertFalse(documentWithoutDocumentProtectionTag.isEnforcedCommentsProtection());
         assertFalse(documentWithoutDocumentProtectionTag.isEnforcedTrackedChangesProtection());
+        documentWithoutDocumentProtectionTag.close();
 
         XWPFDocument documentWithoutEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection_tag_existing.docx");
         assertFalse(documentWithoutEnforcement.isEnforcedReadonlyProtection());
         assertFalse(documentWithoutEnforcement.isEnforcedFillingFormsProtection());
         assertFalse(documentWithoutEnforcement.isEnforcedCommentsProtection());
         assertFalse(documentWithoutEnforcement.isEnforcedTrackedChangesProtection());
+        documentWithoutEnforcement.close();
 
         XWPFDocument documentWithReadonlyEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_readonly_no_password.docx");
         assertTrue(documentWithReadonlyEnforcement.isEnforcedReadonlyProtection());
         assertFalse(documentWithReadonlyEnforcement.isEnforcedFillingFormsProtection());
         assertFalse(documentWithReadonlyEnforcement.isEnforcedCommentsProtection());
         assertFalse(documentWithReadonlyEnforcement.isEnforcedTrackedChangesProtection());
+        documentWithReadonlyEnforcement.close();
 
         XWPFDocument documentWithFillingFormsEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_forms_no_password.docx");
         assertTrue(documentWithFillingFormsEnforcement.isEnforcedFillingFormsProtection());
         assertFalse(documentWithFillingFormsEnforcement.isEnforcedReadonlyProtection());
         assertFalse(documentWithFillingFormsEnforcement.isEnforcedCommentsProtection());
         assertFalse(documentWithFillingFormsEnforcement.isEnforcedTrackedChangesProtection());
+        documentWithFillingFormsEnforcement.close();
 
         XWPFDocument documentWithCommentsEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_comments_no_password.docx");
         assertFalse(documentWithCommentsEnforcement.isEnforcedFillingFormsProtection());
         assertFalse(documentWithCommentsEnforcement.isEnforcedReadonlyProtection());
         assertTrue(documentWithCommentsEnforcement.isEnforcedCommentsProtection());
         assertFalse(documentWithCommentsEnforcement.isEnforcedTrackedChangesProtection());
+        documentWithCommentsEnforcement.close();
 
         XWPFDocument documentWithTrackedChangesEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_trackedChanges_no_password.docx");
         assertFalse(documentWithTrackedChangesEnforcement.isEnforcedFillingFormsProtection());
         assertFalse(documentWithTrackedChangesEnforcement.isEnforcedReadonlyProtection());
         assertFalse(documentWithTrackedChangesEnforcement.isEnforcedCommentsProtection());
         assertTrue(documentWithTrackedChangesEnforcement.isEnforcedTrackedChangesProtection());
-
+        documentWithTrackedChangesEnforcement.close();
     }
 
     @Test
-    public void testShouldEnforceForReadOnly() throws Exception {
+    public void testShouldEnforceForReadOnly() throws IOException {
         //		XWPFDocument document = createDocumentFromSampleFile("test-data/document/documentProtection_no_protection.docx");
         XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
         assertFalse(document.isEnforcedReadonlyProtection());
@@ -84,81 +90,89 @@ public class TestDocumentProtection {
         document.enforceReadonlyProtection();
 
         assertTrue(document.isEnforcedReadonlyProtection());
+        document.close();
     }
 
     @Test
-    public void testShouldEnforceForFillingForms() throws Exception {
+    public void testShouldEnforceForFillingForms() throws IOException {
         XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
         assertFalse(document.isEnforcedFillingFormsProtection());
 
         document.enforceFillingFormsProtection();
 
         assertTrue(document.isEnforcedFillingFormsProtection());
+        document.close();
     }
 
     @Test
-    public void testShouldEnforceForComments() throws Exception {
+    public void testShouldEnforceForComments() throws IOException {
         XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
         assertFalse(document.isEnforcedCommentsProtection());
 
         document.enforceCommentsProtection();
 
         assertTrue(document.isEnforcedCommentsProtection());
+        document.close();
     }
 
     @Test
-    public void testShouldEnforceForTrackedChanges() throws Exception {
+    public void testShouldEnforceForTrackedChanges() throws IOException {
         XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
         assertFalse(document.isEnforcedTrackedChangesProtection());
 
         document.enforceTrackedChangesProtection();
 
         assertTrue(document.isEnforcedTrackedChangesProtection());
+        document.close();
     }
 
     @Test
-    public void testShouldUnsetEnforcement() throws Exception {
+    public void testShouldUnsetEnforcement() throws IOException {
         XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_readonly_no_password.docx");
         assertTrue(document.isEnforcedReadonlyProtection());
 
         document.removeProtectionEnforcement();
 
         assertFalse(document.isEnforcedReadonlyProtection());
+        document.close();
     }
 
     @Test
-    public void testIntegration() throws Exception {
-        XWPFDocument doc = new XWPFDocument();
+    public void testIntegration() throws IOException {
+        XWPFDocument doc1 = new XWPFDocument();
 
-        XWPFParagraph p1 = doc.createParagraph();
+        XWPFParagraph p1 = doc1.createParagraph();
 
         XWPFRun r1 = p1.createRun();
         r1.setText("Lorem ipsum dolor sit amet.");
-        doc.enforceCommentsProtection();
+        doc1.enforceCommentsProtection();
 
         File tempFile = TempFile.createTempFile("documentProtectionFile", ".docx");
         FileOutputStream out = new FileOutputStream(tempFile);
 
-        doc.write(out);
+        doc1.write(out);
         out.close();
 
         FileInputStream inputStream = new FileInputStream(tempFile);
-        XWPFDocument document = new XWPFDocument(inputStream);
+        XWPFDocument doc2 = new XWPFDocument(inputStream);
         inputStream.close();
 
-        assertTrue(document.isEnforcedCommentsProtection());
+        assertTrue(doc2.isEnforcedCommentsProtection());
+        doc2.close();
+        doc1.close();
     }
 
     @Test
-    public void testUpdateFields() throws Exception {
+    public void testUpdateFields() throws IOException {
         XWPFDocument doc = new XWPFDocument();
         assertFalse(doc.isEnforcedUpdateFields());
         doc.enforceUpdateFields();
         assertTrue(doc.isEnforcedUpdateFields());
+        doc.close();
     }
 
     @Test
-    public void bug56076_read() throws Exception {
+    public void bug56076_read() throws IOException {
         // test legacy xored-hashed password
         assertEquals("64CEED7E", CryptoFunctions.xorHashPassword("Example"));
         // check leading 0
@@ -168,15 +182,18 @@ public class TestDocumentProtection {
         XWPFDocument document = XWPFTestDataSamples.openSampleDocument("bug56076.docx");
         boolean isValid = document.validateProtectionPassword("Example");
         assertTrue(isValid);
+        document.close();
     }
 
     @Test
-    public void bug56076_write() throws Exception {
+    public void bug56076_write() throws IOException {
         // test document write protection with password
-        XWPFDocument document = new XWPFDocument();
-        document.enforceCommentsProtection("Example", HashAlgorithm.sha512);
-        document = XWPFTestDataSamples.writeOutAndReadBack(document);
-        boolean isValid = document.validateProtectionPassword("Example");
+        XWPFDocument doc1 = new XWPFDocument();
+        doc1.enforceCommentsProtection("Example", HashAlgorithm.sha512);
+        XWPFDocument doc2 = XWPFTestDataSamples.writeOutAndReadBack(doc1);
+        doc1.close();
+        boolean isValid = doc2.validateProtectionPassword("Example");
         assertTrue(isValid);
+        doc2.close();
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java Sun Jan 15 23:08:47 2017
@@ -54,7 +54,6 @@ import org.apache.poi.util.POILogger;
 public final class PowerPointExtractor extends POIOLE2TextExtractor {
    private static final POILogger LOG = POILogFactory.getLogger(PowerPointExtractor.class);
     
-   private final HSLFSlideShowImpl _hslfshow;
    private final HSLFSlideShow _show;
    private final List<HSLFSlide> _slides;
 
@@ -147,8 +146,7 @@ public final class PowerPointExtractor e
 	 */
 	public PowerPointExtractor(HSLFSlideShowImpl ss) {
 		super(ss);
-		_hslfshow = ss;
-		_show = new HSLFSlideShow(_hslfshow);
+		_show = new HSLFSlideShow(ss);
 		_slides = _show.getSlides();
 	}
 
@@ -184,7 +182,8 @@ public final class PowerPointExtractor e
 	 * Fetches all the slide text from the slideshow, but not the notes, unless
 	 * you've called setSlidesByDefault() and setNotesByDefault() to change this
 	 */
-	public String getText() {
+	@Override
+    public String getText() {
 		return getText(_slidesByDefault, _notesByDefault, _commentsByDefault, _masterByDefault);
 	}
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java Sun Jan 15 23:08:47 2017
@@ -17,12 +17,13 @@
 
 package org.apache.poi.hdgf.streams;
 
-import org.apache.poi.hdgf.pointers.Pointer;
-import static org.apache.poi.hdgf.pointers.PointerV6.*;
+import static org.apache.poi.hdgf.pointers.PointerV6.getNumPointersOffsetV6;
+import static org.apache.poi.hdgf.pointers.PointerV6.getNumPointersV6;
+import static org.apache.poi.hdgf.pointers.PointerV6.getPostNumPointersSkipV6;
 
-import junit.framework.TestCase;
+import org.apache.poi.hdgf.pointers.Pointer;
 
-public abstract class StreamTest extends TestCase {
+public abstract class StreamTest {
     public static class TestPointer extends Pointer {
         private final boolean compressed;
         protected boolean hasPointers = false;

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java Sun Jan 15 23:08:47 2017
@@ -17,73 +17,45 @@
 
 package org.apache.poi.hdgf.streams;
 
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
 import org.apache.poi.hdgf.pointers.Pointer;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 public final class TestStreamBasics extends StreamTest {
-	/** The header from when compressedStream is decompressed */
-	public static final byte[] compressedStreamDCHeader = new byte[] {
-		-60, 2, 0, 0
-	};
-	public static final byte[] compressedStream = new byte[] {
-		123, -60, 2, -21, -16, 1, 0, 0, -72, -13, -16, 78, -32, -5, 1,
-		0, 3, -21, -16, 10, 5, 4, -21, -16, 21, 9, -21, -16, 103, -21,
-		-16, 34, -36, -1, 52, 15, 70, 15, 120, 88, 15, -7, -2, -28, -9,
-		-123, 21, 0, 44, -122, 1, -4, 104, 15, -24, -13, 40, -98, 32,
-		78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
-		-85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
-		-34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
-		-12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
-		-21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
-		-43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
-		-9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
-		-16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
-		17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
-		-21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
-		0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
-		125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
-		-21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
-		17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
-		85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
-		-16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
-		1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
-		85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
-		85, 1, 102, -119, 72, 37, 0, 97, 33 };
-	public static final byte[] uncompressedStream = new byte[] {
-		0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
-		0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		-123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
-		-2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
-		123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
-		64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
-		0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
-		1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
-		-44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
-		0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
-		0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
-		-106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
-		50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
-		36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100,
-		-4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4,
-		79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79,
-		1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85,
-		1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-		0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119,
-		0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127,
-		0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120,
-		0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119,
-		0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
-	};
+	private static byte[] compressedStream, uncompressedStream;
+
+	@BeforeClass
+	public static void init() throws IOException {
+        compressedStream = decompress(
+            "H4sIAAAAAAAAAAFTAaz+e8QC6/ABAAC48/BO4PsBAAPr8AoFBOvwFQnr8Gfr8CLc/zQPRg94WA/5/u"+
+            "T3hRUALIYB/GgP6PMoniBOZr3//uJAKL2Pt3SeqwJCewltqwKnDsi7rbHe/XhuS/f2FPrn9Bbr8PSv"+
+            "QwGAuuvwVOvwRgAX6/BML9hPAdTr8CADEgwR1bwREPgVFv/r8Kz/3U/39mAALuvwLNnXTwF38/CW8/"+
+            "BUAH0a6/BE2k8BEQoAnzIKAADWlA92HwD9HevwnOdPAe5h3EwQ6/BWACT7AftPPwGEYgAAHAMU3v19"+
+            "IevwZPxPAaSlEOoYEynr8NTFEGxkAOsAR5cSJ1UR/U8BX5RxAABoAxIxMRH/QFUBAHIAAKPc6/BkHw"+
+            "AA2OvwpEJ/VQFidwAA0E8S/TLvAUNVAVGBANcADgYEET/BEURVvwEeiAAAKk8SRH7r8LRFVQFmiUgl"+
+            "AGEhwtTYaVMBAAA="
+        );
+	        
+        uncompressedStream = decompress(
+            "H4sIAAAAAAAAAGNgZGDYAcSogJGBGUjCMAsQcwJxOhAroSulEkB2Qqsogw4I41KrMU/BL23vv0cOGn"+
+            "v7t5eAGU7VnLlgBobUibUb0fVX5HnDrROB0mJA/GW9M2MDkA4BYjcGcSDpc8Of8QqQVgCLgkT2AEV+"+
+            "wEX+A8k1//3hpiUw6AFJnZv+jOVAsWmMIDVSQBGXW/6MgsCgNOJiYLhGVHjIAvGc5/6M7xKB5gDZYQ"+
+            "wqIBf+9mdsSWJgkIG6Eh0oAnHKH3/GJUkwF2oCyStAkZwUBgZ3sDnqIPf89WecUsjAkAFWYwjyhUMo"+
+            "I0MRA8NiBuwuvAHES5xCGZPKGRgugP1lBAo951DGwEYGBj42kIg9yHaXUEa5DgYGLbAaF6DIFtdQxr"+
+            "ROmAgIAAD6SJPAdAIAAA=="
+        );
+	}
+	        
 
+	@Test
 	public void testCompressedStream() {
 		// Create a fake pointer
 		Pointer ptr = new TestPointer(true, 0, compressedStream.length, -1, (short)-1);
@@ -93,7 +65,6 @@ public final class TestStreamBasics exte
 		// Check
 		assertNotNull(stream.getPointer());
 		assertNotNull(stream.getStore());
-		assertTrue(stream.getStore() instanceof StreamStore);
 		assertTrue(stream.getStore() instanceof CompressedStreamStore);
 		assertTrue(stream instanceof UnknownStream);
 
@@ -108,7 +79,8 @@ public final class TestStreamBasics exte
 		}
 	}
 
-	public void testUncompressedStream() {
+	@Test
+    public void testUncompressedStream() {
 		// Create a fake pointer
 		Pointer ptr = new TestPointer(false, 0, uncompressedStream.length, -1, (short)-1);
 		// Now the stream
@@ -117,7 +89,6 @@ public final class TestStreamBasics exte
 		// Check
 		assertNotNull(stream.getPointer());
 		assertNotNull(stream.getStore());
-		assertTrue(stream.getStore() instanceof StreamStore);
 		assertFalse(stream.getStore() instanceof CompressedStreamStore);
 		assertTrue(stream instanceof UnknownStream);
 	}

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java Sun Jan 15 23:08:47 2017
@@ -17,15 +17,18 @@
 
 package org.apache.poi.hdgf.streams;
 
+import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hdgf.HDGFDiagram;
 import org.apache.poi.hdgf.chunks.ChunkFactory;
 import org.apache.poi.hdgf.pointers.Pointer;
 import org.apache.poi.hdgf.pointers.PointerFactory;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.POIDataSamples;
+import org.apache.poi.util.IOUtils;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Tests for bugs with streams
@@ -36,33 +39,35 @@ public final class TestStreamBugs extend
 	private PointerFactory ptrFactory;
 	private POIFSFileSystem filesystem;
 
-	@Override
-    protected void setUp() throws Exception {
+	@Before
+    public void setUp() throws IOException {
 		ptrFactory = new PointerFactory(11);
 		chunkFactory = new ChunkFactory(11);
 
         InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("44594.vsd");
         filesystem = new POIFSFileSystem(is);
-
-		DocumentEntry docProps =
-			(DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
+        is.close();
 
 		// Grab the document stream
-		contents = new byte[docProps.getSize()];
-		filesystem.createDocumentInputStream("VisioDocument").read(contents);
+		InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
+		contents = IOUtils.toByteArray(is2);
+		is2.close();
 	}
 
-	public void testGetTrailer() {
+	@Test
+    public void testGetTrailer() {
 		Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
 		Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
 	}
 
-	public void TOIMPLEMENTtestGetCertainChunks() {
+	@SuppressWarnings("unused")
+    public void TOIMPLEMENTtestGetCertainChunks() {
 		int offsetA = 3708;
 		int offsetB = 3744;
 	}
 
-	public void testGetChildren() {
+	@Test
+    public void testGetChildren() {
 		Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
 		TrailerStream trailer = (TrailerStream)
 			Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
@@ -97,7 +102,8 @@ public final class TestStreamBugs extend
 		trailer.findChildren(contents);
 	}
 
-	public void testOpen() throws Exception {
-		HDGFDiagram dg = new HDGFDiagram(filesystem);
+	@Test
+    public void testOpen() throws IOException {
+		new HDGFDiagram(filesystem).close();
 	}
 }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java Sun Jan 15 23:08:47 2017
@@ -17,15 +17,24 @@
 
 package org.apache.poi.hdgf.streams;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hdgf.chunks.Chunk;
 import org.apache.poi.hdgf.chunks.ChunkFactory;
 import org.apache.poi.hdgf.pointers.Pointer;
 import org.apache.poi.hdgf.pointers.PointerFactory;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.POIDataSamples;
+import org.apache.poi.util.IOUtils;
+import org.junit.Before;
+import org.junit.Test;
 
 public final class TestStreamComplex extends StreamTest {
 	private byte[] contents;
@@ -34,26 +43,28 @@ public final class TestStreamComplex ext
 	private ChunkFactory chunkFactory;
 	private PointerFactory ptrFactory;
 
-	@Override
-    protected void setUp() throws Exception {
+	@Before
+    public void setUp() throws IOException {
 		ptrFactory = new PointerFactory(11);
 		chunkFactory = new ChunkFactory(11);
 
         InputStream is = POIDataSamples.getDiagramInstance().openResourceAsStream("Test_Visio-Some_Random_Text.vsd");
 		POIFSFileSystem filesystem = new POIFSFileSystem(is);
-
-		DocumentEntry docProps =
-			(DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
+		is.close();
 
 		// Grab the document stream
-		contents = new byte[docProps.getSize()];
-		filesystem.createDocumentInputStream("VisioDocument").read(contents);
+		InputStream is2 = filesystem.createDocumentInputStream("VisioDocument");
+		contents = IOUtils.toByteArray(is2);
+		is2.close();
+		
+		filesystem.close();
 	}
 
 	/**
 	 * Test creating the trailer, but not looking for children
 	 */
-	public void testTrailer() {
+	@Test
+    public void testTrailer() {
 		// Find the trailer
 		Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
 
@@ -74,7 +85,8 @@ public final class TestStreamComplex ext
 		assertEquals(0xff, ts.getChildPointers()[3].getType());
 	}
 
-	public void testChunks() {
+	@Test
+    public void testChunks() {
 		Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
 		TrailerStream ts = (TrailerStream)
 			Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
@@ -94,7 +106,8 @@ public final class TestStreamComplex ext
 		cs.findChunks();
 	}
 
-	public void testStrings() {
+	@Test
+    public void testStrings() {
 		Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
 		TrailerStream ts = (TrailerStream)
 			Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
@@ -110,7 +123,8 @@ public final class TestStreamComplex ext
 		assertTrue(stream instanceof StringsStream);
 	}
 
-	public void testPointerToStrings() {
+	@Test
+    public void testPointerToStrings() {
 		// The stream at 0x347f has strings
 		// The stream at 0x4312 has a pointer to 0x347f
 		// The stream at 0x44d3 has a pointer to 0x4312
@@ -154,7 +168,8 @@ public final class TestStreamComplex ext
 		assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
 	}
 
-	public void testTrailerContents() {
+	@Test
+    public void testTrailerContents() {
 		Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
 		TrailerStream ts = (TrailerStream)
 			Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
@@ -205,7 +220,8 @@ public final class TestStreamComplex ext
 		assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
 	}
 
-	public void testChunkWithText() {
+	@Test
+    public void testChunkWithText() {
 		// Parent ChunkStream is at 0x7194
 		// This is one of the last children of the trailer
 		Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hpbf/model/TestEscherParts.java Sun Jan 15 23:08:47 2017
@@ -17,18 +17,24 @@
 
 package org.apache.poi.hpbf.model;
 
-import org.apache.poi.hpbf.HPBFDocument;
-import org.apache.poi.POIDataSamples;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
-import junit.framework.TestCase;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.hpbf.HPBFDocument;
+import org.junit.Test;
 
-public final class TestEscherParts extends TestCase {
+public final class TestEscherParts {
     private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();
 
-	public void testBasics() throws Exception {
-		HPBFDocument doc = new HPBFDocument(
-		    _samples.openResourceAsStream("Sample.pub")
-		);
+    @Test
+	public void testBasics() throws IOException {
+        InputStream is = _samples.openResourceAsStream("Sample.pub");
+		HPBFDocument doc = new HPBFDocument(is);
+		is.close();
 
 		EscherStm es = doc.getEscherStm();
 		EscherDelayStm eds = doc.getEscherDelayStm();
@@ -40,15 +46,17 @@ public final class TestEscherParts exten
 		assertEquals(0, eds.getEscherRecords().length);
 
 		// TODO - check the contents
+		doc.close();
 	}
 
-	public void testComplex() throws Exception {
-		HPBFDocument doc = new HPBFDocument(
-                _samples.openResourceAsStream("SampleBrochure.pub")
-		);
+    @Test
+    public void testComplex() throws Exception {
+        InputStream is = _samples.openResourceAsStream("SampleBrochure.pub"); 
+		HPBFDocument doc1 = new HPBFDocument(is);
+		is.close();
 
-		EscherStm es = doc.getEscherStm();
-		EscherDelayStm eds = doc.getEscherDelayStm();
+		EscherStm es = doc1.getEscherStm();
+		EscherDelayStm eds = doc1.getEscherDelayStm();
 
 		assertNotNull(es);
 		assertNotNull(eds);
@@ -57,20 +65,21 @@ public final class TestEscherParts exten
 		assertEquals(19, eds.getEscherRecords().length);
 
 		// TODO - check contents
-
+		doc1.close();
 
 		// Now do another complex file
-		doc = new HPBFDocument(
-                _samples.openResourceAsStream("SampleNewsletter.pub")
-		);
+		InputStream is2 = _samples.openResourceAsStream("SampleNewsletter.pub"); 
+        HPBFDocument doc2 = new HPBFDocument(is2);
+		is2.close();
 
-		es = doc.getEscherStm();
-		eds = doc.getEscherDelayStm();
+		es = doc2.getEscherStm();
+		eds = doc2.getEscherDelayStm();
 
 		assertNotNull(es);
 		assertNotNull(eds);
 
 		assertEquals(51, es.getEscherRecords().length);
 		assertEquals(92, eds.getEscherRecords().length);
+		doc2.close();
 	}
 }



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


Mime
View raw message