Created
October 13, 2011 19:46
-
-
Save eugenp/1285299 to your computer and use it in GitHub Desktop.
Integration testing of a REST API - Testing the ContentType header for the HTTP response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void givenRequestWithNoAcceptHeader_whenRequestIsExecuted_thenDefaultResponseContentTypeIsJson() | |
throws ClientProtocolException, IOException{ | |
// Given | |
String jsonMimeType = "application/json"; | |
HttpUriRequest request = new HttpGet( "https://api.github.com/users/eugenp" ); | |
// When | |
HttpResponse response = this.httpClient.execute( request ); | |
// Then | |
String mimeType = EntityUtils.getContentMimeType( response.getEntity() ); | |
assertEquals( jsonMimeType, mimeType ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is used in:
http://www.baeldung.com/2011/10/13/integration-testing-a-rest-api/