Search in sources :

Example 21 with ClientUserCodeDeploymentConfig

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();
}
Also used : ClientUserCodeDeploymentService(com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService) File(java.io.File) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 22 with ClientUserCodeDeploymentConfig

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);
}
Also used : DomainClassWithInnerClass(usercodedeployment.DomainClassWithInnerClass) 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 23 with ClientUserCodeDeploymentConfig

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);
}
Also used : DomainClassWithInnerClass(usercodedeployment.DomainClassWithInnerClass) 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 24 with ClientUserCodeDeploymentConfig

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AttributeConfig(com.hazelcast.config.AttributeConfig) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) Config(com.hazelcast.config.Config) EntryProcessorWithAnonymousAndInner(usercodedeployment.EntryProcessorWithAnonymousAndInner) 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 25 with ClientUserCodeDeploymentConfig

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AttributeConfig(com.hazelcast.config.AttributeConfig) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) Person(usercodedeployment.Person) 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