use of com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory in project hazelcast by hazelcast.
the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryCreateMemberGroups.
@Test
public void testSPIAwareMemberGroupFactoryCreateMemberGroups() throws Exception {
String xmlFileName = "test-hazelcast-discovery-spi-metadata.xml";
Config config = getDiscoverySPIConfig(xmlFileName);
// we create this instance in order to fully create Node
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
Node node = TestUtil.getNode(hazelcastInstance);
assertNotNull(node);
MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(node.getDiscoveryService());
Collection<Member> members = createMembers();
Collection<MemberGroup> memberGroups = groupFactory.createMemberGroups(members);
assertEquals("Member Groups: " + String.valueOf(memberGroups), 2, memberGroups.size());
for (MemberGroup memberGroup : memberGroups) {
assertEquals("Member Group: " + String.valueOf(memberGroup), 2, memberGroup.size());
}
hazelcastInstance.shutdown();
}
use of com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory in project hazelcast by hazelcast.
the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryInvalidConfig.
@Test(expected = RuntimeException.class)
public void testSPIAwareMemberGroupFactoryInvalidConfig() throws Exception {
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
try {
MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(TestUtil.getNode(hazelcastInstance).getDiscoveryService());
Collection<Member> members = createMembers();
groupFactory.createMemberGroups(members);
} finally {
hazelcastInstance.shutdown();
}
}
Aggregations