// 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;
}
}
@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();
+ }
}
}
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;
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;
Map<String, String> macros = r.readMacros();
assertNotNull(macros.get("Module20"));
assertContains(macros.get("Module20"), "here start of superscripting");
+ r.close();
}
@Test
Map<String, String> macros = r.readMacros();
assertNotNull(macros.get("Sheet4"));
assertContains(macros.get("Sheet4"), "intentional constituent");
+ r.close();
}
@Test
Map<String, String> macros = r.readMacros();
assertNotNull(macros.get("NewMacros"));
assertContains(macros.get("NewMacros"), "' dirty");
+ r.close();
}
@Test
Map<String, String> macros = r.readMacros();
assertNotNull(macros.get("Module1"));
assertContains(macros.get("Module1"), "9/8/2004");
+ r.close();
}
}