mirror of https://github.com/apache/poi.git
try to fix integration tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
18e10a1cdd
commit
3c4643af9e
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue