Package org.elasticsearch.thrift

Examples of org.elasticsearch.thrift.RestResponse$RestResponseStandardSchemeFactory


    @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));
    }
View Full Code Here


    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));
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.thrift.RestResponse$RestResponseStandardSchemeFactory

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.