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);
}
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;
}
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);
}
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");
}
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");
}
Aggregations