Search in sources :

Example 56 with RestResponse

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!");
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 57 with RestResponse

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);
}
Also used : Marshaller(org.infinispan.commons.marshall.Marshaller) RestResponse(org.infinispan.client.rest.RestResponse) TestClass(org.infinispan.rest.TestClass) Test(org.testng.annotations.Test)

Example 58 with RestResponse

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);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 59 with RestResponse

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();
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 60 with RestResponse

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);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Aggregations

RestResponse (org.infinispan.client.rest.RestResponse)233 Test (org.testng.annotations.Test)108 Json (org.infinispan.commons.dataconversion.internal.Json)52 RestCacheClient (org.infinispan.client.rest.RestCacheClient)42 Test (org.junit.Test)41 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)39 RestClient (org.infinispan.client.rest.RestClient)37 RestEntity (org.infinispan.client.rest.RestEntity)36 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)23 HashMap (java.util.HashMap)8 RestCounterClient (org.infinispan.client.rest.RestCounterClient)8 TestClass (org.infinispan.rest.TestClass)8 RestSchemaClient (org.infinispan.client.rest.RestSchemaClient)7 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)6 RestMetricsClient (org.infinispan.client.rest.RestMetricsClient)6 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)6 Cache (org.infinispan.Cache)5 RestRawClient (org.infinispan.client.rest.RestRawClient)5 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)5