Skip to content

Commit

Permalink
MidpointTestContextWithTask: test name is used for thread name
Browse files Browse the repository at this point in the history
This was previously done for unit tests only.
  • Loading branch information
virgo47 committed Feb 11, 2022
1 parent d818ee7 commit d0a710e
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
* Copyright (c) 2019 Evolveum and contributors
* Copyright (C) 2019-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.test;

import com.evolveum.midpoint.schema.result.OperationResult;
Expand Down Expand Up @@ -42,13 +41,16 @@ public final class MidpointTestContextWithTask implements MidpointTestContext {
*/
private final OperationResult result;

private final String originalThreadName;

private MidpointTestContextWithTask(
Class<?> testClass, String methodName, Task task, OperationResult result) {

this.testClass = testClass;
this.methodName = methodName;
this.task = task;
this.result = result;
this.originalThreadName = Thread.currentThread().getName();
}

@Override
Expand All @@ -74,6 +76,7 @@ public static MidpointTestContextWithTask create(

MidpointTestContextWithTask ctx =
new MidpointTestContextWithTask(testClass, methodName, task, result);
Thread.currentThread().setName(ctx.getTestName());
TEST_CONTEXT_THREAD_LOCAL.set(ctx);
return ctx;
}
Expand All @@ -83,6 +86,7 @@ public static MidpointTestContextWithTask get() {
}

public static void destroy() {
Thread.currentThread().setName(get().originalThreadName);
TEST_CONTEXT_THREAD_LOCAL.remove();
}
}

0 comments on commit d0a710e

Please sign in to comment.