From 81fd441cb188a7e4f5fbabc44d7a0b22c60a33c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Fri, 4 Dec 2020 12:19:15 +0100 Subject: [PATCH] Refactory min-level unset tests for better naming --- .../LoggingMinLevelAbove.java} | 9 +++++---- .../LoggingMinLevelByDefault.java} | 10 ++++++---- .../LoggingMinLevelPromote.java} | 8 ++++---- ...rceTest.java => LoggingMinLevelAboveTest.java} | 12 ++++++++---- ...est.java => LoggingMinLevelByDefaultTest.java} | 12 ++++++++---- ...eTest.java => LoggingMinLevelPromoteTest.java} | 15 +++++++++++---- ...java => NativeLoggingMinLevelByDefaultIT.java} | 2 +- ...T.java => NativeLoggingMinLevelPromoteIT.java} | 2 +- .../unset/NativeLoggingWarnResourceIT.java | 2 +- .../minlevel/unset/SetRuntimeLogLevels.java | 4 ++-- 10 files changed, 47 insertions(+), 29 deletions(-) rename integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/{warn/LoggingWarnResource.java => above/LoggingMinLevelAbove.java} (80%) rename integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/{LoggingResource.java => bydefault/LoggingMinLevelByDefault.java} (73%) rename integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/{trace/LoggingTraceResource.java => promote/LoggingMinLevelPromote.java} (80%) rename integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/{LoggingWarnResourceTest.java => LoggingMinLevelAboveTest.java} (69%) rename integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/{LoggingTraceResourceTest.java => LoggingMinLevelByDefaultTest.java} (70%) rename integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/{LoggingResourceTest.java => LoggingMinLevelPromoteTest.java} (64%) rename integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/{NativeLoggingTraceResourceIT.java => NativeLoggingMinLevelByDefaultIT.java} (65%) rename integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/{NativeLoggingResourceIT.java => NativeLoggingMinLevelPromoteIT.java} (66%) diff --git a/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/warn/LoggingWarnResource.java b/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/above/LoggingMinLevelAbove.java similarity index 80% rename from integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/warn/LoggingWarnResource.java rename to integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/above/LoggingMinLevelAbove.java index 4cd8c3dd96502..f2982156233e5 100644 --- a/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/warn/LoggingWarnResource.java +++ b/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/above/LoggingMinLevelAbove.java @@ -1,4 +1,4 @@ -package io.quarkus.it.logging.minlevel.unset.warn; +package io.quarkus.it.logging.minlevel.unset.above; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -9,9 +9,10 @@ import io.quarkus.it.logging.minlevel.unset.LoggingWitness; -@Path("/log/warn") -public class LoggingWarnResource { - static final Logger LOG = Logger.getLogger(LoggingWarnResource.class); +@Path("/log/above") +public class LoggingMinLevelAbove { + + static final Logger LOG = Logger.getLogger(LoggingMinLevelAbove.class); @GET @Path("/not-info") diff --git a/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/LoggingResource.java b/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/bydefault/LoggingMinLevelByDefault.java similarity index 73% rename from integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/LoggingResource.java rename to integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/bydefault/LoggingMinLevelByDefault.java index f12aa732008a3..0a6c206c6f067 100644 --- a/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/LoggingResource.java +++ b/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/bydefault/LoggingMinLevelByDefault.java @@ -1,4 +1,4 @@ -package io.quarkus.it.logging.minlevel.unset; +package io.quarkus.it.logging.minlevel.unset.bydefault; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -7,10 +7,12 @@ import org.jboss.logging.Logger; -@Path("/log/default") -public class LoggingResource { +import io.quarkus.it.logging.minlevel.unset.LoggingWitness; - static final Logger LOG = Logger.getLogger(LoggingResource.class); +@Path("/log/bydefault") +public class LoggingMinLevelByDefault { + + static final Logger LOG = Logger.getLogger(LoggingMinLevelByDefault.class); @GET @Path("/info") diff --git a/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/trace/LoggingTraceResource.java b/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/promote/LoggingMinLevelPromote.java similarity index 80% rename from integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/trace/LoggingTraceResource.java rename to integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/promote/LoggingMinLevelPromote.java index 4ca35fb7ad6ec..4bc35d2dc7cd9 100644 --- a/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/trace/LoggingTraceResource.java +++ b/integration-tests/logging-min-level-unset/src/main/java/io/quarkus/it/logging/minlevel/unset/promote/LoggingMinLevelPromote.java @@ -1,4 +1,4 @@ -package io.quarkus.it.logging.minlevel.unset.trace; +package io.quarkus.it.logging.minlevel.unset.promote; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -9,9 +9,9 @@ import io.quarkus.it.logging.minlevel.unset.LoggingWitness; -@Path("/log/trace") -public class LoggingTraceResource { - static final Logger LOG = Logger.getLogger(LoggingTraceResource.class); +@Path("/log/promote") +public class LoggingMinLevelPromote { + static final Logger LOG = Logger.getLogger(LoggingMinLevelPromote.class); @GET @Path("/info") diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingWarnResourceTest.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelAboveTest.java similarity index 69% rename from integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingWarnResourceTest.java rename to integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelAboveTest.java index 5a6a6549487e5..0e8ef8cb344d3 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingWarnResourceTest.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelAboveTest.java @@ -8,14 +8,18 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +/** + * This test verifies that a runtime log level can go above the default min-level, + * and only messages at same runtime log level or above are shown. + */ @QuarkusTest @QuarkusTestResource(SetRuntimeLogLevels.class) -public class LoggingWarnResourceTest { +public class LoggingMinLevelAboveTest { @Test public void testNotInfo() { given() - .when().get("/log/warn/not-info") + .when().get("/log/above/not-info") .then() .statusCode(200) .body(is("true")); @@ -24,7 +28,7 @@ public void testNotInfo() { @Test public void testWarn() { given() - .when().get("/log/warn/warn") + .when().get("/log/above/warn") .then() .statusCode(200) .body(is("true")); @@ -33,7 +37,7 @@ public void testWarn() { @Test public void testNotTrace() { given() - .when().get("/log/warn/not-trace") + .when().get("/log/above/not-trace") .then() .statusCode(200) .body(is("true")); diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingTraceResourceTest.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelByDefaultTest.java similarity index 70% rename from integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingTraceResourceTest.java rename to integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelByDefaultTest.java index 59dd900903b87..423be57b74ef0 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingTraceResourceTest.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelByDefaultTest.java @@ -8,14 +8,18 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +/** + * Tests that logging works as expected when min-level is default, + * and there's no applicable runtime log level override. + */ @QuarkusTest @QuarkusTestResource(SetRuntimeLogLevels.class) -public class LoggingTraceResourceTest { +public class LoggingMinLevelByDefaultTest { @Test public void testInfo() { given() - .when().get("/log/trace/info") + .when().get("/log/bydefault/info") .then() .statusCode(200) .body(is("true")); @@ -24,7 +28,7 @@ public void testInfo() { @Test public void testWarn() { given() - .when().get("/log/trace/warn") + .when().get("/log/bydefault/warn") .then() .statusCode(200) .body(is("true")); @@ -33,7 +37,7 @@ public void testWarn() { @Test public void testNotTrace() { given() - .when().get("/log/trace/not-trace") + .when().get("/log/bydefault/not-trace") .then() .statusCode(200) .body(is("true")); diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingResourceTest.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelPromoteTest.java similarity index 64% rename from integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingResourceTest.java rename to integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelPromoteTest.java index 39285decef49a..59823e68a3f10 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingResourceTest.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/LoggingMinLevelPromoteTest.java @@ -8,14 +8,21 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +/** + * This test verifies that log levels are promoted to min-level when set below the default min-level. + * + * So given the default min-level is INFO, + * so if log level is set to TRACE, + * it will be automatically promoted to INFO. + */ @QuarkusTest @QuarkusTestResource(SetRuntimeLogLevels.class) -public class LoggingResourceTest { +public class LoggingMinLevelPromoteTest { @Test public void testInfo() { given() - .when().get("/log/default/info") + .when().get("/log/promote/info") .then() .statusCode(200) .body(is("true")); @@ -24,7 +31,7 @@ public void testInfo() { @Test public void testWarn() { given() - .when().get("/log/default/warn") + .when().get("/log/promote/warn") .then() .statusCode(200) .body(is("true")); @@ -33,7 +40,7 @@ public void testWarn() { @Test public void testNotTrace() { given() - .when().get("/log/warn/not-trace") + .when().get("/log/promote/not-trace") .then() .statusCode(200) .body(is("true")); diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingTraceResourceIT.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingMinLevelByDefaultIT.java similarity index 65% rename from integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingTraceResourceIT.java rename to integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingMinLevelByDefaultIT.java index 6bde2773c2fa5..40746cab36c33 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingTraceResourceIT.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingMinLevelByDefaultIT.java @@ -3,7 +3,7 @@ import io.quarkus.test.junit.NativeImageTest; @NativeImageTest -public class NativeLoggingTraceResourceIT extends LoggingTraceResourceTest { +public class NativeLoggingMinLevelByDefaultIT extends LoggingMinLevelByDefaultTest { // Execute the same tests but in native mode. } diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingResourceIT.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingMinLevelPromoteIT.java similarity index 66% rename from integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingResourceIT.java rename to integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingMinLevelPromoteIT.java index 0dea9ee67bba2..d046b36e4b955 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingResourceIT.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingMinLevelPromoteIT.java @@ -3,7 +3,7 @@ import io.quarkus.test.junit.NativeImageTest; @NativeImageTest -public class NativeLoggingResourceIT extends LoggingResourceTest { +public class NativeLoggingMinLevelPromoteIT extends LoggingMinLevelPromoteTest { // Execute the same tests but in native mode. } diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingWarnResourceIT.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingWarnResourceIT.java index 116ec6c9ede7b..9d0000a87df99 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingWarnResourceIT.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/NativeLoggingWarnResourceIT.java @@ -3,7 +3,7 @@ import io.quarkus.test.junit.NativeImageTest; @NativeImageTest -public class NativeLoggingWarnResourceIT extends LoggingWarnResourceTest { +public class NativeLoggingWarnResourceIT extends LoggingMinLevelAboveTest { // Execute the same tests but in native mode. } diff --git a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/SetRuntimeLogLevels.java b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/SetRuntimeLogLevels.java index bde6a57436950..777bb6e0db2fc 100644 --- a/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/SetRuntimeLogLevels.java +++ b/integration-tests/logging-min-level-unset/src/test/java/io/quarkus/it/logging/minlevel/unset/SetRuntimeLogLevels.java @@ -10,8 +10,8 @@ public final class SetRuntimeLogLevels implements QuarkusTestResourceLifecycleMa @Override public Map start() { final Map systemProperties = new HashMap<>(); - systemProperties.put("quarkus.log.category.\"io.quarkus.it.logging.minlevel.unset.warn\".level", "WARN"); - systemProperties.put("quarkus.log.category.\"io.quarkus.it.logging.minlevel.unset.trace\".level", "TRACE"); + systemProperties.put("quarkus.log.category.\"io.quarkus.it.logging.minlevel.unset.above\".level", "WARN"); + systemProperties.put("quarkus.log.category.\"io.quarkus.it.logging.minlevel.unset.promote\".level", "TRACE"); return systemProperties; }