1818
1919package org .apache .hadoop .util ;
2020
21+ import static org .junit .Assert .assertArrayEquals ;
22+ import static org .junit .Assert .assertEquals ;
23+ import static org .junit .Assert .fail ;
24+
2125import java .util .ArrayList ;
2226import java .util .List ;
2327
24- import junit . framework . TestCase ;
25- import static org .junit .Assert . assertArrayEquals ;
28+ import org . apache . hadoop . test . UnitTestcaseTimeLimit ;
29+ import org .junit .Test ;
2630
27- public class TestStringUtils extends TestCase {
31+ public class TestStringUtils extends UnitTestcaseTimeLimit {
2832 final private static String NULL_STR = null ;
2933 final private static String EMPTY_STR = "" ;
3034 final private static String STR_WO_SPECIAL_CHARS = "AB" ;
@@ -36,6 +40,7 @@ public class TestStringUtils extends TestCase {
3640 final private static String ESCAPED_STR_WITH_BOTH2 =
3741 "\\ ,A\\ \\ \\ ,\\ ,B\\ \\ \\ \\ \\ ," ;
3842
43+ @ Test
3944 public void testEscapeString () throws Exception {
4045 assertEquals (NULL_STR , StringUtils .escapeString (NULL_STR ));
4146 assertEquals (EMPTY_STR , StringUtils .escapeString (EMPTY_STR ));
@@ -49,6 +54,7 @@ public void testEscapeString() throws Exception {
4954 StringUtils .escapeString (STR_WITH_BOTH2 ));
5055 }
5156
57+ @ Test
5258 public void testSplit () throws Exception {
5359 assertEquals (NULL_STR , StringUtils .split (NULL_STR ));
5460 String [] splits = StringUtils .split (EMPTY_STR );
@@ -78,6 +84,7 @@ public void testSplit() throws Exception {
7884 assertEquals (ESCAPED_STR_WITH_BOTH2 , splits [0 ]);
7985 }
8086
87+ @ Test
8188 public void testSimpleSplit () throws Exception {
8289 final String [] TO_TEST = {
8390 "a/b/c" ,
@@ -93,6 +100,7 @@ public void testSimpleSplit() throws Exception {
93100 }
94101 }
95102
103+ @ Test
96104 public void testUnescapeString () throws Exception {
97105 assertEquals (NULL_STR , StringUtils .unEscapeString (NULL_STR ));
98106 assertEquals (EMPTY_STR , StringUtils .unEscapeString (EMPTY_STR ));
@@ -124,6 +132,7 @@ public void testUnescapeString() throws Exception {
124132 StringUtils .unEscapeString (ESCAPED_STR_WITH_BOTH2 ));
125133 }
126134
135+ @ Test
127136 public void testTraditionalBinaryPrefix () throws Exception {
128137 String [] symbol = {"k" , "m" , "g" , "t" , "p" , "e" };
129138 long m = 1024 ;
@@ -138,6 +147,7 @@ public void testTraditionalBinaryPrefix() throws Exception {
138147 assertEquals (956703965184L , StringUtils .TraditionalBinaryPrefix .string2long ("891g" ));
139148 }
140149
150+ @ Test
141151 public void testJoin () {
142152 List <String > s = new ArrayList <String >();
143153 s .add ("a" );
@@ -149,6 +159,7 @@ public void testJoin() {
149159 assertEquals ("a:b:c" , StringUtils .join (":" , s .subList (0 , 3 )));
150160 }
151161
162+ @ Test
152163 public void testGetTrimmedStrings () throws Exception {
153164 String compactDirList = "/spindle1/hdfs,/spindle2/hdfs,/spindle3/hdfs" ;
154165 String spacedDirList = "/spindle1/hdfs, /spindle2/hdfs, /spindle3/hdfs" ;
@@ -169,6 +180,7 @@ public void testGetTrimmedStrings() throws Exception {
169180 assertArrayEquals (emptyArray , StringUtils .getTrimmedStrings (emptyList2 ));
170181 }
171182
183+ @ Test
172184 public void testCamelize () {
173185 // common use cases
174186 assertEquals ("Map" , StringUtils .camelize ("MAP" ));
0 commit comments