|
|
|
@ -18,8 +18,6 @@ package org.springframework.boot.actuate.logging;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
|
|
|
|
@ -30,9 +28,9 @@ import org.junit.jupiter.api.io.TempDir;
|
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
|
import org.springframework.mock.env.MockEnvironment;
|
|
|
|
|
import org.springframework.util.FileCopyUtils;
|
|
|
|
|
import org.springframework.util.StreamUtils;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.assertj.core.api.Assertions.contentOf;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests for {@link LogFileWebEndpoint}.
|
|
|
|
@ -71,7 +69,7 @@ class LogFileWebEndpointTests {
|
|
|
|
|
this.environment.setProperty("logging.file.name", this.logFile.getAbsolutePath());
|
|
|
|
|
Resource resource = this.endpoint.logFile();
|
|
|
|
|
assertThat(resource).isNotNull();
|
|
|
|
|
assertThat(contentOf(resource)).isEqualTo("--TEST--");
|
|
|
|
|
assertThat(contentOf(resource.getFile())).isEqualTo("--TEST--");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -80,7 +78,7 @@ class LogFileWebEndpointTests {
|
|
|
|
|
this.environment.setProperty("logging.file", this.logFile.getAbsolutePath());
|
|
|
|
|
Resource resource = this.endpoint.logFile();
|
|
|
|
|
assertThat(resource).isNotNull();
|
|
|
|
|
assertThat(contentOf(resource)).isEqualTo("--TEST--");
|
|
|
|
|
assertThat(contentOf(resource.getFile())).isEqualTo("--TEST--");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -88,13 +86,7 @@ class LogFileWebEndpointTests {
|
|
|
|
|
LogFileWebEndpoint endpoint = new LogFileWebEndpoint(this.environment, this.logFile);
|
|
|
|
|
Resource resource = endpoint.logFile();
|
|
|
|
|
assertThat(resource).isNotNull();
|
|
|
|
|
assertThat(contentOf(resource)).isEqualTo("--TEST--");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String contentOf(Resource resource) throws IOException {
|
|
|
|
|
try (InputStream input = resource.getInputStream()) {
|
|
|
|
|
return StreamUtils.copyToString(input, StandardCharsets.UTF_8);
|
|
|
|
|
}
|
|
|
|
|
assertThat(contentOf(resource.getFile())).isEqualTo("--TEST--");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|