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