1 18 21 package org.apache.roller.util; 22 23 import org.apache.roller.ui.authoring.struts.actions.BookmarksActionTest; 24 25 import junit.framework.Test; 26 import junit.framework.TestCase; 27 import junit.framework.TestSuite; 28 29 32 public class RegexUtilTest extends TestCase 33 { 34 35 38 public RegexUtilTest() 39 { 40 super(); 41 } 42 43 46 public RegexUtilTest(String arg0) 47 { 48 super(arg0); 49 } 50 51 54 protected void setUp() throws Exception 55 { 56 super.setUp(); 57 } 58 59 62 protected void tearDown() throws Exception 63 { 64 super.tearDown(); 65 } 66 67 public void testEncodingEmail() 68 { 69 String test = "test <a HREF='mailto:this@email.com'>email</a> string"; 71 String expect = "test <a HREF='mailto:%74%68%69%73%40%65%6d%61%69%6c%2e%63%6f%6d'>email</a> string"; 72 String result = RegexUtil.encodeEmail(test) ; 73 assertEquals(expect, result); 75 } 76 77 public void testObfuscateEmail() 78 { 79 String test = "this@email.com"; 81 String expect = "this-AT-email-DOT-com"; 82 String result = RegexUtil.encodeEmail(test); 83 assertEquals(expect, result); 84 } 85 86 public void testHexEmail() 87 { 88 String test = "test <a HREF='mailto:this@email.com'>this@email.com</a> string, and this@email.com"; 90 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"; 91 String result = RegexUtil.encodeEmail(test); 92 assertEquals(expect, result); 94 } 95 96 public static Test suite() 97 { 98 return new TestSuite(RegexUtilTest.class); 99 }} 100 | Popular Tags |