Skip to content

Instantly share code, notes, and snippets.

@eugenp
Created October 9, 2011 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugenp/1274109 to your computer and use it in GitHub Desktop.
Save eugenp/1274109 to your computer and use it in GitHub Desktop.
Integration testing of a REST API - Testing the HTTP response code
@Test
public void givenUserDoesNotExists_whenUserInfoIsRetrieved_then404IsReceived()
throws ClientProtocolException, IOException{
// Given
String name = randomAlphabetic( 8 );
HttpUriRequest request = new HttpGet( "https://api.github.com/users/" + name );
// When
HttpResponse httpResponse = httpClient.execute( request );
// Then
RestAssert.assertResponseCodeIs( httpResponse, 404 );
}
@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