use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldUpdateEntryWhenReplacingUsingPut.
@Test
public void shouldUpdateEntryWhenReplacingUsingPut() throws Exception {
// given
putStringValueInCache("default", "test", "test");
// when
join(client.cache("default").put("test", "Hey!"));
RestResponse getResponse = join(client.cache("default").get("test"));
// then
ResponseAssertion.assertThat(getResponse).isOk();
Assertions.assertThat(getResponse.getBody()).isEqualTo("Hey!");
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldNegotiateFromDefaultCacheWithBinary.
@Test
public void shouldNegotiateFromDefaultCacheWithBinary() throws Exception {
TestClass testClass = new TestClass();
Marshaller marshaller = TestingUtil.createProtoStreamMarshaller(RestTestSCI.INSTANCE);
byte[] javaSerialized = marshaller.objectToByteBuffer(testClass);
putBinaryValueInCache("default", "test", javaSerialized, APPLICATION_OCTET_STREAM);
RestResponse response = get("default", "test", APPLICATION_OCTET_STREAM_TYPE);
ResponseAssertion.assertThat(response).hasContentType(APPLICATION_OCTET_STREAM_TYPE);
ResponseAssertion.assertThat(response).hasReturnedBytes(javaSerialized);
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldAcceptUrlEncodedContentForDefaultCache.
@Test
public void shouldAcceptUrlEncodedContentForDefaultCache() throws Exception {
String value = "word1 word2";
String urlEncoded = URLEncoder.encode(value, "UTF-8");
putBinaryValueInCache("default", "test", urlEncoded.getBytes(UTF_8), APPLICATION_WWW_FORM_URLENCODED);
RestResponse getResponse = get("default", "test", TEXT_PLAIN_TYPE);
ResponseAssertion.assertThat(getResponse).hasReturnedText(value);
ResponseAssertion.assertThat(getResponse).hasContentType(TEXT_PLAIN_TYPE);
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldNotReturnValueIfSendingCorrectETag.
@Test
public void shouldNotReturnValueIfSendingCorrectETag() throws Exception {
// given
putStringValueInCache("default", "test", "test");
// when
RestResponse firstResponse = join(client.cache("default").get("test"));
String etagFromFirstCall = firstResponse.headers().get("ETag").get(0);
Map<String, String> headers = createHeaders(IF_NONE_MATCH, etagFromFirstCall);
CompletionStage<RestResponse> secondResponse = client.cache("default").get("test", headers);
// then
Assertions.assertThat(etagFromFirstCall).isNotNull().isNotEmpty();
ResponseAssertion.assertThat(secondResponse).isNotModified();
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldNegotiateFromDefaultCacheWithoutAccept.
@Test
public void shouldNegotiateFromDefaultCacheWithoutAccept() throws Exception {
putStringValueInCache("default", "test", "test");
RestResponse getResponse = get("default", "test", null);
ResponseAssertion.assertThat(getResponse).hasReturnedText("test");
ResponseAssertion.assertThat(getResponse).hasContentType(APPLICATION_OCTET_STREAM_TYPE);
}
Aggregations