Skip to content

Commit

Permalink
Enables the verification of log markers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbisutti authored and trask committed Oct 18, 2022
1 parent 5b773d1 commit 2bcb4d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void testTraceLog4j2() throws Exception {
logs.sort(Comparator.comparing(MessageData::getSeverityLevel));

MessageData md1 = logs.get(0);
// MessageData md2 = logs.get(1);
MessageData md2 = logs.get(1);
MessageData md3 = logs.get(2);
MessageData md4 = logs.get(3);

Expand All @@ -70,7 +70,7 @@ void testTraceLog4j2() throws Exception {
assertThat(md1.getProperties()).containsEntry("MDC key", "MDC value");
assertThat(md1.getProperties()).hasSize(4);

// assertThat(md2.getProperties()).containsEntry("Marker", "aMarker");
assertThat(md2.getProperties()).containsEntry("Marker", "aMarker");

assertThat(md3.getMessage()).isEqualTo("This is log4j2 error.");
assertThat(md3.getSeverityLevel()).isEqualTo(SeverityLevel.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ abstract class TraceLogBackTest {

@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create();

boolean checkLogBackCodeAttributes() {
return true;
// Not really sure that Logback is enabled with Wildfly
// https://anotheria.net/blog/devops/enable-logback-in-jboss/
// https://www.oreilly.com/library/view/wildfly-cookbook/9781784392413/ch04s08.html
boolean isWildflyServer() {
return false;
}

@Test
Expand All @@ -57,7 +60,7 @@ void testTraceLogBack() throws Exception {

MessageData md1 = logs.get(0);
MessageData md2 = logs.get(1);
// MessageData md3 = logs.get(2);
MessageData md3 = logs.get(2);

assertThat(md1.getMessage()).isEqualTo("This is logback warn.");
assertThat(md1.getSeverityLevel()).isEqualTo(SeverityLevel.WARNING);
Expand All @@ -67,7 +70,7 @@ void testTraceLogBack() throws Exception {
.containsKey("ThreadName")
.containsEntry("MDC key", "MDC value");

if (checkLogBackCodeAttributes()) {
if (!isWildflyServer()) {
assertThat(md1.getProperties())
.containsEntry("FileName", "SimpleTestTraceLogBackServlet.java")
.containsEntry(
Expand All @@ -87,7 +90,7 @@ void testTraceLogBack() throws Exception {
.containsEntry("LoggerName", "smoketestapp")
.containsKey("ThreadName");

if (checkLogBackCodeAttributes()) {
if (!isWildflyServer()) {
assertThat(md2.getProperties())
.containsEntry("FileName", "SimpleTestTraceLogBackServlet.java")
.containsEntry(
Expand All @@ -100,7 +103,9 @@ void testTraceLogBack() throws Exception {
assertThat(md2.getProperties()).hasSize(3);
}

// assertThat(md3.getProperties()).containsEntry("Marker", "aMarker");
if (!isWildflyServer()) {
assertThat(md3.getProperties()).containsEntry("Marker", "aMarker");
}

SmokeTestExtension.assertParentChild(
rd, rdEnvelope, mdEnvelope1, "GET /TraceLogBackUsingAgent/traceLogBack");
Expand Down Expand Up @@ -136,7 +141,7 @@ void testTraceLogBackWithException() throws Exception {
.containsKey("ThreadName")
.containsEntry("MDC key", "MDC value");

if (checkLogBackCodeAttributes()) {
if (!isWildflyServer()) {
assertThat(ed.getProperties())
.containsEntry("FileName", "SimpleTestTraceLogBackWithExceptionServlet.java")
.containsEntry(
Expand Down Expand Up @@ -177,16 +182,16 @@ static class Tomcat8Java19Test extends TraceLogBackTest {}
@Environment(WILDFLY_13_JAVA_8)
static class Wildfly13Java8Test extends TraceLogBackTest {
@Override
boolean checkLogBackCodeAttributes() {
return false;
boolean isWildflyServer() {
return true;
}
}

@Environment(WILDFLY_13_JAVA_8_OPENJ9)
static class Wildfly13Java8OpenJ9Test extends TraceLogBackTest {
@Override
boolean checkLogBackCodeAttributes() {
return false;
boolean isWildflyServer() {
return true;
}
}
}

0 comments on commit 2bcb4d7

Please sign in to comment.