use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentConfigTest method testConfigWithFileDoesNotExist.
@Test(expected = FileNotFoundException.class)
public void testConfigWithFileDoesNotExist() throws ClassNotFoundException, IOException {
ClientUserCodeDeploymentConfig config = new ClientUserCodeDeploymentConfig();
config.setEnabled(true);
ClassLoader classLoader = getClass().getClassLoader();
File file = new File("/wrongPath/IncrementingEntryProcessor.jar");
config.addJar(file);
ClientUserCodeDeploymentService service = new ClientUserCodeDeploymentService(config, classLoader);
service.start();
}
use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentTest method testWithMainAndInnerClassesWorksIndependentOfOrder_withMainFirst.
@Test
public void testWithMainAndInnerClassesWorksIndependentOfOrder_withMainFirst() {
ClientConfig clientConfig = new ClientConfig();
ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
clientUserCodeDeploymentConfig.addClass(DomainClassWithInnerClass.class);
clientUserCodeDeploymentConfig.addClass(DomainClassWithInnerClass.InnerClass.class);
clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
factory.newHazelcastInstance(createNodeConfig());
factory.newHazelcastClient(clientConfig);
}
use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentTest method testWithMainAndInnerClassesWorksIndependentOfOrder_withInnerFirst.
@Test
public void testWithMainAndInnerClassesWorksIndependentOfOrder_withInnerFirst() {
ClientConfig clientConfig = new ClientConfig();
ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
clientUserCodeDeploymentConfig.addClass(DomainClassWithInnerClass.InnerClass.class);
clientUserCodeDeploymentConfig.addClass(DomainClassWithInnerClass.class);
clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
factory.newHazelcastInstance(createNodeConfig());
factory.newHazelcastClient(clientConfig);
}
use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentTest method testWithMultipleMembers_anonymousAndInnerClasses.
@Test
public void testWithMultipleMembers_anonymousAndInnerClasses() {
ClientConfig clientConfig = new ClientConfig();
ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
clientUserCodeDeploymentConfig.addJar("EntryProcessorWithAnonymousAndInner.jar");
clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
Config config = createNodeConfig();
factory.newHazelcastInstance(config);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
factory.newHazelcastInstance(config);
assertCodeDeploymentWorking(client, new EntryProcessorWithAnonymousAndInner());
}
use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.
the class ClientUserCodeDeploymentTest method testCustomAttributeExtractor.
@Test
public void testCustomAttributeExtractor() {
String mapName = randomMapName();
// this attribute does not exist in the domain class
String attributeName = "syntheticAttribute";
ClientConfig clientConfig = new ClientConfig();
ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
clientUserCodeDeploymentConfig.addClass(CapitalizingFirstNameExtractor.class);
clientUserCodeDeploymentConfig.addClass(Person.class);
clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
Config config = createNodeConfig();
config.getMapConfig(mapName).addAttributeConfig(new AttributeConfig(attributeName, "usercodedeployment.CapitalizingFirstNameExtractor"));
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
IMap<Integer, Person> map = client.getMap(mapName);
map.put(0, new Person("ada"));
map.put(1, new Person("non-ada"));
Set<Map.Entry<Integer, Person>> results = map.entrySet(equal(attributeName, "ADA"));
assertEquals(1, results.size());
assertEquals("ada", results.iterator().next().getValue().getName());
}
Aggregations