@@ -49,54 +49,80 @@ public class LogFileWebEndpointAutoConfigurationTests {
49
49
public final TemporaryFolder temp = new TemporaryFolder ();
50
50
51
51
@ Test
52
- public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet () {
53
- this .contextRunner .withPropertyValues ("logging.file.name:test.log" ).run (
54
- (context ) -> assertThat (context ).hasSingleBean (LogFileWebEndpoint .class ));
52
+ public void runWithOnlyExposedShouldNotHaveEndpointBean () {
53
+ this .contextRunner
54
+ .withPropertyValues ("management.endpoints.web.exposure.include=logfile" )
55
+ .run ((context ) -> assertThat (context )
56
+ .doesNotHaveBean (LogFileWebEndpoint .class ));
55
57
}
56
58
57
59
@ Test
58
- @ Deprecated
59
- public void logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSetWithDeprecatedProperty () {
60
- this . contextRunner . withPropertyValues ( "logging.file:test.log" ). run (
61
- ( context ) -> assertThat ( context ). hasSingleBean (LogFileWebEndpoint .class ));
60
+ public void runWhenLoggingFileIsSetAndNotExposedShouldNotHaveEndpointBean () {
61
+ this . contextRunner . withPropertyValues ( "logging.file.name:test.log" )
62
+ . run (( context ) -> assertThat ( context )
63
+ . doesNotHaveBean (LogFileWebEndpoint .class ));
62
64
}
63
65
64
66
@ Test
65
- public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSet () {
66
- this .contextRunner .withPropertyValues ("logging.file.path:test/logs" ).run (
67
- (context ) -> assertThat (context ).hasSingleBean (LogFileWebEndpoint .class ));
67
+ public void runWhenLoggingFileIsSetAndExposedShouldHaveEndpointBean () {
68
+ this .contextRunner
69
+ .withPropertyValues ("logging.file.name:test.log" ,
70
+ "management.endpoints.web.exposure.include=logfile" )
71
+ .run ((context ) -> assertThat (context )
72
+ .hasSingleBean (LogFileWebEndpoint .class ));
68
73
}
69
74
70
75
@ Test
71
76
@ Deprecated
72
- public void logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSetWithDeprecatedProperty () {
73
- this .contextRunner .withPropertyValues ("logging.path:test/logs" ).run (
74
- (context ) -> assertThat (context ).hasSingleBean (LogFileWebEndpoint .class ));
77
+ public void runWhenLoggingFileIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean () {
78
+ this .contextRunner
79
+ .withPropertyValues ("logging.file:test.log" ,
80
+ "management.endpoints.web.exposure.include=logfile" )
81
+ .run ((context ) -> assertThat (context )
82
+ .hasSingleBean (LogFileWebEndpoint .class ));
75
83
}
76
84
77
85
@ Test
78
- public void logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet () {
86
+ public void runWhenLoggingPathIsSetAndNotExposedShouldNotHaveEndpointBean () {
87
+ this .contextRunner .withPropertyValues ("logging.file.path:test/logs" )
88
+ .run ((context ) -> assertThat (context )
89
+ .doesNotHaveBean (LogFileWebEndpoint .class ));
90
+ }
91
+
92
+ @ Test
93
+ public void runWhenLoggingPathIsSetAndExposedShouldHaveEndpointBean () {
79
94
this .contextRunner
80
- .withPropertyValues (
81
- "management.endpoint.logfile.external-file:external.log " )
95
+ .withPropertyValues ("logging.file.path:test/logs" ,
96
+ "management.endpoints.web.exposure.include=logfile " )
82
97
.run ((context ) -> assertThat (context )
83
98
.hasSingleBean (LogFileWebEndpoint .class ));
84
99
}
85
100
86
101
@ Test
87
- public void logFileWebEndpointCanBeDisabled () {
102
+ @ Deprecated
103
+ public void runWhenLoggingPathIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean () {
88
104
this .contextRunner
89
- .withPropertyValues ("logging.file.name :test.log " ,
90
- "management.endpoint.logfile.enabled:false " )
105
+ .withPropertyValues ("logging.path :test/logs " ,
106
+ "management.endpoints.web.exposure.include=logfile " )
91
107
.run ((context ) -> assertThat (context )
92
- .doesNotHaveBean (LogFileWebEndpoint .class ));
108
+ .hasSingleBean (LogFileWebEndpoint .class ));
109
+ }
110
+
111
+ @ Test
112
+ public void logFileWebEndpointIsAutoConfiguredWhenExternalFileIsSet () {
113
+ this .contextRunner
114
+ .withPropertyValues (
115
+ "management.endpoint.logfile.external-file:external.log" ,
116
+ "management.endpoints.web.exposure.include=logfile" )
117
+ .run ((context ) -> assertThat (context )
118
+ .hasSingleBean (LogFileWebEndpoint .class ));
93
119
}
94
120
95
121
@ Test
96
- public void logFileWebEndpointCanBeExcluded () {
122
+ public void logFileWebEndpointCanBeDisabled () {
97
123
this .contextRunner
98
124
.withPropertyValues ("logging.file.name:test.log" ,
99
- "management.endpoints.web.exposure.exclude= logfile" )
125
+ "management.endpoint. logfile.enabled:false " )
100
126
.run ((context ) -> assertThat (context )
101
127
.doesNotHaveBean (LogFileWebEndpoint .class ));
102
128
}
@@ -106,6 +132,7 @@ public void logFileWebEndpointUsesConfiguredExternalFile() throws IOException {
106
132
File file = this .temp .newFile ();
107
133
FileCopyUtils .copy ("--TEST--" .getBytes (), file );
108
134
this .contextRunner .withPropertyValues (
135
+ "management.endpoints.web.exposure.include=logfile" ,
109
136
"management.endpoint.logfile.external-file:" + file .getAbsolutePath ())
110
137
.run ((context ) -> {
111
138
assertThat (context ).hasSingleBean (LogFileWebEndpoint .class );
0 commit comments