use of org.infinispan.client.hotrod.event.EventLogListener in project infinispan by infinispan.
the class ComplexValue method testListenersWithDifferentFormats.
@Test
public void testListenersWithDifferentFormats() {
remoteCache.clear();
ComplexKey complexKey = new ComplexKey("Key-1", 89.88f);
ComplexValue complexValue = new ComplexValue(Util.threadLocalRandomUUID());
// Receive events as JSON Strings
DataFormat jsonStringFormat = DataFormat.builder().keyType(APPLICATION_JSON).keyMarshaller(new UTF8StringMarshaller()).build();
EventLogListener<Object> l = new EventLogListener<>(remoteCache.withDataFormat(jsonStringFormat));
withClientListener(l, remote -> {
remoteCache.put(complexKey, complexValue);
l.expectOnlyCreatedEvent("\n{\n \"_type\": \"org.infinispan.test.client.DataFormatTest.ComplexKey\",\n \"id\": \"Key-1\",\n \"ratio\": 89.88\n}\n");
});
}
use of org.infinispan.client.hotrod.event.EventLogListener in project infinispan by infinispan.
the class SecureListenerTest method testAddListenerWithoutPermission.
public void testAddListenerWithoutPermission() throws IOException, PrivilegedActionException {
org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = newClientBuilder();
clientBuilder.security().authentication().saslMechanism("CRAM-MD5").username("RWuser").password("password");
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
RemoteCache<Object, Object> clientCache = remoteCacheManager.getCache(CACHE_NAME);
EventLogListener<Object> listener = new EventLogListener<>(clientCache);
Exceptions.expectException(HotRodClientException.class, () -> clientCache.addClientListener(listener));
Cache<Object, Object> serverCache = cacheManager.getCache(CACHE_NAME);
CacheNotifier cacheNotifier = TestingUtil.extractComponent(serverCache, CacheNotifier.class);
assertEquals(0, cacheNotifier.getListeners().size());
remoteCacheManager.close();
assertEquals(0, cacheNotifier.getListeners().size());
}
use of org.infinispan.client.hotrod.event.EventLogListener in project infinispan by infinispan.
the class SecureListenerTest method testImplicitRemoveOnClose.
public void testImplicitRemoveOnClose() throws IOException, PrivilegedActionException {
org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder = newClientBuilder();
clientBuilder.security().authentication().callbackHandler(new TestCallbackHandler("RWLuser", null, "password"));
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
RemoteCache<Object, Object> clientCache = remoteCacheManager.getCache(CACHE_NAME);
EventLogListener<Object> listener = new EventLogListener<>(clientCache);
clientCache.addClientListener(listener);
Cache<Object, Object> serverCache = cacheManager.getCache(CACHE_NAME);
CacheNotifier cacheNotifier = TestingUtil.extractComponent(serverCache, CacheNotifier.class);
assertEquals(1, cacheNotifier.getListeners().size());
clientCache.put("key", "value");
listener.expectSingleEvent("key", ClientEvent.Type.CLIENT_CACHE_ENTRY_CREATED);
remoteCacheManager.close();
eventuallyEquals(0, () -> cacheNotifier.getListeners().size());
}
Aggregations