aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/test/java/com/yahoo/vespa/config/server/zookeeper/InitializedCounterTest.java
blob: 95d17156e63035a85a6c0152424f471f79013846 (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
29
30
31
32
33
34
35
// Copyright 2016 Yahoo Inc. 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.vespa.config.server.TestWithCurator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

/**
 * @author lulf
 * @since 5.1
 */
public class InitializedCounterTest extends TestWithCurator {

    @Rule
    public TemporaryFolder folder = new TemporaryFolder();

    @Before
    public void setupZK() {
        configCurator.createNode("/sessions");
        configCurator.createNode("/sessions/1");
        configCurator.createNode("/sessions/2");
    }

    @Test
    public void requireThatCounterIsInitializedFromNumberOfSessions() {
        InitializedCounter counter = new InitializedCounter(curator, "/counter", "/sessions");
        assertThat(counter.counter.get(), is(2l));
    }

}