Updates for boot 2 actuator path changes
This commit is contained in:
@@ -10,6 +10,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
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.cloud.client.serviceregistry.Registration;
|
||||
@@ -36,6 +37,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ServiceRegistryEndpointTests.TestConfiguration.class, properties = "management.endpoints.web.expose=*")
|
||||
public class ServiceRegistryEndpointTests {
|
||||
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
|
||||
|
||||
private static final String UPDATED_STATUS = "updatedstatus";
|
||||
private static final String MYSTATUS = "mystatus";
|
||||
|
||||
@@ -54,14 +57,14 @@ public class ServiceRegistryEndpointTests {
|
||||
|
||||
@Test
|
||||
public void testGet() throws Exception {
|
||||
this.mvc.perform(get("/application/service-registry")).andExpect(status().isOk())
|
||||
this.mvc.perform(get(BASE_PATH + "/service-registry")).andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString(MYSTATUS)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost() throws Exception {
|
||||
Map<String, String> status = Collections.singletonMap("status", UPDATED_STATUS);
|
||||
this.mvc.perform(post("/application/service-registry")
|
||||
this.mvc.perform(post(BASE_PATH + "/service-registry")
|
||||
.content(new ObjectMapper().writeValueAsString(status))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
@@ -29,6 +29,7 @@ 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.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -51,6 +52,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@SpringBootTest(classes = TestConfiguration.class, properties = "management.endpoints.web.expose=*")
|
||||
public class EnvironmentManagerIntegrationTests {
|
||||
|
||||
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
|
||||
|
||||
@Autowired
|
||||
private TestProperties properties;
|
||||
|
||||
@@ -72,7 +75,7 @@ public class EnvironmentManagerIntegrationTests {
|
||||
assertEquals("Hello scope!", properties.getMessage());
|
||||
String content = property("message", "Foo");
|
||||
|
||||
this.mvc.perform(post("/application/env")
|
||||
this.mvc.perform(post(BASE_PATH + "/env")
|
||||
.content(content)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
@@ -92,7 +95,7 @@ public class EnvironmentManagerIntegrationTests {
|
||||
@Test
|
||||
public void testRefreshFails() throws Exception {
|
||||
try {
|
||||
this.mvc.perform(post("/application/env")
|
||||
this.mvc.perform(post(BASE_PATH + "/env")
|
||||
.content(property("delay", "foo"))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
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;
|
||||
@@ -50,7 +51,9 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ClientApp.class, properties = "management.endpoints.web.expose=*", webEnvironment = RANDOM_PORT)
|
||||
public class RefreshEndpointIntegrationTests {
|
||||
|
||||
|
||||
private static final String BASE_PATH = new WebEndpointProperties().getBasePath();
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@@ -58,9 +61,9 @@ public class RefreshEndpointIntegrationTests {
|
||||
public void webAccess() throws Exception {
|
||||
TestRestTemplate template = new TestRestTemplate();
|
||||
template.exchange(
|
||||
getUrlEncodedEntity("http://localhost:" + this.port + "/application/env", "message",
|
||||
getUrlEncodedEntity("http://localhost:" + this.port + BASE_PATH + "/env", "message",
|
||||
"Hello Dave!"), String.class);
|
||||
template.postForObject("http://localhost:" + this.port + "/application/refresh", null, String.class);
|
||||
template.postForObject("http://localhost:" + this.port + BASE_PATH + "/refresh", null, String.class);
|
||||
String message = template.getForObject("http://localhost:" + this.port + "/",
|
||||
String.class);
|
||||
assertEquals("Hello Dave!", message);
|
||||
|
||||
Reference in New Issue
Block a user