Adjust thread-names when running integration

This allows to identify in thread-dumps which
file is taking a long time or is causing issues

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897332 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2022-01-22 08:57:46 +00:00
parent 7f1d843752
commit 9d97acc448
1 changed files with 36 additions and 17 deletions

View File

@ -149,13 +149,20 @@ public class TestAllFiles {
@ParameterizedTest(name = "Extracting - #{index} {0} {1}")
@MethodSource("extractFiles")
void handleExtracting(String file, FileHandlerKnown handler, String password, Class<? extends Throwable> exClass, String exMessage) throws IOException {
if (StressTestUtils.excludeFile(file, EXPECTED_FAILURES)) return;
String threadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("Extracting - " + file + " - " + handler);
if (StressTestUtils.excludeFile(file, EXPECTED_FAILURES))
return;
System.out.println("Running extractFiles on "+file);
FileHandler fileHandler = handler.getHandler();
assertNotNull(fileHandler, "Did not find a handler for file " + file);
Executable exec = () -> fileHandler.handleExtracting(new File(ROOT_DIR, file));
verify(file, exec, exClass, exMessage, password);
System.out.println("Running extractFiles on " + file);
FileHandler fileHandler = handler.getHandler();
assertNotNull(fileHandler, "Did not find a handler for file " + file);
Executable exec = () -> fileHandler.handleExtracting(new File(ROOT_DIR, file));
verify(file, exec, exClass, exMessage, password);
} finally {
Thread.currentThread().setName(threadName);
}
}
public static Stream<Arguments> handleFiles() throws IOException {
@ -165,12 +172,18 @@ public class TestAllFiles {
@ParameterizedTest(name = "#{index} {0} {1}")
@MethodSource("handleFiles")
void handleFile(String file, FileHandlerKnown handler, String password, Class<? extends Throwable> exClass, String exMessage) throws IOException {
System.out.println("Running handleFiles on "+file);
FileHandler fileHandler = handler.getHandler();
assertNotNull(fileHandler, "Did not find a handler for file " + file);
try (InputStream stream = new BufferedInputStream(new FileInputStream(new File(ROOT_DIR, file)), 64 * 1024)) {
Executable exec = () -> fileHandler.handleFile(stream, file);
verify(file, exec, exClass, exMessage, password);
String threadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("Handle - " + file + " - " + handler);
System.out.println("Running handleFiles on "+file);
FileHandler fileHandler = handler.getHandler();
assertNotNull(fileHandler, "Did not find a handler for file " + file);
try (InputStream stream = new BufferedInputStream(new FileInputStream(new File(ROOT_DIR, file)), 64 * 1024)) {
Executable exec = () -> fileHandler.handleFile(stream, file);
verify(file, exec, exClass, exMessage, password);
}
} finally {
Thread.currentThread().setName(threadName);
}
}
@ -181,11 +194,17 @@ public class TestAllFiles {
@ParameterizedTest(name = "Additional - #{index} {0} {1}")
@MethodSource("handleAdditionals")
void handleAdditional(String file, FileHandlerKnown handler, String password, Class<? extends Throwable> exClass, String exMessage) {
System.out.println("Running additionals on "+file);
FileHandler fileHandler = handler.getHandler();
assertNotNull(fileHandler, "Did not find a handler for file " + file);
Executable exec = () -> fileHandler.handleAdditional(new File(ROOT_DIR, file));
verify(file, exec, exClass, exMessage, password);
String threadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("Additional - " + file + " - " + handler);
System.out.println("Running additionals on "+file);
FileHandler fileHandler = handler.getHandler();
assertNotNull(fileHandler, "Did not find a handler for file " + file);
Executable exec = () -> fileHandler.handleAdditional(new File(ROOT_DIR, file));
verify(file, exec, exClass, exMessage, password);
} finally {
Thread.currentThread().setName(threadName);
}
}
@SuppressWarnings("unchecked")