Package com.hazelcast.test

Examples of com.hazelcast.test.TestHazelcastInstanceFactory


    }

    @Test(expected = DistributedObjectDestroyedException.class)
    @ClientCompatibleTest
    public void testLatchDestroyed() throws Exception {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        HazelcastInstance hz1 = factory.newHazelcastInstance();
        HazelcastInstance hz2 = factory.newHazelcastInstance();
        final ICountDownLatch latch = hz1.getCountDownLatch("test");
        latch.trySetCount(2);

        new TestThread() {
            public void doRun() throws Exception {
View Full Code Here


@Category(QuickTest.class)
public class EventServiceTest extends HazelcastTestSupport {

    @Test(timeout = 90000)
    public void testEventService() throws Exception {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);

        HazelcastInstanceProxy h1 = (HazelcastInstanceProxy) factory.newHazelcastInstance();
        HazelcastInstanceProxy h2 = (HazelcastInstanceProxy) factory.newHazelcastInstance();
        HazelcastInstanceProxy h3 = (HazelcastInstanceProxy) factory.newHazelcastInstance();

        CountDownLatch l1 = new CountDownLatch(1000);
        CountDownLatch l2 = new CountDownLatch(1000);
        CountDownLatch l3 = new CountDownLatch(1000);
View Full Code Here

public class CountDownLatchMigrationTest extends HazelcastTestSupport {

    @Test
    @ClientCompatibleTest
    public void testLatchMigration() throws InterruptedException {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(5);
        HazelcastInstance hz1 = factory.newHazelcastInstance();
        HazelcastInstance hz2 = factory.newHazelcastInstance();
        warmUpPartitions(hz2, hz1);

        ICountDownLatch latch1 = hz1.getCountDownLatch("test");
        latch1.trySetCount(10);
        Thread.sleep(500);

        ICountDownLatch latch2 = hz2.getCountDownLatch("test");
        assertEquals(10, latch2.getCount());
        latch2.countDown();
        assertEquals(9, latch1.getCount());
        hz1.shutdown();
        assertEquals(9, latch2.getCount());

        HazelcastInstance hz3 = factory.newHazelcastInstance();
        warmUpPartitions(hz3);
        ICountDownLatch latch3 = hz3.getCountDownLatch("test");
        latch3.countDown();
        assertEquals(8, latch3.getCount());

        hz2.shutdown();
        latch3.countDown();
        assertEquals(7, latch3.getCount());

        HazelcastInstance hz4 = factory.newHazelcastInstance();
        HazelcastInstance hz5 = factory.newHazelcastInstance();
        warmUpPartitions(hz5, hz4);
        Thread.sleep(250);

        hz3.shutdown();
        ICountDownLatch latch4 = hz4.getCountDownLatch("test");
View Full Code Here

    private static HazelcastInstance local;
    private static HazelcastInstance remote;

    @BeforeClass
    public static void setUp() {
        instances = new TestHazelcastInstanceFactory(2).newInstances();
        warmUpPartitions(instances);
        local = instances[0];
        remote = instances[1];
    }
View Full Code Here

@RunWith(HazelcastSerialClassRunner.class)
@Category(QuickTest.class)
public class JCacheListenerTest extends HazelcastTestSupport {

    protected CachingProvider getCachingProvider() {
        TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        HazelcastInstance hz1 = factory.newHazelcastInstance();
        HazelcastInstance hz2 = factory.newHazelcastInstance();

        return HazelcastServerCachingProvider.createCachingProvider(hz2);
    }
View Full Code Here

    @Test
    @ClientCompatibleTest
    public void testAtomicLongFailure() {
        int k = 4;
        TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(k + 1);
        HazelcastInstance instance = nodeFactory.newHazelcastInstance();
        String name = "testAtomicLongFailure";
        IAtomicLong atomicLong = instance.getAtomicLong(name);
        atomicLong.set(100);
        for (int i = 0; i < k; i++) {
            HazelcastInstance newInstance = nodeFactory.newHazelcastInstance();
            IAtomicLong newAtomicLong = newInstance.getAtomicLong(name);
            assertEquals((long) 100 + i, newAtomicLong.get());
            newAtomicLong.incrementAndGet();
            instance.shutdown();
            instance = newInstance;
View Full Code Here

    @Test
    @ClientCompatibleTest
    public void testAtomicLongSpawnNodeInParallel() throws InterruptedException {
        int total = 6;
        int parallel = 2;
        final TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(total + 1);
        HazelcastInstance instance = nodeFactory.newHazelcastInstance();
        final String name = "testAtomicLongSpawnNodeInParallel";
        IAtomicLong atomicLong = instance.getAtomicLong(name);
        atomicLong.set(100);
        final ExecutorService ex = Executors.newFixedThreadPool(parallel);
        try {
            for (int i = 0; i < total / parallel; i++) {
                final HazelcastInstance[] instances = new HazelcastInstance[parallel];
                final CountDownLatch countDownLatch = new CountDownLatch(parallel);
                final AtomicInteger exceptionCount = new AtomicInteger(0);
                for (int j = 0; j < parallel; j++) {
                    final int id = j;
                    ex.execute(new Runnable() {
                        public void run() {
                            try {
                                instances[id] = nodeFactory.newHazelcastInstance();
                                instances[id].getAtomicLong(name).incrementAndGet();
                            } catch (Exception e) {
                                exceptionCount.incrementAndGet();
                                e.printStackTrace();
                            } finally {
View Full Code Here

    @Test(expected = ExecutionException.class, timeout = 120000)
    public void testGithubIssue2509()
            throws Exception {

        TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(2);

        HazelcastInstance h1 = nodeFactory.newHazelcastInstance();
        HazelcastInstance h2 = nodeFactory.newHazelcastInstance();

        UnDeserializable unDeserializable = new UnDeserializable(1);
        IExecutorService executorService = h1.getExecutorService("default");
        Issue2509Runnable task = new Issue2509Runnable(unDeserializable);
        Future<?> future = executorService.submitToMember(task, h2.getCluster().getLocalMember());
View Full Code Here

    static final String ELEMENT = "item";

    @Test
    public void testAdd_withinTxn() throws Exception {
        final String setName = randomString();
        final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        final HazelcastInstance instance = factory.newInstances()[0];
        final ISet<String> set = instance.getSet(setName);

        final TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        final TransactionalSet<Object> txnSet = context.getSet(setName);
View Full Code Here

    }

    @Test
    public void testSetSizeAfterAdd_withinTxn() throws Exception {
        final String setName = randomString();
        final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
        final HazelcastInstance instance = factory.newInstances()[0];
        final ISet<String> set = instance.getSet(setName);

        final TransactionContext context = instance.newTransactionContext();
        context.beginTransaction();
        final TransactionalSet<Object> txnSet = context.getSet(setName);
View Full Code Here

TOP

Related Classes of com.hazelcast.test.TestHazelcastInstanceFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.