Example usage for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod

List of usage examples for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.methods DeleteMethod DeleteMethod.

Prototype

public DeleteMethod(String paramString) 

Source Link

Usage

From source file:terrastore.server.impl.JsonHttpServerTest.java

@Test
public void testRemoveByRangeWithPredicate() throws Exception {
    UpdateService updateService = createMock(UpdateService.class);
    QueryService queryService = createMock(QueryService.class);
    BackupService backupService = createMock(BackupService.class);
    StatsService statsService = createMock(StatsService.class);

    Range range = new Range(new Key("aaaa"), new Key("ffff"), 100, "", 10000L);

    updateService.removeByRange("bucket", range, new Predicate("condition:some"));
    expectLastCall().andReturn(new Keys(Collections.EMPTY_SET)).once();

    replay(updateService, queryService, backupService, statsService);

    JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService);

    HttpClient client = new HttpClient();
    DeleteMethod method = new DeleteMethod(
            "http://localhost:8080/bucket/range?startKey=aaaa&endKey=ffff&limit=100&timeToLive=10000&predicate=condition:some");
    client.executeMethod(method);/*from   w  ww  .j a  v  a  2 s . co  m*/

    assertEquals(HttpStatus.SC_OK, method.getStatusCode());

    method.releaseConnection();

    stopServer(server);

    verify(updateService, queryService, backupService, statsService);
}

From source file:terrastore.server.impl.JsonHttpServerTest.java

@Test
public void testJsonErrorMessageOnInternalFail() throws Exception {
    UpdateService updateService = createMock(UpdateService.class);
    QueryService queryService = createMock(QueryService.class);
    BackupService backupService = createMock(BackupService.class);
    StatsService statsService = createMock(StatsService.class);

    updateService.removeBucket("bucket");
    expectLastCall().andThrow(new UpdateOperationException(new ErrorMessage(500, "error"))).once();

    replay(updateService, queryService, backupService, statsService);

    JsonHttpServer server = startServerWith(updateService, queryService, backupService, statsService);

    HttpClient client = new HttpClient();
    DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket");
    method.setRequestHeader("Content-Type", "application/json");
    client.executeMethod(method);/*w ww .j  a v a 2 s .c o  m*/

    assertEquals(500, method.getStatusCode());
    assertEquals(toJson(new ErrorMessage(500, "error")), method.getResponseBodyAsString());

    method.releaseConnection();

    stopServer(server);

    verify(updateService, queryService, backupService, statsService);
}

From source file:webdav.ManageWebDAVContacts.java

private void deleteVCardsFromWebDAV(String strUriFile) {
    try {/*from   w  w w  . j av  a  2 s.  co m*/
        DeleteMethod httpMethod = new DeleteMethod(strUriFile);
        this.client.executeMethod(httpMethod);
        httpMethod.releaseConnection();
    } catch (IOException e) {
        e.printStackTrace();
    }
}