use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class PersonKey2StringMapper method getStringMapping.
public String getStringMapping(Object key) {
Person person = (Person) key;
Address addr = person.getAddress();
if (addr == null)
return person.getName();
return person.getName() + "_" + addr.getStreet() + "_" + addr.getCity() + "_" + addr.getZip();
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class TextObjectTranscoderTest method setUp.
@BeforeClass(alwaysRun = true)
public void setUp() {
dataSrc = new Person("Joe");
Address address = new Address();
address.setCity("London");
dataSrc.setAddress(address);
transcoder = new DefaultTranscoder(TestingUtil.createProtoStreamMarshaller(RestTestSCI.INSTANCE));
supportedMediaTypes = transcoder.getSupportedMediaTypes();
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class AllowListMarshallingTest method testSafeClassAllowed.
public void testSafeClassAllowed() {
remoteCacheManager.getCache().put("safe", new Person());
remoteCacheManager.getCache().get("safe");
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class ProtostreamTranscoderTest method testWrappedMessage.
@Test
public void testWrappedMessage() throws IOException {
Person input = new Person("value");
// Produces MessageWrapped and unwrapped payloads
byte[] wrapped = (byte[]) transcoder.transcode(input, APPLICATION_OBJECT, APPLICATION_PROTOSTREAM);
byte[] unwrapped = (byte[]) transcoder.transcode(input, APPLICATION_OBJECT, UNWRAPPED_PROTOSTREAM);
assertEquals(input, ProtobufUtil.fromWrappedByteArray(ctx, wrapped));
assertEquals(input, ProtobufUtil.fromByteArray(ctx, unwrapped, Person.class));
// Convert from MessageWrapped back to object
Object fromWrapped = transcoder.transcode(wrapped, APPLICATION_PROTOSTREAM, APPLICATION_OBJECT);
assertEquals(input, fromWrapped);
// Convert from unwrapped payload back to object, specifying the object type
Object fromUnWrappedWithType = transcoder.transcode(unwrapped, UNWRAPPED_PROTOSTREAM, TYPED_OBJECT);
assertEquals(input, fromUnWrappedWithType);
// Should throw exception if trying to convert from unwrapped without passing the type
try {
transcoder.transcode(unwrapped, UNWRAPPED_PROTOSTREAM, APPLICATION_OBJECT);
Assert.fail("should not convert from unwrapped without type");
} catch (MarshallingException ignored) {
}
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class LazyCacheAPITest method testReplace.
public void testReplace(Method m) {
Person key = new Person(m.getName());
cache.put(key, "1");
assert "1".equals(cache.get(new Person(m.getName())));
Object oldValue = cache.replace(new Person(m.getName()), "2");
assert "1".equals(oldValue);
assert "2".equals(cache.get(new Person(m.getName())));
}
Aggregations