Search in sources :

Example 1 with RestClient

use of com.baidu.hugegraph.rest.RestClient in project hugegraph-common by hugegraph.

the class RestClientTest method testPostHttpsWithAllParams.

@Test
public void testPostHttpsWithAllParams() {
    String trustStoreFile = "src/test/resources/cacerts.jks";
    String trustStorePassword = "changeit";
    RestClient client = new RestClientImpl("/test", "user", "", 1000, 10, 5, trustStoreFile, trustStorePassword, 200);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 2 with RestClient

use of com.baidu.hugegraph.rest.RestClient in project hugegraph-common by hugegraph.

the class RestClientTest method testGet.

@Test
public void testGet() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    RestResult restResult = client.get("path");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 3 with RestClient

use of com.baidu.hugegraph.rest.RestClient in project hugegraph-common by hugegraph.

the class RestClientTest method testPostWithAllParams.

@Test
public void testPostWithAllParams() {
    RestClient client = new RestClientImpl("/test", "user", "", 1000, 10, 5, 200);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 4 with RestClient

use of com.baidu.hugegraph.rest.RestClient in project hugegraph-common by hugegraph.

the class RestClientTest method testPut.

@Test
public void testPut() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    RestResult restResult = client.put("path", "id1", "body");
    Assert.assertEquals(200, restResult.status());
}
Also used : RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Example 5 with RestClient

use of com.baidu.hugegraph.rest.RestClient in project hugegraph-common by hugegraph.

the class RestClientTest method testPostWithHeaderAndContent.

@Test
public void testPostWithHeaderAndContent() {
    MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
    headers.add("key1", "value1-1");
    headers.add("key1", "value1-2");
    headers.add("Content-Encoding", "gzip");
    String content = "{\"names\": [\"marko\", \"josh\", \"lop\"]}";
    RestClient client = new RestClientImpl("/test", 1000, 200, headers, content);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
    Assert.assertEquals(headers, restResult.headers());
    Assert.assertEquals(content, restResult.content());
    Assert.assertEquals(ImmutableList.of("marko", "josh", "lop"), restResult.readList("names", String.class));
}
Also used : MultivaluedHashMap(jakarta.ws.rs.core.MultivaluedHashMap) RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) Test(org.junit.Test)

Aggregations

AbstractRestClient (com.baidu.hugegraph.rest.AbstractRestClient)24 RestClient (com.baidu.hugegraph.rest.RestClient)24 Test (org.junit.Test)24 RestResult (com.baidu.hugegraph.rest.RestResult)19 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)3 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)2 HashMap (java.util.HashMap)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 HttpClientConnection (org.apache.http.HttpClientConnection)1 HttpRoute (org.apache.http.conn.routing.HttpRoute)1 PoolStats (org.apache.http.pool.PoolStats)1