Updates for boot 2.0 compatibility

This commit is contained in:
Spencer Gibb
2017-11-27 14:31:19 -05:00
parent 7c62bd8871
commit e19ecf71da
5 changed files with 18 additions and 14 deletions

View File

@@ -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());
}

View File

@@ -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());
}

View File

@@ -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());
}