Search in sources :

Example 1 with PersonExpiryPolicyFactory

use of classloading.domain.PersonExpiryPolicyFactory in project hazelcast by hazelcast.

the class CacheTypesConfigTest method cacheConfigShouldBeAddedOnJoiningMember_whenExpiryPolicyFactoryNotResolvable.

// tests deferred resolution of expiry policy factory
@Test
public void cacheConfigShouldBeAddedOnJoiningMember_whenExpiryPolicyFactoryNotResolvable() throws InterruptedException {
    HazelcastInstance hz1 = factory.newHazelcastInstance(getConfig());
    CachingProvider cachingProvider = createServerCachingProvider(hz1);
    cachingProvider.getCacheManager().createCache(cacheName, createCacheConfig().setExpiryPolicyFactory(new PersonExpiryPolicyFactory()));
    HazelcastInstance hz2 = factory.newHazelcastInstance(getClassFilteringConfig());
    assertClusterSize(2, hz1, hz2);
    ICache<String, Person> cache = hz2.getCacheManager().getCache(cacheName);
    String key = generateKeyOwnedBy(hz2);
    expect.expectCause(new RootCauseMatcher(ClassNotFoundException.class, "classloading.domain.PersonExpiryPolicyFactory - " + "Package excluded explicitly"));
    cache.invoke(key, new PersonEntryProcessor());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) PersonExpiryPolicyFactory(classloading.domain.PersonExpiryPolicyFactory) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) Person(classloading.domain.Person) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) PersonEntryProcessor(classloading.domain.PersonEntryProcessor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with PersonExpiryPolicyFactory

use of classloading.domain.PersonExpiryPolicyFactory in project hazelcast by hazelcast.

the class PreJoinCacheConfigTest method serializationSucceeds_cacheExpiryFactory.

@Test
public void serializationSucceeds_cacheExpiryFactory() {
    CacheConfig<String, Person> cacheConfig = newDefaultCacheConfig("test");
    cacheConfig.setExpiryPolicyFactory(new PersonExpiryPolicyFactory());
    PreJoinCacheConfig preJoinCacheConfig = new PreJoinCacheConfig(cacheConfig);
    Data data = serializationService.toData(preJoinCacheConfig);
    PreJoinCacheConfig deserialized = serializationService.toObject(data);
    assertEquals(preJoinCacheConfig, deserialized);
    assertEquals(cacheConfig, deserialized.asCacheConfig());
    assertNull(deserialized.getCacheWriterFactory());
    assertTrue("Invalid Factory Class", deserialized.getExpiryPolicyFactory() instanceof PersonExpiryPolicyFactory);
}
Also used : PersonExpiryPolicyFactory(classloading.domain.PersonExpiryPolicyFactory) Data(com.hazelcast.internal.serialization.Data) Person(classloading.domain.Person) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) CacheConfigTest(com.hazelcast.config.CacheConfigTest) Test(org.junit.Test)

Aggregations

Person (classloading.domain.Person)2 PersonExpiryPolicyFactory (classloading.domain.PersonExpiryPolicyFactory)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 PersonEntryProcessor (classloading.domain.PersonEntryProcessor)1 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)1 CacheConfigTest (com.hazelcast.config.CacheConfigTest)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Data (com.hazelcast.internal.serialization.Data)1 RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)1 CachingProvider (javax.cache.spi.CachingProvider)1