Search in sources :

Example 26 with Cluster

use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.

the class HazelcastOSGiInstanceTest method getClusterCalledSuccessfullyOverOSGiInstance.

@Test
public void getClusterCalledSuccessfullyOverOSGiInstance() {
    Cluster mockCluster = mock(Cluster.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = createHazelcastOSGiInstance(mockHazelcastInstance);
    when(mockHazelcastInstance.getCluster()).thenReturn(mockCluster);
    assertEquals(mockCluster, hazelcastOSGiInstance.getCluster());
    verify(mockHazelcastInstance).getCluster();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastOSGiTestUtil.createHazelcastOSGiInstance(com.hazelcast.osgi.impl.HazelcastOSGiTestUtil.createHazelcastOSGiInstance) Cluster(com.hazelcast.cluster.Cluster) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with Cluster

use of com.hazelcast.cluster.Cluster in project hazelcast by hazelcast.

the class AbstractSplitBrainProtectionFunctionTest method prepareSplitBrainProtectionFunctionForIcmpFDTest.

protected void prepareSplitBrainProtectionFunctionForIcmpFDTest(SplitBrainProtectionFunction splitBrainProtectionFunction) {
    Cluster mockCluster = mock(Cluster.class);
    when(mockCluster.getLocalMember()).thenReturn(members[0]);
    HazelcastInstance mockInstance = mock(HazelcastInstance.class);
    when(mockInstance.getConfig()).thenReturn(getIcmpFDEnabledConfig());
    when(mockInstance.getCluster()).thenReturn(mockCluster);
    assert splitBrainProtectionFunction instanceof HazelcastInstanceAware;
    ((HazelcastInstanceAware) splitBrainProtectionFunction).setHazelcastInstance(mockInstance);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Cluster(com.hazelcast.cluster.Cluster) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Example 28 with Cluster

use of com.hazelcast.cluster.Cluster in project hazelcast-simulator by hazelcast.

the class HazelcastUtilsTest method testGetHazelcastAddress_withClientWorker_oldHazelcastVersion.

@Test
public void testGetHazelcastAddress_withClientWorker_oldHazelcastVersion() {
    Cluster cluster = mock(Cluster.class);
    when(cluster.getLocalMember()).thenThrow(new UnsupportedOperationException("Client has no local member!"));
    hazelcastInstance = mock(HazelcastInstance.class);
    when(hazelcastInstance.getLocalEndpoint()).thenThrow(new NoSuchMethodError("expected exception"));
    when(hazelcastInstance.getCluster()).thenReturn(cluster);
    String address = getHazelcastAddress("javaclient", "172.16.16.1", hazelcastInstance);
    assertEquals("client:172.16.16.1", address);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Cluster(com.hazelcast.cluster.Cluster) Test(org.junit.Test)

Aggregations

Cluster (com.hazelcast.cluster.Cluster)28 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 Member (com.hazelcast.cluster.Member)14 Test (org.junit.Test)13 QuickTest (com.hazelcast.test.annotation.QuickTest)11 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)10 ClientConfig (com.hazelcast.client.config.ClientConfig)5 Config (com.hazelcast.config.Config)5 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)4 MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)4 ClientClusterService (com.hazelcast.client.impl.spi.ClientClusterService)4 IPartition (com.hazelcast.internal.partition.IPartition)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)3 Partition (com.hazelcast.partition.Partition)3 PartitionService (com.hazelcast.partition.PartitionService)3 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 ExecutionException (java.util.concurrent.ExecutionException)3 HazelcastCommandLine.getHazelcastClientInstanceImpl (com.hazelcast.client.console.HazelcastCommandLine.getHazelcastClientInstanceImpl)2 RandomLB (com.hazelcast.client.util.RandomLB)2 RoundRobinLB (com.hazelcast.client.util.RoundRobinLB)2