From 41ade968c9be7cca672aaa7f3aebc14b5b41cecd Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Thu, 23 Sep 2021 14:55:51 +0300 Subject: [PATCH] Enable logging from integration tests Fixes: #20303 --- .../java/io/quarkus/test/junit/IntegrationTestUtil.java | 7 +++++++ .../test/junit/QuarkusIntegrationTestExtension.java | 4 +++- .../test/junit/QuarkusMainIntegrationTestExtension.java | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java index 33c9cb3d4a18d..61c720a0856e1 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java @@ -45,6 +45,7 @@ import io.quarkus.bootstrap.utils.BuildToolHelper; import io.quarkus.deployment.builditem.DevServicesLauncherConfigResultBuildItem; import io.quarkus.runtime.configuration.ProfileManager; +import io.quarkus.runtime.logging.LoggingSetupRecorder; import io.quarkus.test.common.ArtifactLauncher; import io.quarkus.test.common.PathTestHelper; import io.quarkus.test.common.TestClassIndexer; @@ -296,6 +297,12 @@ public void accept(String s, String s2) { return new DefaultDevServicesLaunchResult(propertyMap, networkId, curatedApplication); } + static void activateLogging() { + // calling this method of the Recorder essentially sets up logging and configures most things + // based on the provided configuration + LoggingSetupRecorder.handleFailedStart(); + } + static class DefaultDevServicesLaunchResult implements ArtifactLauncher.InitContext.DevServicesLaunchResult { private final Map properties; private final String networkId; 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 4aee12aea1add..0395143536cfa 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 @@ -1,5 +1,6 @@ package io.quarkus.test.junit; +import static io.quarkus.test.junit.IntegrationTestUtil.*; import static io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory; import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties; import static io.quarkus.test.junit.IntegrationTestUtil.doProcessTestInstance; @@ -84,7 +85,7 @@ private IntegrationTestExtensionState ensureStarted(ExtensionContext extensionCo ExtensionContext.Store store = root.getStore(ExtensionContext.Namespace.GLOBAL); IntegrationTestExtensionState state = store.get(IntegrationTestExtensionState.class.getName(), IntegrationTestExtensionState.class); - Class selectedProfile = IntegrationTestUtil.findProfile(testClass); + Class selectedProfile = findProfile(testClass); boolean wrongProfile = !Objects.equals(selectedProfile, quarkusTestProfile); // we reload the test resources if we changed test class and if we had or will have per-test test resources boolean reloadTestResources = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass) @@ -184,6 +185,7 @@ public void close() throws Throwable { "Artifact type + '" + artifactType + "' is not supported by @QuarkusIntegrationTest"); } + activateLogging(); startLauncher(launcher, additionalProperties, () -> ssl = true); IntegrationTestExtensionState state = new IntegrationTestExtensionState(testResourceManager, launcher, diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainIntegrationTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainIntegrationTestExtension.java index 05520715721a7..e50da9059ac40 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainIntegrationTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusMainIntegrationTestExtension.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.determineBuildOutputDirectory; import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties; import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources; @@ -148,6 +149,7 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S } launcher.includeAsSysProps(additionalProperties); + activateLogging(); return launcher.runToCompletion(args); } finally {