use of org.infinispan.client.rest.RestEntity 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();
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldConflictWhenTryingToReplaceExistingEntryUsingPost.
@Test
public void shouldConflictWhenTryingToReplaceExistingEntryUsingPost() throws Exception {
// given
putStringValueInCache("default", "test", "test");
// when
RestEntity restEntity = RestEntity.create(MediaType.fromString("text/plain;charset=UTF-8"), "Hey!");
CompletionStage<RestResponse> response = client.cache("default").post("test", restEntity);
// then
ResponseAssertion.assertThat(response).isConflicted();
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class BaseCacheResourceTest method putInCache.
private void putInCache(String cacheName, Object key, String keyContentType, String value, String contentType) {
RestEntity entity = RestEntity.create(MediaType.fromString(contentType), value);
CompletionStage<RestResponse> response = client.cache(cacheName).put(key.toString(), keyContentType, entity);
ResponseAssertion.assertThat(response).isOk();
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldPutTextValueInCache.
@Test
public void shouldPutTextValueInCache() {
// when
RestEntity restEntity = RestEntity.create(MediaType.fromString("text/plain;charset=UTF-8"), "Hey!");
CompletionStage<RestResponse> response = client.cache("default").post("test", restEntity);
ResponseAssertion.assertThat(response).isOk();
RestResponse getResponse = join(client.cache("default").get("test"));
// then
ResponseAssertion.assertThat(getResponse).isOk();
ResponseAssertion.assertThat(getResponse).hasEtag();
Assertions.assertThat(getResponse.getBody()).isEqualTo("Hey!");
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class CacheResourceV2Test method createDeleteCache.
private void createDeleteCache(String xml) {
RestEntity xmlEntity = RestEntity.create(APPLICATION_XML, xml);
RestCacheClient cacheClient = client.cache("cacheCRUD");
CompletionStage<RestResponse> response = cacheClient.createWithConfiguration(xmlEntity, VOLATILE);
assertThat(response).isOk();
response = cacheClient.stats();
assertThat(response).isOk().hasJson().hasProperty("current_number_of_entries").is(-1);
response = cacheClient.delete();
assertThat(response).isOk();
response = cacheClient.stats();
assertThat(response).isNotFound().hasReturnedText("ISPN012010: Cache with name 'cacheCRUD' not found amongst the configured caches");
}
Aggregations