Package com.hazelcast.core

Examples of com.hazelcast.core.IAtomicLong.compareAndSet()


    public static IAtomicLong mockIAtomicLong() {
        final AtomicLong atomicLong = new AtomicLong(); // keeps actual value
        IAtomicLong iAtomicLong = mock(IAtomicLong.class);

        when( iAtomicLong.getAndIncrement() ).then( delegateTo(atomicLong) );
        when( iAtomicLong.compareAndSet(anyLong(), anyLong()) ).then( delegateTo(atomicLong) );

        return iAtomicLong;
    }
}
View Full Code Here


    @Test
    @ClientCompatibleTest
    public void testCompareAndSet_whenSuccess(){
        HazelcastInstance hzInstance = createHazelcastInstance();
        IAtomicLong atomicNumber = hzInstance.getAtomicLong(randomString());
        assertTrue(atomicNumber.compareAndSet(0, 271));
        assertEquals(271,atomicNumber.get());
    }

    @Test
    @ClientCompatibleTest
View Full Code Here

    @Test
    @ClientCompatibleTest
    public void testCompareAndSet_whenNotSuccess(){
        HazelcastInstance hzInstance = createHazelcastInstance();
        IAtomicLong atomicNumber = hzInstance.getAtomicLong(randomString());
        assertFalse(atomicNumber.compareAndSet(172, 0));
        assertEquals(0,atomicNumber.get());
    }

    @Test
    @ClientCompatibleTest
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.