1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.fckeditor.tool;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertTrue;
25
26 import java.util.HashSet;
27 import java.util.Set;
28
29 import org.junit.Test;
30
31
32
33
34
35
36 public class UtilsTest {
37
38 @Test
39 public void getSet01() {
40 Set<String> set = new HashSet<String>();
41 set.add("a");
42 set.add("ab");
43 set.add("c");
44
45 Set<String> newSet = Utils.getSet("a|Ab|c", "|");
46 for (String string : newSet) {
47 assertTrue(set.contains(string));
48 }
49 }
50
51 @Test
52 public void getSet02() {
53 Set<String> set = new HashSet<String>();
54 set.add("png");
55 set.add("jpg");
56 set.add("gif");
57
58 Set<String> newSet = Utils.getSet("png|jpg|gif");
59 for (String string : newSet) {
60 assertTrue(set.contains(string));
61 }
62 }
63
64 @Test
65 public void getSet03() {
66 Set<String> set = Utils.getSet(null);
67 assertTrue(set != null);
68 assertTrue(set.isEmpty());
69 }
70
71 @Test
72 public void getSet04() {
73 Set<String> set = Utils.getSet("");
74 assertTrue(set != null);
75 assertTrue(set.isEmpty());
76 }
77
78 @Test
79 public void replaceAll01() {
80 String str = Utils.replaceAll("//a/b//c", "//", "/");
81 assertEquals(str, "/a/b/c");
82 }
83
84 @Test
85 public void replaceAll02() {
86 String str = Utils.replaceAll(null, "a", "c");
87 assertEquals(str, "");
88 }
89
90 @Test
91 public void replaceAll03() {
92 String str = Utils.replaceAll("foo", null, "c");
93 assertEquals(str, "foo");
94 }
95
96 @Test
97 public void replaceAll04() {
98 String str = Utils.replaceAll("foo", "o", "a");
99 assertEquals(str, "faa");
100 }
101 }