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
dd9c9fd1
Commit
dd9c9fd1
authored
Aug 10, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Migrate legacy endpoint that have a dash in their id"
See gh-21615
parent
0f9f10f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
EndpointIdTests.java
...pringframework/boot/actuate/endpoint/EndpointIdTests.java
+16
-8
SampleLegacyEndpointWithDot.java
.../java/smoketest/actuator/SampleLegacyEndpointWithDot.java
+2
-2
No files found.
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/EndpointIdTests.java
View file @
dd9c9fd1
...
...
@@ -101,22 +101,30 @@ class EndpointIdTests {
@Test
void
ofWhenMigratingLegacyNameRemovesDots
(
CapturedOutput
output
)
{
EndpointId
.
resetLoggedWarnings
();
MockEnvironment
environment
=
new
MockEnvironment
();
environment
.
setProperty
(
"management.endpoints.migrate-legacy-ids"
,
"true"
);
EndpointId
endpointId
=
EndpointId
.
of
(
environment
,
"foo.bar"
);
assertThat
(
endpointId
.
toString
()).
isEqualTo
(
"foobar"
);
EndpointId
endpointId
=
migrateLegacyName
(
"one.two.three"
);
assertThat
(
endpointId
.
toString
()).
isEqualTo
(
"onetwothree"
);
assertThat
(
output
).
doesNotContain
(
"contains invalid characters"
);
}
@Test
void
ofWhenMigratingLegacyNameRemovesHyphens
(
CapturedOutput
output
)
{
EndpointId
endpointId
=
migrateLegacyName
(
"one-two-three"
);
assertThat
(
endpointId
.
toString
()).
isEqualTo
(
"onetwothree"
);
assertThat
(
output
).
doesNotContain
(
"contains invalid characters"
);
}
@Test
void
ofWhenMigratingLegacyNameRemovesMixOfDashAndDot
(
CapturedOutput
output
)
{
EndpointId
endpointId
=
migrateLegacyName
(
"one.two-three"
);
assertThat
(
endpointId
.
toString
()).
isEqualTo
(
"onetwothree"
);
assertThat
(
output
).
doesNotContain
(
"contains invalid characters"
);
}
private
EndpointId
migrateLegacyName
(
String
name
)
{
EndpointId
.
resetLoggedWarnings
();
MockEnvironment
environment
=
new
MockEnvironment
();
environment
.
setProperty
(
"management.endpoints.migrate-legacy-ids"
,
"true"
);
EndpointId
endpointId
=
EndpointId
.
of
(
environment
,
"foo-bar"
);
assertThat
(
endpointId
.
toString
()).
isEqualTo
(
"foobar"
);
assertThat
(
output
).
doesNotContain
(
"contains invalid characters"
);
return
EndpointId
.
of
(
environment
,
name
);
}
@Test
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleLegacyEndpoint.java
→
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleLegacyEndpoint
WithDot
.java
View file @
dd9c9fd1
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,7 +25,7 @@ import org.springframework.stereotype.Component;
@Component
@Endpoint
(
id
=
"lega.cy"
)
public
class
SampleLegacyEndpoint
{
public
class
SampleLegacyEndpoint
WithDot
{
@ReadOperation
public
Map
<
String
,
String
>
example
()
{
...
...
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