]> source.dussan.org Git - poi.git/commitdiff
Add some missing close() calls
authorDominik Stadler <centic@apache.org>
Thu, 20 Oct 2016 20:31:50 +0000 (20:31 +0000)
committerDominik Stadler <centic@apache.org>
Thu, 20 Oct 2016 20:31:50 +0000 (20:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765875 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java
src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java

index 26fe68a63218a651347c21fe3cf1a286a2d885cb..0d7bc5a8a34cf52153e0d2df00d0316d590cb366 100644 (file)
@@ -684,11 +684,11 @@ public class TestExtractorFactory {
         // Text
         try {
             ExtractorFactory.createExtractor(OPCPackage.open(txt.toString()));
-            fail("TestExtractorFactory.testPackage() failed on " + txt.toString());
+            fail("TestExtractorFactory.testPackage() failed on " + txt);
         } catch(UnsupportedFileFormatException e) {
             // Good
         } catch (Exception e) {
-            System.out.println("TestExtractorFactory.testPackage() failed on " + txt.toString());
+            System.out.println("TestExtractorFactory.testPackage() failed on " + txt);
             throw e;
         }
     }
@@ -1028,9 +1028,12 @@ public class TestExtractorFactory {
     @Test(expected=AssertionError.class)
     public void test45565() throws Exception {
         POITextExtractor extractor = ExtractorFactory.createExtractor(HSSFTestDataSamples.getSampleFile("45565.xls"));
-        String text = extractor.getText();
-        assertContains(text, "testdoc");
-        assertContains(text, "test phrase");
-        extractor.close();
+        try {
+            String text = extractor.getText();
+            assertContains(text, "testdoc");
+            assertContains(text, "test phrase");
+        } finally {
+            extractor.close();
+        }
     }
 }
index 73222ed01a304471422614426003960361d12364..8a150323f736f1fd8930f4ea309e4f5a91c28b9a 100644 (file)
@@ -366,5 +366,6 @@ public final class TestOldExcelExtractor {
         } catch (EncryptedDocumentException e) {
             assertTrue("correct exception thrown", true);
         }
+        ex.close();
     }
 }
index 6ac37eacba02c2ccbad01cfdd84becea18539a4d..eeb43b4d27e2fe7b3de6e50cbd902ceada39629d 100644 (file)
 
 package org.apache.poi.poifs.macros;
 
-import static org.apache.poi.POITestCase.assertContains;
-import static org.apache.poi.POITestCase.skipTest;
-import static org.apache.poi.POITestCase.testPassesNow;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.StringUtil;
+import org.junit.Ignore;
+import org.junit.Test;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -31,12 +32,9 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.poi.POIDataSamples;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
-import org.apache.poi.util.IOUtils;
-import org.apache.poi.util.StringUtil;
-import org.junit.Ignore;
-import org.junit.Test;
+import static org.apache.poi.POITestCase.assertContains;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 
 public class TestVBAMacroReader {
     private static final Map<POIDataSamples, String> expectedMacroContents;
@@ -255,6 +253,7 @@ public class TestVBAMacroReader {
         Map<String, String> macros = r.readMacros();
         assertNotNull(macros.get("Module20"));
         assertContains(macros.get("Module20"), "here start of superscripting");
+        r.close();
     }
 
     @Test
@@ -264,6 +263,7 @@ public class TestVBAMacroReader {
         Map<String, String> macros = r.readMacros();
         assertNotNull(macros.get("Sheet4"));
         assertContains(macros.get("Sheet4"), "intentional constituent");
+        r.close();
     }
 
     @Test
@@ -273,6 +273,7 @@ public class TestVBAMacroReader {
         Map<String, String> macros = r.readMacros();
         assertNotNull(macros.get("NewMacros"));
         assertContains(macros.get("NewMacros"), "' dirty");
+        r.close();
     }
 
     @Test
@@ -283,5 +284,6 @@ public class TestVBAMacroReader {
         Map<String, String> macros = r.readMacros();
         assertNotNull(macros.get("Module1"));
         assertContains(macros.get("Module1"), "9/8/2004");
+        r.close();
     }
 }