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
8fb85f26
Commit
8fb85f26
authored
Jan 13, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test to make sure that proxy paths with /another/level/** works
parent
3d91dae0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
ProxyRouteLocator.java
...springframework/cloud/netflix/zuul/ProxyRouteLocator.java
+2
-2
SampleZuulProxyApplicationTests.java
...k/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
+27
-4
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ProxyRouteLocator.java
View file @
8fb85f26
...
...
@@ -33,7 +33,7 @@ public class ProxyRouteLocator implements RouteLocator {
private
AtomicReference
<
Map
<
String
,
ZuulRoute
>>
routes
=
new
AtomicReference
<>();
private
Map
<
String
,
ZuulRoute
>
staticRoutes
=
new
LinkedHashMap
<
String
,
ZuulRoute
>();
private
Map
<
String
,
ZuulRoute
>
staticRoutes
=
new
LinkedHashMap
<>();
public
ProxyRouteLocator
(
DiscoveryClient
discovery
,
ZuulProperties
properties
)
{
this
.
discovery
=
discovery
;
...
...
@@ -61,7 +61,7 @@ public class ProxyRouteLocator implements RouteLocator {
routes
.
set
(
locateRoutes
());
}
Map
<
String
,
String
>
values
=
new
LinkedHashMap
<
String
,
String
>();
Map
<
String
,
String
>
values
=
new
LinkedHashMap
<>();
for
(
String
key
:
routes
.
get
().
keySet
())
{
String
url
=
key
;
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/SampleZuulProxyApplicationTests.java
View file @
8fb85f26
...
...
@@ -14,6 +14,7 @@ import org.springframework.boot.test.IntegrationTest;
import
org.springframework.boot.test.SpringApplicationConfiguration
;
import
org.springframework.boot.test.TestRestTemplate
;
import
org.springframework.cloud.netflix.ribbon.RibbonClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClients
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpEntity
;
...
...
@@ -38,6 +39,7 @@ import com.netflix.zuul.ZuulFilter;
@WebAppConfiguration
@IntegrationTest
({
"server.port: 0"
,
"zuul.routes.other: /test/**=http://localhost:7777/local"
,
"zuul.routes.another: /another/twolevel/**"
,
"zuul.routes.simple: /simple/**"
})
@DirtiesContext
public
class
SampleZuulProxyApplicationTests
{
...
...
@@ -65,7 +67,7 @@ public class SampleZuulProxyApplicationTests {
public
void
getOnSelfViaRibbonRoutingFilter
()
{
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/simple/local/1"
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>((
Void
)
null
),
String
.
class
);
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"Gotten!"
,
result
.
getBody
());
}
...
...
@@ -76,7 +78,7 @@ public class SampleZuulProxyApplicationTests {
endpoint
.
reset
();
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/self/1"
,
HttpMethod
.
DELETE
,
new
HttpEntity
<
Void
>((
Void
)
null
),
String
.
class
);
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"Deleted!"
,
result
.
getBody
());
}
...
...
@@ -85,10 +87,18 @@ public class SampleZuulProxyApplicationTests {
public
void
testNotFound
()
{
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/myinvalidpath"
,
HttpMethod
.
GET
,
new
HttpEntity
<
Void
>((
Void
)
null
),
String
.
class
);
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
NOT_FOUND
,
result
.
getStatusCode
());
}
@Test
public
void
getSecondLevel
()
{
ResponseEntity
<
String
>
result
=
new
TestRestTemplate
().
exchange
(
"http://localhost:"
+
port
+
"/another/twolevel/local/1"
,
HttpMethod
.
GET
,
new
HttpEntity
<>((
Void
)
null
),
String
.
class
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
"Gotten!"
,
result
.
getBody
());
}
}
//Don't use @SpringBootApplication because we don't want to component scan
...
...
@@ -96,7 +106,10 @@ public class SampleZuulProxyApplicationTests {
@EnableAutoConfiguration
@RestController
@EnableZuulProxy
@RibbonClient
(
name
=
"simple"
,
configuration
=
SimpleRibbonClientConfiguration
.
class
)
@RibbonClients
({
@RibbonClient
(
name
=
"simple"
,
configuration
=
SimpleRibbonClientConfiguration
.
class
),
@RibbonClient
(
name
=
"another"
,
configuration
=
AnotherRibbonClientConfiguration
.
class
)
})
class
SampleZuulProxyApplication
{
@RequestMapping
(
"/testing123"
)
...
...
@@ -166,3 +179,13 @@ class SimpleRibbonClientConfiguration {
return
balancer
;
}
}
@Configuration
class
AnotherRibbonClientConfiguration
{
@Bean
public
ILoadBalancer
ribbonLoadBalancer
(
EurekaInstanceConfig
instance
)
{
BaseLoadBalancer
balancer
=
new
BaseLoadBalancer
();
balancer
.
setServersList
(
Arrays
.
asList
(
new
Server
(
"localhost"
,
instance
.
getNonSecurePort
())));
return
balancer
;
}
}
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