aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java
blob: 8bda0e32f574c435307dbef3ad7e03de5398cb7a (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
24
25
26
27
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.zookeeper;

import com.yahoo.path.Path;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

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

    @Test
    public void requireThatCounterIsInitializedFromNumberOfSessions() {
        Curator curator = new MockCurator();
        curator.create(Path.fromString("/sessions"));
        curator.create(Path.fromString("/sessions/1"));
        curator.create(Path.fromString("/sessions/2"));

        InitializedCounter counter = new InitializedCounter(curator, Path.fromString("/counter"), Path.fromString("/sessions"));
        assertEquals(2, counter.counter.get());
    }

}