Example usage for org.apache.commons.httpclient HttpStatus SC_NO_CONTENT

List of usage examples for org.apache.commons.httpclient HttpStatus SC_NO_CONTENT

Introduction

In this page you can find the example usage for org.apache.commons.httpclient HttpStatus SC_NO_CONTENT.

Prototype

int SC_NO_CONTENT

To view the source code for org.apache.commons.httpclient HttpStatus SC_NO_CONTENT.

Click Source Link

Document

<tt>204 No Content</tt> (HTTP/1.0 - RFC 1945)

Usage

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

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

    backupService.exportBackup("bucket", "destination", "secret");
    expectLastCall().once();//  w w  w .ja  v a 2 s  .c o m

    replay(updateService, queryService, backupService, statsService);

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

    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod(
            "http://localhost:8080/bucket/export?destination=destination&secret=secret");
    method.setRequestEntity(new StringRequestEntity("", "application/json", null));
    client.executeMethod(method);

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

    method.releaseConnection();

    stopServer(server);

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

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

@Test
public void testRemoveBucket() 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().once();//  ww  w. j  av  a  2 s.co m

    replay(updateService, queryService, backupService, statsService);

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

    HttpClient client = new HttpClient();
    DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket");
    client.executeMethod(method);

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

    method.releaseConnection();

    stopServer(server);

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

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

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

    updateService.putValue(eq("bucket"), eq(new Key("test1")), EasyMock.<Value>anyObject(),
            eq(new Predicate(null)));
    expectLastCall().once();/*www  .  java 2 s  .co  m*/

    replay(updateService, queryService, backupService, statsService);

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

    HttpClient client = new HttpClient();
    PutMethod method = new PutMethod("http://localhost:8080/bucket/test1");
    method.setRequestHeader("Content-Type", "application/json");
    method.setRequestEntity(new StringRequestEntity(JSON_VALUE, "application/json", null));
    client.executeMethod(method);

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

    method.releaseConnection();

    stopServer(server);

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

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

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

    updateService.putValue(eq("bucket"), eq(new Key("test1")), EasyMock.<Value>anyObject(),
            eq(new Predicate("test:condition")));
    expectLastCall().once();/*from  w  w w. j ava 2s  . co  m*/

    replay(updateService, queryService, backupService, statsService);

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

    HttpClient client = new HttpClient();
    PutMethod method = new PutMethod("http://localhost:8080/bucket/test1?predicate=test:condition");
    method.setRequestHeader("Content-Type", "application/json");
    method.setRequestEntity(new StringRequestEntity(JSON_VALUE, "application/json", null));
    client.executeMethod(method);

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

    method.releaseConnection();

    stopServer(server);

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

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

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

    updateService.removeValue("bucket", new Key("test1"));
    expectLastCall().once();/*from ww w.ja v a 2  s  .com*/

    replay(updateService, queryService, backupService, statsService);

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

    HttpClient client = new HttpClient();
    DeleteMethod method = new DeleteMethod("http://localhost:8080/bucket/test1");
    client.executeMethod(method);

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

    method.releaseConnection();

    stopServer(server);

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