Skip to content

Commit 6164e3e

Browse files
committed
Merge branch '2.1.x'
2 parents d590c3e + aebb60d commit 6164e3e

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@
1616

1717
package org.springframework.boot.context.logging;
1818

19+
import java.io.File;
20+
1921
import org.junit.jupiter.api.Test;
2022
import org.junit.jupiter.api.extension.ExtendWith;
23+
import org.junit.jupiter.api.io.TempDir;
2124
import org.slf4j.Logger;
2225
import org.slf4j.LoggerFactory;
2326

27+
import org.springframework.beans.factory.ObjectProvider;
2428
import org.springframework.boot.WebApplicationType;
2529
import org.springframework.boot.builder.SpringApplicationBuilder;
2630
import org.springframework.boot.context.event.ApplicationStartingEvent;
31+
import org.springframework.boot.logging.LogFile;
2732
import org.springframework.boot.logging.LoggingSystem;
2833
import org.springframework.boot.testsupport.system.CapturedOutput;
2934
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
@@ -50,6 +55,17 @@ void loggingSystemRegisteredInTheContext() {
5055
}
5156
}
5257

58+
@Test
59+
void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) throws Exception {
60+
String logFile = new File(tempDir, "test.log").getAbsolutePath();
61+
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class)
62+
.web(WebApplicationType.NONE).properties("logging.file=" + logFile).run()) {
63+
SampleService service = context.getBean(SampleService.class);
64+
assertThat(service.logFile).isNotNull();
65+
assertThat(service.logFile.toString()).isEqualTo(logFile);
66+
}
67+
}
68+
5369
@Test
5470
void loggingPerformedDuringChildApplicationStartIsNotLost(CapturedOutput capturedOutput) {
5571
new SpringApplicationBuilder(Config.class).web(WebApplicationType.NONE).child(Config.class)
@@ -71,8 +87,11 @@ static class SampleService {
7187

7288
private final LoggingSystem loggingSystem;
7389

74-
SampleService(LoggingSystem loggingSystem) {
90+
private final LogFile logFile;
91+
92+
SampleService(LoggingSystem loggingSystem, ObjectProvider<LogFile> logFile) {
7593
this.loggingSystem = loggingSystem;
94+
this.logFile = logFile.getIfAvailable();
7695
}
7796

7897
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/EndpointsPropertiesSampleActuatorApplicationTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ void testCustomContextPath() {
6363
assertThat(entity.getBody()).contains("\"hello\":\"world\"");
6464
}
6565

66-
@Test
67-
void logfileWithRandomName() {
68-
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
69-
.getForEntity("/admin/logfile", String.class);
70-
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
71-
}
72-
7366
private String getPassword() {
7467
return "password";
7568
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
server.error.path: /oops
2-
management.endpoint.health.show-details: always
3-
management.endpoints.web.base-path: /admin
4-
logging.file=./target/${spring.application.instance_id}.log
5-
spring.application.instance_id=${random.value}
1+
server.error.path:/oops
2+
management.endpoint.health.show-details:always
3+
management.endpoints.web.base-path:/admin

0 commit comments

Comments
 (0)