Package org.apache.wink.client

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


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

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

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

        NewsStory newsStory = null;
View Full Code Here


        ClientConfig config = new ClientConfig();
        config.handlers(new DummyHandler());
        RestClient client = new RestClient(config);
        Resource resource = client.resource(serviceURL + "/testResourcePost");
        ClientResponse response =
            resource.contentType("text/plain").accept("text/plain")
                .post(SENT_MESSAGE.toLowerCase());

        // Check that request filter converted request entity to upper
        assertEquals(SENT_MESSAGE.toUpperCase(), server.getRequestContentAsString());
View Full Code Here

    public void testResourcePut() throws IOException {
        server.setMockResponseCode(200);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL + "/testResourcePut");
        String response =
            resource.contentType("text/plain").accept("text/plain").put(String.class, SENT_MESSAGE);
        assertEquals(RECEIVED_MESSAGE, response);
        assertEquals(SENT_MESSAGE, server.getRequestContentAsString());

        // do put with response
        ClientResponse clientResponse = resource.put(SENT_MESSAGE);
View Full Code Here

    public void testResourcePost() throws IOException {
        server.setMockResponseCode(200);
        RestClient client = getRestClient();
        Resource resource = client.resource(serviceURL + "/testResourcePost");
        String response =
            resource.contentType("text/plain").accept("text/plain")
                .post(String.class, SENT_MESSAGE);
        assertEquals(RECEIVED_MESSAGE, response);
        assertEquals(SENT_MESSAGE, server.getRequestContentAsString());

        // do post with response
View Full Code Here

        Resource resource = client.resource(baseURI);
        setRequestHeaders(resource);
        JAXBContext context = JAXBContext.newInstance(NewsStory.class);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(story, sw);
        ClientResponse response = resource.contentType("text/xml").post(sw.toString().getBytes());
        int status = response.getStatusCode();
        Response resp = Response.status(status).build();
        for (String key : response.getHeaders().keySet()) {
            List<String> values = response.getHeaders().get(key);
            List<Object> objValues = new ArrayList<Object>();
View Full Code Here

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

        ClientResponse response = resource.contentType("text/xml").put(sw.toString().getBytes());
        int status = response.getStatusCode();

        Response resp = Response.status(status).build();
        for (String key : response.getHeaders().keySet()) {
            List<String> values = response.getHeaders().get(key);
View Full Code Here

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

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

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

        NewsStory newsStory = null;
View Full Code Here

        Resource resource = client.resource(baseURI);
        setRequestHeaders(resource);
        JAXBContext context = JAXBContext.newInstance(NewsStory.class);
        StringWriter sw = new StringWriter();
        context.createMarshaller().marshal(story, sw);
        ClientResponse response = resource.contentType("text/xml").post(sw.toString().getBytes());
        int status = response.getStatusCode();
        Response resp = Response.status(status).build();
        for (String key : response.getHeaders().keySet()) {
            List<String> values = response.getHeaders().get(key);
            List<Object> objValues = new ArrayList<Object>();
View Full Code Here

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

        ClientResponse response = resource.contentType("text/xml").put(sw.toString().getBytes());
        int status = response.getStatusCode();

        Response resp = Response.status(status).build();
        for (String key : response.getHeaders().keySet()) {
            List<String> values = response.getHeaders().get(key);
View Full Code Here

    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();

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

        NewsStory newsStory = null;
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.