Commit 3b7cc53c by Spencer Gibb

Merge branch 'jlouns-master'

parents 5964d160 45e9a620
...@@ -121,10 +121,10 @@ public class ProxyRouteLocator { ...@@ -121,10 +121,10 @@ public class ProxyRouteLocator {
} }
if (routesMap.get(DEFAULT_ROUTE) != null) { 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 // Move the defaultServiceId to the end
routesMap.remove(DEFAULT_ROUTE); routesMap.remove(DEFAULT_ROUTE);
routesMap.put(DEFAULT_ROUTE, new ZuulRoute(defaultServiceId)); routesMap.put(DEFAULT_ROUTE, defaultRoute);
} }
LinkedHashMap<String, ZuulRoute> values = new LinkedHashMap<>(); LinkedHashMap<String, ZuulRoute> values = new LinkedHashMap<>();
......
...@@ -144,6 +144,30 @@ public class ProxyRouteLocatorTests { ...@@ -144,6 +144,30 @@ public class ProxyRouteLocatorTests {
} }
@Test @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() { public void testIgnoreRoutes() {
ProxyRouteLocator routeLocator = new ProxyRouteLocator(this.discovery, this.properties); ProxyRouteLocator routeLocator = new ProxyRouteLocator(this.discovery, this.properties);
this.properties.setIgnoredServices(Lists.newArrayList(IGNOREDSERVICE)); this.properties.setIgnoredServices(Lists.newArrayList(IGNOREDSERVICE));
...@@ -199,4 +223,11 @@ public class ProxyRouteLocatorTests { ...@@ -199,4 +223,11 @@ public class ProxyRouteLocatorTests {
private String getMapping(String serviceId) { private String getMapping(String serviceId) {
return "/" + 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);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment