Don't user root path for HAL endpoints

Update LinksMvcEndpoint and HalBrowserMvcEndpoint so that no longer try
to use the `/` context path. Links are now available from `/links` and
the HAL browser is available from `/hal`.

The actuator HAL browser now works with either WebJars or the Spring
Data version. It also now transforms the initial HTML so that the
form is pre-populated with `/links`.

When using Spring Data's HAL browser, the root includes a link to
`/links` with a rel of `actuator`.

See gh-3621
This commit is contained in:
Phillip Webb
2015-08-05 22:17:29 -07:00
parent 44aacd9559
commit 28f32da74f
15 changed files with 310 additions and 264 deletions

View File

@@ -59,10 +59,10 @@ public class SampleHypermediaJpaApplicationCustomLinksPathIntegrationTests {
@Test
public void links() throws Exception {
this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/links").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$._links").exists())
.andExpect(jsonPath("$._links.health").exists())
.andExpect(jsonPath("$._links.books").exists());
.andExpect(jsonPath("$._links.books").doesNotExist());
}
@Test

View File

@@ -61,8 +61,7 @@ public class SampleHypermediaJpaApplicationSharedRootIntegrationTests {
public void home() throws Exception {
this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$._links").exists())
.andExpect(jsonPath("$._links.health").exists())
.andExpect(jsonPath("$._links.admin").exists())
.andExpect(jsonPath("$._links.actuator").exists())
.andExpect(jsonPath("$._links.books").exists());
}

View File

@@ -69,7 +69,7 @@ public class SampleHypermediaJpaApplicationVanillaIntegrationTests {
@Test
public void adminLinks() throws Exception {
this.mockMvc.perform(get("/admin").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/admin/links").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$._links").exists());
}