1 18 19 package org.apache.roller.ui.rendering.plugins; 20 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 import org.apache.roller.TestUtils; 26 import org.apache.roller.pojos.UserData; 27 import org.apache.roller.pojos.WebsiteData; 28 import org.apache.roller.ui.authoring.struts.actions.WeblogEntryActionTest; 29 import org.apache.roller.ui.ServletTestBase; 30 31 32 35 public class SmileysTest extends ServletTestBase { 36 37 private static Log log = LogFactory.getLog(WeblogEntryActionTest.class); 38 39 private WebsiteData testWeblog = null; 40 private UserData testUser = null; 41 42 43 public SmileysTest() { 44 super(); 45 } 46 47 48 public static Test suite() { 49 return new TestSuite(SmileysTest.class); 50 } 51 52 53 56 public void setUp() throws Exception { 57 super.setUp(); 58 try { 59 testUser = TestUtils.setupUser("bkmrkTestUser"); 60 testWeblog = TestUtils.setupWeblog("bkmrkTestWeblog", testUser); 61 TestUtils.endSession(true); 62 } catch (Exception ex) { 63 log.error(ex); 64 throw new Exception ("Test setup failed", ex); 65 } 66 } 67 68 69 public void tearDown() throws Exception { 70 super.tearDown(); 71 try { 72 TestUtils.teardownWeblog(testWeblog.getId()); 73 TestUtils.teardownUser(testUser.getId()); 74 TestUtils.endSession(true); 75 } catch (Exception ex) { 76 log.error(ex); 77 throw new Exception ("Test teardown failed", ex); 78 } 79 } 80 81 82 public void testSmileEmoticon() throws Exception { 83 doFilters(); 84 85 SmileysPlugin plugin = new SmileysPlugin(); 86 plugin.init(testWeblog); 87 assertTrue( SmileysPlugin.smileyPatterns.length > 0 ); 88 89 String test = "put on a happy :-) face"; 90 String expected = 91 "put on a happy <img SRC=\"http://localhost:8080/roller/images/smileys/smile.gif" + 92 "\" class=\"smiley\" alt=\":-)\" title=\":-)\" /> face"; 93 String result = plugin.render(null, test); 94 assertEquals(expected, result); 95 } 96 97 } 98 | Popular Tags |