01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License. For additional information regarding
15: * copyright in this work, please see the NOTICE file in the top level
16: * directory of this distribution.
17: */
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: * Test smileys plugin.
33: */
34: public class SmileysTest extends ServletTestBase {
35:
36: private static Log log = LogFactory
37: .getLog(WeblogEntryActionTest.class);
38:
39: private WebsiteData testWeblog = null;
40: private UserData testUser = null;
41:
42: public SmileysTest() {
43: super ();
44: }
45:
46: public static Test suite() {
47: return new TestSuite(SmileysTest.class);
48: }
49:
50: /**
51: * All tests in this suite require a user and a weblog.
52: */
53: public void setUp() throws Exception {
54: super .setUp();
55: try {
56: testUser = TestUtils.setupUser("bkmrkTestUser");
57: testWeblog = TestUtils.setupWeblog("bkmrkTestWeblog",
58: testUser);
59: TestUtils.endSession(true);
60: } catch (Exception ex) {
61: log.error(ex);
62: throw new Exception("Test setup failed", ex);
63: }
64: }
65:
66: public void tearDown() throws Exception {
67: super .tearDown();
68: try {
69: TestUtils.teardownWeblog(testWeblog.getId());
70: TestUtils.teardownUser(testUser.getId());
71: TestUtils.endSession(true);
72: } catch (Exception ex) {
73: log.error(ex);
74: throw new Exception("Test teardown failed", ex);
75: }
76: }
77:
78: public void testSmileEmoticon() throws Exception {
79: doFilters();
80:
81: SmileysPlugin plugin = new SmileysPlugin();
82: plugin.init(testWeblog);
83: assertTrue(SmileysPlugin.smileyPatterns.length > 0);
84:
85: String test = "put on a happy :-) face";
86: String expected = "put on a happy <img src=\"http://localhost:8080/roller/images/smileys/smile.gif"
87: + "\" class=\"smiley\" alt=\":-)\" title=\":-)\" /> face";
88: String result = plugin.render(null, test);
89: assertEquals(expected, result);
90: }
91:
92: }
|