01: /*
02: * This program is free software; you can redistribute it and/or modify
03: * it under the terms of the GNU General Public License as published by
04: * the Free Software Foundation; either version 2 of the License, or
05: * (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * 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 str1;
27: String str2;
28: String str3;
29: String str4;
30: String str5;
31:
32: /*
33: * @see TestCase#setUp()
34: */
35: protected void setUp() throws Exception {
36: str1 = "public class StringUtilsTest extends TestCase";
37: str2 = "private class StringUtilsTest extends TestCase";
38: str3 = "public interface StringUtilsTest extends TestCase";
39: str4 = "public class StringUtilsTest extends AAAA";
40: str5 = "public class StringUtilsTest extends TestCase";
41: }
42:
43: /*
44: * @see TestCase#tearDown()
45: */
46: protected void tearDown() throws Exception {
47: str1 = null;
48: str2 = null;
49: }
50:
51: public void testIsEmail() {
52: assertEquals(StringUtils.isEmail("liudong@mo168.com"), true);
53: assertEquals(StringUtils.isEmail("winter.lau@163.com"), true);
54: assertEquals(StringUtils.isEmail("love_java@21cn.com"), true);
55: assertEquals(StringUtils.isEmail("@mo168.com"), false);
56: assertEquals(StringUtils.isEmail("winter.lau@"), false);
57: assertEquals(StringUtils.isEmail("love_java @ adfa.com"), false);
58: }
59:
60: public void testReplaceIgnoreCase() {
61: assertEquals(StringUtils.replaceIgnoreCase(str1, "pUblic",
62: "private"), str2);
63: assertEquals(StringUtils.replaceIgnoreCase(str1, "clAss",
64: "interface"), str3);
65: assertEquals(StringUtils.replaceIgnoreCase(str1, "TestCase",
66: "AAAA"), str4);
67: assertEquals(
68: StringUtils.replaceIgnoreCase(str1, "AAA", "AAAA"),
69: str5);
70: }
71:
72: }
|