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
300f6bf4
Commit
300f6bf4
authored
May 18, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish contribution
Closes gh-13208
parent
d31dbac6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
LocalHostUriTemplateHandler.java
...ork/boot/test/web/client/LocalHostUriTemplateHandler.java
+2
-2
LocalHostUriTemplateHandlerTests.java
...oot/test/web/client/LocalHostUriTemplateHandlerTests.java
+23
-1
RootUriTemplateHandler.java
...ringframework/boot/web/client/RootUriTemplateHandler.java
+2
-1
No files found.
spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandler.java
View file @
300f6bf4
...
@@ -70,11 +70,11 @@ public class LocalHostUriTemplateHandler extends RootUriTemplateHandler {
...
@@ -70,11 +70,11 @@ public class LocalHostUriTemplateHandler extends RootUriTemplateHandler {
* @param handler the delegate handler
* @param handler the delegate handler
* @since 2.0.3
* @since 2.0.3
*/
*/
public
LocalHostUriTemplateHandler
(
Environment
environment
,
String
scheme
,
UriTemplateHandler
handler
)
{
public
LocalHostUriTemplateHandler
(
Environment
environment
,
String
scheme
,
UriTemplateHandler
handler
)
{
super
(
handler
);
super
(
handler
);
Assert
.
notNull
(
environment
,
"Environment must not be null"
);
Assert
.
notNull
(
environment
,
"Environment must not be null"
);
Assert
.
notNull
(
scheme
,
"Scheme must not be null"
);
Assert
.
notNull
(
scheme
,
"Scheme must not be null"
);
Assert
.
notNull
(
handler
,
"Handler must not be null"
);
this
.
environment
=
environment
;
this
.
environment
=
environment
;
this
.
scheme
=
scheme
;
this
.
scheme
=
scheme
;
}
}
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandlerTests.java
View file @
300f6bf4
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,13 +16,21 @@
...
@@ -16,13 +16,21 @@
package
org
.
springframework
.
boot
.
test
.
web
.
client
;
package
org
.
springframework
.
boot
.
test
.
web
.
client
;
import
java.net.URI
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.mock.env.MockEnvironment
;
import
org.springframework.mock.env.MockEnvironment
;
import
org.springframework.web.util.UriTemplateHandler
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
/**
* Tests for {@link LocalHostUriTemplateHandler}.
* Tests for {@link LocalHostUriTemplateHandler}.
...
@@ -91,4 +99,18 @@ public class LocalHostUriTemplateHandlerTests {
...
@@ -91,4 +99,18 @@ public class LocalHostUriTemplateHandlerTests {
assertThat
(
handler
.
getRootUri
()).
isEqualTo
(
"http://localhost:8080/foo"
);
assertThat
(
handler
.
getRootUri
()).
isEqualTo
(
"http://localhost:8080/foo"
);
}
}
@Test
public
void
expandShouldUseCustomHandler
()
{
MockEnvironment
environment
=
new
MockEnvironment
();
UriTemplateHandler
uriTemplateHandler
=
mock
(
UriTemplateHandler
.
class
);
Map
<
String
,
?>
uriVariables
=
new
HashMap
<>();
URI
uri
=
URI
.
create
(
"http://www.example.com"
);
given
(
uriTemplateHandler
.
expand
(
"https://localhost:8080/"
,
uriVariables
))
.
willReturn
(
uri
);
LocalHostUriTemplateHandler
handler
=
new
LocalHostUriTemplateHandler
(
environment
,
"https"
,
uriTemplateHandler
);
assertThat
(
handler
.
expand
(
"/"
,
uriVariables
)).
isEqualTo
(
uri
);
verify
(
uriTemplateHandler
).
expand
(
"https://localhost:8080/"
,
uriVariables
);
}
}
}
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java
View file @
300f6bf4
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -38,6 +38,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
...
@@ -38,6 +38,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
private
final
UriTemplateHandler
handler
;
private
final
UriTemplateHandler
handler
;
protected
RootUriTemplateHandler
(
UriTemplateHandler
handler
)
{
protected
RootUriTemplateHandler
(
UriTemplateHandler
handler
)
{
Assert
.
notNull
(
handler
,
"Handler must not be null"
);
this
.
rootUri
=
null
;
this
.
rootUri
=
null
;
this
.
handler
=
handler
;
this
.
handler
=
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