Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
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
openSource
spring-cloud-netflix
Commits
899a5779
Commit
899a5779
authored
Jun 01, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for zuul with encoded path parameter
parent
682ceec4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
SampleZuulProxyApplicationTests.java
...k/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
+18
-0
No files found.
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
View file @
899a5779
...
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
cloud
.
netflix
.
zuul
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Arrays
;
import
org.junit.Test
;
...
...
@@ -41,6 +42,7 @@ import org.springframework.test.annotation.DirtiesContext;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -50,6 +52,7 @@ import com.netflix.loadbalancer.BaseLoadBalancer;
import
com.netflix.loadbalancer.ILoadBalancer
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.zuul.ZuulFilter
;
import
org.springframework.web.util.UriUtils
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -141,6 +144,16 @@ public class SampleZuulProxyApplicationTests {
assertEquals
(
"Hello space"
,
result
.
getBody
());
}
@Test
public
void
postWithEncodedValueWorks
()
throws
UnsupportedEncodingException
{
String
id
=
UriUtils
.
encodePathSegment
(
"id/with/slashes"
,
"UTF-8"
);
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
postForEntity
(
"http://localhost:"
+
this
.
port
+
"/simple/local/{id}"
,
"body"
,
String
.
class
,
id
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"Posted id/with/slashes!"
,
UriUtils
.
decode
(
result
.
getBody
(),
"UTF-8"
));
}
}
// Don't use @SpringBootApplication because we don't want to component scan
...
...
@@ -173,6 +186,11 @@ class SampleZuulProxyApplication {
return
"Gotten "
+
id
+
"!"
;
}
@RequestMapping
(
value
=
"/local/{id}"
,
method
=
RequestMethod
.
POST
)
public
String
post
(
@PathVariable
String
id
,
@RequestBody
String
body
)
{
return
"Posted "
+
id
+
"!"
;
}
@RequestMapping
(
"/"
)
public
String
home
()
{
return
"Hello world"
;
...
...
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