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
d999b802
Commit
d999b802
authored
Dec 04, 2014
by
Jonathan Lounsbury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing issue with default routes
parent
fc0aac3b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
ProxyRouteLocator.java
...springframework/cloud/netflix/zuul/ProxyRouteLocator.java
+2
-2
ProxyRouteLocatorTests.java
...gframework/cloud/netflix/zuul/ProxyRouteLocatorTests.java
+31
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ProxyRouteLocator.java
View file @
d999b802
...
...
@@ -121,10 +121,10 @@ public class ProxyRouteLocator {
}
if
(
routesMap
.
get
(
DEFAULT_ROUTE
)
!=
null
)
{
String
defaultServiceId
=
routesMap
.
get
(
DEFAULT_ROUTE
).
getServiceId
(
);
ZuulRoute
defaultRoute
=
routesMap
.
get
(
DEFAULT_ROUTE
);
// Move the defaultServiceId to the end
routesMap
.
remove
(
DEFAULT_ROUTE
);
routesMap
.
put
(
DEFAULT_ROUTE
,
new
ZuulRoute
(
default
ServiceId
));
routesMap
.
put
(
DEFAULT_ROUTE
,
new
ZuulRoute
(
default
Route
.
getPath
(),
defaultRoute
.
getLocation
()
));
}
LinkedHashMap
<
String
,
ZuulRoute
>
values
=
new
LinkedHashMap
<>();
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/ProxyRouteLocatorTests.java
View file @
d999b802
...
...
@@ -144,6 +144,30 @@ public class ProxyRouteLocatorTests {
}
@Test
public
void
testGetDefaultRoute
()
{
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
this
.
properties
);
this
.
properties
.
getRoutes
().
put
(
ASERVICE
,
new
ZuulRoute
(
"/"
,
ASERVICE
));
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
assertDefaultMapping
(
routesMap
,
ASERVICE
);
}
@Test
public
void
testGetDefaultPhysicalRoute
()
{
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
this
.
properties
);
this
.
properties
.
getRoutes
().
put
(
ASERVICE
,
new
ZuulRoute
(
"/"
,
"http://"
+
ASERVICE
));
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
assertDefaultMapping
(
routesMap
,
"http://"
+
ASERVICE
);
}
@Test
public
void
testIgnoreRoutes
()
{
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
this
.
properties
);
this
.
properties
.
setIgnoredServices
(
Lists
.
newArrayList
(
IGNOREDSERVICE
));
...
...
@@ -199,4 +223,11 @@ public class ProxyRouteLocatorTests {
private
String
getMapping
(
String
serviceId
)
{
return
"/"
+
serviceId
+
"/**"
;
}
protected
void
assertDefaultMapping
(
Map
<
String
,
String
>
routesMap
,
String
expectedRoute
)
{
String
mapping
=
"/"
;
String
route
=
routesMap
.
get
(
mapping
);
assertEquals
(
"routesMap had wrong value for "
+
mapping
,
expectedRoute
,
route
);
}
}
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