1 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 18 public class SmileysTest extends VelocityServletTestBase 19 { 20 public void testSmileEmoticon() throws Exception 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 test = "put on a happy :-) face"; 35 String expected = 36 "put on a happy <img SRC=\"/roller/images/smileys/smile.gif" + 37 "\" class=\"smiley\" alt=\":-)\" title=\":-)\"> face"; 38 String result = plugin.render(test); 39 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 |