Search in sources :

Example 1 with CustomLoadBalancer

use of com.hazelcast.client.test.CustomLoadBalancer in project hazelcast by hazelcast.

the class TestCustomLoadBalancerContext method testCustomLoadBalancer.

@Test
public void testCustomLoadBalancer() {
    ClientConfig config1 = client1.getClientConfig();
    LoadBalancer loadBalancer1 = config1.getLoadBalancer();
    assertTrue(loadBalancer1 instanceof CustomLoadBalancer);
    assertEquals("default-name", ((CustomLoadBalancer) loadBalancer1).getName());
    ClientConfig config2 = client2.getClientConfig();
    LoadBalancer loadBalancer2 = config2.getLoadBalancer();
    assertTrue(loadBalancer2 instanceof CustomLoadBalancer);
    assertEquals("custom-balancer-name", ((CustomLoadBalancer) loadBalancer2).getName());
}
Also used : CustomLoadBalancer(com.hazelcast.client.test.CustomLoadBalancer) CustomLoadBalancer(com.hazelcast.client.test.CustomLoadBalancer) LoadBalancer(com.hazelcast.client.LoadBalancer) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CustomLoadBalancer

use of com.hazelcast.client.test.CustomLoadBalancer in project hazelcast by hazelcast.

the class ClientConfigXmlGeneratorTest method loadBalancerCustom.

@Test
public void loadBalancerCustom() {
    clientConfig.setLoadBalancer(new CustomLoadBalancer());
    ClientConfig newClientConfig = newConfigViaGenerator();
    LoadBalancer actual = newClientConfig.getLoadBalancer();
    assertNull(actual);
    String actualClassName = newClientConfig.getLoadBalancerClassName();
    assertEquals("com.hazelcast.client.test.CustomLoadBalancer", actualClassName);
}
Also used : CustomLoadBalancer(com.hazelcast.client.test.CustomLoadBalancer) CustomLoadBalancer(com.hazelcast.client.test.CustomLoadBalancer) LoadBalancer(com.hazelcast.client.LoadBalancer) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with CustomLoadBalancer

use of com.hazelcast.client.test.CustomLoadBalancer in project hazelcast by hazelcast.

the class ClientConfigLoadBalancerTest method shouldCreateCustomLoadBalancerWhenConfigInstanceNotProvidedAndClassNameSpecified.

@Test
public void shouldCreateCustomLoadBalancerWhenConfigInstanceNotProvidedAndClassNameSpecified() {
    hazelcastFactory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setLoadBalancerClassName("com.hazelcast.client.test.CustomLoadBalancer");
    HazelcastInstance instance = hazelcastFactory.newHazelcastClient(clientConfig);
    HazelcastClientInstanceImpl client = ClientTestUtil.getHazelcastClientInstanceImpl(instance);
    LoadBalancer actual = client.getLoadBalancer();
    assertTrue(actual instanceof CustomLoadBalancer);
}
Also used : CustomLoadBalancer(com.hazelcast.client.test.CustomLoadBalancer) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) CustomLoadBalancer(com.hazelcast.client.test.CustomLoadBalancer) LoadBalancer(com.hazelcast.client.LoadBalancer) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LoadBalancer (com.hazelcast.client.LoadBalancer)3 CustomLoadBalancer (com.hazelcast.client.test.CustomLoadBalancer)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1