Search in sources :

Example 16 with ClientUserCodeDeploymentConfig

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

the class ClientUserCodeDeploymentExceptionTest method testClientsWith_wrongClassName.

@Test(expected = ClassNotFoundException.class)
public void testClientsWith_wrongClassName() throws Throwable {
    Config config = createNodeConfig();
    config.getUserCodeDeploymentConfig().setEnabled(true);
    factory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    clientUserCodeDeploymentConfig.addClass("NonExisting.class").setEnabled(true);
    clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig);
    try {
        factory.newHazelcastClient(clientConfig);
    } catch (HazelcastException e) {
        throw e.getCause();
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) 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 17 with ClientUserCodeDeploymentConfig

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

the class ClientUserCodeDeploymentExceptionTest method testClientsWith_wrongJarPath.

@Test(expected = FileNotFoundException.class)
public void testClientsWith_wrongJarPath() throws Throwable {
    Config config = createNodeConfig();
    config.getUserCodeDeploymentConfig().setEnabled(true);
    factory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    clientUserCodeDeploymentConfig.addJar("NonExisting.jar").setEnabled(true);
    clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig);
    try {
        factory.newHazelcastClient(clientConfig);
    } catch (HazelcastException e) {
        throw e.getCause();
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) 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 18 with ClientUserCodeDeploymentConfig

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

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

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