Search in sources :

Example 96 with RestResponse

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

the class CacheResourceV2Test method testConversionFromXML.

@Test
public void testConversionFromXML() {
    RestRawClient rawClient = client.raw();
    String xml = "<infinispan>\n" + "    <cache-container>\n" + "        <distributed-cache name=\"cacheName\" mode=\"SYNC\">\n" + "            <memory>\n" + "                <object size=\"20\"/>\n" + "            </memory>\n" + "        </distributed-cache>\n" + "    </cache-container>\n" + "</infinispan>";
    CompletionStage<RestResponse> response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_JSON_TYPE), xml, APPLICATION_XML_TYPE);
    assertThat(response).isOk();
    checkJSON(response);
    response = rawClient.post("/rest/v2/caches?action=convert", Collections.singletonMap("Accept", APPLICATION_YAML_TYPE), xml, APPLICATION_XML_TYPE);
    assertThat(response).isOk();
    checkYaml(response);
}
Also used : RestRawClient(org.infinispan.client.rest.RestRawClient) RestResponse(org.infinispan.client.rest.RestResponse) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Test(org.testng.annotations.Test)

Example 97 with RestResponse

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

the class ContainerResourceTest method testInfo.

@Test
public void testInfo() {
    RestResponse response = join(cacheManagerClient.info());
    ResponseAssertion.assertThat(response).isOk();
    String json = response.getBody();
    Json cmInfo = Json.read(json);
    assertFalse(cmInfo.at("version").asString().isEmpty());
    assertEquals(2, cmInfo.at("cluster_members").asList().size());
    assertEquals(2, cmInfo.at("cluster_members_physical_addresses").asList().size());
    assertEquals("LON-1", cmInfo.at("local_site").asString());
    assertTrue(cmInfo.at("relay_node").asBoolean());
    assertEquals(1, cmInfo.at("relay_nodes_address").asList().size());
    assertEquals(1, cmInfo.at("sites_view").asList().size());
    assertEquals("LON-1", cmInfo.at("sites_view").asList().get(0));
    assertTrue(cmInfo.at("rebalancing_enabled").asBoolean());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Json(org.infinispan.commons.dataconversion.internal.Json) Test(org.testng.annotations.Test)

Example 98 with RestResponse

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

the class ContainerResourceTest method createCache.

private void createCache(String json, String name) {
    RestEntity jsonEntity = RestEntity.create(APPLICATION_JSON, json);
    CompletionStage<RestResponse> response = client.cache(name).createWithConfiguration(jsonEntity);
    assertThat(response).isOk();
}
Also used : RestEntity(org.infinispan.client.rest.RestEntity) RestResponse(org.infinispan.client.rest.RestResponse)

Example 99 with RestResponse

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

the class ContainerResourceTest method testRebalancingActions.

@Test
public void testRebalancingActions() {
    assertRebalancingStatus(true);
    RestResponse response = join(adminCacheManagerClient.disableRebalancing());
    ResponseAssertion.assertThat(response).isOk();
    assertRebalancingStatus(false);
    response = join(adminCacheManagerClient.enableRebalancing());
    ResponseAssertion.assertThat(response).isOk();
    assertRebalancingStatus(true);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 100 with RestResponse

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

the class ContainerResourceTest method testStats.

@Test
public void testStats() {
    RestResponse response = join(adminCacheManagerClient.stats());
    ResponseAssertion.assertThat(response).isOk();
    String json = response.getBody();
    Json cmStats = Json.read(json);
    assertTrue(cmStats.at("statistics_enabled").asBoolean());
    assertEquals(0, cmStats.at("stores").asInteger());
    assertEquals(0, cmStats.at("number_of_entries").asInteger());
    // Advance 1 second for the cached stats to expire
    timeService.advance(1000);
    cacheManagers.iterator().next().getCache("cache1").put("key", "value");
    cmStats = Json.read(join(adminCacheManagerClient.stats()).getBody());
    assertEquals(1, cmStats.at("stores").asInteger());
    assertEquals(1, cmStats.at("number_of_entries").asInteger());
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Json(org.infinispan.commons.dataconversion.internal.Json) 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