parent
753bbf4785
commit
8efdc1e46d
|
@ -20,6 +20,8 @@ jobs:
|
||||||
toolchain: false
|
toolchain: false
|
||||||
- version: 21
|
- version: 21
|
||||||
toolchain: true
|
toolchain: true
|
||||||
|
- version: 22
|
||||||
|
toolchain: true
|
||||||
exclude:
|
exclude:
|
||||||
- os:
|
- os:
|
||||||
name: Linux
|
name: Linux
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,6 +25,8 @@ import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
|
import org.springframework.boot.ansi.AnsiOutput;
|
||||||
|
import org.springframework.boot.ansi.AnsiOutput.Enabled;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.contentOf;
|
import static org.assertj.core.api.Assertions.contentOf;
|
||||||
|
@ -42,18 +44,39 @@ public abstract class AbstractLoggingSystemTests {
|
||||||
|
|
||||||
private String originalTempDirectory;
|
private String originalTempDirectory;
|
||||||
|
|
||||||
|
private AnsiOutput.Enabled ansiOutputEnabled;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void configureTempDir(@TempDir Path temp) {
|
void beforeEach(@TempDir Path temp) {
|
||||||
|
disableAnsiOutput();
|
||||||
|
configureTempDir(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableAnsiOutput() {
|
||||||
|
this.ansiOutputEnabled = AnsiOutput.getEnabled();
|
||||||
|
AnsiOutput.setEnabled(Enabled.NEVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureTempDir(@TempDir Path temp) {
|
||||||
this.originalTempDirectory = System.getProperty(JAVA_IO_TMPDIR);
|
this.originalTempDirectory = System.getProperty(JAVA_IO_TMPDIR);
|
||||||
System.setProperty(JAVA_IO_TMPDIR, temp.toAbsolutePath().toString());
|
System.setProperty(JAVA_IO_TMPDIR, temp.toAbsolutePath().toString());
|
||||||
MDC.clear();
|
MDC.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void reinstateTempDir() {
|
void afterEach() {
|
||||||
|
reinstateTempDir();
|
||||||
|
restoreAnsiOutputEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reinstateTempDir() {
|
||||||
System.setProperty(JAVA_IO_TMPDIR, this.originalTempDirectory);
|
System.setProperty(JAVA_IO_TMPDIR, this.originalTempDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restoreAnsiOutputEnabled() {
|
||||||
|
AnsiOutput.setEnabled(this.ansiOutputEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void clear() {
|
void clear() {
|
||||||
for (LoggingSystemProperty property : LoggingSystemProperty.values()) {
|
for (LoggingSystemProperty property : LoggingSystemProperty.values()) {
|
||||||
|
|
Loading…
Reference in New Issue