use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method givenSomeMemberCanAccessTheEP_whenTheEPIsFilteredLocally_thenItWillBeLoadedOverNetwork_anonymousInnerClasses.
@Test
public void givenSomeMemberCanAccessTheEP_whenTheEPIsFilteredLocally_thenItWillBeLoadedOverNetwork_anonymousInnerClasses() {
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);
EntryProcessorWithAnonymousAndInner incrementingEntryProcessor = new EntryProcessorWithAnonymousAndInner();
executeSimpleTestScenario(i1Config, i2Config, incrementingEntryProcessor);
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class UserCodeDeploymentBasicTest method testUserCodeDeploymentIsDisabledByDefault.
@Test
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(singletonList("usercodedeployment"), null);
i2Config.setClassLoader(filteringCL);
IncrementingEntryProcessor incrementingEntryProcessor = new IncrementingEntryProcessor();
try {
executeSimpleTestScenario(i1Config, i2Config, incrementingEntryProcessor);
fail();
} catch (Exception e) {
assertInstanceOfByClassName(HazelcastSerializationException.class.getName(), e);
}
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class DynamicConfigAdvancedTest method test_userCustomizations_withUserCodeDeployment.
@Test
public void test_userCustomizations_withUserCodeDeployment() {
factory = new TestHazelcastInstanceFactory();
// first member is aware of MapLoader class
HazelcastInstance member1 = factory.newHazelcastInstance(newConfigWithUserCodeDeployment());
member1.getConfig().addMapConfig(mapConfigWithMapLoader());
IMap<Integer, Integer> intMap = member1.getMap(MAP_NAME);
assertEquals(1, (long) intMap.get(1));
// start another member which is not aware of map loader
Config config = newConfigWithUserCodeDeployment();
FilteringClassLoader cl = new FilteringClassLoader(singletonList("classloading"), null);
config.setClassLoader(cl);
factory.newHazelcastInstance(config);
for (int i = 0; i < 1000; i++) {
assertEquals(i, (long) intMap.get(i));
}
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class GenericRecordTest method testGenericRecordToStringValidJson.
@Test
public void testGenericRecordToStringValidJson() throws IOException {
CompactSerializationConfig compactSerializationConfig = new CompactSerializationConfig();
compactSerializationConfig.setEnabled(true);
InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().setSchemaService(schemaService).setConfig(new SerializationConfig().setCompactSerializationConfig(compactSerializationConfig)).build();
MainDTO expectedDTO = createMainDTO();
expectedDTO.nullableBool = null;
expectedDTO.p.localDateTimes[0] = null;
Data data = serializationService.toData(expectedDTO);
assertTrue(data.isCompact());
// internal generic record created on the servers on query
InternalGenericRecord internalGenericRecord = serializationService.readAsInternalGenericRecord(data);
String string = internalGenericRecord.toString();
Json.parse(string);
// generic record read from a remote instance without classes on the classpath
List<String> excludes = Collections.singletonList("example.serialization");
FilteringClassLoader classLoader = new FilteringClassLoader(excludes, null);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
InternalSerializationService ss2 = new DefaultSerializationServiceBuilder().setSchemaService(schemaService).setClassLoader(classLoader).setConfig(new SerializationConfig().setCompactSerializationConfig(new CompactSerializationConfig())).build();
GenericRecord genericRecord = ss2.toObject(data);
Json.parse(genericRecord.toString());
// generic record build by API
GenericRecord apiGenericRecord = createCompactGenericRecord(expectedDTO);
Json.parse(apiGenericRecord.toString());
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.
the class ClientDeploymentTest method beforeClass.
@BeforeClass
public static void beforeClass() {
Config config = smallInstanceConfig();
config.getJetConfig().setResourceUploadEnabled(true);
FilteringClassLoader filteringClassLoader = new FilteringClassLoader(singletonList("deployment"), null);
config.setClassLoader(filteringClassLoader);
initializeWithClient(MEMBER_COUNT, config, null);
}
Aggregations