diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-03-31 11:52:40 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-03-31 11:53:33 +0200 |
commit | 2430b74a942659d549771cb4dd8b81d77692d905 (patch) | |
tree | c79b8b48bf150bea00ab9e0c6ad594740709d4fa /vespajlib/src/test | |
parent | 168f767ec12253f43ace27946dc530fde9e37d5e (diff) |
Rename back to HostName, and merge the value class and utilities
Diffstat (limited to 'vespajlib/src/test')
3 files changed, 41 insertions, 53 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/net/HostNameTest.java b/vespajlib/src/test/java/com/yahoo/net/HostNameTest.java new file mode 100644 index 00000000000..fa756b31616 --- /dev/null +++ b/vespajlib/src/test/java/com/yahoo/net/HostNameTest.java @@ -0,0 +1,41 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.net; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @author jonmv + */ +public class HostNameTest { + + @Test + void testNames() { + HostName.of("name-123.0.321-eman"); + HostName.of(("." + "a".repeat(32)).repeat(2).substring(1, 65)); + HostName.of("123"); + + assertThrows(IllegalArgumentException.class, () -> HostName.of("_")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("-")); + assertThrows(IllegalArgumentException.class, () -> HostName.of(".")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("-foo")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo-")); + assertThrows(IllegalArgumentException.class, () -> HostName.of(".foo")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo.")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo..bar")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo.-.bar")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo/")); + assertThrows(IllegalArgumentException.class, () -> HostName.of("foo%")); + assertThrows(IllegalArgumentException.class, () -> HostName.of(("." + "a".repeat(32)).repeat(2).substring(1, 66))); + assertThrows(IllegalArgumentException.class, () -> HostName.of("a".repeat(64))); + } + + @Test + void testHostnameIsFound() { + assertFalse(HostName.getLocalhost().isEmpty()); + } + +} diff --git a/vespajlib/src/test/java/com/yahoo/net/HostnameTest.java b/vespajlib/src/test/java/com/yahoo/net/HostnameTest.java deleted file mode 100644 index ef502aea2cd..00000000000 --- a/vespajlib/src/test/java/com/yahoo/net/HostnameTest.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.net; - -import com.yahoo.net.Hostname; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertThrows; - -/** - * @author jonmv - */ -public class HostnameTest { - - @Test - void testNames() { - Hostname.of("name-123.0.321-eman"); - Hostname.of(("." + "a".repeat(32)).repeat(2).substring(1, 65)); - Hostname.of("123"); - - assertThrows(IllegalArgumentException.class, () -> Hostname.of("_")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("-")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of(".")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("-foo")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo-")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of(".foo")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo.")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo..bar")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo.-.bar")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo/")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("foo%")); - assertThrows(IllegalArgumentException.class, () -> Hostname.of(("." + "a".repeat(32)).repeat(2).substring(1, 66))); - assertThrows(IllegalArgumentException.class, () -> Hostname.of("a".repeat(64))); - } - -} diff --git a/vespajlib/src/test/java/com/yahoo/net/HostnamesTestCase.java b/vespajlib/src/test/java/com/yahoo/net/HostnamesTestCase.java deleted file mode 100644 index 2e942605e3e..00000000000 --- a/vespajlib/src/test/java/com/yahoo/net/HostnamesTestCase.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.net; - -import org.junit.Test; - -import static org.junit.Assert.assertFalse; - -/** - * @author Ulf Lilleengen - */ -public class HostnamesTestCase { - - @Test - public void testHostnameIsFound() { - assertFalse(Hostnames.getLocalhost().isEmpty()); - } - -} |