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 assertArrayEquals(set.toArray(), newSet.toArray());
45 }
46
47 @Test
48 public void getSet02() {
49 Set<String> set = new HashSet<String>();
50 set.add("png");
51 set.add("jpg");
52 set.add("gif");
53
54 Set<String> newSet = Utils.getSet("png|jpg|gif");
55 assertArrayEquals(set.toArray(), newSet.toArray());
56 }
57
58 @Test
59 public void getSet03() {
60 Set<String> set = Utils.getSet(null);
61 assertTrue(set != null);
62 assertTrue(set.isEmpty());
63 }
64
65 @Test
66 public void getSet04() {
67 Set<String> set = Utils.getSet("");
68 assertTrue(set != null);
69 assertTrue(set.isEmpty());
70 }
71
72 @Test
73 public void isBlank01() {
74 assertTrue(Utils.isBlank(null));
75 }
76
77 @Test
78 public void isBlank02() {
79 assertTrue(Utils.isBlank(""));
80 }
81
82 @Test
83 public void isBlank03() {
84 assertTrue(Utils.isBlank(" "));
85 }
86
87 @Test
88 public void isBlank04() {
89 assertTrue(Utils.isBlank(" \t \n \r"));
90 }
91
92 @Test
93 public void isBlank05() {
94 assertFalse(Utils.isBlank(" h "));
95 }
96
97 @Test
98 public void isBlank06() {
99 assertFalse(Utils.isBlank("\t n "));
100 }
101
102 @Test
103 public void isNotBlank01() {
104 assertTrue(Utils.isNotBlank(" h "));
105 }
106
107 @Test
108 public void isNotBlank02() {
109 assertTrue(Utils.isNotBlank(" h \t "));
110 }
111
112 @Test
113 public void isNotBlank03() {
114 assertFalse(Utils.isNotBlank(" \t \n \r"));
115 }
116
117 @Test
118 public void isNotBlank04() {
119 assertFalse(Utils.isNotBlank(null));
120 }
121
122 @Test
123 public void isNotBlank05() {
124 assertFalse(Utils.isNotBlank(""));
125 }
126
127 @Test
128 public void isNotBlank06() {
129 assertFalse(Utils.isNotBlank(" "));
130 }
131
132 }