use of org.infinispan.client.rest.RestCacheClient 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.RestCacheClient 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.RestCacheClient in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldPutImmortalEntryWithMinusOneTtlAndIdleTime.
@Test
public void shouldPutImmortalEntryWithMinusOneTtlAndIdleTime() {
RestCacheClient expirationCache = client.cache("expiration");
// when
CompletionStage<RestResponse> response = expirationCache.put("test", "test", -1, -1);
ResponseAssertion.assertThat(response).isOk();
RestResponse getResponse = join(expirationCache.get("test"));
// then
ResponseAssertion.assertThat(getResponse).isOk();
Assertions.assertThat(getLifespan(getResponse)).isNull();
Assertions.assertThat(getMaxIdle(getResponse)).isNull();
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceTest method testIfModifiedHeaderForCache.
@Test
public void testIfModifiedHeaderForCache() {
putStringValueInCache("expiration", "test", "test");
RestCacheClient cacheClient = client.cache("expiration");
RestResponse resp = join(cacheClient.get("test"));
String dateLast = resp.headers().get("Last-Modified").get(0);
CompletionStage<RestResponse> sameLastModAndIfModified = cacheClient.get("test", createHeaders(IF_MODIFIED_SINCE, dateLast));
assertThat(sameLastModAndIfModified).isNotModified();
putStringValueInCache("expiration", "test", "test-new");
RestResponse lastmodAfterIfModified = join(cacheClient.get("test"));
dateLast = lastmodAfterIfModified.headers().get("Last-Modified").get(0);
assertThat(lastmodAfterIfModified).isOk();
Map<String, String> header = createHeaders(IF_MODIFIED_SINCE, plus1Day(dateLast));
CompletionStage<RestResponse> lastmodBeforeIfModified = cacheClient.get("test", header);
assertThat(lastmodBeforeIfModified).isNotModified();
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class CacheResourceTest method shouldReadTextWithPojoCache.
@Test
public void shouldReadTextWithPojoCache() {
// given
RestCacheClient pojoCache = client.cache("pojoCache");
String key = "k1";
String value = "v1";
join(pojoCache.put(key, value));
// when
RestResponse response = join(pojoCache.get(key));
// then
assertThat(response).isOk();
assertThat(response).hasContentType(TEXT_PLAIN_TYPE);
assertThat(response).hasReturnedText(value);
}
Aggregations