Search in sources :

Example 41 with RestResponse

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

the class RollingUpgradeIT method doRollingUpgrade.

protected void doRollingUpgrade(RestClient client) {
    RestResponse response = join(client.cache(CACHE_NAME).synchronizeData());
    assertEquals(response.getBody(), 200, response.getStatus());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse)

Example 42 with RestResponse

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

the class XSiteRestMetricsOperations method assertSiteStatusMetrics.

private static void assertSiteStatusMetrics(RestMetricsClient client, String metric, int expected) throws Exception {
    try (RestResponse response = sync(client.metrics())) {
        assertEquals(200, response.getStatus());
        RestMetricsResource.checkIsPrometheus(response.contentType());
        RestMetricsResource.checkRule(response.getBody(), "vendor_" + metric, (stringValue) -> {
            int parsed = (int) Double.parseDouble(stringValue);
            assertThat(parsed).isEqualTo(expected);
        });
    }
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse)

Example 43 with RestResponse

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

the class StaticResourceTest method testConsole.

@Test
public void testConsole() {
    RestResponse response1 = call("/console/page.htm");
    RestResponse response2 = call("/console/folder/test.css");
    RestResponse response3 = call("/console");
    assertResponse(response1, "static-test/console/page.htm", "console", TEXT_HTML);
    assertResponse(response2, "static-test/console/folder/test.css", ".a", TEXT_CSS);
    ResponseAssertion.assertThat(response2).isOk();
    assertResponse(response3, "static-test/console/index.html", "console", TEXT_HTML);
    RestResponse response = call("/console/");
    ResponseAssertion.assertThat(response).isOk();
    response = call("/console/create");
    ResponseAssertion.assertThat(response).isOk();
    response = call("/notconsole/");
    ResponseAssertion.assertThat(response).isNotFound();
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 44 with RestResponse

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

the class StaticResourceTest method testGetFile.

@Test
public void testGetFile() {
    RestResponse response = call("/static/nonexistent.html");
    ResponseAssertion.assertThat(response).isNotFound();
    response = call("/static");
    assertResponse(response, "static-test/index.html", "<h1>Hello</h1>", TEXT_HTML);
    response = call("/static/index.html");
    assertResponse(response, "static-test/index.html", "<h1>Hello</h1>", TEXT_HTML);
    response = call("/static/xml/file.xml");
    assertResponse(response, "static-test/xml/file.xml", "<distributed-cache", MediaType.fromString("text/xml"), APPLICATION_XML);
    response = call("/static/other/text/file.txt");
    assertResponse(response, "static-test/other/text/file.txt", "This is a text file", TEXT_PLAIN);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 45 with RestResponse

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

the class TasksResourceTest method testParameterizedTaskExec.

@Test
public void testParameterizedTaskExec() {
    RestTaskClient taskClient = client.tasks();
    CompletionStage<RestResponse> response = taskClient.exec("PARAMETERIZED_TASK", singletonMap("parameter", "Hello"));
    ResponseAssertion.assertThat(response).isOk();
    Json jsonNode = Json.read(join(response).getBody());
    assertEquals("Hello", 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)

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