use of org.infinispan.client.rest.RestResponse 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.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldPutImmortalEntryWithZeroTtlAndIdleTime.
@Test
public void shouldPutImmortalEntryWithZeroTtlAndIdleTime() {
RestCacheClient expirationCache = client.cache("expiration");
// when
CompletionStage<RestResponse> response = expirationCache.post("test", "test", 0, 0);
ResponseAssertion.assertThat(response).isOk();
RestResponse getResponse = join(expirationCache.get("test"));
// then
ResponseAssertion.assertThat(getResponse).isOk();
Assertions.assertThat(getLifespan(getResponse)).isEqualTo(DEFAULT_LIFESPAN_SECONDS);
Assertions.assertThat(getMaxIdle(getResponse)).isEqualTo(DEFAULT_MAX_IDLE_SECONDS);
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldPutLargeObject.
@Test
public void shouldPutLargeObject() {
byte[] payload = new byte[1_000_000];
final RestCacheClient binaryCache = client.cache("binary");
CompletionStage<RestResponse> response = binaryCache.post("test", RestEntity.create(APPLICATION_OCTET_STREAM, payload));
ResponseAssertion.assertThat(response).isOk();
ResponseAssertion.assertThat(response).hasEtag();
RestResponse getResponse = join(binaryCache.get("test"));
Assertions.assertThat(getResponse.getBodyAsByteArray().length).isEqualTo(1_000_000);
}
use of org.infinispan.client.rest.RestResponse 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.RestResponse 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!");
}
Aggregations