aboutsummaryrefslogtreecommitdiffstats
path: root/poi-integration/src/test/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-07-16 08:28:44 +0000
committerPJ Fanning <fanningpj@apache.org>2021-07-16 08:28:44 +0000
commit3c4643af9ec8c425fde7756c9514cf7362419737 (patch)
treeae4c4320872b96e81ab9a10e810dfd75b958de5a /poi-integration/src/test/java
parent18e10a1cddbef4baaa6146c07212263168bba1f0 (diff)
downloadpoi-3c4643af9ec8c425fde7756c9514cf7362419737.tar.gz
poi-3c4643af9ec8c425fde7756c9514cf7362419737.zip
try to fix integration tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891579 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/HPSFFileHandler.java10
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/OPCFileHandler.java11
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/StressTestUtils.java33
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java9
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/XWPFFileHandler.java11
5 files changed, 40 insertions, 34 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java b/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java
index dadb2a2d5c..3caf166f31 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/HPSFFileHandler.java
@@ -27,9 +27,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
@@ -49,7 +46,7 @@ class HPSFFileHandler extends POIFSFileHandler {
private static final ThreadLocal<File> copyOutput = ThreadLocal.withInitial(HPSFFileHandler::getTempFile);
- static final Set<String> EXCLUDES_HANDLE_ADD = unmodifiableHashSet(
+ static final Set<String> EXCLUDES_HANDLE_ADD = StressTestUtils.unmodifiableHashSet(
"spreadsheet/45290.xls",
"spreadsheet/46904.xls",
"spreadsheet/55982.xls",
@@ -59,11 +56,6 @@ class HPSFFileHandler extends POIFSFileHandler {
"document/word2.doc"
);
- private static Set<String> unmodifiableHashSet(String... a) {
- return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
- }
-
-
@Override
public void handleFile(InputStream stream, String path) throws Exception {
POIFSFileSystem poifs = new POIFSFileSystem(stream);
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 5408e2b437..3b55861325 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,9 +23,6 @@ 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;
@@ -35,7 +32,7 @@ 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(
+ private static final Set<String> EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet(
"document/truncated62886.docx"
);
@@ -44,7 +41,7 @@ class OPCFileHandler extends AbstractFileHandler {
// ignore password protected files
if (POIXMLDocumentHandler.isEncrypted(stream)) return;
- if (EXPECTED_FAILURES.contains(path)) return;
+ if (StressTestUtils.excludeFile(path, EXPECTED_FAILURES)) return;
OPCPackage p = OPCPackage.open(stream);
@@ -80,8 +77,4 @@ 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/StressTestUtils.java b/poi-integration/src/test/java/org/apache/poi/stress/StressTestUtils.java
new file mode 100644
index 0000000000..4d34326d23
--- /dev/null
+++ b/poi-integration/src/test/java/org/apache/poi/stress/StressTestUtils.java
@@ -0,0 +1,33 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.stress;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+public class StressTestUtils {
+ static Set<String> unmodifiableHashSet(String... a) {
+ return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
+ }
+
+ static boolean excludeFile(String path, Set<String> excludeSet) {
+ String modifiedPath = path.replace('\\', '/');
+ return excludeSet.contains(modifiedPath);
+ }
+}
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
index 17e52e413c..e90cdbd810 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java
@@ -16,7 +16,6 @@
==================================================================== */
package org.apache.poi.stress;
-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -78,7 +77,7 @@ public class TestAllFiles {
"**/.git/**",
};
- private static final Set<String> EXPECTED_FAILURES = unmodifiableHashSet(
+ private static final Set<String> EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet(
"document/truncated62886.docx"
);
@@ -118,7 +117,7 @@ public class TestAllFiles {
@ParameterizedTest(name = "#{index} {0} {1}")
@MethodSource("extractFiles")
void handleExtracting(String file, FileHandlerKnown handler, String password, Class<? extends Throwable> exClass, String exMessage) throws IOException {
- if (EXPECTED_FAILURES.contains(file)) return;
+ if (StressTestUtils.excludeFile(file, EXPECTED_FAILURES)) return;
System.out.println("Running extractFiles on "+file);
FileHandler fileHandler = handler.fileHandler.get();
@@ -203,8 +202,4 @@ public class TestAllFiles {
return msg;
}
-
- 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 1c94cd3536..b61128f63f 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
@@ -20,9 +20,6 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import org.apache.poi.ooxml.POIXMLException;
@@ -30,7 +27,7 @@ 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(
+ private static final Set<String> EXPECTED_FAILURES = StressTestUtils.unmodifiableHashSet(
"document/truncated62886.docx"
);
@@ -39,7 +36,7 @@ class XWPFFileHandler extends AbstractFileHandler {
// ignore password protected files
if (POIXMLDocumentHandler.isEncrypted(stream)) return;
- if (EXPECTED_FAILURES.contains(path)) return;
+ if (StressTestUtils.excludeFile(path, EXPECTED_FAILURES)) return;
try (XWPFDocument doc = new XWPFDocument(stream)) {
new POIXMLDocumentHandler().handlePOIXMLDocument(doc);
@@ -62,8 +59,4 @@ class XWPFFileHandler extends AbstractFileHandler {
handleExtracting(file);
}
-
- private static Set<String> unmodifiableHashSet(String... a) {
- return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
- }
} \ No newline at end of file