1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.text.lookup;
19
20 import java.net.InetAddress;
21
22 import org.junit.jupiter.api.Assertions;
23 import org.junit.jupiter.api.Test;
24
25
26
27
28 class InetAddressStringLookupLoopbackAddressTest {
29
30 @Test
31 void testAddress() {
32 Assertions.assertEquals(InetAddress.getLoopbackAddress().getHostAddress(), InetAddressStringLookup.LOOPACK_ADDRESS.apply("address"));
33 }
34
35 @Test
36 void testBadKey() {
37 Assertions.assertThrows(IllegalArgumentException.class, () -> InetAddressStringLookup.LOOPACK_ADDRESS.apply("FOO"));
38 }
39
40 @Test
41 void testCanonicalName() {
42 Assertions.assertEquals(InetAddress.getLoopbackAddress().getCanonicalHostName(), InetAddressStringLookup.LOOPACK_ADDRESS.apply("canonical-name"));
43 }
44
45 @Test
46 void testName() {
47 Assertions.assertEquals(InetAddress.getLoopbackAddress().getHostName(), InetAddressStringLookup.LOOPACK_ADDRESS.apply("name"));
48 }
49
50 @Test
51 void testNull() {
52 Assertions.assertNull(InetAddressStringLookup.LOOPACK_ADDRESS.apply(null));
53 }
54
55 @Test
56 void testToString() {
57
58 Assertions.assertFalse(InetAddressStringLookup.LOOPACK_ADDRESS.toString().isEmpty());
59 }
60
61 }