Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.accept()


            .queryParam("name", "ephemeral-test")
            .queryParam("ephemeral", "true")
            .queryParam("session", session.id)
            .queryParam("null", "true");
       
        Builder b = wr.accept(MediaType.APPLICATION_JSON);
        ClientResponse cr = b.post(ClientResponse.class);
        assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
       
        Stat stat = new Stat();
        zk.getData("/ephemeral-test", false, stat);
View Full Code Here


        WebResource wr = znodesr.path(path).queryParam("dataformat", encoding);
        if (data == null) {
            wr = wr.queryParam("null", "true");
        }

        Builder builder = wr.accept(accept)
            .type(MediaType.APPLICATION_OCTET_STREAM);

        ClientResponse cr;
        if (data == null) {
            cr = builder.put(ClientResponse.class);
View Full Code Here

        String name = "roottest-create";
        byte[] data = "foo".getBytes();

        WebResource wr = znodesr.path(path).queryParam("dataformat", "utf8")
            .queryParam("name", name);
        Builder builder = wr.accept(MediaType.APPLICATION_JSON);

        ClientResponse cr;
        cr = builder.post(ClientResponse.class, data);
        assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
View Full Code Here

        }
        if (sequence) {
            wr = wr.queryParam("sequence", "true");
        }

        Builder builder = wr.accept(accept);

        ClientResponse cr;
        if (data == null) {
            cr = builder.post(ClientResponse.class);
        } else {
View Full Code Here

        }
        try {
            ClientResponse response;
            //Заголовки запроса
            if (accept != null && accept.length != 0) {
                response = currentResource.accept(accept).get(ClientResponse.class);
            } else {
                response = currentResource.get(ClientResponse.class);
            }
            switch (response.getClientResponseStatus()) {
                case ACCEPTED:
View Full Code Here

        webResource.addFilter(new LoggingFilter());
        GenericType<Collection<Customer>> genericType =
                new GenericType<Collection<Customer>>() {};
       

        Collection<Customer> customers = webResource.accept(MediaType.APPLICATION_XML).get(genericType);
        Assert.assertEquals(customers.size(), 2);
    }

    @Test
    public void testCustomer() throws Exception {
View Full Code Here

    @Test
    public void testCustomer() throws Exception {
        WebResource webResource = resource().path("customers/1");
        webResource.addFilter(new LoggingFilter());

        Customer customer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        customer.setName("Tom Dooley");
        webResource.type(MediaType.APPLICATION_XML).put(customer);

        Customer updatedCustomer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        Assert.assertEquals(customer, updatedCustomer);
View Full Code Here

        Customer customer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        customer.setName("Tom Dooley");
        webResource.type(MediaType.APPLICATION_XML).put(customer);

        Customer updatedCustomer = webResource.accept(MediaType.APPLICATION_XML).get(Customer.class);
        Assert.assertEquals(customer, updatedCustomer);
    }

    //@Test disabled until XML schema generation is fixed for externally bound bean collections
    public void testApplicationWadl() {
View Full Code Here

            JSONObject bookmark = new JSONObject();
            bookmark.put("uri", "http://java.sun.com").put("sdesc", "test desc").put("ldesc", "long test description");
            webResource.type("application/json").post(bookmark);

            JSONArray bookmarks = webResource.accept("application/json").get(JSONArray.class);
            assertTrue(bookmarks != null);
            int bookmarksSize = bookmarks.length();

            String testBookmarkUrl = bookmarks.getString(0);
            WebResource bookmarkResource = client().resource(testBookmarkUrl);
View Full Code Here

            int bookmarksSize = bookmarks.length();

            String testBookmarkUrl = bookmarks.getString(0);
            WebResource bookmarkResource = client().resource(testBookmarkUrl);

            bookmark = bookmarkResource.accept("application/json").get(JSONObject.class);
            assertTrue(bookmark != null);

            bookmarkResource.delete();

            bookmarks = resource().path("resources/users/testuid/bookmarks").accept("application/json").get(JSONArray.class);
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.