Skip to content

Commit

Permalink
DATAREST-892 - Fixed integration tests checking for HTTP Content-Type…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
odrotbohm committed Sep 9, 2016
1 parent 4cb0632 commit 360ed8a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void exposesSchemasForResourcesExposed() throws Exception {
public void servesHalWhenRequested() throws Exception {

mvc.perform(get("/")). //
andExpect(content().contentType(MediaTypes.HAL_JSON)). //
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)). //
andExpect(jsonPath("$._links", notNullValue()));
}

Expand Down Expand Up @@ -211,7 +211,7 @@ public void exposesDescriptionAsAlpsDocuments() throws Exception {
accept(ALPS_MEDIA_TYPE))
.//
andExpect(status().isOk()).//
andExpect(content().contentType(ALPS_MEDIA_TYPE));
andExpect(content().contentTypeCompatibleWith(ALPS_MEDIA_TYPE));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void assertAllowHeaders(HttpEntity<?> response, HttpMethod... meth
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();
}

Expand Down Expand Up @@ -191,6 +191,7 @@ public ResultActions follow(Link link, MediaType accept) throws Exception {

/**
* Follow URL supplied as a string with a specific Accept header.
*
* @param href
* @param accept
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
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;
Expand Down Expand Up @@ -115,10 +114,10 @@ public void profileLinkOnCollectionResourceLeadsToRepositorySpecificMetadata() t
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));
}

}

0 comments on commit 360ed8a

Please sign in to comment.