Search in sources :

Example 1 with Test107CacheEntryListener

use of com.pany.ehcache.Test107CacheEntryListener in project ehcache3 by ehcache.

the class Eh107XmlIntegrationTest method testTemplateAddsListeners.

@Test
public void testTemplateAddsListeners() throws Exception {
    CacheManager cacheManager = cachingProvider.getCacheManager(getClass().getResource("/ehcache-107-listeners.xml").toURI(), getClass().getClassLoader());
    MutableConfiguration<String, String> configuration = new MutableConfiguration<>();
    configuration.setTypes(String.class, String.class);
    MutableCacheEntryListenerConfiguration<String, String> listenerConfiguration = new MutableCacheEntryListenerConfiguration<>(Test107CacheEntryListener::new, null, false, true);
    configuration.addCacheEntryListenerConfiguration(listenerConfiguration);
    Cache<String, String> cache = cacheManager.createCache("foos", configuration);
    cache.put("Hello", "Bonjour");
    assertThat(Test107CacheEntryListener.seen.size(), is(1));
    assertThat(TestCacheEventListener.seen.size(), is(1));
}
Also used : MutableCacheEntryListenerConfiguration(javax.cache.configuration.MutableCacheEntryListenerConfiguration) CacheManager(javax.cache.CacheManager) Test107CacheEntryListener(com.pany.ehcache.Test107CacheEntryListener) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Test(org.junit.Test)

Aggregations

Test107CacheEntryListener (com.pany.ehcache.Test107CacheEntryListener)1 CacheManager (javax.cache.CacheManager)1 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)1 MutableConfiguration (javax.cache.configuration.MutableConfiguration)1 Test (org.junit.Test)1