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.*;
24 import java.util.HashSet;
25 import java.util.Set;
26
27 import org.junit.Test;
28
29
30
31
32
33
34 public class UtilsTest {
35
36 @Test
37 public void getSet01() {
38 Set<String> set = new HashSet<String>();
39 set.add("a");
40 set.add("ab");
41 set.add("c");
42
43 Set<String> newSet = Utils.getSet("a|Ab|c", "|");
44 for (String string : newSet) {
45 assertTrue(set.contains(string));
46 }
47 }
48
49 @Test
50 public void getSet02() {
51 Set<String> set = new HashSet<String>();
52 set.add("png");
53 set.add("jpg");
54 set.add("gif");
55
56 Set<String> newSet = Utils.getSet("png|jpg|gif");
57 for (String string : newSet) {
58 assertTrue(set.contains(string));
59 }
60 }
61
62 @Test
63 public void getSet03() {
64 Set<String> set = Utils.getSet(null);
65 assertTrue(set != null);
66 assertTrue(set.isEmpty());
67 }
68
69 @Test
70 public void getSet04() {
71 Set<String> set = Utils.getSet("");
72 assertTrue(set != null);
73 assertTrue(set.isEmpty());
74 }
75
76 @Test
77 public void isBlank01() {
78 assertTrue(Utils.isBlank(null));
79 }
80
81 @Test
82 public void isBlank02() {
83 assertTrue(Utils.isBlank(""));
84 }
85
86 @Test
87 public void isBlank03() {
88 assertTrue(Utils.isBlank(" "));
89 }
90
91 @Test
92 public void isBlank04() {
93 assertTrue(Utils.isBlank(" \t \n \r"));
94 }
95
96 @Test
97 public void isBlank05() {
98 assertFalse(Utils.isBlank(" h "));
99 }
100
101 @Test
102 public void isBlank06() {
103 assertFalse(Utils.isBlank("\t n "));
104 }
105
106 @Test
107 public void isNotBlank01() {
108 assertTrue(Utils.isNotBlank(" h "));
109 }
110
111 @Test
112 public void isNotBlank02() {
113 assertTrue(Utils.isNotBlank(" h \t "));
114 }
115
116 @Test
117 public void isNotBlank03() {
118 assertFalse(Utils.isNotBlank(" \t \n \r"));
119 }
120
121 @Test
122 public void isNotBlank04() {
123 assertFalse(Utils.isNotBlank(null));
124 }
125
126 @Test
127 public void isNotBlank05() {
128 assertFalse(Utils.isNotBlank(""));
129 }
130
131 @Test
132 public void isNotBlank06() {
133 assertFalse(Utils.isNotBlank(" "));
134 }
135
136 }