summaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java
blob: 656e81a4c2f60d2714274d64bdd660a5007f97d3 (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
28
// Copyright 2017 Yahoo Holdings. 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.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

/**
 * @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"));
        assertThat(counter.counter.get(), is(2L));
    }

}