Search in sources :

Example 6 with RestClient

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

the class RestClientTest method testPutWithParams.

@Test
public void testPutWithParams() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    Map<String, Object> params = ImmutableMap.of("param1", "value1");
    RestResult restResult = client.put("path", "id1", "body", params);
    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 7 with RestClient

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

the class RestClientTest method testPostWithMaxTotalAndPerRoute.

@Test
public // TODO: How to verify it?
void testPostWithMaxTotalAndPerRoute() {
    RestClient client = new RestClientImpl("/test", 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 8 with RestClient

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

the class RestClientTest method testGetWithId.

@Test
public void testGetWithId() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    RestResult restResult = client.get("path", "id1");
    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 9 with RestClient

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

the class RestClientTest method testPostWithParams.

@Test
public void testPostWithParams() {
    RestClient client = new RestClientImpl("/test", 1000, 200);
    MultivaluedMap<String, Object> headers = ImmutableMultivaluedMap.empty();
    Map<String, Object> params = ImmutableMap.of("param1", "value1");
    RestResult restResult = client.post("path", "body", headers, params);
    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 10 with RestClient

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

the class RestClientTest method testPutWithException.

@Test
public void testPutWithException() {
    RestClient client = new RestClientImpl("/test", 1000, 400);
    Assert.assertThrows(ClientException.class, () -> {
        client.put("path", "id1", "body");
    });
}
Also used : 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