Skip to content

Commit

Permalink
Fix issue with QuarkusIntegrationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jul 9, 2021
1 parent 6bc1548 commit 1067329
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public void close() throws Throwable {

@Override
public void postProcessTestInstance(Object testInstance, ExtensionContext context) {
ensureStarted(context);
if (!failedBoot) {
doProcessTestInstance(testInstance, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private void populateTestMethodInvokers(ClassLoader quarkusClassLoader) {

@Override
public void beforeEach(ExtensionContext context) throws Exception {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(context.getRequiredTestClass())) {
return;
}
resetHangTimeout();
Expand Down Expand Up @@ -554,7 +554,7 @@ public static String getEndpointPath(ExtensionContext context, List<Function<Cla

@Override
public void afterEach(ExtensionContext context) throws Exception {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(context.getRequiredTestClass())) {
return;
}
resetHangTimeout();
Expand Down Expand Up @@ -618,12 +618,15 @@ public void afterEach(ExtensionContext context) throws Exception {
constructor.newInstance(actualTestInstance, actualTestMethod));
}

private boolean isNativeOrIntegrationTest() {
private boolean isNativeOrIntegrationTest(Class<?> clazz) {
for (Class<?> i : currentTestClassStack) {
if (i.isAnnotationPresent(NativeImageTest.class) || i.isAnnotationPresent(QuarkusIntegrationTest.class)) {
return true;
}
}
if (clazz.isAnnotationPresent(NativeImageTest.class) || clazz.isAnnotationPresent(QuarkusIntegrationTest.class)) {
return true;
}
return false;
}

Expand Down Expand Up @@ -691,7 +694,7 @@ public void beforeAll(ExtensionContext context) throws Exception {
currentTestClassStack.push(context.getRequiredTestClass());
//set the right launch mode in the outer CL, used by the HTTP host config source
ProfileManager.setLaunchMode(LaunchMode.TEST);
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(context.getRequiredTestClass())) {
return;
}
resetHangTimeout();
Expand Down Expand Up @@ -730,7 +733,7 @@ private void popMockContext() {
@Override
public void interceptBeforeAllMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand All @@ -747,7 +750,7 @@ public void interceptBeforeAllMethod(Invocation<Void> invocation, ReflectiveInvo
@Override
public <T> T interceptTestClassConstructor(Invocation<T> invocation,
ReflectiveInvocationContext<Constructor<T>> invocationContext, ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
return invocation.proceed();
}
resetHangTimeout();
Expand Down Expand Up @@ -841,7 +844,7 @@ private void initTestState(ExtensionContext extensionContext, ExtensionState sta
@Override
public void interceptBeforeEachMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand All @@ -852,7 +855,7 @@ public void interceptBeforeEachMethod(Invocation<Void> invocation, ReflectiveInv
@Override
public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand All @@ -863,7 +866,7 @@ public void interceptTestMethod(Invocation<Void> invocation, ReflectiveInvocatio
@Override
public void interceptTestTemplateMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand All @@ -875,7 +878,7 @@ public void interceptTestTemplateMethod(Invocation<Void> invocation, ReflectiveI
@Override
public <T> T interceptTestFactoryMethod(Invocation<T> invocation,
ReflectiveInvocationContext<Method> invocationContext, ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
return invocation.proceed();
}
T result = (T) runExtensionMethod(invocationContext, extensionContext);
Expand All @@ -886,7 +889,7 @@ public <T> T interceptTestFactoryMethod(Invocation<T> invocation,
@Override
public void interceptAfterEachMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand All @@ -897,7 +900,7 @@ public void interceptAfterEachMethod(Invocation<Void> invocation, ReflectiveInvo
@Override
public void interceptAfterAllMethod(Invocation<Void> invocation, ReflectiveInvocationContext<Method> invocationContext,
ExtensionContext extensionContext) throws Throwable {
if (isNativeOrIntegrationTest()) {
if (isNativeOrIntegrationTest(extensionContext.getRequiredTestClass())) {
invocation.proceed();
return;
}
Expand Down Expand Up @@ -1045,7 +1048,7 @@ private Method determineTCCLExtensionMethod(ReflectiveInvocationContext<Method>
public void afterAll(ExtensionContext context) throws Exception {
resetHangTimeout();
try {
if (!isNativeOrIntegrationTest() && (runningQuarkusApplication != null)) {
if (!isNativeOrIntegrationTest(context.getRequiredTestClass()) && (runningQuarkusApplication != null)) {
popMockContext();
}
if (originalCl != null) {
Expand Down

0 comments on commit 1067329

Please sign in to comment.