use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class CacheTypesConfigTest method getClassFilteringConfig.
private Config getClassFilteringConfig() {
List<String> excludes = Arrays.asList("classloading");
ClassLoader classLoader = new FilteringClassLoader(excludes, null);
return getConfig().setClassLoader(classLoader);
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentTest method createNodeConfig.
private Config createNodeConfig() {
Config config = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
config.setClassLoader(filteringCL);
config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode).setProviderMode(providerMode);
return config;
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenTheEPButItIsBlacklisted_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt.
@Test
public void givenTheEPButItIsBlacklisted_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt() {
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).setBlacklistedPrefixes("usercodedeployment.blacklisted").setClassCacheMode(classCacheMode);
EntryProcessor<Integer, Integer, Integer> myEP = new BlacklistedEP();
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 givenInnerClassOneIsCachedInServer1_whenInnerClassTwoIsRequested_thenServer1RespondsNull.
@Test
public void givenInnerClassOneIsCachedInServer1_whenInnerClassTwoIsRequested_thenServer1RespondsNull() {
Config config = new Config();
config.getUserCodeDeploymentConfig().setEnabled(true);
Config configWithoutEnclosingClass = new Config();
FilteringClassLoader filteringCL = new FilteringClassLoader(asList("usercodedeployment"), null);
configWithoutEnclosingClass.setClassLoader(filteringCL);
configWithoutEnclosingClass.getUserCodeDeploymentConfig().setEnabled(true);
ClassWithTwoInnerClasses.StaticNestedIncrementingEntryProcessor<String> ep = new ClassWithTwoInnerClasses.StaticNestedIncrementingEntryProcessor<String>();
HazelcastInstance instance1WithoutEp = factory.newHazelcastInstance(configWithoutEnclosingClass);
HazelcastInstance instance2WithoutEp = factory.newHazelcastInstance(configWithoutEnclosingClass);
// instance with ep
factory.newHazelcastInstance(config);
String mapName = randomName();
IMap<String, Integer> map = instance1WithoutEp.getMap(mapName);
String key = generateKeyOwnedBy(instance2WithoutEp);
map.put(key, 0);
map.executeOnEntries(ep);
assertEquals(1, (int) map.get(key));
ClassWithTwoInnerClasses.StaticNestedDecrementingEntryProcessor ep2 = new ClassWithTwoInnerClasses.StaticNestedDecrementingEntryProcessor();
// executing ep on instance without that ep
map.executeOnKey(key, ep2);
assertEquals(0, (int) map.get(key));
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenTheEPButItIsNotOnTheWhitelist_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt.
@Test
public void givenTheEPButItIsNotOnTheWhitelist_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt() {
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").setClassCacheMode(classCacheMode);
EntryProcessor<Integer, Integer, Integer> myEP = new IncrementingEntryProcessor();
try {
executeSimpleTestScenario(i1Config, i2Config, myEP);
fail();
} catch (Exception e) {
assertInstanceOfByClassName(HazelcastSerializationException.class.getName(), e);
}
}
Aggregations