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 static org.junit.jupiter.api.Assertions.assertEquals;
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertNull;
23
24 import org.junit.jupiter.api.AfterEach;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27
28
29
30
31 class ConstantStringLookupBasicTest {
32
33
34
35
36 public static final String NULL_STRING_FIXTURE = null;
37
38
39
40
41 public static final String STRING_FIXTURE = "Hello World!";
42
43
44
45
46 @AfterEach
47 public void afterEach() {
48 ConstantStringLookup.clear();
49 }
50
51
52
53
54 @BeforeEach
55 public void beforeEach() {
56 ConstantStringLookup.clear();
57 }
58
59 @Test
60 void testNull() {
61 assertNull(ConstantStringLookup.INSTANCE.apply(null));
62 }
63
64 @Test
65 void testNullClassFetch() {
66 assertNull(new ConstantStringLookup() {
67 @Override
68 protected Class<?> fetchClass(final String className) throws ClassNotFoundException {
69 return null;
70 }
71 }.apply(ConstantStringLookupBasicTest.class.getName() + ".STRING_FIXTURE"));
72 }
73
74 @Test
75 void testNullValue() {
76 assertEquals(NULL_STRING_FIXTURE, ConstantStringLookup.INSTANCE
77 .apply(ConstantStringLookupBasicTest.class.getName() + ".NULL_STRING_FIXTURE"));
78 }
79
80 @Test
81 void testOne() {
82 assertEquals(STRING_FIXTURE,
83 ConstantStringLookup.INSTANCE.apply(ConstantStringLookupBasicTest.class.getName() + ".STRING_FIXTURE"));
84 }
85
86 @Test
87 void testToString() {
88
89 assertFalse(ConstantStringLookup.INSTANCE.toString().isEmpty());
90 }
91
92 }