KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > utils > TestStringUtils


1 package test.utils;
2
3 import junit.framework.Test;
4 import junit.framework.TestCase;
5 import junit.framework.TestSuite;
6
7 import org.apache.axis.utils.StringUtils;
8
9 public class TestStringUtils extends TestCase
10 {
11
12     public TestStringUtils (String JavaDoc name) {
13         super(name);
14     }
15
16     public static Test suite() {
17         return new TestSuite(TestStringUtils.class);
18     }
19
20     public void testStripWhite() {
21         assertEquals(null, StringUtils.strip(null, null));
22         assertEquals("", StringUtils.strip("", null));
23         assertEquals("", StringUtils.strip(" \r\n ", null));
24         assertEquals("abc", StringUtils.strip("abc", null));
25         assertEquals("abc", StringUtils.strip(" abc", null));
26         assertEquals("abc", StringUtils.strip("abc ", null));
27         assertEquals("abc", StringUtils.strip(" abc ", null));
28     }
29
30     public void testStripStartWhite() {
31         assertEquals(null, StringUtils.stripStart(null, null));
32         assertEquals("", StringUtils.stripStart("", null));
33         assertEquals("", StringUtils.stripStart(" \r\n ", null));
34         assertEquals("abc", StringUtils.stripStart("abc", null));
35         assertEquals("abc", StringUtils.stripStart(" abc", null));
36         assertEquals("abc ", StringUtils.stripStart("abc ", null));
37         assertEquals("abc ", StringUtils.stripStart(" abc ", null));
38     }
39
40     public void testStripEndWhite() {
41         assertEquals(null, StringUtils.stripEnd(null, null));
42         assertEquals("", StringUtils.stripEnd("", null));
43         assertEquals("", StringUtils.stripEnd(" \r\n ", null));
44         assertEquals("abc", StringUtils.stripEnd("abc", null));
45         assertEquals(" abc", StringUtils.stripEnd(" abc", null));
46         assertEquals("abc", StringUtils.stripEnd("abc ", null));
47         assertEquals(" abc", StringUtils.stripEnd(" abc ", null));
48     }
49     
50 }
51
Popular Tags