Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
b055410a
Commit
b055410a
authored
Mar 25, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix outdated tests
Closes gh-16298
parent
b604ccce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
22 deletions
+49
-22
LogFileWebEndpointAutoConfigurationTests.java
...ure/logging/LogFileWebEndpointAutoConfigurationTests.java
+49
-22
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java
View file @
b055410a
...
...
@@ -49,54 +49,80 @@ public class LogFileWebEndpointAutoConfigurationTests {
public
final
TemporaryFolder
temp
=
new
TemporaryFolder
();
@Test
public
void
logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSet
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file.name:test.log"
).
run
(
(
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
public
void
runWithOnlyExposedShouldNotHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"management.endpoints.web.exposure.include=logfile"
)
.
run
((
context
)
->
assertThat
(
context
)
.
doesNotHaveBean
(
LogFileWebEndpoint
.
class
));
}
@Test
@Deprecated
public
void
logFileWebEndpointIsAutoConfiguredWhenLoggingFileIsSetWithDeprecatedProperty
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file:test.log"
).
run
(
(
context
)
->
assertThat
(
context
).
hasSingl
eBean
(
LogFileWebEndpoint
.
class
));
public
void
runWhenLoggingFileIsSetAndNotExposedShouldNotHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file.name:test.log"
)
.
run
((
context
)
->
assertThat
(
context
)
.
doesNotHav
eBean
(
LogFileWebEndpoint
.
class
));
}
@Test
public
void
logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSet
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file.path:test/logs"
).
run
(
(
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
public
void
runWhenLoggingFileIsSetAndExposedShouldHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file.name:test.log"
,
"management.endpoints.web.exposure.include=logfile"
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
@Test
@Deprecated
public
void
logFileWebEndpointIsAutoConfiguredWhenLoggingPathIsSetWithDeprecatedProperty
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.path:test/logs"
).
run
(
(
context
)
->
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
));
public
void
runWhenLoggingFileIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file:test.log"
,
"management.endpoints.web.exposure.include=logfile"
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
@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
.
withPropertyValues
(
"management.endpoint
.logfile.external-file:external.log
"
)
.
withPropertyValues
(
"logging.file.path:test/logs"
,
"management.endpoint
s.web.exposure.include=logfile
"
)
.
run
((
context
)
->
assertThat
(
context
)
.
hasSingleBean
(
LogFileWebEndpoint
.
class
));
}
@Test
public
void
logFileWebEndpointCanBeDisabled
()
{
@Deprecated
public
void
runWhenLoggingPathIsSetWithDeprecatedPropertyAndExposedShouldHaveEndpointBean
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.
file.name:test.log
"
,
"management.endpoint
.logfile.enabled:fals
e"
)
.
withPropertyValues
(
"logging.
path:test/logs
"
,
"management.endpoint
s.web.exposure.include=logfil
e"
)
.
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
public
void
logFileWebEndpointCanBe
Exclud
ed
()
{
public
void
logFileWebEndpointCanBe
Disabl
ed
()
{
this
.
contextRunner
.
withPropertyValues
(
"logging.file.name:test.log"
,
"management.endpoint
s.web.exposure.exclude=logfil
e"
)
"management.endpoint
.logfile.enabled:fals
e"
)
.
run
((
context
)
->
assertThat
(
context
)
.
doesNotHaveBean
(
LogFileWebEndpoint
.
class
));
}
...
...
@@ -106,6 +132,7 @@ public class LogFileWebEndpointAutoConfigurationTests {
File
file
=
this
.
temp
.
newFile
();
FileCopyUtils
.
copy
(
"--TEST--"
.
getBytes
(),
file
);
this
.
contextRunner
.
withPropertyValues
(
"management.endpoints.web.exposure.include=logfile"
,
"management.endpoint.logfile.external-file:"
+
file
.
getAbsolutePath
())
.
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
LogFileWebEndpoint
.
class
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment