Package org.apache.commons.httpclient.methods

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


   */
  @Test
  public void deleteParticipant_InvalidAPIKey() throws HttpException,
      IOException {
    HttpClient client = new HttpClient();
    DeleteMethod post = new DeleteMethod(TEST_PARTICIPANTS_SERVICE_URL_VALID);
    post.setQueryString("api_key=" + API_KEY_INVALID + "&widgetid="
        + WIDGET_ID_VALID + "&userid=test&shareddatakey=participantstest");
    client.executeMethod(post);
    int code = post.getStatusCode();
    assertEquals(403, code);
    post.releaseConnection();
  }
View Full Code Here


   */
  @Test
  public void deleteParticipant_InvalidParticipant() throws HttpException,
      IOException {
    HttpClient client = new HttpClient();
    DeleteMethod post = new DeleteMethod(TEST_PARTICIPANTS_SERVICE_URL_VALID);
    post.setQueryString("api_key=" + API_KEY_VALID + "&widgetid="
        + WIDGET_ID_VALID
        + "&userid=test&shareddatakey=participantstest&participant_id=99");
    client.executeMethod(post);
    int code = post.getStatusCode();
    assertEquals(404, code);
    post.releaseConnection();
  }
View Full Code Here

   */
  @Test
  public void deleteParticipant_InvalidInstance() throws HttpException,
      IOException {
    HttpClient client = new HttpClient();
    DeleteMethod post = new DeleteMethod(TEST_PARTICIPANTS_SERVICE_URL_VALID);
    post.setQueryString("api_key="
        + API_KEY_VALID
        + "&widgetid="
        + WIDGET_ID_VALID
        + "&userid=test&shareddatakey=participantstestinvalidkey&participant_id=1");
    client.executeMethod(post);
    int code = post.getStatusCode();
    assertEquals(400, code);
    post.releaseConnection();
  }
View Full Code Here

 
  @AfterClass
  public static void tearDown() throws HttpException, IOException{
    HttpClient client = new HttpClient();
    setAuthenticationCredentials(client);
    DeleteMethod delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_ACCESS_TEST));
    client.executeMethod(delete);
    delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_UPLOAD_TEST));
    client.executeMethod(delete);
    delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_UPLOAD_TEST_2));
    client.executeMethod(delete);
  }
View Full Code Here

  }
 
  @Test
  public void deleteWidgetUnauthorized() throws HttpException, IOException{
    HttpClient client = new HttpClient();
    DeleteMethod delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + "/1");
    client.executeMethod(delete);
    assertEquals(401, delete.getStatusCode());
   
    //
    // Check it wasn't deleted
    //
    GetMethod get = new GetMethod(TEST_WIDGETS_SERVICE_URL_VALID + "/1");
View Full Code Here

    HttpClient client = new HttpClient();
    //
    // Use admin credentials
    //
    setAuthenticationCredentials(client);
    DeleteMethod delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + "/9999");
    client.executeMethod(delete);
    assertEquals(404, delete.getStatusCode());
  }
View Full Code Here

    post.releaseConnection();  
   
    //
    // Delete the widget
    //
    DeleteMethod delete = new DeleteMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_DELETE_TEST));
    client.executeMethod(delete);
    assertEquals(200, delete.getStatusCode());
   
    //
    // Check it was deleted
    //
    GetMethod get = new GetMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_DELETE_TEST));
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

        public Message invoke(Message msg) {
            // 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) {
                  if ( provider.supportsFeedEntries())
                    msg.setFaultBody(new NotFoundException());
                  else
                    msg.setFaultBody(new org.apache.tuscany.sca.data.collection.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

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.