Skip to content

Commit

Permalink
Refactory min-level unset tests for better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
galderz committed Dec 4, 2020
1 parent cae32ee commit 81fd441
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public final class SetRuntimeLogLevels implements QuarkusTestResourceLifecycleMa
@Override
public Map<String, String> start() {
final Map<String, String> 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;
}

Expand Down

0 comments on commit 81fd441

Please sign in to comment.