Skip to content

Instantly share code, notes, and snippets.

@eugenp
Created October 13, 2011 19:46
Show Gist options
  • Save eugenp/1285299 to your computer and use it in GitHub Desktop.
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
@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 );
}
@eugenp
Copy link
Author

eugenp commented Feb 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment