ReactorContextTestExecutionListener should use named hooks
Fixes: gh-6075
This commit is contained in:
committed by
Rob Winch
parent
59e138cb6a
commit
9eb58c94e0
+3
-2
@@ -44,6 +44,7 @@ public class ReactorContextTestExecutionListener
|
||||
extends DelegatingTestExecutionListener {
|
||||
|
||||
private static final String HOOKS_CLASS_NAME = "reactor.core.publisher.Hooks";
|
||||
private static final String CONTEXT_OPERATOR_KEY = SecurityContext.class.getName();
|
||||
|
||||
public ReactorContextTestExecutionListener() {
|
||||
super(createDelegate());
|
||||
@@ -59,12 +60,12 @@ public class ReactorContextTestExecutionListener
|
||||
@Override
|
||||
public void beforeTestMethod(TestContext testContext) throws Exception {
|
||||
SecurityContext securityContext = TestSecurityContextHolder.getContext();
|
||||
Hooks.onLastOperator(Operators.lift((s, sub) -> new SecuritySubContext<>(sub, securityContext)));
|
||||
Hooks.onLastOperator(CONTEXT_OPERATOR_KEY, Operators.lift((s, sub) -> new SecuritySubContext<>(sub, securityContext)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTestMethod(TestContext testContext) throws Exception {
|
||||
Hooks.resetOnLastOperator();
|
||||
Hooks.resetOnLastOperator(CONTEXT_OPERATOR_KEY);
|
||||
}
|
||||
|
||||
private static class SecuritySubContext<T> implements CoreSubscriber<T> {
|
||||
|
||||
Reference in New Issue
Block a user