aboutsummaryrefslogtreecommitdiffstats
path: root/zkfacade/src/test/java/com/yahoo/vespa/curator/CuratorCounterTest.java
blob: dc5842d4a97c6dff394a98de02699b575420c2a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.curator;

import com.yahoo.vespa.curator.mock.MockCurator;
import org.apache.curator.framework.recipes.atomic.DistributedAtomicLong;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author Ulf Lilleengen
 */
public class CuratorCounterTest {

    @Test
    public void testCounter() throws Exception {
        DistributedAtomicLong counter = new MockCurator().createAtomicCounter("/mycounter");
        counter.initialize(4L);
        assertEquals(4L, counter.get().postValue().longValue());
        assertEquals(5L, counter.increment().postValue().longValue());
    }

}