use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class CounterResourceTest method createCounter.
private void createCounter(String name, CounterConfiguration configuration) {
AbstractCounterConfiguration config = ConvertUtil.configToParsedConfig(name, configuration);
RestEntity restEntity = RestEntity.create(APPLICATION_JSON, counterConfigToJson(config));
CompletionStage<RestResponse> response = client.counter(name).create(restEntity);
assertThat(response).isOk();
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class MultiResourceTest method createCaches.
private void createCaches(String... names) {
RestEntity jsonEntity = RestEntity.create(APPLICATION_JSON, "{}");
for (String cacheName : names) {
CompletionStage<RestResponse> response = client.cache(cacheName).createWithConfiguration(jsonEntity, CacheContainerAdmin.AdminFlag.VOLATILE);
ResponseAssertion.assertThat(response).isOk();
}
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldPutUnknownFormatValueInCache.
@Test
public void shouldPutUnknownFormatValueInCache() {
// when
RestEntity restEntity = RestEntity.create(MediaType.fromString("application/unknown"), "Hey!");
CompletionStage<RestResponse> response = client.cache("unknown").post("test", restEntity);
ResponseAssertion.assertThat(response).isOk();
RestResponse getResponse = join(client.cache("unknown").get("test"));
// then
ResponseAssertion.assertThat(getResponse).isOk();
ResponseAssertion.assertThat(getResponse).hasEtag();
Assertions.assertThat(getResponse.getBody()).isEqualTo("Hey!");
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class BaseCacheResourceTest method shouldFailTooLargeObject.
@Test
public void shouldFailTooLargeObject() {
// when
byte[] payload = new byte[1_100_000];
RestEntity restEntity = RestEntity.create(APPLICATION_OCTET_STREAM, payload);
CompletionStage<RestResponse> response = client.cache("default").post("test", restEntity);
// then
ResponseAssertion.assertThat(response).isPayloadTooLarge();
}
use of org.infinispan.client.rest.RestEntity in project infinispan by infinispan.
the class CacheResourceTest method testServerDeserialization.
@Test
public void testServerDeserialization() throws Exception {
Object value = new Person();
byte[] jsonMarshalled = (byte[]) new JsonTranscoder().transcode(value, APPLICATION_OBJECT, APPLICATION_JSON);
byte[] xmlMarshalled = (byte[]) new XMLTranscoder().transcode(value, APPLICATION_OBJECT, APPLICATION_XML);
byte[] javaMarshalled = new JavaSerializationMarshaller().objectToByteBuffer(value);
String expectError = "Class '" + value.getClass().getName() + "' blocked by deserialization allow list";
RestEntity jsonEntity = RestEntity.create(APPLICATION_JSON, jsonMarshalled);
RestEntity xmlEntity = RestEntity.create(APPLICATION_XML, xmlMarshalled);
RestEntity javaEntity = RestEntity.create(APPLICATION_SERIALIZED_OBJECT, javaMarshalled);
CompletionStage<RestResponse> jsonResponse = client.cache("objectCache").put("addr2", jsonEntity);
assertThat(jsonResponse).isError();
assertThat(jsonResponse).containsReturnedText(expectError);
CompletionStage<RestResponse> xmlResponse = client.cache("objectCache").put("addr3", xmlEntity);
assertThat(xmlResponse).isError();
assertThat(xmlResponse).containsReturnedText(expectError);
CompletionStage<RestResponse> serializationResponse = client.cache("objectCache").put("addr4", javaEntity);
assertThat(serializationResponse).isError();
assertThat(serializationResponse).containsReturnedText(expectError);
}
Aggregations