Add some missing close(), reduce output in unit tests and remove some other Eclipse warnings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1689590 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c3b9dacc77
commit
090b86cb71
@ -88,12 +88,14 @@ public class XSLFFileHandler extends AbstractFileHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// a test-case to test this locally without executing the full TestAllFiles
|
// a test-case to test this locally without executing the full TestAllFiles
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
InputStream stream = new FileInputStream("test-data/slideshow/pptx2svg.pptx");
|
InputStream stream = new FileInputStream("test-data/slideshow/SampleShow.pptx");
|
||||||
try {
|
try {
|
||||||
handleFile(stream);
|
handleFile(stream);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -60,6 +60,8 @@ public final class TestOutlookTextExtractor extends POITestCase {
|
|||||||
String dateText = f.format(cal.getTime());
|
String dateText = f.format(cal.getTime());
|
||||||
assertContains(text, "Date: " + dateText + "\n");
|
assertContains(text, "Date: " + dateText + "\n");
|
||||||
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
||||||
|
|
||||||
|
ext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
@ -77,18 +79,25 @@ public final class TestOutlookTextExtractor extends POITestCase {
|
|||||||
assertContains(text, "Subject: test message\n");
|
assertContains(text, "Subject: test message\n");
|
||||||
assertContains(text, "Date: Fri, 6 Jul 2007 05:27:17 +0000\n");
|
assertContains(text, "Date: Fri, 6 Jul 2007 05:27:17 +0000\n");
|
||||||
assertContains(text, "This is a test message.");
|
assertContains(text, "This is a test message.");
|
||||||
|
|
||||||
|
ext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructors() throws Exception {
|
public void testConstructors() throws Exception {
|
||||||
String inp = (new OutlookTextExtactor(new FileInputStream(
|
OutlookTextExtactor ext = new OutlookTextExtactor(new FileInputStream(
|
||||||
samples.getFile("simple_test_msg.msg")
|
samples.getFile("simple_test_msg.msg")));
|
||||||
)).getText());
|
String inp = ext.getText();
|
||||||
String poifs = (new OutlookTextExtactor(new POIFSFileSystem(new FileInputStream(
|
ext.close();
|
||||||
samples.getFile("simple_test_msg.msg")
|
|
||||||
))).getText());
|
ext = new OutlookTextExtactor(new POIFSFileSystem(new FileInputStream(
|
||||||
String mapi = (new OutlookTextExtactor(new MAPIMessage(new FileInputStream(
|
samples.getFile("simple_test_msg.msg"))));
|
||||||
samples.getFile("simple_test_msg.msg")
|
String poifs = ext.getText();
|
||||||
))).getText());
|
ext.close();
|
||||||
|
|
||||||
|
ext = new OutlookTextExtactor(new MAPIMessage(new FileInputStream(
|
||||||
|
samples.getFile("simple_test_msg.msg"))));
|
||||||
|
String mapi = ext.getText();
|
||||||
|
ext.close();
|
||||||
|
|
||||||
assertEquals(inp, poifs);
|
assertEquals(inp, poifs);
|
||||||
assertEquals(inp, mapi);
|
assertEquals(inp, mapi);
|
||||||
@ -128,6 +137,8 @@ public final class TestOutlookTextExtractor extends POITestCase {
|
|||||||
assertContains(text, "Subject: This is a test message please ignore\n");
|
assertContains(text, "Subject: This is a test message please ignore\n");
|
||||||
assertContains(text, "Date:");
|
assertContains(text, "Date:");
|
||||||
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
||||||
|
|
||||||
|
ext.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +175,8 @@ public final class TestOutlookTextExtractor extends POITestCase {
|
|||||||
assertContains(text, "Subject: This is a test message please ignore\n");
|
assertContains(text, "Subject: This is a test message please ignore\n");
|
||||||
assertContains(text, "Date: Mon, 11 Jan 2010 16:2"); // Exact times differ slightly
|
assertContains(text, "Date: Mon, 11 Jan 2010 16:2"); // Exact times differ slightly
|
||||||
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
assertContains(text, "The quick brown fox jumps over the lazy dog");
|
||||||
|
|
||||||
|
ext.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +205,8 @@ public final class TestOutlookTextExtractor extends POITestCase {
|
|||||||
|
|
||||||
// Embeded bits are checked in
|
// Embeded bits are checked in
|
||||||
// TestExtractorFactory
|
// TestExtractorFactory
|
||||||
|
|
||||||
|
ext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEncodings() throws Exception {
|
public void testEncodings() throws Exception {
|
||||||
@ -209,5 +224,7 @@ public final class TestOutlookTextExtractor extends POITestCase {
|
|||||||
// And check some chinese bits
|
// And check some chinese bits
|
||||||
assertContains(text, "(\u5f35\u6bd3\u502b)");
|
assertContains(text, "(\u5f35\u6bd3\u502b)");
|
||||||
assertContains(text, "( MSG \u683c\u5f0f\u6e2c\u8a66 )");
|
assertContains(text, "( MSG \u683c\u5f0f\u6e2c\u8a66 )");
|
||||||
|
|
||||||
|
ext.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,11 +79,11 @@ public abstract class BaseXLSIteratingTest {
|
|||||||
try {
|
try {
|
||||||
runOneFile(dir, file, failed);
|
runOneFile(dir, file, failed);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Failed: " + file);
|
|
||||||
if(SILENT_EXCLUDED.contains(file)) {
|
if(SILENT_EXCLUDED.contains(file)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Failed: " + file);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
// try to read it in HSSFWorkbook to quickly fail if we cannot read the file there at all and thus probably can use SILENT_EXCLUDED instead
|
// try to read it in HSSFWorkbook to quickly fail if we cannot read the file there at all and thus probably can use SILENT_EXCLUDED instead
|
||||||
|
@ -32,7 +32,6 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
Loading…
Reference in New Issue
Block a user