KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > velocity > plugins > smileys > SmileysTest


1 /*
2  * Created on Jun 8, 2004
3  */

4 package org.roller.presentation.velocity.plugins.smileys;
5
6 import junit.framework.Test;
7 import junit.framework.TestSuite;
8
9 import org.roller.presentation.MockRollerRequest;
10 import org.roller.presentation.VelocityServletTestBase;
11
12 import com.mockrunner.mock.web.MockHttpServletRequest;
13 import com.mockrunner.mock.web.MockServletContext;
14
15 /**
16  * @author lance.lavandowska
17  */

18 public class SmileysTest extends VelocityServletTestBase
19 {
20     public void testSmileEmoticon() throws Exception JavaDoc
21     {
22         MockServletContext ctx = getMockFactory().getMockServletContext();
23         ctx.setServletContextName("/roller");
24         
25         MockHttpServletRequest request = getMockFactory().getMockRequest();
26         request.setContextPath("/roller");
27        
28         doFilters();
29
30         SmileysPlugin plugin = new SmileysPlugin();
31         plugin.init(new MockRollerRequest(request, ctx), null);
32         assertTrue( SmileysPlugin.smileyPatterns.length > 0 );
33
34         String JavaDoc test = "put on a happy :-) face";
35         String JavaDoc expected =
36             "put on a happy <img SRC=\"/roller/images/smileys/smile.gif" +
37             "\" class=\"smiley\" alt=\":-)\" title=\":-)\"> face";
38         String JavaDoc result = plugin.render(test);
39         //System.out.println(result);
40
assertEquals(expected, result);
41     }
42         
43     public SmileysTest()
44     {
45         super();
46     }
47
48     public static Test suite()
49     {
50         return new TestSuite(SmileysTest.class);
51     }
52 }
53
Popular Tags