StackTraceTests Class — spring-boot Architecture
Architecture documentation for the StackTraceTests class in StructuredLoggingJsonPropertiesTests.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java lines 113–222
@Nested
class StackTraceTests {
@Test
void createPrinterWhenEmptyReturnsNull() {
StackTrace properties = new StackTrace(null, null, null, null, null, null);
assertThat(properties.createPrinter()).isNull();
}
@Test
void createPrinterWhenNoPrinterAndNotEmptyReturnsStandard() {
StackTrace properties = new StackTrace(null, Root.LAST, null, null, null, null);
assertThat(properties.createPrinter()).isInstanceOf(StandardStackTracePrinter.class);
}
@Test
void createPrinterWhenLoggingSystemReturnsNull() {
StackTrace properties = new StackTrace("logging-system", null, null, null, null, null);
assertThat(properties.createPrinter()).isNull();
}
@Test
void createPrinterWhenLoggingSystemRelaxedReturnsNull() {
StackTrace properties = new StackTrace("LoggingSystem", null, null, null, null, null);
assertThat(properties.createPrinter()).isNull();
}
@Test
void createPrinterWhenStandardReturnsStandardPrinter() {
StackTrace properties = new StackTrace("standard", null, null, null, null, null);
assertThat(properties.createPrinter()).isInstanceOf(StandardStackTracePrinter.class);
}
@Test
void createPrinterWhenStandardRelaxedReturnsStandardPrinter() {
StackTrace properties = new StackTrace("STANDARD", null, null, null, null, null);
assertThat(properties.createPrinter()).isInstanceOf(StandardStackTracePrinter.class);
}
@Test
void createPrinterWhenStandardAppliesCustomizations() {
Exception exception = TestException.create();
StackTrace properties = new StackTrace(null, Root.FIRST, 300, 2, true, false);
StandardStackTracePrinter printer = (StandardStackTracePrinter) properties.createPrinter();
assertThat(printer).isNotNull();
printer = printer.withLineSeparator("\n");
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
assertThat(actual).isEqualToNormalizingNewlines("""
java.lang.RuntimeException: root
at org.springframework.boot.logging.TestException.createTestException(TestException.java:NN)
at org.springframework.boot.logging.TestException$CreatorThread.run(TestException.java:NN)
Wrapped by: java.lang.RuntimeException: cause
at org.springframework.boot.log...""");
}
@Test
void createPrinterWhenStandardWithHashesPrintsHash() {
Exception exception = TestException.create();
StackTrace properties = new StackTrace(null, null, null, null, null, true);
StackTracePrinter printer = properties.createPrinter();
assertThat(printer).isNotNull();
String actual = printer.printStackTraceToString(exception);
assertThat(actual).containsPattern("<#[0-9a-z]{8}>");
}
@Test
void createPrinterWhenClassNameCreatesPrinter() {
Exception exception = TestException.create();
StackTrace properties = new StackTrace(TestStackTracePrinter.class.getName(), null, null, null, true, null);
StackTracePrinter printer = properties.createPrinter();
assertThat(printer).isNotNull();
assertThat(printer.printStackTraceToString(exception)).isEqualTo("java.lang.RuntimeException: exception");
}
@Test
void createPrinterWhenClassNameInjectsConfiguredPrinter() {
Exception exception = TestException.create();
StackTrace properties = new StackTrace(TestStackTracePrinterCustomized.class.getName(), Root.FIRST, 300, 2,
true, null);
StackTracePrinter printer = properties.createPrinter();
assertThat(printer).isNotNull();
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
assertThat(actual).isEqualTo("RuntimeExceptionroot! at org.springfr...");
}
@Test
void hasCustomPrinterShouldReturnFalseWhenPrinterIsEmpty() {
StackTrace stackTrace = new StackTrace("", null, null, null, null, null);
assertThat(stackTrace.hasCustomPrinter()).isFalse();
}
@Test
void hasCustomPrinterShouldReturnFalseWhenPrinterHasLoggingSystem() {
StackTrace stackTrace = new StackTrace("loggingsystem", null, null, null, null, null);
assertThat(stackTrace.hasCustomPrinter()).isFalse();
}
@Test
void hasCustomPrinterShouldReturnFalseWhenPrinterHasStandard() {
StackTrace stackTrace = new StackTrace("standard", null, null, null, null, null);
assertThat(stackTrace.hasCustomPrinter()).isFalse();
}
@Test
void hasCustomPrinterShouldReturnTrueWhenPrinterHasCustom() {
StackTrace stackTrace = new StackTrace("custom-printer", null, null, null, null, null);
assertThat(stackTrace.hasCustomPrinter()).isTrue();
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free