use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceV2Test method createCache.
private RestCacheClient createCache(RestClient c, String json, String name) {
RestEntity jsonEntity = RestEntity.create(APPLICATION_JSON, json);
RestCacheClient cache = c.cache(name);
CompletionStage<RestResponse> response = cache.createWithConfiguration(jsonEntity);
assertThat(response).isOk();
return cache;
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceV2Test method createCache.
private void createCache(String cacheName, MediaType mediaType) {
RestCacheClient cacheClient = client.cache(cacheName);
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
if (mediaType != null)
builder.encoding().mediaType(mediaType.toString());
String jsonConfig = cacheConfigToJson(cacheName, builder.build());
RestEntity cacheConfig = RestEntity.create(APPLICATION_JSON, jsonConfig);
RestResponse response = join(cacheClient.createWithConfiguration(cacheConfig));
assertThat(response).isOk();
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceV2Test method testCacheV2KeyOps.
@Test
public void testCacheV2KeyOps() {
RestCacheClient cacheClient = client.cache("default");
RestResponse response = join(cacheClient.post("key", "value"));
assertThat(response).isOk();
response = join(cacheClient.post("key", "value"));
assertThat(response).isConflicted().hasReturnedText("An entry already exists");
response = join(cacheClient.put("key", "value-new"));
assertThat(response).isOk();
response = join(cacheClient.get("key"));
assertThat(response).hasReturnedText("value-new");
response = join(cacheClient.head("key"));
assertThat(response).isOk();
assertThat(response).hasNoContent();
response = join(cacheClient.remove("key"));
assertThat(response).isOk();
response = join(cacheClient.get("key"));
assertThat(response).isNotFound();
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceV2Test method testRebalancingActions.
@Test
public void testRebalancingActions() {
String cacheName = "default";
assertRebalancingStatus(cacheName, true);
RestCacheClient cacheClient = adminClient.cache(cacheName);
RestResponse response = join(cacheClient.disableRebalancing());
ResponseAssertion.assertThat(response).isOk();
assertRebalancingStatus(cacheName, false);
response = join(cacheClient.enableRebalancing());
ResponseAssertion.assertThat(response).isOk();
assertRebalancingStatus(cacheName, true);
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceV2Test method testMutableAttributes.
@Test
public void testMutableAttributes() {
String cacheName = "mutable-attributes";
String json = "{\"local-cache\":{\"encoding\":{\"media-type\":\"text/plain\"}}}";
RestCacheClient cacheClient = createCache(adminClient, json, cacheName);
CompletionStage<RestResponse> response = cacheClient.configurationAttributes(true);
assertThat(response).isOk();
Json attributes = Json.read(join(response).getBody());
assertEquals(10, attributes.asJsonMap().size());
assertEquals("long", attributes.at("clustering.remote-timeout").at("type").asString());
assertEquals(15000, attributes.at("clustering.remote-timeout").at("value").asLong());
}
Aggregations