Examples of NewsStory


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

        ClientResponse response = resource.contentType("text/xml").get();
        int status = response.getStatusCode();

        InputStream is = response.getEntity(InputStream.class);

        NewsStory newsStory = null;
        String contentLength = response.getHeaders().getFirst("Content-Length");
        long cl = 0;
        if(contentLength != null) {
            cl = Long.valueOf(response.getHeaders().getFirst("Content-Length"));  
        }
View Full Code Here

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

        ClientResponse response = resource.contentType("text/xml").get();
        int status = response.getStatusCode();

        InputStream is = response.getEntity(InputStream.class);

        NewsStory newsStory = null;
        String contentLength = response.getHeaders().getFirst("Content-Length");
        long cl = 0;
        if(contentLength != null) {
            cl = Long.valueOf(response.getHeaders().getFirst("Content-Length"));  
        }
View Full Code Here

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

        try {
            HttpClient client = new HttpClient();
            setRequestHeaders(get);
            int status = client.executeMethod(get);
            InputStream is = get.getResponseBodyAsStream();
            NewsStory newsStory = null;
            long cl = get.getResponseContentLength();
            if (is != null && cl != 0) {
                JAXBContext context = JAXBContext.newInstance(NewsStory.class);
                newsStory = (NewsStory)context.createUnmarshaller().unmarshal(is);
            }
View Full Code Here

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");
        NewsWinkClient client = new NewsWinkClient(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 NewsWinkClient(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 NewsWinkClient(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

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

     * 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");
        NewsWinkClient client = new NewsWinkClient(NEWS_BASE_URI, null);
        Response response = client.addNewsStory(story);
        assertNotNull(response);
        String lastModified = (String)response.getMetadata().getFirst("Last-Modified");

View Full Code Here

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

        ClientResponse response = resource.contentType("text/xml").get();
        int status = response.getStatusCode();

        InputStream is = response.getEntity(InputStream.class);

        NewsStory newsStory = null;
        String contentLength = response.getHeaders().getFirst("Content-Length");
        long cl = 0;
        if(contentLength != null) {
            cl = Long.valueOf(response.getHeaders().getFirst("Content-Length"));  
        }
View Full Code Here

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");
        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
View Full Code Here

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

     * 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");
        NewsWinkApacheClient client = new NewsWinkApacheClient(NEWS_BASE_URI, null);
        Response response = client.addNewsStory(story);
        assertNotNull(response);
        String lastModified = (String)response.getMetadata().getFirst("Last-Modified");

View Full Code Here

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

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

     * 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
Copyright © 2018 www.massapi.com. 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.