use of org.infinispan.client.hotrod.event.CustomEventLogListener.RawStaticCustomEventLogListener in project infinispan by infinispan.
the class ClientCustomEventsTest method testRawCustomEvents.
public void testRawCustomEvents() {
RawStaticCustomEventLogListener<Integer> eventListener = new RawStaticCustomEventLogListener<>(remoteCacheManager.getCache());
withClientListener(eventListener, remote -> {
eventListener.expectNoEvents();
Marshaller marshaller = remote.getRemoteCacheManager().getMarshaller();
Integer key = 1;
Object value = "one";
try {
byte[] keyBytes = marshaller.objectToByteBuffer(key);
byte[] valBytes = marshaller.objectToByteBuffer(value);
// Put initial value and assert converter creates a byte[] of the key + value bytes
remote.put(key, value);
eventListener.expectCreatedEvent(CustomEventLogListener.concat(keyBytes, valBytes));
value = "newone";
// Repeat with new value
valBytes = marshaller.objectToByteBuffer(value);
remote.put(key, value);
eventListener.expectModifiedEvent(CustomEventLogListener.concat(keyBytes, valBytes));
// Only keyBytes should be returned as no value in remove event
remote.remove(key);
eventListener.expectRemovedEvent(keyBytes);
} catch (InterruptedException | IOException e) {
fail(e.getMessage());
}
});
}
Aggregations