Home / Class/ AbstractLoggingSystemTests Class — spring-boot Architecture

AbstractLoggingSystemTests Class — spring-boot Architecture

Architecture documentation for the AbstractLoggingSystemTests class in AbstractLoggingSystemTests.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/test/java/org/springframework/boot/logging/AbstractLoggingSystemTests.java lines 42–105

public abstract class AbstractLoggingSystemTests {

	private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";

	private String originalTempDirectory;

	@BeforeEach
	void configureTempDir(@TempDir Path temp) throws IOException {
		this.originalTempDirectory = System.getProperty(JAVA_IO_TMPDIR);
		Files.delete(Files.createTempFile("prevent", "pollution"));
		File.createTempFile("prevent", "pollution").delete();
		System.setProperty(JAVA_IO_TMPDIR, temp.toAbsolutePath().toString());
		MDC.clear();
	}

	@AfterEach
	void reinstateTempDir() {
		System.setProperty(JAVA_IO_TMPDIR, this.originalTempDirectory);
	}

	@AfterEach
	void clear() {
		for (LoggingSystemProperty property : LoggingSystemProperty.values()) {
			System.getProperties().remove(property.getEnvironmentVariableName());
		}
		MDC.clear();
	}

	protected final String[] getSpringConfigLocations(AbstractLoggingSystem system) {
		return system.getSpringConfigLocations();
	}

	protected final LogFile getLogFile(@Nullable String file, @Nullable String path) {
		return getLogFile(file, path, true);
	}

	protected final LogFile getLogFile(@Nullable String file, @Nullable String path, boolean applyToSystemProperties) {
		LogFile logFile = new LogFile(file, path);
		if (applyToSystemProperties) {
			logFile.applyToSystemProperties();
		}
		return logFile;
	}

	protected final String tmpDir() {
		String path = StringUtils.cleanPath(System.getProperty(JAVA_IO_TMPDIR));
		if (path.endsWith("/")) {
			path = path.substring(0, path.length() - 1);
		}
		return path;
	}

	protected final @Nullable String getLineWithText(File file, CharSequence outputSearch) {
		return getLineWithText(contentOf(file), outputSearch);
	}

	protected final @Nullable String getLineWithText(CharSequence output, CharSequence outputSearch) {
		return Arrays.stream(output.toString().split("\\r?\\n"))
			.filter((line) -> line.contains(outputSearch))
			.findFirst()
			.orElse(null);
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free