Search in sources :

Example 1 with Person

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);
}
Also used : XMLTranscoder(org.infinispan.server.core.dataconversion.XMLTranscoder) RestEntity(org.infinispan.client.rest.RestEntity) RestResponse(org.infinispan.client.rest.RestResponse) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) Person(org.infinispan.rest.search.entity.Person) JsonTranscoder(org.infinispan.server.core.dataconversion.JsonTranscoder) JavaSerializationMarshaller(org.infinispan.commons.marshall.JavaSerializationMarshaller) Test(org.testng.annotations.Test)

Aggregations

RestEntity (org.infinispan.client.rest.RestEntity)1 RestResponse (org.infinispan.client.rest.RestResponse)1 JavaSerializationMarshaller (org.infinispan.commons.marshall.JavaSerializationMarshaller)1 Util.getResourceAsString (org.infinispan.commons.util.Util.getResourceAsString)1 Person (org.infinispan.rest.search.entity.Person)1 JsonTranscoder (org.infinispan.server.core.dataconversion.JsonTranscoder)1 XMLTranscoder (org.infinispan.server.core.dataconversion.XMLTranscoder)1 Test (org.testng.annotations.Test)1