Add some missing close() calls

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765875 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2016-10-20 20:31:50 +00:00
parent e9b4a17d77
commit f2c9dbec3f
3 changed files with 23 additions and 17 deletions

View 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"));
try {
String text = extractor.getText();
assertContains(text, "testdoc");
assertContains(text, "test phrase");
} finally {
extractor.close();
}
}
}

View File

@ -366,5 +366,6 @@ public final class TestOldExcelExtractor {
} catch (EncryptedDocumentException e) {
assertTrue("correct exception thrown", true);
}
ex.close();
}
}

View File

@ -17,11 +17,12 @@
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();
}
}