Updates for boot 2.0 compatibility

parent ae34b773
...@@ -23,9 +23,9 @@ import org.junit.Test; ...@@ -23,9 +23,9 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
...@@ -46,6 +46,7 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; ...@@ -46,6 +46,7 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import static org.springframework.cloud.netflix.test.TestAutoConfiguration.PASSWORD; import static org.springframework.cloud.netflix.test.TestAutoConfiguration.PASSWORD;
import static org.springframework.cloud.netflix.test.TestAutoConfiguration.USER; import static org.springframework.cloud.netflix.test.TestAutoConfiguration.USER;
...@@ -53,10 +54,12 @@ import static org.springframework.cloud.netflix.test.TestAutoConfiguration.USER; ...@@ -53,10 +54,12 @@ import static org.springframework.cloud.netflix.test.TestAutoConfiguration.USER;
* @author Spencer Gibb * @author Spencer Gibb
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = HystrixOnlyApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = HystrixOnlyApplication.class, webEnvironment = RANDOM_PORT,
properties = "management.endpoint.health.show-details=true")
@DirtiesContext @DirtiesContext
@ActiveProfiles("proxysecurity") @ActiveProfiles("proxysecurity")
public class HystrixOnlyTests { public class HystrixOnlyTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
@LocalServerPort @LocalServerPort
private int port; private int port;
...@@ -96,7 +99,7 @@ public class HystrixOnlyTests { ...@@ -96,7 +99,7 @@ public class HystrixOnlyTests {
private Map getHealth() { private Map getHealth() {
return new TestRestTemplate().exchange( return new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/application/health", HttpMethod.GET, "http://localhost:" + this.port + BASE_PATH + "/health", HttpMethod.GET,
new HttpEntity<Void>(createBasicAuthHeader(USER, PASSWORD)), new HttpEntity<Void>(createBasicAuthHeader(USER, PASSWORD)),
Map.class).getBody(); Map.class).getBody();
} }
......
...@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory; ...@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; 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.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
...@@ -56,7 +57,7 @@ import static org.junit.Assert.fail; ...@@ -56,7 +57,7 @@ import static org.junit.Assert.fail;
"spring.application.name=hystrixstreamtest" }) "spring.application.name=hystrixstreamtest" })
@DirtiesContext @DirtiesContext
public class HystrixStreamEndpointTests { public class HystrixStreamEndpointTests {
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
private static final Log log = LogFactory.getLog(HystrixStreamEndpointTests.class); private static final Log log = LogFactory.getLog(HystrixStreamEndpointTests.class);
@LocalServerPort @LocalServerPort
...@@ -76,7 +77,7 @@ public class HystrixStreamEndpointTests { ...@@ -76,7 +77,7 @@ public class HystrixStreamEndpointTests {
String.class); String.class);
assertEquals("bad response code", HttpStatus.OK, response.getStatusCode()); assertEquals("bad response code", HttpStatus.OK, response.getStatusCode());
URL hystrixUrl = new URL(url + "/application/hystrix.stream"); URL hystrixUrl = new URL(url + BASE_PATH + "/hystrix.stream");
List<String> data = new ArrayList<>(); List<String> data = new ArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
......
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