Search in sources :

Example 46 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class TasksResourceTest method testTaskList.

@Test
public void testTaskList() {
    RestTaskClient taskClient = adminClient.tasks();
    RestResponse response = join(taskClient.list(ALL));
    ResponseAssertion.assertThat(response).isOk();
    Json jsonNode = Json.read(response.getBody());
    assertEquals(4, jsonNode.asList().size());
    Json task = jsonNode.at(0);
    assertEquals("Dummy", task.at("type").asString());
    assertEquals("ONE_NODE", task.at("execution_mode").asString());
    assertEquals("DummyRole", task.at("allowed_role").asString());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Json(org.infinispan.commons.dataconversion.internal.Json) RestTaskClient(org.infinispan.client.rest.RestTaskClient) Test(org.testng.annotations.Test)

Example 47 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class TasksResourceTest method testFailingTaskExec.

@Test
public void testFailingTaskExec() {
    RestTaskClient taskClient = client.tasks();
    CompletionStage<RestResponse> response = taskClient.exec("FAILING_TASK");
    ResponseAssertion.assertThat(response).isError();
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestTaskClient(org.infinispan.client.rest.RestTaskClient) Test(org.testng.annotations.Test)

Example 48 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class TasksResourceTest method testTaskExec.

@Test
public void testTaskExec() {
    RestTaskClient taskClient = client.tasks();
    RestResponse response = join(taskClient.exec("SUCCESSFUL_TASK"));
    ResponseAssertion.assertThat(response).isOk();
    Json jsonNode = Json.read(response.getBody());
    assertEquals("result", jsonNode.asString());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Json(org.infinispan.commons.dataconversion.internal.Json) RestTaskClient(org.infinispan.client.rest.RestTaskClient) Test(org.testng.annotations.Test)

Example 49 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class AbstractRestResourceTest method putBinaryValueInCache.

void putBinaryValueInCache(String cacheName, String key, byte[] value, MediaType mediaType) {
    RestEntity restEntity = RestEntity.create(mediaType, value);
    CompletionStage<RestResponse> response = client.cache(cacheName).put(key, restEntity);
    ResponseAssertion.assertThat(response).isOk();
}
Also used : RestEntity(org.infinispan.client.rest.RestEntity) RestResponse(org.infinispan.client.rest.RestResponse)

Example 50 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BaseCacheResourceTest method shouldGetOctetStreamValueStoredInSpecificFormat.

@Test
public void shouldGetOctetStreamValueStoredInSpecificFormat() throws Exception {
    // given
    TestClass testClass = new TestClass();
    testClass.setName("test");
    putBinaryValueInCache("serialized", "test", convertToBytes(testClass), APPLICATION_SERIALIZED_OBJECT);
    // when
    RestResponse response = join(client.cache("serialized").get("test"));
    TestClass convertedObject = convertFromBytes(response.getBodyAsByteArray());
    // then
    ResponseAssertion.assertThat(response).isOk();
    ResponseAssertion.assertThat(response).hasContentType(APPLICATION_SERIALIZED_OBJECT.toString());
    ResponseAssertion.assertThat(response).hasNoCharset();
    Assertions.assertThat(convertedObject.getName()).isEqualTo("test");
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) TestClass(org.infinispan.rest.TestClass) Test(org.testng.annotations.Test)

Aggregations

RestResponse (org.infinispan.client.rest.RestResponse)233 Test (org.testng.annotations.Test)108 Json (org.infinispan.commons.dataconversion.internal.Json)52 RestCacheClient (org.infinispan.client.rest.RestCacheClient)42 Test (org.junit.Test)41 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)39 RestClient (org.infinispan.client.rest.RestClient)37 RestEntity (org.infinispan.client.rest.RestEntity)36 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)23 HashMap (java.util.HashMap)8 RestCounterClient (org.infinispan.client.rest.RestCounterClient)8 TestClass (org.infinispan.rest.TestClass)8 RestSchemaClient (org.infinispan.client.rest.RestSchemaClient)7 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)6 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)6 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)6 Cache (org.infinispan.Cache)5 RestRawClient (org.infinispan.client.rest.RestRawClient)5 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)5