Author: kiwiwings
Date: Mon Mar 21 00:14:21 2016
New Revision: 1735912

URL: http://svn.apache.org/viewvc?rev=1735912&view=rev
Log:
fix eclipse warnings
close resources

Modified:
    poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java
    
poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
    poi/trunk/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java
    
poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
    poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
    poi/trunk/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java
    
poi/trunk/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java
    
poi/trunk/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
    
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
    
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java
    poi/trunk/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java
    poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFExternalFunctions.java
    
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
    poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherDump.java
    poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
    poi/trunk/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java
    poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
    poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
    
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFExternalFunctions.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestSheetHiding.java
    
poi/trunk/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetHiding.java

Modified: 
poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java 
(original)
+++ poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java 
Mon Mar 21 00:14:21 2016
@@ -28,7 +28,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.poi.hpsf.HPSFRuntimeException;
@@ -109,20 +108,15 @@ public class CopyCompare
         String copyFileName = null;
 
         /* Check the command-line arguments. */
-        if (args.length == 1)
-        {
+        if (args.length == 1) {
             originalFileName = args[0];
             File f = TempFile.createTempFile("CopyOfPOIFileSystem-", ".ole2");
             f.deleteOnExit();
             copyFileName = f.getAbsolutePath();
-        }
-        else if (args.length == 2)
-        {
+        } else if (args.length == 2) {
             originalFileName = args[0];
             copyFileName = args[1];
-        }
-        else
-        {
+        } else {
             System.err.println("Usage: " + CopyCompare.class.getName() +
                                "originPOIFS [copyPOIFS]");
             System.exit(1);
@@ -133,25 +127,28 @@ public class CopyCompare
         final POIFSReader r = new POIFSReader();
         final CopyFile cf = new CopyFile(copyFileName);
         r.registerListener(cf);
-        r.read(new FileInputStream(originalFileName));
+        FileInputStream fis = new FileInputStream(originalFileName);
+        r.read(fis);
+        fis.close();
         
         /* Write the new POIFS to disk. */
         cf.close();
 
         /* Read all documents from the original POI file system and compare 
them
          * with the equivalent document from the copy. */
-        final POIFSFileSystem opfs =
-            new POIFSFileSystem(new FileInputStream(originalFileName));
-        final POIFSFileSystem cpfs =
-            new POIFSFileSystem(new FileInputStream(copyFileName));
+        final POIFSFileSystem opfs = new POIFSFileSystem(new 
File(originalFileName));
+        final POIFSFileSystem cpfs = new POIFSFileSystem(new 
File(copyFileName));
 
         final DirectoryEntry oRoot = opfs.getRoot();
         final DirectoryEntry cRoot = cpfs.getRoot();
         final StringBuffer messages = new StringBuffer();
-        if (equal(oRoot, cRoot, messages))
+        if (equal(oRoot, cRoot, messages)) {
             System.out.println("Equal");
-        else
+        } else {
             System.out.println("Not equal: " + messages.toString());
+        }
+        cpfs.close();
+        opfs.close();
     }
 
 
@@ -183,29 +180,23 @@ public class CopyCompare
     {
         boolean equal = true;
         /* Iterate over d1 and compare each entry with its counterpart in d2. 
*/
-        for (final Iterator i = d1.getEntries(); equal && i.hasNext();)
-        {
-            final Entry e1 = (Entry) i.next();
+        for (final Entry e1 : d1) {
             final String n1 = e1.getName();
             Entry e2 = null;
-            try
-            {
+            try {
                 e2 = d2.getEntry(n1);
-            }
-            catch (FileNotFoundException ex)
-            {
+            } catch (FileNotFoundException ex) {
                 msg.append("Document \"" + e1 + "\" exists, document \"" +
                            e2 + "\" does not.\n");
                 equal = false;
                 break;
             }
 
-            if (e1.isDirectoryEntry() && e2.isDirectoryEntry())
+            if (e1.isDirectoryEntry() && e2.isDirectoryEntry()) {
                 equal = equal((DirectoryEntry) e1, (DirectoryEntry) e2, msg);
-            else if (e1.isDocumentEntry() && e2.isDocumentEntry())
+            } else if (e1.isDocumentEntry() && e2.isDocumentEntry()) {
                 equal = equal((DocumentEntry) e1, (DocumentEntry) e2, msg);
-            else
-            {
+            } else {
                 msg.append("One of \"" + e1 + "\" and \"" + e2 + "\" is a " +
                            "document while the other one is a directory.\n");
                 equal = false;
@@ -214,17 +205,12 @@ public class CopyCompare
 
         /* Iterate over d2 just to make sure that there are no entries in d2
          * that are not in d1. */
-        for (final Iterator i = d2.getEntries(); equal && i.hasNext();)
-        {
-            final Entry e2 = (Entry) i.next();
+        for (final Entry e2 : d2) {
             final String n2 = e2.getName();
             Entry e1 = null;
-            try
-            {
+            try {
                 e1 = d1.getEntry(n2);
-            }
-            catch (FileNotFoundException ex)
-            {
+            } catch (FileNotFoundException ex) {
                 msg.append("Document \"" + e2 + "\" exitsts, document \"" +
                            e1 + "\" does not.\n");
                 equal = false;
@@ -263,34 +249,32 @@ public class CopyCompare
         boolean equal = true;
         final DocumentInputStream dis1 = new DocumentInputStream(d1);
         final DocumentInputStream dis2 = new DocumentInputStream(d2);
-        if (PropertySet.isPropertySetStream(dis1) &&
-            PropertySet.isPropertySetStream(dis2))
-        {
-            final PropertySet ps1 = PropertySetFactory.create(dis1);
-            final PropertySet ps2 = PropertySetFactory.create(dis2);
-            equal = ps1.equals(ps2);
-            if (!equal)
-            {
-                msg.append("Property sets are not equal.\n");
-                return equal;
-            }
-        }
-        else
-        {
-            int i1;
-            int i2;
-            do
-            {
-                i1 = dis1.read();
-                i2 = dis2.read();
-                if (i1 != i2)
-                {
-                    equal = false;
-                    msg.append("Documents are not equal.\n");
-                    break;
+        try {
+            if (PropertySet.isPropertySetStream(dis1) &&
+                PropertySet.isPropertySetStream(dis2)) {
+                final PropertySet ps1 = PropertySetFactory.create(dis1);
+                final PropertySet ps2 = PropertySetFactory.create(dis2);
+                equal = ps1.equals(ps2);
+                if (!equal) {
+                    msg.append("Property sets are not equal.\n");
+                    return equal;
                 }
+            } else {
+                int i1;
+                int i2;
+                do {
+                    i1 = dis1.read();
+                    i2 = dis2.read();
+                    if (i1 != i2) {
+                        equal = false;
+                        msg.append("Documents are not equal.\n");
+                        break;
+                    }
+                } while (equal && i1 == -1);
             }
-            while (equal && i1 == -1);
+        } finally {
+            dis2.close();
+            dis1.close();
         }
         return true;
     }
@@ -306,8 +290,7 @@ public class CopyCompare
      * original property set by using the {@link
      * MutablePropertySet#MutablePropertySet(PropertySet)} constructor.</p>
      */
-    static class CopyFile implements POIFSReaderListener
-    {
+    static class CopyFile implements POIFSReaderListener {
         String dstName;
         OutputStream out;
         POIFSFileSystem poiFs;
@@ -321,8 +304,7 @@ public class CopyCompare
          * @param dstName The name of the disk file the destination POIFS is to
          * be written to.
          */
-        public CopyFile(final String dstName)
-        {
+        public CopyFile(final String dstName) {
             this.dstName = dstName;
             poiFs = new POIFSFileSystem();
         }
@@ -332,8 +314,7 @@ public class CopyCompare
          * <p>The method is called by POI's eventing API for each file in the
          * origin POIFS.</p>
          */
-        public void processPOIFSReaderEvent(final POIFSReaderEvent event)
-        {
+        public void processPOIFSReaderEvent(final POIFSReaderEvent event) {
             /* The following declarations are shortcuts for accessing the
              * "event" object. */
             final POIFSDocumentPath path = event.getPath();
@@ -342,21 +323,16 @@ public class CopyCompare
 
             Throwable t = null;
 
-            try
-            {
+            try {
                 /* Find out whether the current document is a property set
                  * stream or not. */
-                if (PropertySet.isPropertySetStream(stream))
-                {
+                if (PropertySet.isPropertySetStream(stream)) {
                     /* Yes, the current document is a property set stream.
                      * Let's create a PropertySet instance from it. */
                     PropertySet ps = null;
-                    try
-                    {
+                    try {
                         ps = PropertySetFactory.create(stream);
-                    }
-                    catch (NoPropertySetStreamException ex)
-                    {
+                    } catch (NoPropertySetStreamException ex) {
                         /* This exception will not be thrown because we already
                          * checked above. */
                     }
@@ -364,22 +340,16 @@ public class CopyCompare
                     /* Copy the property set to the destination POI file
                      * system. */
                     copy(poiFs, path, name, ps);
-                }
-                else
+                } else {
                     /* No, the current document is not a property set stream. 
We
                      * copy it unmodified to the destination POIFS. */
                     copy(poiFs, event.getPath(), event.getName(), stream);
-            }
-            catch (MarkUnsupportedException ex)
-            {
+                }
+            } catch (MarkUnsupportedException ex) {
                 t = ex;
-            }
-            catch (IOException ex)
-            {
+            } catch (IOException ex) {
                 t = ex;
-            }
-            catch (WritingNotSupportedException ex)
-            {
+            } catch (WritingNotSupportedException ex) {
                 t = ex;
             }
 
@@ -388,8 +358,7 @@ public class CopyCompare
              * lines check whether a checked exception occured and throws an
              * unchecked exception. The message of that exception is that of
              * the underlying checked exception. */
-            if (t != null)
-            {
+            if (t != null) {
                 throw new HPSFRuntimeException
                     ("Could not read file \"" + path + "/" + name +
                      "\". Reason: " + Util.toString(t));
@@ -412,8 +381,7 @@ public class CopyCompare
                          final POIFSDocumentPath path,
                          final String name,
                          final PropertySet ps)
-            throws WritingNotSupportedException, IOException
-        {
+        throws WritingNotSupportedException, IOException {
             final DirectoryEntry de = getPath(poiFs, path);
             final MutablePropertySet mps = new MutablePropertySet(ps);
             de.createDocument(name, mps.toInputStream());
@@ -434,13 +402,14 @@ public class CopyCompare
         public void copy(final POIFSFileSystem poiFs,
                          final POIFSDocumentPath path,
                          final String name,
-                         final DocumentInputStream stream) throws IOException
-        {
+                         final DocumentInputStream stream)
+        throws IOException {
             final DirectoryEntry de = getPath(poiFs, path);
             final ByteArrayOutputStream out = new ByteArrayOutputStream();
             int c;
-            while ((c = stream.read()) != -1)
+            while ((c = stream.read()) != -1) {
                 out.write(c);
+            }
             stream.close();
             out.close();
             final InputStream in =
@@ -455,8 +424,7 @@ public class CopyCompare
          * @throws FileNotFoundException
          * @throws IOException
          */
-        public void close() throws FileNotFoundException, IOException
-        {
+        public void close() throws FileNotFoundException, IOException {
             out = new FileOutputStream(dstName);
             poiFs.writeFilesystem(out);
             out.close();
@@ -467,7 +435,7 @@ public class CopyCompare
         /** Contains the directory paths that have already been created in the
          * output POI filesystem and maps them to their corresponding
          * {@link org.apache.poi.poifs.filesystem.DirectoryNode}s. */
-        private final Map paths = new HashMap();
+        private final Map<String,DirectoryEntry> paths = new 
HashMap<String,DirectoryEntry>();
 
 
 
@@ -495,13 +463,11 @@ public class CopyCompare
          * should use this {@link DirectoryEntry} to create documents in it.
          */
         public DirectoryEntry getPath(final POIFSFileSystem poiFs,
-                                      final POIFSDocumentPath path)
-        {
-            try
-            {
+                                      final POIFSDocumentPath path) {
+            try {
                 /* Check whether this directory has already been created. */
                 final String s = path.toString();
-                DirectoryEntry de = (DirectoryEntry) paths.get(s);
+                DirectoryEntry de = paths.get(s);
                 if (de != null)
                     /* Yes: return the corresponding DirectoryEntry. */
                     return de;
@@ -509,12 +475,11 @@ public class CopyCompare
                 /* No: We have to create the directory - or return the root's
                  * DirectoryEntry. */
                 int l = path.length();
-                if (l == 0)
+                if (l == 0) {
                     /* Get the root directory. It does not have to be created
                      * since it always exists in a POIFS. */
                     de = poiFs.getRoot();
-                else
-                {
+                } else {
                     /* Create a subordinate directory. The first step is to
                      * ensure that the parent directory exists: */
                     de = getPath(poiFs, path.getParent());
@@ -524,9 +489,7 @@ public class CopyCompare
                 }
                 paths.put(s, de);
                 return de;
-            }
-            catch (IOException ex)
-            {
+            } catch (IOException ex) {
                 /* This exception will be thrown if the directory already
                  * exists. However, since we have full control about directory
                  * creation we can ensure that this will never happen. */

Modified: 
poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java
 (original)
+++ 
poi/trunk/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java
 Mon Mar 21 00:14:21 2016
@@ -114,7 +114,9 @@ public class WriteAuthorAndTitle
         final POIFSReader r = new POIFSReader();
         final ModifySICopyTheRest msrl = new ModifySICopyTheRest(dstName);
         r.registerListener(msrl);
-        r.read(new FileInputStream(srcName));
+        FileInputStream fis = new FileInputStream(srcName);
+        r.read(fis);
+        fis.close();
         
         /* Write the new POIFS to disk. */
         msrl.close();

Modified: 
poi/trunk/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java 
(original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java Mon 
Mar 21 00:14:21 2016
@@ -201,6 +201,8 @@ public class BusinessPlan {
         FileOutputStream out = new FileOutputStream(file);
         wb.write(out);
         out.close();
+        
+        wb.close();
     }
 
     /**

Modified: 
poi/trunk/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java 
(original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java 
Mon Mar 21 00:14:21 2016
@@ -80,6 +80,8 @@ public class CellStyleDetails {
            
            System.out.println();
         }
+        
+        wb.close();
     }
     
     private static String renderColor(Color color) {

Modified: 
poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
 (original)
+++ 
poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java
 Mon Mar 21 00:14:21 2016
@@ -91,6 +91,8 @@ public class BigGridDemo {
         FileOutputStream out = new FileOutputStream("big-grid.xlsx");
         substitute(new File("template.xlsx"), tmp, sheetRef.substring(1), out);
         out.close();
+        
+        wb.close();
     }
 
     /**

Modified: 
poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java 
(original)
+++ 
poi/trunk/src/integrationtest/org/apache/poi/stress/AbstractFileHandler.java 
Mon Mar 21 00:14:21 2016
@@ -89,6 +89,7 @@ public abstract class AbstractFileHandle
             assertNotNull(extractor.getText());
             
             // also try metadata
+            @SuppressWarnings("resource")
             POITextExtractor metadataExtractor = 
extractor.getMetadataTextExtractor();
             assertNotNull(metadataExtractor.getText());
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/dev/BiffDrawingToXml.java Mon Mar 21 
00:14:21 2016
@@ -32,7 +32,6 @@ import org.apache.poi.hssf.model.Interna
 import org.apache.poi.hssf.record.DrawingGroupRecord;
 import org.apache.poi.hssf.usermodel.HSSFPatriarch;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.util.StringUtil;
 
 /**
@@ -133,16 +132,15 @@ public class BiffDrawingToXml {
     }
 
     public static void writeToFile(OutputStream fos, InputStream xlsWorkbook, 
boolean excludeWorkbookRecords, String[] params) throws IOException {
-        NPOIFSFileSystem fs = new NPOIFSFileSystem(xlsWorkbook);
-        HSSFWorkbook workbook = new HSSFWorkbook(fs);
+        HSSFWorkbook workbook = new HSSFWorkbook(xlsWorkbook);
         InternalWorkbook internalWorkbook = workbook.getInternalWorkbook();
         DrawingGroupRecord r = (DrawingGroupRecord) 
internalWorkbook.findFirstRecordBySid(DrawingGroupRecord.sid);
-        r.decode();
 
         StringBuilder builder = new StringBuilder();
         builder.append("<workbook>\n");
         String tab = "\t";
-        if (!excludeWorkbookRecords) {
+        if (!excludeWorkbookRecords && r != null) {
+            r.decode();
             List<EscherRecord> escherRecords = r.getEscherRecords();
             for (EscherRecord record : escherRecords) {
                 builder.append(record.toXml(tab));
@@ -160,6 +158,7 @@ public class BiffDrawingToXml {
         builder.append("</workbook>\n");
         fos.write(builder.toString().getBytes(StringUtil.UTF8));
         fos.close();
+        workbook.close();
     }
 
 }

Modified: 
poi/trunk/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java 
(original)
+++ 
poi/trunk/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4Decryptor.java 
Mon Mar 21 00:14:21 2016
@@ -116,6 +116,7 @@ public class BinaryRC4Decryptor extends
         return skey;
     }
 
+    @SuppressWarnings("resource")
     public InputStream getDataStream(DirectoryNode dir) throws IOException,
             GeneralSecurityException {
         DocumentInputStream dis = 
dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);

Modified: 
poi/trunk/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java 
(original)
+++ 
poi/trunk/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java 
Mon Mar 21 00:14:21 2016
@@ -57,13 +57,13 @@ public class CryptoAPIDecryptor extends
         Cipher cipher;
         byte oneByte[] = { 0 };
         
-        public void seek(int pos) {
-            if (pos > count) {
-                throw new ArrayIndexOutOfBoundsException(pos);
+        public void seek(int newpos) {
+            if (newpos > count) {
+                throw new ArrayIndexOutOfBoundsException(newpos);
             }
             
-            this.pos = pos;
-            mark = pos;
+            this.pos = newpos;
+            mark = newpos;
         }
 
         public void setBlock(int block) throws GeneralSecurityException {
@@ -233,9 +233,11 @@ public class CryptoAPIDecryptor extends
             sbis.setBlock(entry.block);
             InputStream is = new BoundedInputStream(sbis, entry.streamSize);
             fsOut.createDocument(is, entry.streamName);
+            is.close();
         }
 
         leis.close();
+        sbis.close();
         sbis = null;
         bos.reset();
         fsOut.writeFilesystem(bos);

Modified: 
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java 
(original)
+++ 
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java 
Mon Mar 21 00:14:21 2016
@@ -122,6 +122,7 @@ public class StandardDecryptor extends D
         return CryptoFunctions.getCipher(key, em.getCipherAlgorithm(), cm, 
null, Cipher.DECRYPT_MODE);
     }
 
+    @SuppressWarnings("resource")
     public InputStream getDataStream(DirectoryNode dir) throws IOException {
         DocumentInputStream dis = 
dir.createDocumentInputStream(DEFAULT_POIFS_ENTRY);
 

Modified: 
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java 
(original)
+++ 
poi/trunk/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptor.java 
Mon Mar 21 00:14:21 2016
@@ -123,14 +123,9 @@ public class StandardEncryptor extends E
         protected long countBytes;
         protected final File fileOut;
         protected final DirectoryNode dir;
-        
-        protected StandardCipherOutputStream(DirectoryNode dir) throws 
IOException {
-            super(null);
-
-            this.dir = dir;
-            fileOut = TempFile.createTempFile("encrypted_package", "crypt");
-            FileOutputStream rawStream = new FileOutputStream(fileOut);
 
+        @SuppressWarnings("resource")
+        private StandardCipherOutputStream(DirectoryNode dir, File fileOut) 
throws IOException {
             // although not documented, we need the same padding as with agile 
encryption
             // and instead of calculating the missing bytes for the block size 
ourselves
             // we leave it up to the CipherOutputStream, which generates/saves 
them on close()
@@ -141,9 +136,15 @@ public class StandardEncryptor extends E
             // KeyData.blockSize value. Any padding bytes can be used. Note 
that the StreamSize
             // field of the EncryptedPackage field specifies the number of 
bytes of 
             // unencrypted data as specified in section 2.3.4.4.
-            CipherOutputStream cryptStream = new CipherOutputStream(rawStream, 
getCipher(getSecretKey(), "PKCS5Padding"));
-            
-            this.out = cryptStream;
+            super(
+                new CipherOutputStream(new FileOutputStream(fileOut), 
getCipher(getSecretKey(), "PKCS5Padding"))   
+            );
+            this.fileOut = fileOut;
+            this.dir = dir;
+        }
+        
+        protected StandardCipherOutputStream(DirectoryNode dir) throws 
IOException {
+            this(dir, TempFile.createTempFile("encrypted_package", "crypt"));
         }
         
         @Override

Modified: 
poi/trunk/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java 
(original)
+++ poi/trunk/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReader.java 
Mon Mar 21 00:14:21 2016
@@ -212,13 +212,13 @@ public class POIFSReader
 
     private void processProperties(final BlockList small_blocks,
                                    final BlockList big_blocks,
-                                   final Iterator properties,
+                                   final Iterator<Property> properties,
                                    final POIFSDocumentPath path)
         throws IOException
     {
         while (properties.hasNext())
         {
-            Property property = ( Property ) properties.next();
+            Property property = properties.next();
             String   name     = property.getName();
 
             if (property.isDirectory())
@@ -235,8 +235,8 @@ public class POIFSReader
             }
             else
             {
-                int      startBlock = property.getStartBlock();
-                Iterator listeners  = registry.getListeners(path, name);
+                int startBlock = property.getStartBlock();
+                Iterator<POIFSReaderListener> listeners  = 
registry.getListeners(path, name);
 
                 if (listeners.hasNext())
                 {
@@ -257,8 +257,7 @@ public class POIFSReader
                     }
                     while (listeners.hasNext())
                     {
-                        POIFSReaderListener listener =
-                            ( POIFSReaderListener ) listeners.next();
+                        POIFSReaderListener listener = listeners.next();
 
                         listener.processPOIFSReaderEvent(
                             new POIFSReaderEvent(
@@ -303,6 +302,7 @@ public class POIFSReader
 
         public void processPOIFSReaderEvent(final POIFSReaderEvent event)
         {
+            @SuppressWarnings("resource")
             DocumentInputStream istream = event.getStream();
             POIFSDocumentPath   path    = event.getPath();
             String              name    = event.getName();

Modified: poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/CellUtil.java Mon Mar 21 00:14:21 
2016
@@ -205,7 +205,8 @@ public final class CellUtil {
         * @since POI 3.14 beta 2
         */
        public static void setCellStyleProperties(Cell cell, Map<String, 
Object> properties) {
-               Workbook workbook = cell.getSheet().getWorkbook();
+               @SuppressWarnings("resource")
+        Workbook workbook = cell.getSheet().getWorkbook();
                CellStyle originalStyle = cell.getCellStyle();
                CellStyle newStyle = null;
                Map<String, Object> values = getFormatProperties(originalStyle);

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java 
Mon Mar 21 00:14:21 2016
@@ -19,6 +19,8 @@ package org.apache.poi.ss.usermodel;
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.IOException;
+
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.xssf.streaming.SXSSFCell;
@@ -38,17 +40,19 @@ public abstract class BaseTestXCell exte
     }
 
     @Test
-    public void testXmlEncoding(){
-        Workbook wb = _testDataProvider.createWorkbook();
-        Sheet sh = wb.createSheet();
+    public void testXmlEncoding() throws IOException {
+        Workbook wb1 = _testDataProvider.createWorkbook();
+        Sheet sh = wb1.createSheet();
         Row row = sh.createRow(0);
         Cell cell = row.createCell(0);
         String sval = "\u0000\u0002\u0012<>\t\n\u00a0 &\"POI\'\u2122";
         cell.setCellValue(sval);
 
-        wb = _testDataProvider.writeOutAndReadBack(wb);
+        Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
+        wb1.close();
 
         // invalid characters are replaced with question marks
-        assertEquals("???<>\t\n\u00a0 &\"POI\'\u2122", 
wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
+        assertEquals("???<>\t\n\u00a0 &\"POI\'\u2122", 
wb2.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
+        wb2.close();
     }
 }

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSheetHiding.java
 Mon Mar 21 00:14:21 2016
@@ -20,9 +20,6 @@ package org.apache.poi.xssf.usermodel;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.ss.usermodel.BaseTestSheetHiding;
 
-/**
- * @author Yegor Kozlov
- */
 public final class TestSheetHiding extends BaseTestSheetHiding {
     public TestSheetHiding() {
         super(XSSFITestDataProvider.instance,

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java 
(original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java 
Mon Mar 21 00:14:21 2016
@@ -66,7 +66,7 @@ public final class TestXSSFCell extends
      * Shared String Table
      */
     @Test
-    public void test47026_1() throws Exception {
+    public void test47026_1() throws IOException {
         Workbook wb = _testDataProvider.openSampleWorkbook("47026.xlsm");
         Sheet sheet = wb.getSheetAt(0);
         Row row = sheet.getRow(0);
@@ -77,7 +77,7 @@ public final class TestXSSFCell extends
     }
 
     @Test
-    public void test47026_2() throws Exception {
+    public void test47026_2() throws IOException {
         Workbook wb = _testDataProvider.openSampleWorkbook("47026.xlsm");
         Sheet sheet = wb.getSheetAt(0);
         Row row = sheet.getRow(0);
@@ -95,7 +95,7 @@ public final class TestXSSFCell extends
      * instead of using the shared string table. See bug 47206
      */
     @Test
-    public void testInlineString() throws Exception {
+    public void testInlineString() throws IOException {
         XSSFWorkbook wb = 
(XSSFWorkbook)_testDataProvider.openSampleWorkbook("xlsx-jdbc.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
         XSSFRow row = sheet.getRow(1);
@@ -121,7 +121,7 @@ public final class TestXSSFCell extends
      *  Bug 47278 -  xsi:nil attribute for <t> tag caused Excel 2007 to fail 
to open workbook
      */
     @Test
-    public void test47278() throws Exception {
+    public void test47278() throws IOException {
         XSSFWorkbook wb = (XSSFWorkbook)_testDataProvider.createWorkbook();
         Sheet sheet = wb.createSheet();
         Row row = sheet.createRow(0);
@@ -187,7 +187,7 @@ public final class TestXSSFCell extends
      * Bug 47889: problems when calling XSSFCell.getStringCellValue() on a 
workbook created in Gnumeric
      */
     @Test
-    public void test47889() throws Exception {
+    public void test47889() throws IOException {
         XSSFWorkbook wb = 
(XSSFWorkbook)_testDataProvider.openSampleWorkbook("47889.xlsx");
         XSSFSheet sh = wb.getSheetAt(0);
 
@@ -214,7 +214,7 @@ public final class TestXSSFCell extends
     }
 
     @Test
-    public void testMissingRAttribute() throws Exception {
+    public void testMissingRAttribute() throws IOException {
         XSSFWorkbook wb1 = new XSSFWorkbook();
         XSSFSheet sheet = wb1.createSheet();
         XSSFRow row = sheet.createRow(0);
@@ -269,7 +269,7 @@ public final class TestXSSFCell extends
     }
 
     @Test
-    public void testMissingRAttributeBug54288() throws Exception {
+    public void testMissingRAttributeBug54288() throws IOException {
         // workbook with cells missing the R attribute
         XSSFWorkbook wb = 
(XSSFWorkbook)_testDataProvider.openSampleWorkbook("54288.xlsx");
         // same workbook re-saved in Excel 2010, the R attribute is updated 
for every cell with the right value.
@@ -453,7 +453,7 @@ public final class TestXSSFCell extends
     }
 
     @Test
-    public void testEncodingbeloAscii() throws Exception {
+    public void testEncodingbeloAscii() throws IOException {
         StringBuffer sb = new StringBuffer();
         // test all possible characters
         for(int i = 0; i < Character.MAX_VALUE; i++) {

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFExternalFunctions.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFExternalFunctions.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFExternalFunctions.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFExternalFunctions.java
 Mon Mar 21 00:14:21 2016
@@ -24,12 +24,7 @@ import org.apache.poi.xssf.XSSFITestData
  * Tests setting and evaluating user-defined functions in HSSF
  */
 public final class TestXSSFExternalFunctions extends BaseTestExternalFunctions 
{
-
        public TestXSSFExternalFunctions() {
-               super(XSSFITestDataProvider.instance);
+               super(XSSFITestDataProvider.instance, "atp.xlsx");
        }
-
-    public void testATP(){
-        baseTestInvokeATP("atp.xlsx");
-    }
 }

Modified: 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
 (original)
+++ 
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
 Mon Mar 21 00:14:21 2016
@@ -17,7 +17,10 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 
@@ -27,14 +30,12 @@ import org.apache.poi.ss.usermodel.Comme
 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.util.CellAddress;
 import org.apache.poi.ss.util.CellUtil;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.junit.Test;
 
-/**
- * @author Yegor Kozlov
- */
 public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
 
     public TestXSSFSheetShiftRows(){
@@ -43,7 +44,8 @@ public final class TestXSSFSheetShiftRow
 
     @Override
     @Test
-       public void testShiftRowBreaks() { // disabled test from superclass
+       public void testShiftRowBreaks() {
+        // disabled test from superclass
         // TODO - support shifting of page breaks
     }
 
@@ -85,10 +87,10 @@ public final class TestXSSFSheetShiftRow
                // 
org.apache.xmlbeans.impl.values.XmlValueDisconnectedException.
                // NOTE: another negative shift on another group of rows is 
successful, provided no new rows in  
                // place of previously shifted rows were attempted to be 
created as explained above.
-               testSheet.shiftRows(6, 7, 1);   // -- CHANGE the shift to 
positive once the behaviour of  
-                                                                               
// the above has been tested
+
+               // -- CHANGE the shift to positive once the behaviour of the 
above has been tested
+               testSheet.shiftRows(6, 7, 1); 
                
-               //saveReport(wb, new File("/tmp/53798.xlsx"));
                Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
                wb.close();
                assertNotNull(read);
@@ -131,7 +133,6 @@ public final class TestXSSFSheetShiftRow
         }
                testSheet.shiftRows(6, 6, 1);
                
-               //saveReport(wb, new File("/tmp/53798.xlsx"));
                Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
                wb.close();
                assertNotNull(read);
@@ -155,7 +156,7 @@ public final class TestXSSFSheetShiftRow
 
         Sheet sheet = wb.getSheetAt(0);
 
-        Comment comment = sheet.getCellComment(0, 0);
+        Comment comment = sheet.getCellComment(new CellAddress(0, 0));
         assertNotNull(comment);
         assertEquals("Amdocs", comment.getAuthor());
         assertEquals("Amdocs:\ntest\n", comment.getString().getString());
@@ -163,22 +164,15 @@ public final class TestXSSFSheetShiftRow
         sheet.shiftRows(0, 1, 1);
 
         // comment in row 0 is gone
-        comment = sheet.getCellComment(0, 0);
+        comment = sheet.getCellComment(new CellAddress(0, 0));
         assertNull(comment);
         
         // comment is now in row 1
-        comment = sheet.getCellComment(1, 0);
+        comment = sheet.getCellComment(new CellAddress(1, 0));
         assertNotNull(comment);
         assertEquals("Amdocs", comment.getAuthor());
         assertEquals("Amdocs:\ntest\n", comment.getString().getString());
         
-//        FileOutputStream outputStream = new 
FileOutputStream("/tmp/56017.xlsx");
-//        try {
-//            wb.write(outputStream);
-//        } finally {
-//            outputStream.close();
-//        }
-        
         Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
         wb.close();
         assertNotNull(wbBack);
@@ -186,11 +180,11 @@ public final class TestXSSFSheetShiftRow
         Sheet sheetBack = wbBack.getSheetAt(0);
 
         // comment in row 0 is gone
-        comment = sheetBack.getCellComment(0, 0);
+        comment = sheetBack.getCellComment(new CellAddress(0, 0));
         assertNull(comment);
 
         // comment is now in row 1
-        comment = sheetBack.getCellComment(1, 0);
+        comment = sheetBack.getCellComment(new CellAddress(1, 0));
         assertNotNull(comment);
         assertEquals("Amdocs", comment.getAuthor());
         assertEquals("Amdocs:\ntest\n", comment.getString().getString());
@@ -211,7 +205,6 @@ public final class TestXSSFSheetShiftRow
         wbRead.removeSheetAt(0);
         assertEquals(0, wbRead.getActiveSheetIndex());
 
-        //wb.write(new FileOutputStream("/tmp/57171.xls"));
         wbRead.close();
     }
 
@@ -222,7 +215,6 @@ public final class TestXSSFSheetShiftRow
         wb.removeSheetAt(0);
         assertEquals(4, wb.getActiveSheetIndex());
 
-        //wb.write(new FileOutputStream("/tmp/57163.xls"));
         wb.close();
     }
 
@@ -320,7 +312,6 @@ public final class TestXSSFSheetShiftRow
         wb.close();
     }
 
-    // TODO: enable when bug 57165 is fixed
        @Test
     public void test57165() throws IOException {
         Workbook wb = 
XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
@@ -333,29 +324,17 @@ public final class TestXSSFSheetShiftRow
         wb.setSheetName(1, "New Sheet");
         assertEquals(0, wb.getActiveSheetIndex());
 
-        //wb.write(new FileOutputStream("/tmp/57165.xls"));
         wb.close();
     }
 
-//    public void test57165b() throws IOException {
-//        Workbook wb = new XSSFWorkbook();
-//        try {
-//            wb.createSheet("New Sheet 1");
-//            wb.createSheet("New Sheet 2");
-//        } finally {
-//            wb.close();
-//        }
-//    }
-
     private static void removeAllSheetsBut(int sheetIndex, Workbook wb) {
         int sheetNb = wb.getNumberOfSheets();
         // Move this sheet at the first position
         wb.setSheetOrder(wb.getSheetName(sheetIndex), 0);
         // Must make this sheet active (otherwise, for XLSX, Excel might 
protest that active sheet no longer exists)
         // I think POI should automatically handle this case when deleting 
sheets...
-//      wb.setActiveSheet(0);
-        for (int sn = sheetNb - 1; sn > 0; sn--)
-        {
+        // wb.setActiveSheet(0);
+        for (int sn = sheetNb - 1; sn > 0; sn--) {
             wb.removeSheetAt(sn);
         }
     }
@@ -365,33 +344,26 @@ public final class TestXSSFSheetShiftRow
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57828.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
 
-        Comment comment1 = sheet.getCellComment(2, 1);
+        Comment comment1 = sheet.getCellComment(new CellAddress(2, 1));
         assertNotNull(comment1);
 
-        Comment comment2 = sheet.getCellComment(2, 2);
+        Comment comment2 = sheet.getCellComment(new CellAddress(2, 2));
         assertNotNull(comment2);
 
-        Comment comment3 = sheet.getCellComment(1, 1);
+        Comment comment3 = sheet.getCellComment(new CellAddress(1, 1));
         assertNull("NO comment in (1,1) and it should be null", comment3);
 
         sheet.shiftRows(2, 2, -1);
 
-        comment3 = sheet.getCellComment(1, 1);
+        comment3 = sheet.getCellComment(new CellAddress(1, 1));
         assertNotNull("Comment in (2,1) moved to (1,1) so its not null now.", 
comment3);
 
-        comment1 = sheet.getCellComment(2, 1);
+        comment1 = sheet.getCellComment(new CellAddress(2, 1));
         assertNull("No comment currently in (2,1) and hence it is null", 
comment1);
 
-        comment2 = sheet.getCellComment(1, 2);
+        comment2 = sheet.getCellComment(new CellAddress(1, 2));
         assertNotNull("Comment in (2,2) should have moved as well because of 
shift rows. But its not", comment2);
         
-//        OutputStream stream = new FileOutputStream("/tmp/57828.xlsx");
-//        try {
-//             wb.write(stream);
-//        } finally {
-//             stream.close();
-//        }
-        
         wb.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherDump.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherDump.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherDump.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherDump.java Mon Mar 21 
00:14:21 2016
@@ -30,29 +30,37 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LocaleUtil;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class TestEscherDump {
+    static NullPrinterStream nullPS;
+    
+    @BeforeClass
+    public static void init() throws UnsupportedEncodingException {
+        nullPS = new NullPrinterStream();
+    }
+    
     @Test
     public void testSimple() throws Exception {
         // simple test to at least cover some parts of the class
-        EscherDump.main(new String[] {}, new NullPrinterStream());
+        EscherDump.main(new String[] {}, nullPS);
         
-        new EscherDump().dump(0, new byte[] {}, new NullPrinterStream());
-        new EscherDump().dump(new byte[] {}, 0, 0, new NullPrinterStream());
-        new EscherDump().dumpOld(0, new ByteArrayInputStream(new byte[] {}), 
new NullPrinterStream());
+        new EscherDump().dump(0, new byte[] {}, nullPS);
+        new EscherDump().dump(new byte[] {}, 0, 0, nullPS);
+        new EscherDump().dumpOld(0, new ByteArrayInputStream(new byte[] {}), 
nullPS);
     }
 
     @Test
     public void testWithData() throws Exception {
-        new EscherDump().dumpOld(8, new ByteArrayInputStream(new byte[] { 00, 
00, 00, 00, 00, 00, 00, 00 }), new NullPrinterStream());
+        new EscherDump().dumpOld(8, new ByteArrayInputStream(new byte[] { 00, 
00, 00, 00, 00, 00, 00, 00 }), nullPS);
     }
 
     @Test
     public  void testWithSamplefile() throws Exception {
         //InputStream stream = HSSFTestDataSamples.openSampleFileStream(")
         byte[] data = 
POIDataSamples.getDDFInstance().readFile("Container.dat");
-        new EscherDump().dump(data.length, data, new NullPrinterStream());
+        new EscherDump().dump(data.length, data, nullPS);
         //new EscherDump().dumpOld(data.length, new 
ByteArrayInputStream(data), System.out);
         
         data = new byte[2586114];
@@ -72,6 +80,7 @@ public class TestEscherDump {
      * to redirect stdout to avoid spamming the console with output
      */
     private static class NullPrinterStream extends PrintStream {
+        @SuppressWarnings("resource")
         private NullPrinterStream() throws UnsupportedEncodingException {
             super(new NullOutputStream(),true,LocaleUtil.CHARSET_1252.name());
         }

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java Mon Mar 21 
00:14:21 2016
@@ -849,10 +849,14 @@ public class TestWrite
         sinfDoc = 
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = 
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
 
-        sinf = (SummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(sinfDoc));
+        InputStream sinfStream = new NDocumentInputStream(sinfDoc);
+        sinf = (SummaryInformation)PropertySetFactory.create(sinfStream);
+        sinfStream.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        dinf = (DocumentSummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(dinfDoc));
+        InputStream dinfStream = new NDocumentInputStream(dinfDoc);
+        dinf = 
(DocumentSummaryInformation)PropertySetFactory.create(dinfStream);
+        dinfStream.close();
         assertEquals(131077, dinf.getOSVersion());
         
         
@@ -874,10 +878,14 @@ public class TestWrite
         sinfDoc = 
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = 
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
         
-        sinf = (SummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(sinfDoc));
+        InputStream sinfStream2 = new NDocumentInputStream(sinfDoc);
+        sinf = (SummaryInformation)PropertySetFactory.create(sinfStream2);
+        sinfStream2.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        dinf = (DocumentSummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(dinfDoc));
+        InputStream dinfStream2 = new NDocumentInputStream(dinfDoc);
+        dinf = 
(DocumentSummaryInformation)PropertySetFactory.create(dinfStream2);
+        dinfStream2.close();
         assertEquals(131077, dinf.getOSVersion());
 
         
@@ -896,16 +904,24 @@ public class TestWrite
         sinfDoc = 
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = 
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
 
-        sinf = (SummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(sinfDoc));
+        InputStream sinfStream3 = new NDocumentInputStream(sinfDoc);
+        sinf = (SummaryInformation)PropertySetFactory.create(sinfStream3);
+        sinfStream3.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        dinf = (DocumentSummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(dinfDoc));
+        InputStream dinfStream3 = new NDocumentInputStream(dinfDoc);
+        dinf = 
(DocumentSummaryInformation)PropertySetFactory.create(dinfStream3);
+        dinfStream3.close();
         assertEquals(131077, dinf.getOSVersion());
         
         
         // Have them write themselves in-place with no changes, as an 
OutputStream
-        sinf.write(new NDocumentOutputStream(sinfDoc));
-        dinf.write(new NDocumentOutputStream(dinfDoc));
+        OutputStream soufStream = new NDocumentOutputStream(sinfDoc);
+        sinf.write(soufStream);
+        soufStream.close();
+        OutputStream doufStream = new NDocumentOutputStream(dinfDoc);
+        dinf.write(doufStream);
+        doufStream.close();
         
         // And also write to some bytes for checking
         ByteArrayOutputStream sinfBytes = new ByteArrayOutputStream();
@@ -918,17 +934,25 @@ public class TestWrite
         sinfDoc = 
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = 
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
 
-        byte[] sinfData = IOUtils.toByteArray(new 
NDocumentInputStream(sinfDoc));
-        byte[] dinfData = IOUtils.toByteArray(new 
NDocumentInputStream(dinfDoc));
+        InputStream sinfStream4 = new NDocumentInputStream(sinfDoc);
+        byte[] sinfData = IOUtils.toByteArray(sinfStream4);
+        sinfStream4.close();
+        InputStream dinfStream4 = new NDocumentInputStream(dinfDoc);
+        byte[] dinfData = IOUtils.toByteArray(dinfStream4);
+        dinfStream4.close();
         assertThat(sinfBytes.toByteArray(), equalTo(sinfData));
         assertThat(dinfBytes.toByteArray(), equalTo(dinfData));
 
         
         // Read back in as-is
-        sinf = (SummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(sinfDoc));
+        InputStream sinfStream5 = new NDocumentInputStream(sinfDoc);
+        sinf = (SummaryInformation)PropertySetFactory.create(sinfStream5);
+        sinfStream5.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        dinf = (DocumentSummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(dinfDoc));
+        InputStream dinfStream5 = new NDocumentInputStream(dinfDoc);
+        dinf = 
(DocumentSummaryInformation)PropertySetFactory.create(dinfStream5);
+        dinfStream5.close();
         assertEquals(131077, dinf.getOSVersion());
         
         assertEquals("Reiichiro Hori", sinf.getAuthor());
@@ -946,17 +970,25 @@ public class TestWrite
         
         
         // Save this into the filesystem
-        sinf.write(new NDocumentOutputStream(sinfDoc));
-        dinf.write(new NDocumentOutputStream(dinfDoc));
+        OutputStream soufStream2 = new NDocumentOutputStream(sinfDoc);
+        sinf.write(soufStream2);
+        soufStream2.close();
+        OutputStream doufStream2 = new NDocumentOutputStream(dinfDoc);
+        dinf.write(doufStream2);
+        doufStream2.close();
         
         
         // Read them back in again
         sinfDoc = 
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
-        sinf = (SummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(sinfDoc));
+        InputStream sinfStream6 = new NDocumentInputStream(sinfDoc);
+        sinf = (SummaryInformation)PropertySetFactory.create(sinfStream6);
+        sinfStream6.close();
         assertEquals(131077, sinf.getOSVersion());
         
         dinfDoc = 
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
-        dinf = (DocumentSummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(dinfDoc));
+        InputStream dinfStream6 = new NDocumentInputStream(dinfDoc);
+        dinf = 
(DocumentSummaryInformation)PropertySetFactory.create(dinfStream6);
+        dinfStream6.close();
         assertEquals(131077, dinf.getOSVersion());
 
         assertEquals("Changed Author", sinf.getAuthor());
@@ -976,11 +1008,15 @@ public class TestWrite
         
         // Re-check on load
         sinfDoc = 
(DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
-        sinf = (SummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(sinfDoc));
+        InputStream sinfStream7 = new NDocumentInputStream(sinfDoc);
+        sinf = (SummaryInformation)PropertySetFactory.create(sinfStream7);
+        sinfStream7.close();
         assertEquals(131077, sinf.getOSVersion());
         
         dinfDoc = 
(DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
-        dinf = (DocumentSummaryInformation)PropertySetFactory.create(new 
NDocumentInputStream(dinfDoc));
+        InputStream dinfStream7 = new NDocumentInputStream(dinfDoc);
+        dinf = 
(DocumentSummaryInformation)PropertySetFactory.create(dinfStream7);
+        dinfStream7.close();
         assertEquals(131077, dinf.getOSVersion());
 
         assertEquals("Changed Author", sinf.getAuthor());

Modified: 
poi/trunk/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java 
Mon Mar 21 00:14:21 2016
@@ -97,15 +97,20 @@ public abstract class BaseXLSIteratingTe
                        
                        // try to read it in HSSFWorkbook to quickly fail if we 
cannot read the file there at all and thus probably should use EXCLUDED instead
                        FileInputStream stream = new FileInputStream(file);
+                       HSSFWorkbook wb = null;
                        try {
-                               assertNotNull(new HSSFWorkbook(stream));
+                           wb = new HSSFWorkbook(stream);
+                               assertNotNull(wb);
                        } finally {
+                           if (wb != null) {
+                               wb.close();
+                           }
                                stream.close();
                        }
                }
        }
 
-       abstract void runOneFile(File file) throws Exception;
+       abstract void runOneFile(File pFile) throws Exception;
 
        /**
         * Implementation of an OutputStream which does nothing, used

Modified: 
poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java?rev=1735912&r1=1735911&r2=1735912&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java 
(original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java 
Mon Mar 21 00:14:21 2016
@@ -21,33 +21,30 @@ import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.PrintStream;
 
-import org.junit.Ignore;
-import org.junit.Test;
-
 public class TestBiffDrawingToXml extends BaseXLSIteratingTest {
        static {
-               // TODO: is it ok to fail these? 
-               // Look at the output of the test for the detailed stacktrace 
of the failures...
-//             EXCLUDED.add("password.xls"); 
-//             EXCLUDED.add("XRefCalc.xls"); 
-//             EXCLUDED.add("43493.xls");
-//             EXCLUDED.add("51832.xls"); 
-       }
-       
-       @Override
-       @Ignore("Not yet done, nearly all files fail with various errors, 
remove this method when done to use the one from the abstract base class!...")
-       @Test
-       public void testMain() throws Exception {
+        EXCLUDED.add("35897-type4.xls"); // unsupported crypto api header 
+        EXCLUDED.add("43493.xls");  // HSSFWorkbook cannot open it as well
+        EXCLUDED.add("46904.xls");
+        EXCLUDED.add("44958_1.xls");
+        EXCLUDED.add("51832.xls");
+        EXCLUDED.add("59074.xls");
+               EXCLUDED.add("password.xls"); 
+        EXCLUDED.add("testEXCEL_2.xls");  // Biff 2 / Excel 2, pre-OLE2
+        EXCLUDED.add("testEXCEL_3.xls");  // Biff 3 / Excel 3, pre-OLE2
+        EXCLUDED.add("testEXCEL_4.xls");  // Biff 4 / Excel 4, pre-OLE2
+        EXCLUDED.add("testEXCEL_5.xls");  // Biff 5 / Excel 5
+        EXCLUDED.add("testEXCEL_95.xls"); // Biff 5 / Excel 95
+               EXCLUDED.add("xor-encryption-abc.xls"); 
        }
        
        @Override
-       void runOneFile(File file)
-                       throws Exception {
+       void runOneFile(File pFile) throws Exception {
                PrintStream save = System.out;
                try {
                        //System.setOut(new 
PrintStream(TestBiffViewer.NULL_OUTPUT_STREAM));
                        // use a NullOutputStream to not write the bytes 
anywhere for best runtime 
-                   InputStream wb = new FileInputStream(file);
+                   InputStream wb = new FileInputStream(pFile);
                    try {
                        BiffDrawingToXml.writeToFile(NULL_OUTPUT_STREAM, wb, 
false, new String[] {});
                    } finally {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to