Skip to content

Commit

Permalink
Fix location-based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppkarwasz committed Jan 15, 2024
1 parent 6709cd1 commit c46b89d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void builder() {
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 3);
assertEquals(
"org.apache.logging.log4j.core.LoggerTest.builder(LoggerTest.java:123)",
"org.apache.logging.log4j.core.LoggerTest.builder(LoggerTest.java:129)",
events.get(0).getSource().toString(),
"Incorrect location");
assertEquals(Level.DEBUG, events.get(0).getLevel(), "Incorrect Level");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testMarkerPatternSelector(@Named("List") final ListAppender app) {
final String expect = String.format(
"[TRACE] TestMarkerPatternSelector ====== "
+ "o.a.l.l.c.PatternSelectorTest.testMarkerPatternSelector:%d Enter ======%n",
CURRENT_LINE + 4);
CURRENT_LINE + 5);
assertEquals(expect, messages.get(0));
assertEquals("[INFO ] TestMarkerPatternSelector Hello World" + Strings.LINE_SEPARATOR, messages.get(1));
app.clear();
Expand All @@ -73,12 +73,12 @@ public void testScriptPatternSelector(@Named("List2") final ListAppender app) {
String expect = String.format(
"[TRACE] TestScriptPatternSelector ====== "
+ "o.a.l.l.c.PatternSelectorTest.testScriptPatternSelector:%d Enter ======%n",
CURRENT_LINE + 26);
CURRENT_LINE + 27);
assertEquals(expect, messages.get(0));
expect = String.format(
"[INFO ] TestScriptPatternSelector o.a.l.l.c.PatternSelectorTest.testScriptPatternSelector.%d "
+ "Hello World%n",
CURRENT_LINE + 27);
CURRENT_LINE + 28);
assertEquals(expect, messages.get(1));
assertEquals("[INFO ] NoLocation No location information" + Strings.LINE_SEPARATOR, messages.get(2));
app.clear();
Expand All @@ -101,12 +101,12 @@ public void testJavaScriptPatternSelector(@Named("List3") final ListAppender app
String expect = String.format(
"[TRACE] TestJavaScriptPatternSelector ====== "
+ "o.a.l.l.c.PatternSelectorTest.testJavaScriptPatternSelector:%d Enter ======%n",
CURRENT_LINE + 54);
CURRENT_LINE + 55);
assertEquals(expect, messages.get(0));
expect = String.format(
"[INFO ] TestJavaScriptPatternSelector "
+ "o.a.l.l.c.PatternSelectorTest.testJavaScriptPatternSelector.%d Hello World%n",
CURRENT_LINE + 55);
CURRENT_LINE + 56);
assertEquals(expect, messages.get(1));
assertEquals("[INFO ] JavascriptNoLocation No location information" + Strings.LINE_SEPARATOR, messages.get(2));
app.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void testMemMapLocation(final LoggerContext context) throws Exception {
both(hasSize(2))
.and(
contains(
"org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderTest.testMemMapLocation(MemoryMappedFileAppenderTest.java:103): Test log1",
"org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderTest.testMemMapLocation(MemoryMappedFileAppenderTest.java:106): Test log2")));
"org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderTest.testMemMapLocation(MemoryMappedFileAppenderTest.java:105): Test log1",
"org.apache.logging.log4j.core.appender.MemoryMappedFileAppenderTest.testMemMapLocation(MemoryMappedFileAppenderTest.java:108): Test log2")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testCustomPattern() {
formatter.format(event, buf);
}
final String str = buf.toString();
final String expected = "INFO [PatternParserTest :98 ] - Hello, world" + Strings.LINE_SEPARATOR;
final String expected = "INFO [PatternParserTest :100 ] - Hello, world" + Strings.LINE_SEPARATOR;
assertTrue(str.endsWith(expected), "Expected to end with: " + expected + ". Actual: " + str);
}

Expand Down

0 comments on commit c46b89d

Please sign in to comment.