1 4 package org.roller.util; 5 6 import org.roller.presentation.bookmarks.BookmarksActionTest; 7 8 import junit.framework.Test; 9 import junit.framework.TestCase; 10 import junit.framework.TestSuite; 11 12 15 public class RegexUtilTest extends TestCase 16 { 17 18 21 public RegexUtilTest() 22 { 23 super(); 24 } 25 26 29 public RegexUtilTest(String arg0) 30 { 31 super(arg0); 32 } 33 34 37 protected void setUp() throws Exception 38 { 39 super.setUp(); 40 } 41 42 45 protected void tearDown() throws Exception 46 { 47 super.tearDown(); 48 } 49 50 public void testEncodingEmail() 51 { 52 String test = "test <a HREF='mailto:this@email.com'>email</a> string"; 54 String expect = "test <a HREF='mailto:%74%68%69%73%40%65%6d%61%69%6c%2e%63%6f%6d'>email</a> string"; 55 String result = RegexUtil.encodeEmail(test) ; 56 assertEquals(expect, result); 58 } 59 60 public void testObfuscateEmail() 61 { 62 String test = "this@email.com"; 64 String expect = "this-AT-email-DOT-com"; 65 String result = RegexUtil.encodeEmail(test); 66 assertEquals(expect, result); 67 } 68 69 public void testHexEmail() 70 { 71 String test = "test <a HREF='mailto:this@email.com'>this@email.com</a> string, and this@email.com"; 73 String expect = "test <a HREF='mailto:%74%68%69%73%40%65%6d%61%69%6c%2e%63%6f%6d'>this-AT-email-DOT-com</a> string, and this-AT-email-DOT-com"; 74 String result = RegexUtil.encodeEmail(test); 75 assertEquals(expect, result); 77 } 78 79 public static Test suite() 80 { 81 return new TestSuite(RegexUtilTest.class); 82 }} 83 | Popular Tags |