aboutsummaryrefslogtreecommitdiffstats
path: root/poi-integration
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2022-01-22 08:57:46 +0000
committerDominik Stadler <centic@apache.org>2022-01-22 08:57:46 +0000
commit9d97acc448776e783163a9afd27203919f203848 (patch)
tree0f2a4aed8e6f4d632fdadb233ac0f8ca7b59e2e7 /poi-integration
parent7f1d84375201a0b5c12203c98638d30e2fa64726 (diff)
downloadpoi-9d97acc448776e783163a9afd27203919f203848.tar.gz
poi-9d97acc448776e783163a9afd27203919f203848.zip
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
Diffstat (limited to 'poi-integration')
-rw-r--r--poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java53
1 files changed, 36 insertions, 17 deletions
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 c584c108d3..ece5daca7a 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
@@ -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")