public void testSimpleApis() throws Exception {
RestRequest request = new RestRequest(Method.POST, "/test/type1/1");
request.setBody(ByteBuffer.wrap(XContentFactory.jsonBuilder().startObject()
.field("field", "value")
.endObject().bytes().copyBytesArray().array()));
RestResponse response = client.execute(request);
Map<String, Object> map = parseBody(response);
assertThat(response.getStatus(), equalTo(Status.CREATED));
assertThat(map.get("_index").toString(), equalTo("test"));
assertThat(map.get("_type").toString(), equalTo("type1"));
assertThat(map.get("_id").toString(), equalTo("1"));
request = new RestRequest(Method.GET, "/test/type1/1");
response = client.execute(request);
map = parseBody(response);
assertThat(response.getStatus(), equalTo(Status.OK));
assertThat(map.get("_index").toString(), equalTo("test"));
assertThat(map.get("_type").toString(), equalTo("type1"));
assertThat(map.get("_id").toString(), equalTo("1"));
assertThat(map.get("_source"), notNullValue());
assertThat(map.get("_source"), instanceOf(Map.class));
assertThat(((Map<String, String>)map.get("_source")).get("field"), is("value"));
request = new RestRequest(Method.GET, "/_cluster/health");
response = client.execute(request);
assertThat(response.getStatus(), equalTo(Status.OK));
request = new RestRequest(Method.GET, "/bogusindex");
response = client.execute(request);
assertThat(response.getStatus(), equalTo(Status.NOT_FOUND));
}