Skip to content

Commit

Permalink
Merge pull request #27275 from luc-rovio/Issue_27212
Browse files Browse the repository at this point in the history
Take RunOnVertxContext into account when annotated on class
  • Loading branch information
gsmet authored Aug 17, 2022
2 parents c3d6891 + 5373e4f commit 8a5d1df
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public Object invoke(Object actualTestInstance, Method actualTestMethod, List<Ob
RunTestMethodOnContextHandler handler = new RunTestMethodOnContextHandler(actualTestInstance, actualTestMethod,
actualTestMethodArgs, uniAsserter, cf);
Context context = vertx.getOrCreateContext();
boolean shouldDuplicateContext = shouldContextBeDuplicated(actualTestMethod);
boolean shouldDuplicateContext = shouldContextBeDuplicated(
actualTestInstance != null ? actualTestInstance.getClass() : Object.class, actualTestMethod);
if (shouldDuplicateContext) {
context = VertxContext.getOrCreateDuplicatedContext(context);
VertxContextSafetyToggle.setContextSafe(context, true);
Expand All @@ -95,8 +96,11 @@ public Object invoke(Object actualTestInstance, Method actualTestMethod, List<Ob
}
}

private boolean shouldContextBeDuplicated(Method m) {
final RunOnVertxContext runOnVertxContext = m.getAnnotation(RunOnVertxContext.class);
private boolean shouldContextBeDuplicated(Class<?> c, Method m) {
RunOnVertxContext runOnVertxContext = m.getAnnotation(RunOnVertxContext.class);
if (runOnVertxContext == null) {
runOnVertxContext = c.getAnnotation(RunOnVertxContext.class);
}
if (runOnVertxContext == null) {
return false;
} else {
Expand Down

0 comments on commit 8a5d1df

Please sign in to comment.