Package org.apache.wink.itest.cache

Examples of org.apache.wink.itest.cache.NewsStory


     * 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");
        NewsHttpClient client = new NewsHttpClient(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 NewsHttpClient(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 NewsHttpClient(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
View Full Code Here


     * and different response entities.
     */
    public void testNewsResourceWithLastModified() throws Exception {

        // first create the resource
        NewsStory story = new NewsStory();
        story.setContent("This is a breaking news story");
        story.setTitle("Local Hero Saves Kid");
        NewsHttpClient client = new NewsHttpClient(NEWS_BASE_URI, null);
        Response response = client.addNewsStory(story);
        assertNotNull(response);
        String lastModified = (String)response.getMetadata().getFirst("Last-Modified");

View Full Code Here

TOP

Related Classes of org.apache.wink.itest.cache.NewsStory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.