* status codes and different response entities.
*/
public void testNewsResourceWithETag() throws Exception {
// always start with a fresh set of resources for testing purposes
// first create the resource
NewsStory story = new NewsStory();
story.setContent("This is a breaking news story");
story.setTitle("Local Hero Saves Kid");
NewsWinkApacheClient client = new NewsWinkApacheClient(NEWS_BASE_URI, null);
Response response = client.addNewsStory(story);
assertNotNull(response);
String location = (String)response.getMetadata().getFirst("Location");
String etag = (String)response.getMetadata().getFirst("ETag");
// now send a request with an 'If-Match' with a matching value,
// we should get back a 304
Map<String, String> reqHdrs = new HashMap<String, String>();
reqHdrs.put("If-Match", etag);
client = new NewsWinkApacheClient(NEWS_BASE_URI, reqHdrs);
location = location.startsWith("/") ? location.substring(1) : location;
response = client.getNewsStory("Local%20Hero%20Saves%20Kid");
assertNotNull(response);
assertEquals("Expected 200 not returned", response.getStatus(), 200);
// update the content of the story
client = new NewsWinkApacheClient(NEWS_BASE_URI, null);
String newContent = "A local man rescued a kid from a burning building";
story.setContent(newContent);
response = client.updateNewsStory(story);
String updatedETag = (String)response.getMetadata().getFirst("ETag");
assertNotNull(updatedETag);
// now try to get with the old ETag value, we should get a 412