mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '3.2.x'
Closes gh-39824
This commit is contained in:
commit
5c6140f858
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -20,6 +20,8 @@ jobs:
|
||||
toolchain: false
|
||||
- version: 21
|
||||
toolchain: true
|
||||
- version: 22
|
||||
toolchain: true
|
||||
exclude:
|
||||
- os:
|
||||
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");
|
||||
* 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.slf4j.MDC;
|
||||
|
||||
import org.springframework.boot.ansi.AnsiOutput;
|
||||
import org.springframework.boot.ansi.AnsiOutput.Enabled;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.contentOf;
|
||||
@ -42,18 +44,39 @@ public abstract class AbstractLoggingSystemTests {
|
||||
|
||||
private String originalTempDirectory;
|
||||
|
||||
private AnsiOutput.Enabled ansiOutputEnabled;
|
||||
|
||||
@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);
|
||||
System.setProperty(JAVA_IO_TMPDIR, temp.toAbsolutePath().toString());
|
||||
MDC.clear();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void reinstateTempDir() {
|
||||
void afterEach() {
|
||||
reinstateTempDir();
|
||||
restoreAnsiOutputEnabled();
|
||||
}
|
||||
|
||||
private void reinstateTempDir() {
|
||||
System.setProperty(JAVA_IO_TMPDIR, this.originalTempDirectory);
|
||||
}
|
||||
|
||||
private void restoreAnsiOutputEnabled() {
|
||||
AnsiOutput.setEnabled(this.ansiOutputEnabled);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void clear() {
|
||||
for (LoggingSystemProperty property : LoggingSystemProperty.values()) {
|
||||
|
Loading…
Reference in New Issue
Block a user