Ejemplo n.º 1
0
  @Test
  public void testSimpleApis() throws Exception {
    RestRequest request = new RestRequest(Method.POST, "/test/type1");
    request.setBody(
        ByteBuffer.wrap(
            XContentFactory.jsonBuilder()
                .startObject()
                .field("field", "value")
                .endObject()
                .copiedBytes()));
    RestResponse response = client.execute(request);
    Map<String, Object> map = parseBody(response);
    assertThat(response.getStatus(), equalTo(Status.CREATED));
    assertThat(map.get("ok").toString(), equalTo("true"));
    assertThat(map.get("_index").toString(), equalTo("test"));
    assertThat(map.get("_type").toString(), equalTo("type1"));

    request = new RestRequest(Method.GET, "/_cluster/health");
    response = client.execute(request);
    assertThat(response.getStatus(), equalTo(Status.OK));
  }