Search in sources :

Example 1 with ClientUserCodeDeploymentService

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

the class ClientUserCodeDeploymentConfigTest method testConfigWithClassName.

@Test
public void testConfigWithClassName() throws IOException, ClassNotFoundException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    String className = "usercodedeployment.IncrementingEntryProcessor";
    config.addClass(className);
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, this.getClass().getClassLoader());
    service.start();
    List<Map.Entry<String, byte[]>> list = service.getClassDefinitionList();
    assertClassLoaded(list, className);
}
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 2 with ClientUserCodeDeploymentService

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

the class ClientUserCodeDeploymentConfigTest method testConfigWithJarFile_withInnerAndAnonymousClass.

@Test
public void testConfigWithJarFile_withInnerAndAnonymousClass() throws IOException, URISyntaxException, ClassNotFoundException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    ClassLoader classLoader = getClass().getClassLoader();
    URL resource = classLoader.getResource("EntryProcessorWithAnonymousAndInner.jar");
    File file = new File(resource.toURI());
    config.addJar(file);
    ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, classLoader);
    service.start();
    List<Map.Entry<String, byte[]>> list = service.getClassDefinitionList();
    assertClassLoaded(list, "usercodedeployment.EntryProcessorWithAnonymousAndInner");
    assertClassLoaded(list, "usercodedeployment.EntryProcessorWithAnonymousAndInner$Test");
}
Also used : ClientUserCodeDeploymentService(com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService) File(java.io.File) 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 3 with ClientUserCodeDeploymentService

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

the class ClientUserCodeDeploymentConfigTest method testConfigWithJarFile.

@Test
public void testConfigWithJarFile() throws URISyntaxException, ClassNotFoundException, IOException {
    ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
    config.setEnabled(true);
    ClassLoader classLoader = getClass().getClassLoader();
    URL resource = classLoader.getResource("IncrementingEntryProcessor.jar");
    File file = new File(resource.toURI());
    config.addJar(file);
    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) File(java.io.File) 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 4 with ClientUserCodeDeploymentService

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

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

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