blob: f9f7a18597c4b5fe5007ac8c10b1fe94aa647d2e (
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
46
47
48
49
50
51
52
|
// Copyright Vespa.ai. 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.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author freva
*/
public class ContainerNameTest {
@Test
void testAlphanumericalContainerName() {
String name = "container123";
ContainerName containerName = new ContainerName(name);
assertEquals(containerName.asString(), name);
}
@Test
void testAlphanumericalWithDashContainerName() {
String name = "container-123";
ContainerName containerName = new ContainerName(name);
assertEquals(containerName.asString(), name);
}
@Test
void testContainerNameFromHostname() {
assertEquals(new ContainerName("container-123"), ContainerName.fromHostname("container-123.sub.domain.tld"));
}
@Test
void testAlphanumericalWithSlashContainerName() {
assertThrows(IllegalArgumentException.class, () -> {
new ContainerName("container/123");
});
}
@Test
void testEmptyContainerName() {
assertThrows(IllegalArgumentException.class, () -> {
new ContainerName("");
});
}
@Test
void testNullContainerName() {
assertThrows(NullPointerException.class, () -> {
new ContainerName(null);
});
}
}
|