Commit 245c256f by Johannes Edmeier

Update to Spring Boot 1.5.9 and Spring Cloud Edgware.RELEASE

closes #597
parent 121d4755
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<version>1.5.9.RELEASE</version>
<relativePath/>
</parent>
<groupId>de.codecentric</groupId>
......@@ -18,8 +18,8 @@
<properties>
<java.version>1.7</java.version>
<main.basedir>${basedir}</main.basedir>
<spring-boot.version>1.5.8.RELEASE</spring-boot.version>
<spring-cloud.version>Dalston.SR4</spring-cloud.version>
<spring-boot.version>1.5.9.RELEASE</spring-boot.version>
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
<hystrix-dashboard.version>1.5.5</hystrix-dashboard.version>
<build-plugin.jacoco.version>0.7.9</build-plugin.jacoco.version>
<build-plugin.coveralls.version>4.3.0</build-plugin.coveralls.version>
......
......@@ -21,16 +21,22 @@ import de.codecentric.boot.admin.web.client.HttpHeadersProvider;
import de.codecentric.boot.admin.zuul.ApplicationRouteLocator;
import de.codecentric.boot.admin.zuul.filters.pre.ApplicationHeadersFilter;
import org.apache.http.impl.client.CloseableHttpClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.trace.TraceRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.commons.httpclient.ApacheHttpClientConnectionManagerFactory;
import org.springframework.cloud.commons.httpclient.ApacheHttpClientFactory;
import org.springframework.cloud.commons.httpclient.HttpClientConfiguration;
import org.springframework.cloud.netflix.zuul.RoutesEndpoint;
import org.springframework.cloud.netflix.zuul.ZuulServerAutoConfiguration;
import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.cloud.netflix.zuul.filters.TraceProxyRequestHelper;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.cloud.netflix.zuul.filters.pre.PreDecorationFilter;
import org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter;
import org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping;
......@@ -39,10 +45,12 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;
@Configuration
@AutoConfigureAfter({AdminServerWebConfiguration.class})
@Import(HttpClientConfiguration.class)
public class RevereseZuulProxyConfiguration extends ZuulServerAutoConfiguration {
@Autowired(required = false)
......@@ -88,8 +96,22 @@ public class RevereseZuulProxyConfiguration extends ZuulServerAutoConfiguration
}
@Bean
public SimpleHostRoutingFilter simpleHostRoutingFilter() {
return new SimpleHostRoutingFilter(proxyRequestHelper(), zuulProperties);
@ConditionalOnMissingBean({SimpleHostRoutingFilter.class, CloseableHttpClient.class})
public SimpleHostRoutingFilter simpleHostRoutingFilter(ProxyRequestHelper helper,
ZuulProperties zuulProperties,
ApacheHttpClientConnectionManagerFactory connectionManagerFactory,
ApacheHttpClientFactory httpClientFactory) {
return new SimpleHostRoutingFilter(helper, zuulProperties,
connectionManagerFactory, httpClientFactory);
}
@Bean
@ConditionalOnMissingBean({SimpleHostRoutingFilter.class})
public SimpleHostRoutingFilter simpleHostRoutingFilter2(ProxyRequestHelper helper,
ZuulProperties zuulProperties,
CloseableHttpClient httpClient) {
return new SimpleHostRoutingFilter(helper, zuulProperties,
httpClient);
}
@Bean
......
......@@ -32,6 +32,7 @@ import org.springframework.cloud.netflix.zuul.filters.Route;
import de.codecentric.boot.admin.model.Application;
import de.codecentric.boot.admin.registry.ApplicationRegistry;
import de.codecentric.boot.admin.zuul.ApplicationRouteLocator.ApplicationRoute;
public class ApplicationRouteLocatorTest {
......@@ -47,42 +48,46 @@ public class ApplicationRouteLocatorTest {
@Test
public void getRoutes_healthOnly() {
when(registry.getApplications()).thenReturn(singletonList(Application.create("app1")
.withHealthUrl("http://localhost/health").withId("1234").build()));
Application application = Application.create("app1")
.withHealthUrl("http://localhost/health")
.withId("1234")
.build();
when(registry.getApplications()).thenReturn(singletonList(application));
assertEquals(1, locator.getRoutes().size());
assertEquals(asList(new Route("1234-health", "/**", "http://localhost/health",
"/api/applications/1234/health", false, null)), locator.getRoutes());
assertEquals(singletonList(new ApplicationRoute(application, "1234-health", "/**", "http://localhost/health",
"/api/applications/1234/health")), locator.getRoutes());
Route matchingRoute = locator.getMatchingRoute("/api/applications/1234/health");
assertEquals(new Route("1234-health", "", "http://localhost/health",
"/api/applications/1234/health", false, null), matchingRoute);
assertEquals(new ApplicationRoute(application, "1234-health", "", "http://localhost/health",
"/api/applications/1234/health"), matchingRoute);
assertNull(locator.getMatchingRoute("/api/applications/1234/danger"));
}
@Test
public void getRoutes() {
when(registry.getApplications()).thenReturn(
singletonList(Application.create("app1").withHealthUrl("http://localhost/health")
.withManagementUrl("http://localhost").withId("1234").build()));
Application application = Application.create("app1")
.withHealthUrl("http://localhost/health")
.withManagementUrl("http://localhost")
.withId("1234")
.build();
when(registry.getApplications()).thenReturn(singletonList(application));
assertEquals(2, locator.getRoutes().size());
assertEquals(asList(
new Route("1234-health", "/**", "http://localhost/health",
"/api/applications/1234/health", false, null),
new Route("1234-env", "/**", "http://localhost/env", "/api/applications/1234/env",
false, null)),
locator.getRoutes());
assertEquals(asList(new ApplicationRoute(application, "1234-health", "/**", "http://localhost/health",
"/api/applications/1234/health"),
new ApplicationRoute(application, "1234-env", "/**", "http://localhost/env",
"/api/applications/1234/env")), locator.getRoutes());
Route matchingHealth = locator.getMatchingRoute("/api/applications/1234/health");
assertEquals(new Route("1234-health", "", "http://localhost/health",
"/api/applications/1234/health", false, null), matchingHealth);
assertEquals(new ApplicationRoute(application, "1234-health", "", "http://localhost/health",
"/api/applications/1234/health"), matchingHealth);
Route matchingEnv = locator.getMatchingRoute("/api/applications/1234/env/reset");
assertEquals(new Route("1234-env", "/reset", "http://localhost/env",
"/api/applications/1234/env", false, null), matchingEnv);
assertEquals(new ApplicationRoute(application, "1234-env", "/reset", "http://localhost/env",
"/api/applications/1234/env"), matchingEnv);
assertNull(locator.getMatchingRoute("/api/applications/1234/danger"));
}
......
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