Adjust local test in integration-test file-handler

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808505 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2017-09-16 08:20:44 +00:00
parent ee35ccda7f
commit 6044d4629c

View File

@ -16,38 +16,37 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.stress; package org.apache.poi.stress;
import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.PushbackInputStream;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.junit.Test; import org.junit.Test;
public class XWPFFileHandler extends AbstractFileHandler { public class XWPFFileHandler extends AbstractFileHandler {
@Override @Override
public void handleFile(InputStream stream, String path) throws Exception { public void handleFile(InputStream stream, String path) throws Exception {
// ignore password protected files // ignore password protected files
if (POIXMLDocumentHandler.isEncrypted(stream)) return; if (POIXMLDocumentHandler.isEncrypted(stream)) return;
XWPFDocument doc = new XWPFDocument(stream); XWPFDocument doc = new XWPFDocument(stream);
new POIXMLDocumentHandler().handlePOIXMLDocument(doc); new POIXMLDocumentHandler().handlePOIXMLDocument(doc);
} }
// 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 {
File file = new File("test-data/document/51921-Word-Crash067.docx"); File file = new File("test-data/document/51921-Word-Crash067.docx");
InputStream stream = new PushbackInputStream(new FileInputStream(file), 100000); InputStream stream = new BufferedInputStream(new FileInputStream(file));
try { try {
handleFile(stream, file.getPath()); handleFile(stream, file.getPath());
} finally { } finally {
stream.close(); stream.close();
} }
handleExtracting(file);
}
handleExtracting(file);
}
} }