Java Code Examples for org.redisson.api.RAtomicDouble#set()

The following examples show how to use org.redisson.api.RAtomicDouble#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonAtomicDoubleTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void test() {
    RAtomicDouble al = redisson.getAtomicDouble("test");
    assertThat(al.get()).isEqualTo(0);
    assertThat(al.getAndIncrement()).isEqualTo(0);
    assertThat(al.get()).isEqualTo(1);
    assertThat(al.getAndDecrement()).isEqualTo(1);
    assertThat(al.get()).isEqualTo(0);
    assertThat(al.getAndIncrement()).isEqualTo(0);
    assertThat(al.getAndSet(12.8012)).isEqualTo(1);
    assertThat(al.get()).isEqualTo(12.8012);

    al.set(1.00123);

    double state = redisson.getAtomicDouble("test").get();
    assertThat(state).isEqualTo(1.00123);
    al.set(BigDecimal.valueOf(Long.MAX_VALUE).doubleValue());
    al.incrementAndGet();

    double newState = redisson.getAtomicDouble("test").get();
    assertThat(newState).isEqualTo(BigDecimal.valueOf(Long.MAX_VALUE).doubleValue());
}
 
Example 2
Source File: RedissonAtomicDoubleTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAndDelete() {
    RAtomicDouble al = redisson.getAtomicDouble("test");
    al.set(10.34);
    assertThat(al.getAndDelete()).isEqualTo(10.34);
    assertThat(al.isExists()).isFalse();

    RAtomicDouble ad2 = redisson.getAtomicDouble("test2");
    assertThat(ad2.getAndDelete()).isZero();
}
 
Example 3
Source File: RedissonAtomicDoubleTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetThenIncrement() {
    RAtomicDouble al = redisson.getAtomicDouble("test");
    al.set(2.81);
    assertThat(al.getAndIncrement()).isEqualTo(2.81);
    assertThat(al.get()).isEqualTo(3.81);
}
 
Example 4
Source File: RedissonAtomicDoubleTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecrementAndGet() {
    RAtomicDouble al = redisson.getAtomicDouble("test");
    al.set(19.30);
    assertThat(al.decrementAndGet()).isEqualTo(18.30);
    assertThat(al.get()).isEqualTo(18.30);
}