From eb5c7074e3828aef7d933d887e7fe47b19c467e1 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Wed, 14 Jun 2023 09:08:03 +0100 Subject: [PATCH] Only invoke public no args callbacks in Arquillian testing --- .../java/io/quarkus/arquillian/QuarkusJunitCallbacks.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test-framework/arquillian/src/main/java/io/quarkus/arquillian/QuarkusJunitCallbacks.java b/test-framework/arquillian/src/main/java/io/quarkus/arquillian/QuarkusJunitCallbacks.java index e9d5ee5154241..e4f6f3c00dcc7 100644 --- a/test-framework/arquillian/src/main/java/io/quarkus/arquillian/QuarkusJunitCallbacks.java +++ b/test-framework/arquillian/src/main/java/io/quarkus/arquillian/QuarkusJunitCallbacks.java @@ -23,7 +23,9 @@ static void invokeJunitBefores(String className, Object testInstance) collectCallbacks(testInstance.getClass(), befores, (Class) testInstance.getClass() .getClassLoader().loadClass(className)); for (Method before : befores) { - before.invoke(testInstance); + if (before.canAccess(testInstance) && before.getParameters().length == 0) { + before.invoke(testInstance); + } } } } @@ -35,7 +37,9 @@ static void invokeJunitAfters(String className, Object testInstance) collectCallbacks(testInstance.getClass(), afters, (Class) testInstance.getClass() .getClassLoader().loadClass(className)); for (Method after : afters) { - after.invoke(testInstance); + if (after.canAccess(testInstance) && after.getParameters().length == 0) { + after.invoke(testInstance); + } } } }