use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenProviderFilterUsesMemberAttribute_whenNoMemberHasMatchingAttribute_thenClassLoadingRequestFails.
@Test
public void givenProviderFilterUsesMemberAttribute_whenNoMemberHasMatchingAttribute_thenClassLoadingRequestFails() {
Config i1Config = new Config();
i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
Config i2Config = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
i2Config.setClassLoader(filteringCL);
i2Config.getUserCodeDeploymentConfig().setEnabled(true).setProviderFilter("HAS_ATTRIBUTE:foo").setClassCacheMode(classCacheMode);
EntryProcessor<Integer, Integer, Integer> myEP = new IncrementingEntryProcessor();
try {
executeSimpleTestScenario(i1Config, i2Config, myEP);
fail();
} catch (Exception e) {
assertInstanceOfByClassName(HazelcastSerializationException.class.getName(), e);
}
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenSomeMemberCanAccessTheEP_whenTheEPIsFilteredLocally_thenItWillBeLoadedOverNetwork.
@Test
public void givenSomeMemberCanAccessTheEP_whenTheEPIsFilteredLocally_thenItWillBeLoadedOverNetwork() {
Config i1Config = new Config();
i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
Config i2Config = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
i2Config.setClassLoader(filteringCL);
i2Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
IncrementingEntryProcessor incrementingEntryProcessor = new IncrementingEntryProcessor();
executeSimpleTestScenario(i1Config, i2Config, incrementingEntryProcessor);
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method testMainClassFetchedFirst_thenInnerlassFetchedFromRemote.
@Test
public void testMainClassFetchedFirst_thenInnerlassFetchedFromRemote() {
Config i1Config = new Config();
i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
Config filteredConfig = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
filteredConfig.setClassLoader(filteringCL);
filteredConfig.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
HazelcastInstance instanceWithClasses = factory.newHazelcastInstance(i1Config);
HazelcastInstance instanceWithoutTheClasses = factory.newHazelcastInstance(filteredConfig);
IMap<Object, Object> map = instanceWithClasses.getMap("test");
DomainClassWithInnerClass mainDomainObject = new DomainClassWithInnerClass(new DomainClassWithInnerClass.InnerClass(2));
map.put("main", mainDomainObject);
DomainClassWithInnerClass.InnerClass innerObject = new DomainClassWithInnerClass.InnerClass(1);
map.put("inner", innerObject);
IMap<Object, Object> map2 = instanceWithoutTheClasses.getMap("test");
map2.get("main");
map2.get("inner");
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenProviderFilterUsesMemberAttribute_whenSomeMemberHasMatchingAttribute_thenClassLoadingRequestSucceed.
@Test
public void givenProviderFilterUsesMemberAttribute_whenSomeMemberHasMatchingAttribute_thenClassLoadingRequestSucceed() {
Config i1Config = new Config();
i1Config.getMemberAttributeConfig().setAttribute("foo", "bar");
i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
Config i2Config = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
i2Config.setClassLoader(filteringCL);
i2Config.getUserCodeDeploymentConfig().setEnabled(true).setProviderFilter("HAS_ATTRIBUTE:foo").setClassCacheMode(classCacheMode);
EntryProcessor<Integer, Integer, Integer> myEP = new IncrementingEntryProcessor();
executeSimpleTestScenario(i1Config, i2Config, myEP);
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenTheEPIsOnTheWhitelist_whenTheEPIsFilteredLocally_thenItWillLoadIt.
@Test
public void givenTheEPIsOnTheWhitelist_whenTheEPIsFilteredLocally_thenItWillLoadIt() {
Config i1Config = new Config();
i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
Config i2Config = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
i2Config.setClassLoader(filteringCL);
i2Config.getUserCodeDeploymentConfig().setEnabled(true).setWhitelistedPrefixes("usercodedeployment.whitelisted, usercodedeployment").setClassCacheMode(classCacheMode);
EntryProcessor<Integer, Integer, Integer> myEP = new WhitelistedEP();
executeSimpleTestScenario(i1Config, i2Config, myEP);
}
Aggregations