Search in sources :

Example 6 with ClientUserCodeDeploymentService

use of com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService 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 7 with ClientUserCodeDeploymentService

use of com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService 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 8 with ClientUserCodeDeploymentService

use of com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testConfigWithURLPath.

@Test
public void testConfigWithURLPath() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    ClassLoader classLoader = getClass().getClassLoader();
    URL resource = classLoader.getResource("IncrementingEntryProcessor.jar");
    config.addJar(resource.toExternalForm());
    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) URL(java.net.URL) 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 ClientUserCodeDeploymentService

use of com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testConfigWithWrongJarPath.

@Test(expected = FileNotFoundException.class)
public void testConfigWithWrongJarPath() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    ClassLoader classLoader = getClass().getClassLoader();
    config.addJar("/wrongPath/IncrementingEntryProcessor.jar");
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, classLoader);
    service.start();
}
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 ClientUserCodeDeploymentService

use of com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentConfigTest method testConfigWithWrongClassName.

@Test(expected = ClassNotFoundException.class)
public void testConfigWithWrongClassName() throws ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    String className = "NonExistingClass";
    config.addClass(className);
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, this.getClass().getClassLoader());
    service.start();
}
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)

Aggregations

ClientUserCodeDeploymentConfig (com.hazelcast.client.config.ClientUserCodeDeploymentConfig)12 ClientUserCodeDeploymentService (com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 File (java.io.File)3 URL (java.net.URL)3 IncrementingEntryProcessor (usercodedeployment.IncrementingEntryProcessor)3