Search in sources :

Example 1 with InternalPartitionImplConstructor

use of com.hazelcast.test.starter.constructor.InternalPartitionImplConstructor in project hazelcast by hazelcast.

the class InternalPartitionImplConstructorTest method testConstructor.

@Test
public void testConstructor() throws Exception {
    PartitionReplica local = new PartitionReplica(new Address("172.16.16.1", 4223), UuidUtil.newUnsecureUUID());
    PartitionReplica[] replicas = new PartitionReplica[] { new PartitionReplica(new Address("127.0.0.1", 2342), UuidUtil.newUnsecureUUID()) };
    InternalPartition partition = new InternalPartitionImpl(42, local, replicas, 1, null);
    InternalPartitionImplConstructor constructor = new InternalPartitionImplConstructor(InternalPartitionImpl.class);
    InternalPartition clonedPartition = (InternalPartition) constructor.createNew(partition);
    assertEquals(partition.getPartitionId(), clonedPartition.getPartitionId());
    assertEquals(partition.version(), clonedPartition.version());
    assertEquals(partition.getOwnerOrNull(), clonedPartition.getOwnerOrNull());
    assertEquals(partition.getReplicaAddress(0), clonedPartition.getReplicaAddress(0));
    assertEquals(partition.getReplica(0), clonedPartition.getReplica(0));
    assertEquals(partition.getReplicaIndex(replicas[0]), clonedPartition.getReplicaIndex(replicas[0]));
}
Also used : Address(com.hazelcast.cluster.Address) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) InternalPartitionImpl(com.hazelcast.internal.partition.impl.InternalPartitionImpl) InternalPartition(com.hazelcast.internal.partition.InternalPartition) InternalPartitionImplConstructor(com.hazelcast.test.starter.constructor.InternalPartitionImplConstructor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Address (com.hazelcast.cluster.Address)1 InternalPartition (com.hazelcast.internal.partition.InternalPartition)1 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)1 InternalPartitionImpl (com.hazelcast.internal.partition.impl.InternalPartitionImpl)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 InternalPartitionImplConstructor (com.hazelcast.test.starter.constructor.InternalPartitionImplConstructor)1 Test (org.junit.Test)1