KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > util > test > MessageProcessorTest


1 /*
2  * $Id: MessageProcessorTest.java,v 1.1 2004/11/23 11:08:47 bel70 Exp $
3  *
4  * ***** BEGIN LICENSE BLOCK *****
5  * The contents of this file are subject to the Mozilla Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License
8  * at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific language governing rights and
13  * limitations under the License.
14  *
15  * The Original Code is JGossip forum code.
16  *
17  * The Initial Developer of the Original Code is the JResearch, Org.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Dmitriy Belov <bel@jresearch.org>
23  * .
24  * * ***** END LICENSE BLOCK ***** */

25 /*
26  * Created on 10.07.2004
27  *
28  */

29 package org.jresearch.gossip.util.test;
30
31 import java.util.ResourceBundle JavaDoc;
32
33 import junit.framework.TestCase;
34
35 import org.apache.struts.util.MessageResources;
36 import org.jresearch.gossip.exception.ConfiguratorException;
37 import org.jresearch.gossip.util.MessageProcessor;
38
39 /**
40  * @author Dmitry Belov
41  *
42  */

43 public class MessageProcessorTest extends TestCase {
44
45     MessageResources messages;
46
47     MessageProcessor mp;
48
49     /*
50      * @see TestCase#setUp()
51      */

52     protected void setUp() throws Exception JavaDoc {
53         super.setUp();
54         MessageProcessor.setEmoticonsMap(ResourceBundle
55                 .getBundle("org/jresearch/gossip/resources/emoticon"));
56         mp = MessageProcessor.getInstance();
57         messages = MessageResources
58                 .getMessageResources("org.jresearch.gossip.resources.lang.lang");
59     }
60
61     /*
62      * @see TestCase#tearDown()
63      */

64     protected void tearDown() throws Exception JavaDoc {
65         super.tearDown();
66     }
67
68     /**
69      * Constructor for MessageProcessorTest.
70      *
71      * @param name
72      */

73     public MessageProcessorTest(String JavaDoc name) {
74         super(name);
75     }
76
77     public void testPrepareMessage() {
78
79         System.out
80                 .println(mp
81                         .prepareMessage(
82                                 "[b]line1[/b] ;&#41; line2 [NOSMILE];&#41;[/NOSMILE];&#41;[NOSMILE];&#41;[/NOSMILE];&#41;",
83                                 0, messages));
84         System.out
85                 .println(mp
86                         .prepareMessage(
87                                 "[b]line1[/b] ;&#41; line2 [NOSMILE];&#41;[/NOSMILE];&#41;[NOSMILE];&#41;[/NOSMILE];&#41;",
88                                 12, messages));
89     }
90
91     public void testCleanup() {
92         System.out
93                 .println(mp
94                         .cleanup("line1 ;&#41; line2 [NOSMILE];&#41;[/NOSMILE];&#41;[NOSMILE];&#41;[/NOSMILE];&#41;"));
95     }
96
97     public void testNl2br() {
98         System.out.println(mp.nl2br("\nline1 \n line2\n"));
99     }
100
101     public void testProcessEmoticons() throws ConfiguratorException {
102         System.out
103                 .println(mp
104                         .processEmoticons(
105                                 "line1 ;&#41; line2 [NOSMILE];&#41;[/nOsMiLe];&#41;[NOSMILE];&#41;[/NOSMILE];&#41;",
106                                 messages));
107     }
108
109 }
Popular Tags