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