#186 - Prepare upgrade to Spring Boot 1.4 M2 and Hibernate 5.
Upgraded to Spring Boot 1.4 M2 and thus Hibernate 5.1 transitively. Switched to H2 as database for all examples using JPA by accident as the invalid error logging for HSQLDB schema creation got worse in 5.1 (see [0]). The JPA examples themselves have to stay on HSQLDB as H2 doesn't support stored procedures. The stored procedures example in turn has to be downgraded to 5.0.7 as all following versions currently break stored procedure execution support [1]. Reworked the JPA auditing example as 5.1 breaks on generic types used in support types like AbstractAuditable [2]. Tweaked content type assertions in some REST related test cases as Spring 4.3 returns an encoding alongside the media type. [0] https://hibernate.atlassian.net/browse/HHH-10605 [1] https://hibernate.atlassian.net/browse/HHH-10515 [2] https://hibernate.atlassian.net/browse/HHH-10514
This commit is contained in:
@@ -22,10 +22,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
|
||||
|
||||
import example.springdata.rest.security.Application;
|
||||
import example.springdata.rest.security.Employee;
|
||||
import example.springdata.rest.security.SecurityConfiguration;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -75,7 +71,7 @@ public class UrlLevelSecurityTests {
|
||||
|
||||
mvc.perform(get("/").//
|
||||
accept(MediaTypes.HAL_JSON)).//
|
||||
andExpect(header().string("Content-Type", MediaTypes.HAL_JSON.toString())).//
|
||||
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
|
||||
andExpect(status().isOk()).//
|
||||
andDo(print());
|
||||
}
|
||||
@@ -94,12 +90,12 @@ public class UrlLevelSecurityTests {
|
||||
public void allowsGetRequestsButRejectsPostForUser() throws Exception {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add(HttpHeaders.ACCEPT, MediaTypes.HAL_JSON.toString());
|
||||
headers.add(HttpHeaders.ACCEPT, MediaTypes.HAL_JSON_VALUE);
|
||||
headers.add(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.encode(("greg:turnquist").getBytes())));
|
||||
|
||||
mvc.perform(get("/employees").//
|
||||
headers(headers)).//
|
||||
andExpect(content().contentType(MediaTypes.HAL_JSON)).//
|
||||
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
|
||||
andExpect(status().isOk()).//
|
||||
andDo(print());
|
||||
|
||||
@@ -113,20 +109,22 @@ public class UrlLevelSecurityTests {
|
||||
public void allowsPostRequestForAdmin() throws Exception {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(HttpHeaders.ACCEPT, "application/hal+json");
|
||||
headers.set(HttpHeaders.ACCEPT, MediaTypes.HAL_JSON_VALUE);
|
||||
headers.set(HttpHeaders.AUTHORIZATION, "Basic " + new String(Base64.encode(("ollie:gierke").getBytes())));
|
||||
|
||||
mvc.perform(get("/employees").//
|
||||
headers(headers)).//
|
||||
andExpect(content().contentType(MediaTypes.HAL_JSON)).//
|
||||
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
|
||||
andExpect(status().isOk()).//
|
||||
andDo(print());
|
||||
|
||||
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||
|
||||
String location = mvc.perform(post("/employees").//
|
||||
content(PAYLOAD).//
|
||||
headers(headers)).//
|
||||
String location = mvc
|
||||
.perform(post("/employees").//
|
||||
content(PAYLOAD).//
|
||||
headers(headers))
|
||||
.//
|
||||
andExpect(status().isCreated()).//
|
||||
andDo(print()).//
|
||||
andReturn().getResponse().getHeader(HttpHeaders.LOCATION);
|
||||
|
||||
Reference in New Issue
Block a user