use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class EmbeddedRestHotRodTest method testHotRodEmbeddedPutRestGetExpiry.
public void testHotRodEmbeddedPutRestGetExpiry() throws Exception {
final String key = "10";
final String key2 = "11";
// 1. Put with HotRod
assertNull(cacheFactory.getHotRodCache().put(key, "v1", 5, TimeUnit.SECONDS));
// 2. Put with Embedded
assertNull(cacheFactory.getEmbeddedCache().put(key2, "v2", 5, TimeUnit.SECONDS));
// 3. Get with REST key
RestResponse response = join(cacheFactory.getRestCacheClient().get(key));
assertEquals(200, response.getStatus());
assertDate(response, "Expires");
// 4. Get with REST key2
response = join(cacheFactory.getRestCacheClient().get(key2));
assertEquals(200, response.getStatus());
assertDate(response, "Expires");
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class EmbeddedRestHotRodTest method testHotRodPutEmbeddedRestGet.
public void testHotRodPutEmbeddedRestGet() {
final String key = "3";
// 1. Put with Hot Rod
RemoteCache<String, Object> remote = cacheFactory.getHotRodCache();
assertNull(remote.withFlags(Flag.FORCE_RETURN_VALUE).put(key, "v1"));
// 2. Get with Embedded
assertEquals("v1", cacheFactory.getEmbeddedCache().get(key));
// 3. Get with REST
RestResponse response = join(cacheFactory.getRestCacheClient().get(key, TEXT_PLAIN_TYPE));
assertEquals(200, response.getStatus());
assertEquals("v1", response.getBody());
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class EmbeddedRestHotRodTest method testHotRodEmbeddedPutRestGetWrongAccept.
public void testHotRodEmbeddedPutRestGetWrongAccept() {
final String key1 = "16";
final String key2 = "17";
// 1. Put with HotRod
assertNull(cacheFactory.getHotRodCache().put(key1, "v1"));
// 2. Put with Embedded
assertNull(cacheFactory.getEmbeddedCache().put(key2, "v2"));
// 3. GET with REST key1
RestResponse response = join(cacheFactory.getRestCacheClient().get(key1, "unknown-media-type"));
assertEquals(406, response.getStatus());
// 4. GET with REST key2
response = join(cacheFactory.getRestCacheClient().get(key2, "unknown-media-type"));
assertEquals(406, response.getStatus());
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class EmbeddedRestHotRodTest method testRestPutEmbeddedHotRodGet.
public void testRestPutEmbeddedHotRodGet() {
final String key = "1";
// 1. Put with REST
RestCacheClient restCacheClient = cacheFactory.getRestCacheClient();
CompletionStage<RestResponse> response = restCacheClient.put(key, RestEntity.create(TEXT_PLAIN, "<hey>ho</hey>"));
assertEquals(204, join(response).getStatus());
// 2. Get with Embedded
assertEquals("<hey>ho</hey>", cacheFactory.getEmbeddedCache().get(key));
// 3. Get with Hot Rod
assertEquals("<hey>ho</hey>", cacheFactory.getHotRodCache().get(key));
}
use of org.infinispan.client.rest.RestResponse in project infinispan by infinispan.
the class EmbeddedRestHotRodTest method testCustomObjectHotRodPutRestGetAcceptJSONAndXML.
public void testCustomObjectHotRodPutRestGetAcceptJSONAndXML() {
final String key = "7";
final Person p = new Person("Jakub");
// 1. Put with HotRod
RemoteCache<String, Object> remote = cacheFactory.getHotRodCache();
assertNull(remote.withFlags(Flag.FORCE_RETURN_VALUE).put(key, p));
// 2. Get with REST (accept application/json)
RestResponse response = join(cacheFactory.getRestCacheClient().get(key, APPLICATION_JSON_TYPE));
assertEquals(200, response.getStatus());
assertEquals(asJson(p), response.getBody());
// 3. Get with REST (accept application/xml)
response = join(cacheFactory.getRestCacheClient().get(key, APPLICATION_XML_TYPE));
assertEquals(200, response.getStatus());
assertTrue(response.getBody().contains("<name>Jakub</name>"));
}
Aggregations