Search in sources :

Example 6 with TestClass

use of org.infinispan.rest.TestClass in project infinispan by infinispan.

the class CacheResourceTest method shouldNegotiateFromPojoCacheWithoutAccept.

@Test
public void shouldNegotiateFromPojoCacheWithoutAccept() {
    // given
    TestClass testClass = new TestClass();
    testClass.setName("test");
    String json = testClass.toJson().toString();
    RestCacheClient pojoCache = client.cache("pojoCache");
    String key = "k1";
    join(pojoCache.put("k1", json));
    // when
    RestResponse response = join(pojoCache.get(key, Collections.emptyMap()));
    // then
    assertThat(response).isOk();
    assertThat(response).hasContentType(MediaType.TEXT_PLAIN_TYPE);
    assertThat(response).hasReturnedText(json);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) TestClass(org.infinispan.rest.TestClass) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Test(org.testng.annotations.Test)

Example 7 with TestClass

use of org.infinispan.rest.TestClass in project infinispan by infinispan.

the class CacheResourceTest method shouldConvertExistingSerializableObjectToXml.

@Test
public void shouldConvertExistingSerializableObjectToXml() {
    // given
    TestClass testClass = new TestClass();
    testClass.setName("test");
    RestCacheClient objectCache = client.cache("objectCache");
    String xml = "<org.infinispan.rest.TestClass><name>test</name></org.infinispan.rest.TestClass>";
    join(objectCache.put("test", RestEntity.create(APPLICATION_XML, xml)));
    // when
    RestResponse response = join(objectCache.get("test", APPLICATION_XML_TYPE));
    // then
    assertThat(response).isOk();
    assertThat(response).hasContentType("application/xml");
    assertThat(response).hasReturnedText(xml);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) TestClass(org.infinispan.rest.TestClass) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Test(org.testng.annotations.Test)

Example 8 with TestClass

use of org.infinispan.rest.TestClass in project infinispan by infinispan.

the class CacheResourceTest method shouldReadAsBinaryWithPojoCache.

@Test
public void shouldReadAsBinaryWithPojoCache() {
    // given
    RestCacheClient pojoCache = client.cache("pojoCache");
    String key = "test";
    TestClass value = new TestClass();
    value.setName("test");
    join(pojoCache.put(key, value.toJson().toString()));
    // when
    RestResponse response = join(pojoCache.get(key, APPLICATION_OCTET_STREAM_TYPE));
    // then
    assertThat(response).isOk();
    assertThat(response).hasContentType(APPLICATION_OCTET_STREAM_TYPE);
}
Also used : RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) TestClass(org.infinispan.rest.TestClass) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Test(org.testng.annotations.Test)

Aggregations

RestResponse (org.infinispan.client.rest.RestResponse)8 TestClass (org.infinispan.rest.TestClass)8 Test (org.testng.annotations.Test)8 RestCacheClient (org.infinispan.client.rest.RestCacheClient)5 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)3 Marshaller (org.infinispan.commons.marshall.Marshaller)1