Search in sources :

Example 1 with IncrementingEntryProcessor

use of usercodedeployment.IncrementingEntryProcessor 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 IncrementingEntryProcessor

use of usercodedeployment.IncrementingEntryProcessor 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 IncrementingEntryProcessor

use of usercodedeployment.IncrementingEntryProcessor 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 IncrementingEntryProcessor

use of usercodedeployment.IncrementingEntryProcessor 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)

Example 5 with IncrementingEntryProcessor

use of usercodedeployment.IncrementingEntryProcessor in project hazelcast by hazelcast.

the class UserCodeDeploymentSmokeTest 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(asList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    i2Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    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

Config (com.hazelcast.config.Config)5 UserCodeDeploymentConfig (com.hazelcast.config.UserCodeDeploymentConfig)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 FilteringClassLoader (com.hazelcast.util.FilteringClassLoader)5 Test (org.junit.Test)5 IncrementingEntryProcessor (usercodedeployment.IncrementingEntryProcessor)5