KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > util > RegexUtilTest


1 /*
2  * Created on Nov 8, 2003
3  */

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 /**
13  * @author lance
14  */

15 public class RegexUtilTest extends TestCase
16 {
17
18     /**
19      *
20      */

21     public RegexUtilTest()
22     {
23         super();
24     }
25
26     /**
27      * @param arg0
28      */

29     public RegexUtilTest(String JavaDoc arg0)
30     {
31         super(arg0);
32     }
33
34     /**
35      * @see TestCase#setUp()
36      */

37     protected void setUp() throws Exception JavaDoc
38     {
39         super.setUp();
40     }
41
42     /**
43      * @see TestCase#tearDown()
44      */

45     protected void tearDown() throws Exception JavaDoc
46     {
47         super.tearDown();
48     }
49     
50     public void testEncodingEmail()
51     {
52         // test mailto: escaping
53
String JavaDoc test = "test <a HREF='mailto:this@email.com'>email</a> string";
54         String JavaDoc expect = "test <a HREF='mailto:%74%68%69%73%40%65%6d%61%69%6c%2e%63%6f%6d'>email</a> string";
55         String JavaDoc result = RegexUtil.encodeEmail(test) ;
56         //System.out.println(result);
57
assertEquals(expect, result);
58     }
59     
60     public void testObfuscateEmail()
61     {
62         // test "plaintext" escaping
63
String JavaDoc test = "this@email.com";
64         String JavaDoc expect = "this-AT-email-DOT-com";
65         String JavaDoc result = RegexUtil.encodeEmail(test);
66         assertEquals(expect, result);
67     }
68     
69     public void testHexEmail()
70     {
71         // test hex & obfuscate together
72
String JavaDoc test = "test <a HREF='mailto:this@email.com'>this@email.com</a> string, and this@email.com";
73         String JavaDoc 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 JavaDoc result = RegexUtil.encodeEmail(test);
75         //System.out.println(result);
76
assertEquals(expect, result);
77     }
78
79     public static Test suite()
80     {
81         return new TestSuite(RegexUtilTest.class);
82     }}
83
Popular Tags