aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/vespa/model/test/PortsMetaTestCase.java
blob: 61d9d8bee2d45f3c9ffb72960e6200d1670704d6 (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
36
37
38
39
40
41
42
43
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.test;

import com.yahoo.vespa.model.PortsMeta;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
 * Tests proper functioning of the PortsMeta.
 *
 * @author Vidar Larsen
 */
public class PortsMetaTestCase {

    @Test
    void testRegister() {
        PortsMeta pm = new PortsMeta();
        pm.on(0).tag("foo");
        pm.on(1).tag("bar");
        pm.on(5).tag("xyzzy");

        assertTrue(pm.contains(0, "foo"));
        assertTrue(pm.contains(1, "bar"));
        assertTrue(pm.contains(5, "xyzzy"));
        assertFalse(pm.contains(0, "bar"));
        assertFalse(pm.contains(2, "anything"));
    }

    @Test
    void testAdminStatusApi() {
        PortsMeta pm = new PortsMeta()
                .on(0).tag("rpc").tag("nc").tag("admin").tag("status")
                .on(1).tag("rpc").tag("rtx").tag("admin").tag("status")
                .on(2).tag("http").tag("admin");

        assertEquals(1, pm.getRpcAdminOffset().intValue());
        assertEquals(1, pm.getRpcStatusOffset().intValue());
        assertEquals(2, pm.getHttpAdminOffset().intValue());
        assertNull(pm.getHttpStatusOffset());
    }

}