Search in sources :

Example 61 with RestResult

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

the class RestClientTest method testPostWithTokenAndAllParams.

@Test
public void testPostWithTokenAndAllParams() {
    RestClient client = new RestClientImpl("/test", "token", 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 62 with RestResult

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

the class RestClientTest method testPostWithUserAndPassword.

@Test
public void testPostWithUserAndPassword() {
    RestClient client = new RestClientImpl("/test", "user", "", 1000, 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 63 with RestResult

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

the class RestClientTest method testPost.

@Test
public void testPost() {
    RestClient client = new RestClientImpl("/test", 1000, 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 64 with RestResult

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

the class RestClientTest method testClose.

@Test
public void testClose() {
    RestClient client = new RestClientImpl("/test", 1000, 10, 5, 200);
    RestResult restResult = client.post("path", "body");
    Assert.assertEquals(200, restResult.status());
    client.close();
    Assert.assertThrows(IllegalStateException.class, () -> {
        client.post("path", "body");
    });
    PoolingHttpClientConnectionManager pool;
    pool = Whitebox.getInternalState(client, "pool");
    Assert.assertNotNull(pool);
    AtomicBoolean isShutDown = Whitebox.getInternalState(pool, "isShutDown");
    Assert.assertTrue(isShutDown.get());
    ScheduledExecutorService cleanExecutor;
    cleanExecutor = Whitebox.getInternalState(client, "cleanExecutor");
    Assert.assertNotNull(cleanExecutor);
    Assert.assertTrue(cleanExecutor.isShutdown());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) RestResult(com.baidu.hugegraph.rest.RestResult) AbstractRestClient(com.baidu.hugegraph.rest.AbstractRestClient) RestClient(com.baidu.hugegraph.rest.RestClient) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager) Test(org.junit.Test)

Example 65 with RestResult

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

the class RestClientTest method testPostWithToken.

@Test
public void testPostWithToken() {
    RestClient client = new RestClientImpl("/test", "token", 1000, 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)

Aggregations

RestResult (com.baidu.hugegraph.rest.RestResult)132 Test (org.junit.Test)44 LinkedHashMap (java.util.LinkedHashMap)23 AbstractRestClient (com.baidu.hugegraph.rest.AbstractRestClient)19 RestClient (com.baidu.hugegraph.rest.RestClient)19 MultivaluedHashMap (jakarta.ws.rs.core.MultivaluedHashMap)12 Response (com.baidu.hugegraph.structure.gremlin.Response)6 Result (com.baidu.hugegraph.structure.gremlin.Result)6 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)6 Edge (com.baidu.hugegraph.structure.graph.Edge)5 Vertex (com.baidu.hugegraph.structure.graph.Vertex)5 Map (java.util.Map)5 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)4 InvalidResponseException (com.baidu.hugegraph.exception.InvalidResponseException)3 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)3 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)3 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)3 ArrayList (java.util.ArrayList)3 NotAllCreatedException (com.baidu.hugegraph.exception.NotAllCreatedException)2 Project (com.baidu.hugegraph.structure.auth.Project)2