Package org.apache.abdera.protocol.client

Examples of org.apache.abdera.protocol.client.ClientResponse


        RequestOptions opts = new RequestOptions();
        String contentType = "application/atom+xml";
        opts.setContentType(contentType);
        IRI colUri = new IRI(providerURI).resolve("customer");
        ClientResponse res = client.post(colUri.toString(), entry, opts);

        // Feed request with predicates
        opts = new RequestOptions();
        contentType = "application/atom+xml";
        opts.setContentType(contentType);
        opts.setHeader( "If-None-Match", eTag);

        res = client.get(providerURI, opts);
        Assert.assertNotNull(res);
        try {
            // Should return 304 - Feed not provided since it matches ETag.
            Assert.assertEquals(304, res.getStatus());
            // AtomTestCaseUtils.printResponseHeaders( "Feed response headers:", "   ", res );
            // System.out.println("Feed response content:");
            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
        } finally {
            res.release();
        }
    }
View Full Code Here


        RequestOptions opts = new RequestOptions();
        final String contentType = "application/atom+xml";
        opts.setContentType(contentType);
        opts.setHeader( "If-Match", eTag);

        ClientResponse res = client.get(providerURI, opts);
        Assert.assertNotNull(res);
        try {
            String thisETag = res.getHeader("ETag");
            Assert.assertNotNull( thisETag );
            Date thisLastModified = res.getLastModified();
            Assert.assertNotNull( thisLastModified );

            // Should return 200 - value since feed matches eTag
            Assert.assertEquals(200, res.getStatus());
            Assert.assertEquals(ResponseType.SUCCESS, res.getType());

            // AtomTestCaseUtils.printResponseHeaders( "Feed modified if-none-match response headers:", "   ", res );
            // System.out.println("Feed response content:");
            // AtomTestCaseUtils.prettyPrint(abdera, res.getDocument());
        } finally {
            res.release();
        }
    }
View Full Code Here

        RequestOptions opts = new RequestOptions();
        final String contentType = "application/atom+xml";
        opts.setContentType(contentType);
        opts.setHeader( "If-Unmodified-Since", dateFormat.format( previousSecond(lastModified) ));

        ClientResponse res = client.get(providerURI, opts);
        Assert.assertNotNull(res);
        try {
            // Should return 412 - Feed not provided since feed is modified since.
            Assert.assertEquals(412, res.getStatus());
        } finally {
            res.release();
        }
    }
View Full Code Here

        RequestOptions opts = new RequestOptions();
        final String contentType = "application/atom+xml";
        opts.setContentType(contentType);
        opts.setHeader( "If-Modified-Since", dateFormat.format( new Date() ));

        ClientResponse res = client.get(providerURI, opts);
        Assert.assertNotNull(res);
        try {
            // Should return 304 - Feed not provided since feed is unmodified.
            Assert.assertEquals(304, res.getStatus());
        } finally {
            res.release();
        }

        // Feed request with predicates
        opts = new RequestOptions();
        opts.setContentType(contentType);
        opts.setHeader( "If-Modified-Since", dateFormat.format( previousSecond(lastModified) ));

        res = client.get(providerURI, opts);
        Assert.assertNotNull(res);
        try {
            // Should return 200 - Feed provided since feed is changed.
            Assert.assertEquals(200, res.getStatus());
            Assert.assertEquals(ResponseType.SUCCESS, res.getType());

            String thisETag = res.getHeader("ETag");
            Assert.assertNotNull( thisETag );
            Date thisLastModified = res.getLastModified();
            Assert.assertNotNull( thisLastModified );
        } finally {
            res.release();
        }
    }
View Full Code Here

        final String contentType = "application/atom+xml";
        opts.setContentType(contentType);
        // AtomTestCaseUtils.printRequestHeaders( "Post request headers", "   ", opts );
        IRI colUri = new IRI(providerURI).resolve("customer");
        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
        ClientResponse res = client.post(colUri.toString(), entry, opts);

        // Assert response status code is 201-OK.
        // Assert response header Content-Type: application/atom+xml; charset=UTF-8
        // Assert response header Location: http://example.org/edit/first-post.atom
        // Assert response header Content-Location: http://example.org/edit/first-post.atom
        // Assert response header ETag: "e180ee84f0671b1"
        // Assert response header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
        // Assert collection size is 1.
        Assert.assertEquals(201, res.getStatus());
        Assert.assertEquals(contentType, res.getContentType().toString().trim());
        // Assert.assertNotNull( res.getLocation().toString() );
        // Assert.assertEquals( "", res.getContentLocation().toString() );
        // Save eTag for subsequent tests;
        eTag = res.getHeader( "ETag" );
        Assert.assertNotNull( eTag );
        lastModified = res.getLastModified();
        Assert.assertNotNull(lastModified);
    }
