Search in sources :

Example 96 with TestHazelcastInstanceFactory

use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.

the class TransactionalMapReadQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setType(QuorumType.READ);
    MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
    mapConfig.setQuorumName(QUORUM_ID);
    cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Example 97 with TestHazelcastInstanceFactory

use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.

the class BaseQuorumListenerTest method testQuorumEventsFiredWhenNodeCountBelowThenAboveThreshold.

@Test
public void testQuorumEventsFiredWhenNodeCountBelowThenAboveThreshold() {
    CountDownLatch quorumNotPresent = new CountDownLatch(1);
    CountDownLatch quorumPresent = new CountDownLatch(1);
    String distributedObjectName = randomString();
    Config config = addQuorum(new Config(), distributedObjectName, quorumListener(quorumPresent, quorumNotPresent));
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    assertOpenEventually(quorumNotPresent, 15);
    factory.newHazelcastInstance(config);
    assertOpenEventually(quorumPresent);
}
Also used : Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 98 with TestHazelcastInstanceFactory

use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.

the class BaseQuorumListenerTest method testQuorumFailureEventFiredWhenNodeCountDropsBelowThreshold.

@Test
public void testQuorumFailureEventFiredWhenNodeCountDropsBelowThreshold() {
    CountDownLatch quorumNotPresent = new CountDownLatch(1);
    String distributedObjectName = randomString();
    Config config = addQuorum(new Config(), distributedObjectName, quorumListener(null, quorumNotPresent));
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance();
    factory.newHazelcastInstance().shutdown();
    assertOpenEventually(quorumNotPresent, 15);
}
Also used : Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 99 with TestHazelcastInstanceFactory

use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.

the class BaseQuorumListenerTest method testCustomResolverFiresQuorumFailureEvent.

@Test
public void testCustomResolverFiresQuorumFailureEvent() {
    CountDownLatch quorumNotPresent = new CountDownLatch(1);
    QuorumListenerConfig listenerConfig = new QuorumListenerConfig(quorumListener(null, quorumNotPresent));
    String distributedObjectName = randomString();
    String quorumName = randomString();
    QuorumConfig quorumConfig = new QuorumConfig().setName(quorumName).setEnabled(true).addListenerConfig(listenerConfig).setQuorumFunctionImplementation(new QuorumFunction() {

        @Override
        public boolean apply(Collection<Member> members) {
            return false;
        }
    });
    Config config = new Config().addQuorumConfig(quorumConfig);
    addQuorumConfig(config, distributedObjectName, quorumName);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance();
    assertOpenEventually(quorumNotPresent, 15);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.core.Member) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 100 with TestHazelcastInstanceFactory

use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.

the class PhoneHomeTest method init.

@Before
public void init() {
    factory = new TestHazelcastInstanceFactory(2);
    hz1 = factory.newHazelcastInstance();
}
Also used : TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Before(org.junit.Before)

Aggregations

TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)948 HazelcastInstance (com.hazelcast.core.HazelcastInstance)827 Test (org.junit.Test)774 QuickTest (com.hazelcast.test.annotation.QuickTest)726 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)575 Config (com.hazelcast.config.Config)488 MapConfig (com.hazelcast.config.MapConfig)185 ParallelTest (com.hazelcast.test.annotation.ParallelTest)145 MapStoreConfig (com.hazelcast.config.MapStoreConfig)121 CountDownLatch (java.util.concurrent.CountDownLatch)108 AssertTask (com.hazelcast.test.AssertTask)97 NightlyTest (com.hazelcast.test.annotation.NightlyTest)86 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)81 Before (org.junit.Before)75 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)58 NearCacheConfig (com.hazelcast.config.NearCacheConfig)53 SlowTest (com.hazelcast.test.annotation.SlowTest)53 IndexConfig (com.hazelcast.config.IndexConfig)50 ArrayList (java.util.ArrayList)45 Map (java.util.Map)43