DATAREST-892 - Fixed integration tests checking for HTTP Content-Type headers.
Spring 4.3 returns Content-Type headers including the character encoding. We needed to relax our assertions on the content type headers to only check for compatibility.
This commit is contained in:
@@ -102,7 +102,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
public void servesHalWhenRequested() throws Exception {
|
||||
|
||||
mvc.perform(get("/")). //
|
||||
andExpect(content().contentType(MediaTypes.HAL_JSON)). //
|
||||
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)). //
|
||||
andExpect(jsonPath("$._links", notNullValue()));
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public abstract class CommonWebTests extends AbstractWebIntegrationTests {
|
||||
accept(ALPS_MEDIA_TYPE))
|
||||
.//
|
||||
andExpect(status().isOk()).//
|
||||
andExpect(content().contentType(ALPS_MEDIA_TYPE));
|
||||
andExpect(content().contentTypeCompatibleWith(ALPS_MEDIA_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,7 +99,7 @@ public class TestMvcClient {
|
||||
public MockHttpServletResponse request(String href, MediaType contentType) throws Exception {
|
||||
return mvc.perform(get(href).accept(contentType)). //
|
||||
andExpect(status().isOk()). //
|
||||
andExpect(content().contentType(contentType)). //
|
||||
andExpect(content().contentTypeCompatibleWith(contentType)). //
|
||||
andReturn().getResponse();
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ public class TestMvcClient {
|
||||
|
||||
/**
|
||||
* Follow URL supplied as a string with a specific Accept header.
|
||||
*
|
||||
* @param href
|
||||
* @param accept
|
||||
* @return
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.data.rest.webmvc.RestMediaTypes;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.LinkDiscoverers;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
@@ -115,10 +114,10 @@ public class ProfileIntegrationTests extends AbstractControllerIntegrationTests
|
||||
Link profileLink = client.discoverUnique(peopleLink, ProfileResourceProcessor.PROFILE_REL);
|
||||
|
||||
client.follow(profileLink, RestMediaTypes.ALPS_JSON).andExpect(status().is2xxSuccessful())
|
||||
.andExpect(header().string(HttpHeaders.CONTENT_TYPE, RestMediaTypes.ALPS_JSON_VALUE));
|
||||
.andExpect(content().contentTypeCompatibleWith(RestMediaTypes.ALPS_JSON));
|
||||
|
||||
client.follow(profileLink, RestMediaTypes.SCHEMA_JSON).andExpect(status().is2xxSuccessful())
|
||||
.andExpect(header().string(HttpHeaders.CONTENT_TYPE, RestMediaTypes.SCHEMA_JSON_VALUE));
|
||||
.andExpect(content().contentTypeCompatibleWith(RestMediaTypes.SCHEMA_JSON));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user