Search in sources :

Example 1 with FilteringClassLoader

use of com.hazelcast.util.FilteringClassLoader in project hazelcast by hazelcast.

the class UserCodeDeploymentSmokeTest method givenProviderFilterUsesMemberAttribute_whenSomeMemberHasMatchingAttribute_thenClassLoadingRequestSucceed.

@Test
public void givenProviderFilterUsesMemberAttribute_whenSomeMemberHasMatchingAttribute_thenClassLoadingRequestSucceed() {
    Config i1Config = new Config();
    i1Config.getMemberAttributeConfig().setStringAttribute("foo", "bar");
    i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    Config i2Config = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(asList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    i2Config.getUserCodeDeploymentConfig().setEnabled(true).setProviderFilter("HAS_ATTRIBUTE:foo").setClassCacheMode(classCacheMode);
    EntryProcessor<Integer, Integer> myEP = new IncrementingEntryProcessor();
    executeSimpleTestScenario(i1Config, i2Config, myEP);
}
Also used : Config(com.hazelcast.config.Config) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) FilteringClassLoader(com.hazelcast.util.FilteringClassLoader) IncrementingEntryProcessor(usercodedeployment.IncrementingEntryProcessor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with FilteringClassLoader

use of com.hazelcast.util.FilteringClassLoader in project hazelcast by hazelcast.

the class UserCodeDeploymentSmokeTest method givenTheEPButItIsNotOnTheWhitelist_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt.

@Test(expected = HazelcastSerializationException.class)
public void givenTheEPButItIsNotOnTheWhitelist_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt() {
    Config i1Config = new Config();
    i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    Config i2Config = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(asList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    i2Config.getUserCodeDeploymentConfig().setEnabled(true).setWhitelistedPrefixes("usercodedeployment.whitelisted").setClassCacheMode(classCacheMode);
    EntryProcessor<Integer, Integer> myEP = new IncrementingEntryProcessor();
    executeSimpleTestScenario(i1Config, i2Config, myEP);
}
Also used : Config(com.hazelcast.config.Config) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) FilteringClassLoader(com.hazelcast.util.FilteringClassLoader) IncrementingEntryProcessor(usercodedeployment.IncrementingEntryProcessor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with FilteringClassLoader

use of com.hazelcast.util.FilteringClassLoader in project hazelcast by hazelcast.

the class UserCodeDeploymentSmokeTest method givenProviderFilterUsesMemberAttribute_whenNoMemberHasMatchingAttribute_thenClassLoadingRequestFails.

@Test(expected = HazelcastSerializationException.class)
public void givenProviderFilterUsesMemberAttribute_whenNoMemberHasMatchingAttribute_thenClassLoadingRequestFails() {
    Config i1Config = new Config();
    i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    Config i2Config = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(asList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    i2Config.getUserCodeDeploymentConfig().setEnabled(true).setProviderFilter("HAS_ATTRIBUTE:foo").setClassCacheMode(classCacheMode);
    EntryProcessor<Integer, Integer> myEP = new IncrementingEntryProcessor();
    executeSimpleTestScenario(i1Config, i2Config, myEP);
}
Also used : Config(com.hazelcast.config.Config) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) FilteringClassLoader(com.hazelcast.util.FilteringClassLoader) IncrementingEntryProcessor(usercodedeployment.IncrementingEntryProcessor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with FilteringClassLoader

use of com.hazelcast.util.FilteringClassLoader in project hazelcast by hazelcast.

the class UserCodeDeploymentSmokeTest method givenTheEPButItIsBlacklisted_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt.

@Test(expected = HazelcastSerializationException.class)
public void givenTheEPButItIsBlacklisted_whenTheEPIsFilteredLocally_thenItWillFailToLoadIt() {
    Config i1Config = new Config();
    i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    Config i2Config = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(asList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    i2Config.getUserCodeDeploymentConfig().setEnabled(true).setBlacklistedPrefixes("usercodedeployment.blacklisted").setClassCacheMode(classCacheMode);
    EntryProcessor<Integer, Integer> myEP = new BlacklistedEP();
    executeSimpleTestScenario(i1Config, i2Config, myEP);
}
Also used : Config(com.hazelcast.config.Config) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) FilteringClassLoader(com.hazelcast.util.FilteringClassLoader) BlacklistedEP(usercodedeployment.blacklisted.BlacklistedEP) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with FilteringClassLoader

use of com.hazelcast.util.FilteringClassLoader in project hazelcast by hazelcast.

the class UserCodeDeploymentSmokeTest method testUserCodeDeploymentIsDisabledByDefault.

@Test(expected = HazelcastSerializationException.class)
public void testUserCodeDeploymentIsDisabledByDefault() {
    //this test also validate the EP is filtered locally and has to be loaded from the other member
    Config i1Config = new Config();
    Config i2Config = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(asList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    IncrementingEntryProcessor incrementingEntryProcessor = new IncrementingEntryProcessor();
    executeSimpleTestScenario(i1Config, i2Config, incrementingEntryProcessor);
}
Also used : Config(com.hazelcast.config.Config) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) FilteringClassLoader(com.hazelcast.util.FilteringClassLoader) IncrementingEntryProcessor(usercodedeployment.IncrementingEntryProcessor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

FilteringClassLoader (com.hazelcast.util.FilteringClassLoader)9 Config (com.hazelcast.config.Config)7 UserCodeDeploymentConfig (com.hazelcast.config.UserCodeDeploymentConfig)7 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 IncrementingEntryProcessor (usercodedeployment.IncrementingEntryProcessor)5 JetTestInstanceFactory (com.hazelcast.jet.JetTestInstanceFactory)2 JetConfig (com.hazelcast.jet.config.JetConfig)2 BlacklistedEP (usercodedeployment.blacklisted.BlacklistedEP)1 WhitelistedEP (usercodedeployment.whitelisted.WhitelistedEP)1