Fix outdated tests

Closes gh-16298
pull/16322/head
Stephane Nicoll 6 years ago
parent b604ccce32
commit b055410ab4

@ -49,54 +49,80 @@ public class LogFileWebEndpointAutoConfigurationTests {
public final TemporaryFolder temp = new TemporaryFolder(); public final TemporaryFolder temp = new TemporaryFolder();
@Test @Test
public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet() { public void runWithOnlyExposedShouldNotHaveEndpointBean() {
this.contextRunner.withPropertyValues("logging.file.name:test.log").run( this.contextRunner
(context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); .withPropertyValues("management.endpoints.web.exposure.include=logfile")
.run((context) -> assertThat(context)
.doesNotHaveBean(LogFileWebEndpoint.class));
} }
@Test @Test
@Deprecated public void runWhenLoggingFileIsSetAndNotExposedShouldNotHaveEndpointBean() {
public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSetWithDeprecatedProperty() { this.contextRunner.withPropertyValues("logging.file.name:test.log")
this.contextRunner.withPropertyValues("logging.file:test.log").run( .run((context) -> assertThat(context)
(context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); .doesNotHaveBean(LogFileWebEndpoint.class));
} }
@Test @Test
public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSet() { public void runWhenLoggingFileIsSetAndExposedShouldHaveEndpointBean() {
this.contextRunner.withPropertyValues("logging.file.path:test/logs").run( this.contextRunner
(context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); .withPropertyValues("logging.file.name:test.log",
"management.endpoints.web.exposure.include=logfile")
.run((context) -> assertThat(context)
.hasSingleBean(LogFileWebEndpoint.class));
} }
@Test @Test
@Deprecated @Deprecated
public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSetWithDeprecatedProperty() { public void runWhenLoggingFileIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean() {
this.contextRunner.withPropertyValues("logging.path:test/logs").run( this.contextRunner
(context) -> assertThat(context).hasSingleBean(LogFileWebEndpoint.class)); .withPropertyValues("logging.file:test.log",
"management.endpoints.web.exposure.include=logfile")
.run((context) -> assertThat(context)
.hasSingleBean(LogFileWebEndpoint.class));
} }
@Test @Test
public void logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet() { public void runWhenLoggingPathIsSetAndNotExposedShouldNotHaveEndpointBean() {
this.contextRunner.withPropertyValues("logging.file.path:test/logs")
.run((context) -> assertThat(context)
.doesNotHaveBean(LogFileWebEndpoint.class));
}
@Test
public void runWhenLoggingPathIsSetAndExposedShouldHaveEndpointBean() {
this.contextRunner this.contextRunner
.withPropertyValues( .withPropertyValues("logging.file.path:test/logs",
"management.endpoint.logfile.external-file:external.log") "management.endpoints.web.exposure.include=logfile")
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.hasSingleBean(LogFileWebEndpoint.class)); .hasSingleBean(LogFileWebEndpoint.class));
} }
@Test @Test
public void logFileWebEndpointCanBeDisabled() { @Deprecated
public void runWhenLoggingPathIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean() {
this.contextRunner this.contextRunner
.withPropertyValues("logging.file.name:test.log", .withPropertyValues("logging.path:test/logs",
"management.endpoint.logfile.enabled:false") "management.endpoints.web.exposure.include=logfile")
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.doesNotHaveBean(LogFileWebEndpoint.class)); .hasSingleBean(LogFileWebEndpoint.class));
}
@Test
public void logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet() {
this.contextRunner
.withPropertyValues(
"management.endpoint.logfile.external-file:external.log",
"management.endpoints.web.exposure.include=logfile")
.run((context) -> assertThat(context)
.hasSingleBean(LogFileWebEndpoint.class));
} }
@Test @Test
public void logFileWebEndpointCanBeExcluded() { public void logFileWebEndpointCanBeDisabled() {
this.contextRunner this.contextRunner
.withPropertyValues("logging.file.name:test.log", .withPropertyValues("logging.file.name:test.log",
"management.endpoints.web.exposure.exclude=logfile") "management.endpoint.logfile.enabled:false")
.run((context) -> assertThat(context) .run((context) -> assertThat(context)
.doesNotHaveBean(LogFileWebEndpoint.class)); .doesNotHaveBean(LogFileWebEndpoint.class));
} }
@ -106,6 +132,7 @@ public class LogFileWebEndpointAutoConfigurationTests {
File file = this.temp.newFile(); File file = this.temp.newFile();
FileCopyUtils.copy("--TEST--".getBytes(), file); FileCopyUtils.copy("--TEST--".getBytes(), file);
this.contextRunner.withPropertyValues( this.contextRunner.withPropertyValues(
"management.endpoints.web.exposure.include=logfile",
"management.endpoint.logfile.external-file:" + file.getAbsolutePath()) "management.endpoint.logfile.external-file:" + file.getAbsolutePath())
.run((context) -> { .run((context) -> {
assertThat(context).hasSingleBean(LogFileWebEndpoint.class); assertThat(context).hasSingleBean(LogFileWebEndpoint.class);

Loading…
Cancel
Save