KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > util > StringUtilsTest


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package dlog4j.util;
17
18 import junit.framework.TestCase;
19
20 /**
21  * dlog4j.util.StringUtils的测试类,用于测试方法replaceIgnoreCase
22  * @author Winter Lau
23  */

24 public class StringUtilsTest extends TestCase {
25
26     String JavaDoc str1;
27     String JavaDoc str2;
28     String JavaDoc str3;
29     String JavaDoc str4;
30     String JavaDoc str5;
31     /*
32      * @see TestCase#setUp()
33      */

34     protected void setUp() throws Exception JavaDoc {
35         str1 = "public class StringUtilsTest extends TestCase";
36         str2 = "private class StringUtilsTest extends TestCase";
37         str3 = "public interface StringUtilsTest extends TestCase";
38         str4 = "public class StringUtilsTest extends AAAA";
39         str5 = "public class StringUtilsTest extends TestCase";
40     }
41
42     /*
43      * @see TestCase#tearDown()
44      */

45     protected void tearDown() throws Exception JavaDoc {
46         str1 = null;
47         str2 = null;
48     }
49
50     public void testIsEmail() {
51         assertEquals(StringUtils.isEmail("liudong@mo168.com"),true);
52         assertEquals(StringUtils.isEmail("winter.lau@163.com"),true);
53         assertEquals(StringUtils.isEmail("love_java@21cn.com"),true);
54         assertEquals(StringUtils.isEmail("@mo168.com"),false);
55         assertEquals(StringUtils.isEmail("winter.lau@"),false);
56         assertEquals(StringUtils.isEmail("love_java @ adfa.com"),false);
57     }
58     
59     public void testReplaceIgnoreCase() {
60         assertEquals(StringUtils.replaceIgnoreCase(str1,"pUblic","private"),str2);
61         assertEquals(StringUtils.replaceIgnoreCase(str1,"clAss","interface"),str3);
62         assertEquals(StringUtils.replaceIgnoreCase(str1,"TestCase","AAAA"),str4);
63         assertEquals(StringUtils.replaceIgnoreCase(str1,"AAA","AAAA"),str5);
64     }
65
66 }
67
Popular Tags