use of org.infinispan.rest.search.entity.Person 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