View Full Code Here

        IRI colUri = new IRI(providerURI).resolve("customer");
        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
        id = eTag.substring( 1, eTag.length()-1);
        // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
        ClientResponse res = client.put(colUri.toString() + "/" + id, new BaseRequestEntity( entry ), opts);
        // Expected Atom server response (item was edited by another user)
        // >      HTTP/1.1 412 Precondition Failed
        //       Date: Sat, 24 Feb 2007 16:34:11 GMT

        // If-Match Assert response status code is 412. Precondition failed.
        // If-None-Match Assert response status code is 200. OK
        Assert.assertEquals(200, res.getStatus());
        // Put provides null body and no etags.
        res.release();
    }
View Full Code Here

        IRI colUri = new IRI(providerURI).resolve("customer");
        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
        String id = eTag.substring( 1, eTag.length()-1);
        // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
        // Expected Atom server response (item was edited by another user)
        // >      HTTP/1.1 412 Precondition Failed
        //       Date: Sat, 24 Feb 2007 16:34:11 GMT

        // Atom server response (item was up to date)
        // >      HTTP/1.1 200 OK
        //        Date: Sat, 24 Feb 2007 13:17:11 GMT
        // >      ETag: "bb4f5e86e92ddb8549604a0df0763581"
        // >      Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500

        // Assert response status code is 200 OK.
        // Assert header Content-Type: application/atom+xml;type=entry
        // Assert header Location: http://example.org/edit/first-post.atom
        // Assert header Content-Location: http://example.org/edit/first-post.atom
        // Assert header ETag: "555555" (etag response != etag request)
        // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
        Assert.assertEquals(200, res.getStatus());
        Assert.assertEquals(contentType, res.getContentType().toString().trim());
        // Assert.assertNotNull( res.getLocation().toString() );
        // Assert.assertEquals( "", res.getContentLocation().toString() );
        Assert.assertNotNull( res.getHeader( "ETag" ) );
        lastModified = res.getLastModified();
        Assert.assertNotNull(lastModified);
        res.release();
    }
View Full Code Here

        IRI colUri = new IRI(providerURI).resolve("customer");
        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
        String id = eTag.substring( 1, eTag.length()-1);
        // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
        // Atom server response (item was up to date)
        // >      HTTP/1.1 304 Not Modified
        //       Date: Sat, 24 Feb 2007 13:17:11 GMT

        // Assert response status code is 304 Not Modified.
        // Assert header ETag: "e180ee84f0671b1"
        // Assert header Last-Modified: Fri, 25 Jul 2008 14:36:44 -0500
        // Assert.assertEquals(304, res.getStatus());
        res.release();
    }
View Full Code Here

        String id = eTag.substring( 1, eTag.length()-1);
        // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
        // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
        // ClientResponse res = client.get(colUri.toString() + "/" + id, opts);
        ClientResponse res = client.execute( "GET", colUri.toString(), (BaseRequestEntity)null, opts);

        // Atom server response (item was up to date)
        // >      HTTP/1.1 304 Not Modified
        //       Date: Sat, 24 Feb 2007 13:17:11 GMT

        // Assert response status code is 304 Not Modified.
        Assert.assertEquals(304, res.getStatus());
        res.release();
    }
View Full Code Here

        IRI colUri = new IRI(providerURI).resolve("customer");
        // res = client.post(colUri.toString() + "?test=foo", entry, opts);
        String id = eTag.substring( 1, eTag.length()-1);
        // Warning. AbderaClient.put(String uri,Base base,RequestOptions options) caches on the client side.
        // ClientResponse res = client.put(colUri.toString() + id, entry, opts);
        ClientResponse res = client.get(colUri.toString() + "/" + id, opts);

        // Atom server response (item was up to date)
        // >      HTTP/1.1 200 OK
        //        Date: Sat, 24 Feb 2007 13:17:11 GMT
        // >      ETag: "bb4f5e86e92ddb8549604a0df0763581"
        // >      Last-Modified: Mon, 28 Jul 2008 10:25:37 -0500

        // Assert response status code is 200 OK.
        // Assert header ETag: "e180ee84f0671b1"
        // Assert header Last-Modified: Greater than If-Mod
        Assert.assertEquals(200, res.getStatus());
        Assert.assertEquals(contentType, res.getContentType().toString().trim());
        // Assert.assertNotNull( res.getLocation().toString() );
        // Assert.assertEquals( "", res.getContentLocation().toString() );
        Assert.assertNotNull( res.getHeader( "ETag" ) );
        lastModified = res.getLastModified();
        Assert.assertNotNull(lastModified);
        res.release();
    }
View Full Code Here

TOP

Related Classes of org.apache.abdera.protocol.client.ClientResponse

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.