Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.DeleteMethod


                        : new InputStreamRequestEntity(e, Long.parseLong(length)));
                excerpt = e.getExcerpt();
            }
            httpMethod = entityEnclosingMethod;
        } else if (isDelete) {
            httpMethod = new DeleteMethod(url);
        } else {
            httpMethod = new GetMethod(url);
        }
        for (Map.Entry<String, Object> p : parameters.entrySet()) {
            String name = p.getKey();
View Full Code Here


    @Test
    public void testDeleteBook() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/books/123";

        DeleteMethod post = new DeleteMethod(endpointAddress);
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(post);
            assertEquals(200, result);
        } finally {
            // Release current connection to the connection pool once you are done
            post.releaseConnection();
       
    }
View Full Code Here

    @Test
    public void testDeleteBookByQuery() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/books/id?value=123";

        DeleteMethod post = new DeleteMethod(endpointAddress);
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(post);
            assertEquals(200, result);
        } finally {
            // Release current connection to the connection pool once you are done
            post.releaseConnection();
       
    }
View Full Code Here

    @Test
    public void testDeleteBook() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/books/123";

        DeleteMethod post = new DeleteMethod(endpointAddress);
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(post);
            assertEquals(200, result);
        } finally {
            // Release current connection to the connection pool once you are done
            post.releaseConnection();
       
    }
View Full Code Here

    @Test
    public void testDeleteBookByQuery() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/books/id?value=123";

        DeleteMethod post = new DeleteMethod(endpointAddress);
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(post);
            assertEquals(200, result);
        } finally {
            // Release current connection to the connection pool once you are done
            post.releaseConnection();
       
    }
View Full Code Here

    switch (type) {
    case GET:
      method = new GetMethod(uri);
      break;
    case DELETE:
      method = new DeleteMethod(uri);
      break;
    case PUT:
      method = new PutMethod(uri);
      if(data == null) {
        break;
View Full Code Here

      HttpMethod httpMethod = null;
      switch(m) {
        case GET:     httpMethod = new GetMethod(uri); break;
        case POST:    httpMethod = getMethod(new PostMethod(uri), entity); break;
        case PUT:     httpMethod = getMethod(new PutMethod(uri), entity); break;
        case DELETE:  httpMethod = new DeleteMethod(uri); break;
        case HEAD:    httpMethod = new HeadMethod(uri); break;
        case OPTIONS: httpMethod = new OptionsMethod(uri); break;
        case TRACE:   httpMethod = new TraceMethod(uri); break;
        default:      httpMethod = getMethod(new ExtensionMethod(method,uri), entity);
      }
View Full Code Here

            // Delete an entry
            String id = (String)((Object[])msg.getBody())[0];

            // Send an HTTP DELETE
            DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
            deleteMethod.setRequestHeader("Authorization", authorizationHeader);
            try {
                httpClient.executeMethod(deleteMethod);
                int status = deleteMethod.getStatusCode();

                // Read the Atom entry
                if (status == 200) {
                    msg.setBody(null);

                } else if (status == 404) {
                    msg.setFaultBody(new NotFoundException());
                } else {
                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
                }

            } catch (Exception e) {
                msg.setFaultBody(new ServiceRuntimeException(e));
            } finally {
                deleteMethod.releaseConnection();
            }

            return msg;
        }
View Full Code Here

            // Delete an entry
            String id = (String)((Object[])msg.getBody())[0];

            // Send an HTTP DELETE
            DeleteMethod deleteMethod = new DeleteMethod(uri + "/" + id);
            deleteMethod.setRequestHeader("Authorization", authorizationHeader);
            try {
                httpClient.executeMethod(deleteMethod);
                int status = deleteMethod.getStatusCode();
                if (status == 200) {
                    msg.setBody(null);

                } else if (status == 404) {
                    msg.setFaultBody(new NotFoundException());
                } else {
                    msg.setFaultBody(new ServiceRuntimeException("HTTP status code: " + status));
                }

            } catch (Exception e) {
                msg.setFaultBody(new ServiceRuntimeException(e));
            } finally {
                deleteMethod.releaseConnection();
            }

            return msg;
        }
View Full Code Here

    @Test
    public void testDeleteBook() throws Exception {
        String endpointAddress =
            "http://localhost:9080/bookstore/books/123";

        DeleteMethod post = new DeleteMethod(endpointAddress);
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(post);
            assertEquals(200, result);
        } finally {
            // Release current connection to the connection pool once you are done
            post.releaseConnection();
       
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.DeleteMethod

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.