Search in sources :

Example 61 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BaseCacheResourceTest method shouldNegotiateOnlySupportedFromDefaultCacheWithMultipleAccept.

@Test
public void shouldNegotiateOnlySupportedFromDefaultCacheWithMultipleAccept() throws Exception {
    String value = "<test/>";
    putStringValueInCache("default", "test", value);
    RestResponse getResponse = get("default", "test", "text/html, application/xml");
    ResponseAssertion.assertThat(getResponse).hasReturnedText("<test/>");
    ResponseAssertion.assertThat(getResponse).hasContentType("application/xml");
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 62 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BaseCacheResourceTest method shouldNegotiateFromJsonCacheWithWildcardAccept.

@Test
public void shouldNegotiateFromJsonCacheWithWildcardAccept() throws Exception {
    String cacheName = "json";
    String key = "1";
    String value = "{\"id\": 1}";
    putJsonValueInCache(cacheName, key, value);
    RestResponse jsonResponse = get(cacheName, key, "*/*");
    ResponseAssertion.assertThat(jsonResponse).isOk();
    ResponseAssertion.assertThat(jsonResponse).hasReturnedText(value);
    ResponseAssertion.assertThat(jsonResponse).hasContentType(APPLICATION_JSON_TYPE);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 63 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BaseCacheResourceTest method shouldNegotiateFromDefaultCacheWithWildcardAccept.

@Test
public void shouldNegotiateFromDefaultCacheWithWildcardAccept() throws Exception {
    putStringValueInCache("default", "test", "test");
    RestResponse getResponse = get("default", "test", "*/*");
    ResponseAssertion.assertThat(getResponse).isOk();
    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)

Example 64 with RestResponse

use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.

the class BaseCacheResourceTest method shouldNegotiateFromJsonCacheWithoutAccept.

@Test
public void shouldNegotiateFromJsonCacheWithoutAccept() throws Exception {
    String cacheName = "json";
    String key = "1";
    String value = "{\"id\": 1}";
    putJsonValueInCache(cacheName, key, value);
    RestResponse getResponse = get(cacheName, key, null);
    ResponseAssertion.assertThat(getResponse).hasReturnedText(value);
    ResponseAssertion.assertThat(getResponse).hasContentType(APPLICATION_JSON_TYPE);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test)

Example 65 with RestResponse

use of org.infinispan.client.rest.RestResponse 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();
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) 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