1 16 package dlog4j.util; 17 18 import junit.framework.TestCase; 19 20 24 public class StringUtilsTest extends TestCase { 25 26 String str1; 27 String str2; 28 String str3; 29 String str4; 30 String str5; 31 34 protected void setUp() throws Exception { 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 45 protected void tearDown() throws Exception { 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 |