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
c5728c95
Commit
c5728c95
authored
Jun 09, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.4.x'
Closes gh-26827
parents
850088de
303edac6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
MetricsRestTemplateCustomizerTests.java
...etrics/web/client/MetricsRestTemplateCustomizerTests.java
+18
-1
RootUriTemplateHandler.java
...ringframework/boot/web/client/RootUriTemplateHandler.java
+1
-1
No files found.
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/MetricsRestTemplateCustomizerTests.java
View file @
c5728c95
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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,16 +25,21 @@ import io.micrometer.core.instrument.MockClock;
import
io.micrometer.core.instrument.Tag
;
import
io.micrometer.core.instrument.simple.SimpleConfig
;
import
io.micrometer.core.instrument.simple.SimpleMeterRegistry
;
import
org.assertj.core.api.InstanceOfAssertFactories
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.actuate.metrics.AutoTimer
;
import
org.springframework.boot.test.web.client.LocalHostUriTemplateHandler
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.boot.web.client.RootUriTemplateHandler
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpRequest
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.client.ClientHttpRequestExecution
;
import
org.springframework.http.client.ClientHttpRequestInterceptor
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.mock.env.MockEnvironment
;
import
org.springframework.test.web.client.MockRestServiceServer
;
import
org.springframework.test.web.client.match.MockRestRequestMatchers
;
import
org.springframework.test.web.client.response.MockRestResponseCreators
;
...
...
@@ -136,6 +141,18 @@ class MetricsRestTemplateCustomizerTests {
nestedMockServer
.
verify
();
}
@Test
void
whenCustomizerAndLocalHostUriTemplateHandlerAreUsedTogetherThenRestTemplateBuilderCanBuild
()
{
MockEnvironment
environment
=
new
MockEnvironment
();
environment
.
setProperty
(
"local.server.port"
,
"8443"
);
LocalHostUriTemplateHandler
uriTemplateHandler
=
new
LocalHostUriTemplateHandler
(
environment
,
"https"
);
RestTemplate
restTemplate
=
new
RestTemplateBuilder
(
this
.
customizer
).
uriTemplateHandler
(
uriTemplateHandler
)
.
build
();
assertThat
(
restTemplate
.
getUriTemplateHandler
())
.
asInstanceOf
(
InstanceOfAssertFactories
.
type
(
RootUriTemplateHandler
.
class
))
.
extracting
(
RootUriTemplateHandler:
:
getRootUri
).
isEqualTo
(
"https://localhost:8443"
);
}
private
static
final
class
TestInterceptor
implements
ClientHttpRequestInterceptor
{
private
final
RestTemplate
restTemplate
;
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java
View file @
c5728c95
...
...
@@ -93,7 +93,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
* @since 2.3.10
*/
public
RootUriTemplateHandler
withHandlerWrapper
(
Function
<
UriTemplateHandler
,
UriTemplateHandler
>
wrapper
)
{
return
new
RootUriTemplateHandler
(
this
.
rootUri
,
wrapper
.
apply
(
this
.
handler
));
return
new
RootUriTemplateHandler
(
getRootUri
()
,
wrapper
.
apply
(
this
.
handler
));
}
/**
...
...
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