Package org.apache.wink.client

Examples of org.apache.wink.client.Resource.accept()


        ClientResponse uri = resource.accept("application/atom+xml").contentType("application/atom+xml").post(entry);
        String location = uri.getHeaders().getFirst("Location");
        assertEquals(BASE_URI+"/blogs/0/entries/1/comments/1", location);
       
        resource = client.resource(location);
        AtomEntry postedEntry = resource.accept("application/atom+xml").get(AtomEntry.class);
        author = postedEntry.getAuthors().get(0);
        assertNotNull(author);
        assertEquals("Wink Coder", author.getName());
        assertEquals("winkcoder@mybusiness.com", author.getEmail());
        assertEquals("I was able to set up the Wink development environment!", entry.getContent().getValue());
View Full Code Here


        assertEquals("winkcoder@mybusiness.com", author.getEmail());
        assertEquals("I was able to set up the Wink development environment!", entry.getContent().getValue());
        assertEquals("Success", entry.getTitle().getValue());
       
        resource = client.resource(BASE_URI+"/blogs/0/entries/1");
        entry = resource.accept("application/atom+xml").get(AtomEntry.class);
        List<AtomLink> expectedLinks = new ArrayList<AtomLink>();
        AtomLink link = new AtomLink();
        link.setHref(BASE_URI+"/blogs/0/entries/1/comments/0");
        expectedLinks.add(link);
        link = new AtomLink();
View Full Code Here

    }
   
    public void testAtomPUTBlogEntry() throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(BASE_URI+"/blogs/0/entries/0");
        AtomEntry entry = resource.accept("application/atom+xml").get(AtomEntry.class);
        AtomPerson author = entry.getAuthors().get(0);
        author.setName(author.getName()+"Updated");
        author.setEmail(author.getEmail()+"Updated");
        AtomText title = entry.getTitle();
        title.setValue(title.getValue()+"Updated");
View Full Code Here

        title.setValue(title.getValue()+"Updated");
        AtomContent content = entry.getContent();
        content.setValue(content.getValue()+"Updated");
       
        resource = client.resource(BASE_URI+"/blogs/0/entries/0");
        AtomEntry updated = resource.accept("application/atom+xml").contentType("application/atom+xml").put(AtomEntry.class, entry);
        assertNotNull(updated.getAuthors());
        assertEquals(1, updated.getAuthors().size());
        author = updated.getAuthors().get(0);
        assertNotNull(author);
        assertEquals("Blog AdminUpdated", author.getName());
View Full Code Here

    }
   
    public void testAtomPUTBlogComment() throws Exception {
        RestClient client = new RestClient();
        Resource resource = client.resource(BASE_URI+"/blogs/0/entries/1/comments/0");
        AtomEntry entry = resource.accept("application/atom+xml").get(AtomEntry.class);
        AtomPerson author = entry.getAuthors().get(0);
        author.setName(author.getName()+"Updated");
        author.setEmail(author.getEmail()+"Updated");
        AtomText title = entry.getTitle();
        title.setValue(title.getValue()+"Updated");
View Full Code Here

        title.setValue(title.getValue()+"Updated");
        AtomContent content = entry.getContent();
        content.setValue(content.getValue()+"Updated");
       
        resource = client.resource(BASE_URI+"/blogs/0/entries/1/comments/0");
        AtomEntry updated = resource.accept("application/atom+xml").contentType("application/atom+xml").put(AtomEntry.class, entry);
        assertNotNull(updated.getAuthors());
        assertEquals(1, updated.getAuthors().size());
        author = updated.getAuthors().get(0);
        assertNotNull(author);
        assertNotNull(author);
View Full Code Here

                             null,
                             MediaType.APPLICATION_ATOM_XML_TYPE,
                             null,
                             new ByteArrayInputStream(FEED.getBytes()));
            AtomFeed responseEntity =
                resource.accept(MediaType.APPLICATION_ATOM_XML_TYPE)
                    .contentType(MediaType.APPLICATION_ATOM_XML_TYPE).post(AtomFeed.class,
                                                                           entryToPost);

            ByteArrayOutputStream os = new ByteArrayOutputStream();
            afp.writeTo(responseEntity,
View Full Code Here

    public void testResourceDelete() {
        server.setMockResponseCode(200);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL);
        String response = resource.accept(MediaType.TEXT_PLAIN_TYPE).delete(String.class);
        assertEquals(RECEIVED_MESSAGE, response);

        // do delete with response
        ClientResponse clientResponse = resource.delete();
        assertEquals(RECEIVED_MESSAGE, clientResponse.getEntity(String.class));
View Full Code Here

    public void testHttpErrorNoResponse() throws IOException {
        server.setMockResponseCode(400);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL);
        try {
            resource.accept("text/plain").invoke("GET", String.class, null);
            fail("ClientWebException must be thrown");
        } catch (ClientWebException e) {
            assertTrue(e.getResponse().getStatusCode() == 400);
        }
    }
View Full Code Here

    public void testHttpErrorWithResponse() throws IOException {
        server.setMockResponseCode(400);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL);
        try {
            ClientResponse res = resource.accept("text/plain").get();
            assertTrue(res.getStatusCode() == 400);
        } catch (Exception e) {
            fail("Exception must not be thrown");
        }
    }
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.