Search in sources :

Example 6 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testUserCodeDeploymentUsesCurrentThreadContextClassLoader.

@Test
public void testUserCodeDeploymentUsesCurrentThreadContextClassLoader() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    CustomClassLoader classLoader = new CustomClassLoader();
    config.setEnabled(true);
    config.addClass(IncrementingEntryProcessor.class);
    Thread.currentThread().setContextClassLoader(classLoader);
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, null);
    service.start();
    List<Map.Entry<String, byte[]>> list = service.getClassDefinitionList();
    assertClassLoaded(list, IncrementingEntryProcessor.class.getName());
    assertTrue(classLoader.getResourceAsStreamCalled);
}
Also used : IncrementingEntryProcessor(usercodedeployment.IncrementingEntryProcessor) ClientUserCodeDeploymentService(com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testConfigWithClasses.

@Test
public void testConfigWithClasses() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    config.setClassNames(Collections.singletonList("usercodedeployment.IncrementingEntryProcessor"));
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, this.getClass().getClassLoader());
    service.start();
    List<Map.Entry<String, byte[]>> list = service.getClassDefinitionList();
    assertClassLoaded(list, IncrementingEntryProcessor.class.getName());
}
Also used : IncrementingEntryProcessor(usercodedeployment.IncrementingEntryProcessor) ClientUserCodeDeploymentService(com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testConfigWithJarPath.

@Test
public void testConfigWithJarPath() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    ClassLoader classLoader = getClass().getClassLoader();
    config.addJar("IncrementingEntryProcessor.jar");
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, classLoader);
    service.start();
    List<Map.Entry<String, byte[]>> list = service.getClassDefinitionList();
    assertClassLoaded(list, "usercodedeployment.IncrementingEntryProcessor");
}
Also used : ClientUserCodeDeploymentService(com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testConfigWithJarPaths.

@Test
public void testConfigWithJarPaths() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    ClassLoader classLoader = getClass().getClassLoader();
    config.setJarPaths(Collections.singletonList("IncrementingEntryProcessor.jar"));
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, classLoader);
    service.start();
    List<Map.Entry<String, byte[]>> list = service.getClassDefinitionList();
    assertClassLoaded(list, "usercodedeployment.IncrementingEntryProcessor");
}
Also used : ClientUserCodeDeploymentService(com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentTest method testWithParentAndChildClassesWorksIndependentOfOrder_withChildParentJar.

@Test
public void testWithParentAndChildClassesWorksIndependentOfOrder_withChildParentJar() {
    ClientConfig clientConfig = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    /*child parent jar contains two classes as follows. This classes are not put into code base on purpose,
        in order not to effect the test. Child class is loaded first when reading via JarInputStream.getNextJarEntry, which
        is the case we wanted to test.

        package usercodedeployment;
        import java.io.Serializable;
        public class ParentClass implements Serializable, Runnable {
            @Override
            public void run() {

            }
        }

        package usercodedeployment;
        public class AChildClass extends AParentClass {
        }

         */
    clientUserCodeDeploymentConfig.addJar("ChildParent.jar");
    clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
    factory.newHazelcastInstance(createNodeConfig());
    factory.newHazelcastClient(clientConfig);
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientUserCodeDeploymentConfig (com.hazelcast.client.config.ClientUserCodeDeploymentConfig)27 Test (org.junit.Test)24 QuickTest (com.hazelcast.test.annotation.QuickTest)23 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)22 ClientConfig (com.hazelcast.client.config.ClientConfig)14 ClientUserCodeDeploymentService (com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService)12 Config (com.hazelcast.config.Config)5 File (java.io.File)3 URL (java.net.URL)3 IncrementingEntryProcessor (usercodedeployment.IncrementingEntryProcessor)3 AttributeConfig (com.hazelcast.config.AttributeConfig)2 UserCodeDeploymentConfig (com.hazelcast.config.UserCodeDeploymentConfig)2 HazelcastException (com.hazelcast.core.HazelcastException)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 DomainClassWithInnerClass (usercodedeployment.DomainClassWithInnerClass)2 ClientDiscoverySpiTest (com.hazelcast.client.impl.spi.impl.discovery.ClientDiscoverySpiTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Node (org.w3c.dom.Node)1 EntryProcessorWithAnonymousAndInner (usercodedeployment.EntryProcessorWithAnonymousAndInner)1 Person (usercodedeployment.Person)1