From 794c71b8eab6c3c1431a0e7c3e1a606dde9c9add Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 15 Oct 2021 14:11:20 +0200 Subject: [PATCH] Initialize the logging layer in case of early exception If the handler has not been activated, we flush the content of the log when we have an exception. Otherwise, the user is missing important information. This is especially important when a resource does not start properly. --- .../test/junit/QuarkusIntegrationTestExtension.java | 4 ++++ .../io/quarkus/test/junit/QuarkusMainTestExtension.java | 7 +++++-- .../java/io/quarkus/test/junit/QuarkusTestExtension.java | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java index 75b0354f45281..e7e91c2ea74a5 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java @@ -30,6 +30,7 @@ import org.junit.jupiter.api.extension.TestInstancePostProcessor; import org.opentest4j.TestAbortedException; +import io.quarkus.bootstrap.logging.InitialConfigurator; import io.quarkus.runtime.test.TestHttpEndpointProvider; import io.quarkus.test.common.ArtifactLauncher; import io.quarkus.test.common.DevServicesContext; @@ -205,6 +206,9 @@ public void close() throws Throwable { return state; } catch (Throwable e) { + if (!InitialConfigurator.DELAYED_HANDLER.isActivated()) { + activateLogging(); + } try { if (testResourceManager != null) { diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainTestExtension.java index ad00572d585da..3e72aa8a89600 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainTestExtension.java @@ -1,5 +1,6 @@ package io.quarkus.test.junit; +import static io.quarkus.test.junit.IntegrationTestUtil.activateLogging; import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources; import java.io.Closeable; @@ -21,6 +22,7 @@ import org.junit.jupiter.api.extension.ParameterResolver; import io.quarkus.bootstrap.app.StartupAction; +import io.quarkus.bootstrap.logging.InitialConfigurator; import io.quarkus.deployment.dev.testing.LogCapturingOutputFilter; import io.quarkus.dev.console.QuarkusConsole; import io.quarkus.dev.testing.TracingHandler; @@ -36,8 +38,6 @@ public class QuarkusMainTestExtension extends AbstractJvmQuarkusTestExtension public static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace .create("io.quarkus.test.main.jvm"); - private static Map devServicesProps; - PrepareResult prepareResult; private static boolean hasPerTestResources; @@ -159,6 +159,9 @@ private int doJavaStart(ExtensionContext context, Class