Search in sources :

Example 1 with ClientUserCodeDeploymentConfig

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

the class ClientUserCodeDeploymentExceptionTest method testClientsWithConflictingClassRepresentations.

/**
 * The two JARs {@code IncrementingEntryProcessor.jar} and {@code IncrementingEntryProcessorConflicting.jar}
 * contain the same class {@link IncrementingEntryProcessor} with different implementations
 */
@Test(expected = IllegalStateException.class)
public void testClientsWithConflictingClassRepresentations() {
    Config config = createNodeConfig();
    config.getUserCodeDeploymentConfig().setEnabled(true);
    factory.newHazelcastInstance(config);
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig1 = new ClientUserCodeDeploymentConfig().addJar("IncrementingEntryProcessor.jar").setEnabled(true);
    ClientConfig clientConfig1 = new ClientConfig().setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig1);
    factory.newHazelcastClient(clientConfig1);
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig2 = new ClientUserCodeDeploymentConfig().addJar("IncrementingEntryProcessorConflicting.jar").setEnabled(true);
    ClientConfig clientConfig2 = new ClientConfig().setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig2);
    factory.newHazelcastClient(clientConfig2);
}
Also used : ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) 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)

Example 2 with ClientUserCodeDeploymentConfig

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

the class ClientUserCodeDeploymentExceptionTest method createClientConfig.

private ClientConfig createClientConfig() {
    ClientConfig config = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    clientUserCodeDeploymentConfig.addClass("usercodedeployment.IncrementingEntryProcessor");
    config.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
    return config;
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig)

Example 3 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig 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 4 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig 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 5 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig 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)

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