Package org.apache.wink.client

Examples of org.apache.wink.client.RestClient.resource()


        return resp;
    }

    public Response updateNewsStory(NewsStory story) throws Exception {
        RestClient client = new RestClient(new ApacheHttpClientConfig());
        Resource resource = client.resource(baseURI);
        setRequestHeaders(resource);

        JAXBContext context = JAXBContext.newInstance(NewsStory.class);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(story, sw);
View Full Code Here


        return resp;
    }

    public Response getNewsStory(String title) throws Exception {
        RestClient client = new RestClient(new ApacheHttpClientConfig());
        Resource resource = client.resource(this.baseURI + "/" + title);
        setRequestHeaders(resource);

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

            // create the rest client instance
            RestClient restClient = new RestClient();

            // create the resource instance to interact with
            String rss_url = "http://www.rssboard.org/files/rss-2.0-sample.xml";
            Resource feedResource = restClient.resource(rss_url);

            // perform a GET on the resource. The resource will be returned as
            // an Rss object
            RssFeed rss = feedResource.accept(MediaType.APPLICATION_XML_TYPE).get(RssFeed.class);
View Full Code Here

            // create the rest client instance
            RestClient restClient = new RestClient();

            // create the resource instance to interact with
            String rss_url = "http://www.rssboard.org/files/rss-2.0-sample.xml";
            Resource feedResource = restClient.resource(rss_url);

            // perform a GET on the resource. The resource will be returned as an Rss object
            RssFeed rssFeed = feedResource.accept(MediaType.APPLICATION_XML).get(RssFeed.class);

            // Map RSS into SyndFeed
View Full Code Here

            // Create Rest Client

            RestClient restClient = new RestClient();

            // Create new Resource on given URL
            Resource resource = restClient.resource(defectsFeed);

            AppService service =
                resource.accept(MediaTypeUtils.ATOM_SERVICE_DOCUMENT).get(AppService.class);

            // Find workspace by it's title
View Full Code Here

            // Find collection by title
            AppCollection collection = workspace.getCollection(COLLECTION_TITLE);
            String href = collection.getHref();

            // Get collection of defects
            Resource feedResource = restClient.resource(href);
            AtomFeed feed = feedResource.accept(MediaType.APPLICATION_ATOM_XML).get(AtomFeed.class);

            // Browse through collection of defects.
            listDefects(feed);
            listTests(restClient, testFeed);
View Full Code Here

        if (authHeader == null) {

            // invoke a call to google authentication service
            RestClient client = new RestClient();
            org.apache.wink.client.Resource authResource =
                client.resource("https://www.google.com/accounts/ClientLogin");
            MultivaluedMapImpl<String, String> params = new MultivaluedMapImpl<String, String>();
            params.putSingle("accountType", "HOSTED_OR_GOOGLE");
            params.putSingle("Email", email);
            params.putSingle("Passwd", password);
            params.putSingle("service", "writely");
View Full Code Here

    public void testContentEncodedInboundRequestRegularOutboundPost() {
        ClientConfig config = new ClientConfig();
        config.handlers();
        RestClient client = new RestClient(config);
        ClientResponse response =
            client.resource(getBaseURI() + "/regular/echo").post(getRepeatedString());
        assertEquals(200, response.getStatusCode());
        assertEquals(getRepeatedString(), response.getEntity(String.class));
        assertNull(response.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING));
        assertNull(response.getHeaders().getFirst(HttpHeaders.VARY));
    }
View Full Code Here

    public void testGZIPContentEncodedInboundRequestContentEncodedOutboundPost() {
        ClientConfig config = new ClientConfig();
        config.handlers(new DeflateHandler());
        RestClient client = new RestClient(config);
        ClientResponse response =
            client.resource(getBaseURI() + "/contentencode/echo").post(getRepeatedString());

        assertEquals(200, response.getStatusCode());
        assertEquals(getRepeatedString(), response.getEntity(String.class));
        assertEquals("deflate", response.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING));
        assertEquals(1, response.getHeaders().get(HttpHeaders.CONTENT_ENCODING).size());
View Full Code Here

    public void testDeflatedContentEncodedInboundRequestContentEncodedOutboundPost() {
        ClientConfig config = new ClientConfig();
        config.handlers(new DeflateHandler());
        RestClient client = new RestClient(config);
        ClientResponse response =
            client.resource(getBaseURI() + "/contentencode/echo").post(getRepeatedString());

        assertEquals(200, response.getStatusCode());
        assertEquals(getRepeatedString(), response.getEntity(String.class));
        assertEquals("deflate", response.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING));
        assertEquals(1, response.getHeaders().get(HttpHeaders.CONTENT_ENCODING).size());
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.