aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/container/ContainerNameTest.java
blob: bff3fb34663ac4b2956cddda97fe4b7ce41ff630 (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
44
45
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.container;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author freva
 */
public class ContainerNameTest {
    @Test
    public void testAlphanumericalContainerName() {
        String name = "container123";
        ContainerName containerName = new ContainerName(name);
        assertEquals(containerName.asString(), name);
    }

    @Test
    public void testAlphanumericalWithDashContainerName() {
        String name = "container-123";
        ContainerName containerName = new ContainerName(name);
        assertEquals(containerName.asString(), name);
    }

    @Test
    public void testContainerNameFromHostname() {
        assertEquals(new ContainerName("container-123"), ContainerName.fromHostname("container-123.sub.domain.tld"));
    }

    @Test(expected=IllegalArgumentException.class)
    public void testAlphanumericalWithSlashContainerName() {
        new ContainerName("container/123");
    }

    @Test(expected=IllegalArgumentException.class)
    public void testEmptyContainerName() {
        new ContainerName("");
    }

    @Test(expected=NullPointerException.class)
    public void testNullContainerName() {
        new ContainerName(null);
    }
}