aboutsummaryrefslogtreecommitdiffstats
path: root/poi-integration/src/test/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-07-14 22:46:39 +0000
committerPJ Fanning <fanningpj@apache.org>2021-07-14 22:46:39 +0000
commit480d13b1180eccfa783c3a5a11d7e6d8f55e6532 (patch)
tree35ea8b3c20d87d376a3214b8e5a6e8c48e08ba78 /poi-integration/src/test/java
parentc104890f334612d9045b03d48b15ed2689f6444b (diff)
downloadpoi-480d13b1180eccfa783c3a5a11d7e6d8f55e6532.tar.gz
poi-480d13b1180eccfa783c3a5a11d7e6d8f55e6532.zip
try to fix failing tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891555 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-integration/src/test/java')
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/OPCFileHandler.java21
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/XWPFFileHandler.java8
2 files changed, 20 insertions, 9 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/OPCFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/OPCFileHandler.java
index e5493d01bd..5408e2b437 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/OPCFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/OPCFileHandler.java
@@ -23,6 +23,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PushbackInputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.poi.openxml4j.opc.ContentTypes;
import org.apache.poi.openxml4j.opc.OPCPackage;
@@ -31,17 +35,18 @@ import org.apache.poi.xwpf.usermodel.XWPFRelation;
import org.junit.jupiter.api.Test;
class OPCFileHandler extends AbstractFileHandler {
+ private static final Set<String> EXPECTED_FAILURES = unmodifiableHashSet(
+ "document/truncated62886.docx"
+ );
+
@Override
public void handleFile(InputStream stream, String path) throws Exception {
// ignore password protected files
if (POIXMLDocumentHandler.isEncrypted(stream)) return;
- OPCPackage p;
- try {
- p = OPCPackage.open(stream);
- } catch (Exception e) {
- throw new RuntimeException("Failed to open '" + path + "' as OPCPackage", e);
- }
+ if (EXPECTED_FAILURES.contains(path)) return;
+
+ OPCPackage p = OPCPackage.open(stream);
for (PackagePart part : p.getParts()) {
if (part.getPartName().toString().equals("/docProps/core.xml")) {
@@ -75,4 +80,8 @@ class OPCFileHandler extends AbstractFileHandler {
handleExtracting(file);
}
+
+ private static Set<String> unmodifiableHashSet(String... a) {
+ return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
+ }
}
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/XWPFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/XWPFFileHandler.java
index dbbb3f5edd..1c94cd3536 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/XWPFFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/XWPFFileHandler.java
@@ -26,25 +26,27 @@ import java.util.HashSet;
import java.util.Set;
import org.apache.poi.ooxml.POIXMLException;
-import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.junit.jupiter.api.Test;
class XWPFFileHandler extends AbstractFileHandler {
+ private static final Set<String> EXPECTED_FAILURES = unmodifiableHashSet(
+ "document/truncated62886.docx"
+ );
@Override
public void handleFile(InputStream stream, String path) throws Exception {
// ignore password protected files
if (POIXMLDocumentHandler.isEncrypted(stream)) return;
+ if (EXPECTED_FAILURES.contains(path)) return;
+
try (XWPFDocument doc = new XWPFDocument(stream)) {
new POIXMLDocumentHandler().handlePOIXMLDocument(doc);
POIXMLDocumentHandler.cursorRecursive(doc.getDocument());
} catch (POIXMLException e) {
Exception cause = (Exception)e.getCause();
throw cause == null ? e : cause;
- } catch (Exception e) {
- throw new RuntimeException("Failed to open '" + path + "' as XWPFDocument", e);
}
}