use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method createAndWriteToCache.
private void createAndWriteToCache(String name, Configuration configuration) {
String jsonConfig = cacheConfigToJson(name, configuration);
RestEntity configEntity = RestEntity.create(APPLICATION_JSON, jsonConfig);
CompletionStage<RestResponse> response = client.cache(name).createWithConfiguration(configEntity);
assertThat(response).isOk();
RestEntity valueEntity = RestEntity.create(APPLICATION_JSON, "{\"_type\":\"Simple\",\"value\":1}");
response = client.cache(name).post("1", valueEntity);
assertThat(response).isOk();
}
use of org.infinispan.client.rest.RestResponse 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.RestResponse 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.RestResponse 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.RestResponse in project infinispan by infinispan.
the class CacheResourceV2Test method assertIndex.
private void assertIndex(int value, boolean present) {
String query = "FROM Entity WHERE value = " + value;
RestResponse response = join(client.cache("indexedCache").query(query));
assertThat(response).isOk();
assertEquals(present, response.getBody().contains(String.valueOf(value)));
}
Aggregations