Updates for boot 2.0 compatibility

parent 7c62bd88
......@@ -22,6 +22,7 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -46,6 +47,7 @@ import static org.junit.Assert.assertTrue;
properties = {"spring.application.name=eureka", "server.servlet.context-path=/context",
"management.security.enabled=false", "management.endpoints.web.expose=*" })
public class ApplicationContextTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
@LocalServerPort
private int port = 0;
......@@ -95,7 +97,7 @@ public class ApplicationContextTests {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/context/application/env", HttpMethod.GET,
"http://localhost:" + this.port + "/context" + BASE_PATH + "/env", HttpMethod.GET,
new HttpEntity<>("parameters", headers), Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
}
......
......@@ -21,6 +21,7 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -45,6 +46,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
"spring.application.name=eureka", "server.servlet.path=/servlet",
"management.security.enabled=false", "management.endpoints.web.expose=*" })
public class ApplicationServletPathTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
@LocalServerPort
private int port = 0;
......@@ -106,7 +108,7 @@ public class ApplicationServletPathTests {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/servlet/application/env", HttpMethod.GET,
"http://localhost:" + this.port + "/servlet" + BASE_PATH + "/env", HttpMethod.GET,
new HttpEntity<>("parameters", headers), Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
}
......
......@@ -22,6 +22,7 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -54,6 +55,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@SpringBootTest(classes = Application.class, webEnvironment = RANDOM_PORT, properties = {
"spring.jmx.enabled=true", "management.security.enabled=false", "management.endpoints.web.expose=*" })
public class ApplicationTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
@LocalServerPort
private int port = 0;
......@@ -76,7 +78,7 @@ public class ApplicationTests {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/application/env", HttpMethod.GET,
"http://localhost:" + this.port + BASE_PATH + "/env", HttpMethod.GET,
new HttpEntity<>("parameters", headers), Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
}
......
......@@ -22,12 +22,10 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.RoutesEndpoint;
import org.springframework.cloud.netflix.zuul.RoutesRefreshedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.ParameterizedTypeReference;
......@@ -54,6 +52,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
value = {"zuul.routes.sslservice.url=https://localhost:8443", "management.security.enabled=false", "management.endpoints.web.expose=*"})
@DirtiesContext
public class RoutesEndpointIntegrationTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
@Autowired
private TestRestTemplate restTemplate;
......@@ -64,14 +63,14 @@ public class RoutesEndpointIntegrationTests {
@Test
@SuppressWarnings("unchecked")
public void getRoutesTest() {
Map<String, String> routes = restTemplate.getForObject("/application/routes", Map.class);
Map<String, String> routes = restTemplate.getForObject(BASE_PATH + "/routes", Map.class);
assertEquals("https://localhost:8443", routes.get("/sslservice/**"));
}
@Test
@SuppressWarnings("unchecked")
public void postRoutesTest() {
Map<String, String> routes = restTemplate.postForObject("/application/routes", null, Map.class);
Map<String, String> routes = restTemplate.postForObject(BASE_PATH + "/routes", null, Map.class);
assertEquals("https://localhost:8443", routes.get("/sslservice/**"));
assertTrue(refreshListener.wasCalled());
}
......@@ -79,7 +78,7 @@ public class RoutesEndpointIntegrationTests {
@Test
public void getRouteDetailsTest() {
ResponseEntity<Map<String, RoutesEndpoint.RouteDetails>> responseEntity = restTemplate.exchange(
"/application/routes/details", HttpMethod.GET, null, new ParameterizedTypeReference<Map<String, RoutesEndpoint.RouteDetails>>() {
BASE_PATH + "/routes/details", HttpMethod.GET, null, new ParameterizedTypeReference<Map<String, RoutesEndpoint.RouteDetails>>() {
});
assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK));
......
......@@ -49,9 +49,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.netflix.zuul.context.RequestContext;
import static org.junit.Assert.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = ServletPathZuulProxyApplicationTests.ServletPathZuulProxyApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
@SpringBootTest(classes = ServletPathZuulProxyApplicationTests.ServletPathZuulProxyApplication.class, webEnvironment = RANDOM_PORT, properties = {
"server.servlet.path: /app" })
@DirtiesContext
public class ServletPathZuulProxyApplicationTests {
......@@ -99,8 +100,7 @@ public class ServletPathZuulProxyApplicationTests {
HttpHeaders httpHeaders = result.getHeaders();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("http://localhost:9000",
httpHeaders.getFirst("Access-Control-Allow-Origin"));
assertEquals("*", httpHeaders.getFirst("Access-Control-Allow-Origin"));
}
@Test
......@@ -115,8 +115,7 @@ public class ServletPathZuulProxyApplicationTests {
HttpHeaders httpHeaders = result.getHeaders();
assertEquals(HttpStatus.OK, result.getStatusCode());
assertEquals("http://localhost:9000",
httpHeaders.getFirst("Access-Control-Allow-Origin"));
assertEquals("*", httpHeaders.getFirst("Access-Control-Allow-Origin"));
}
@Test
......
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