001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.composer;
019:
020: import junit.framework.TestCase;
021:
022: /**
023: * Test cases for generating subject lines, when replying and/or forwarding
024: * messages
025: * <p>
026: *
027: * TODO: Re:[columba-devel]test-subject
028: *
029: * @author fdietz
030: */
031: public class SubjectTest extends TestCase {
032: /**
033: * Check if "Re: " is correctly prepended
034: *
035: */
036: public void testReply() {
037: String s = "Subject";
038:
039: String result = MessageBuilderHelper.createReplySubject(s);
040:
041: assertEquals("Re: Subject", result);
042: }
043:
044: /**
045: * Check if "Fwd: " is correctly prepended
046: *
047: */
048: public void testForward() {
049: String s = "Subject";
050:
051: String result = MessageBuilderHelper.createForwardSubject(s);
052:
053: assertEquals("Fwd: Subject", result);
054: }
055:
056: /**
057: * Check if "Re: " is only prepended if not already found in string
058: *
059: */
060: public void testReply2() {
061: String s = "Re: Subject";
062:
063: String result = MessageBuilderHelper.createReplySubject(s);
064:
065: assertEquals("Re: Subject", result);
066: }
067:
068: /**
069: * Check if "Fwd: " is only prepended if not already found in string
070: *
071: */
072: public void testForward2() {
073: String s = "Fwd: Subject";
074:
075: String result = MessageBuilderHelper.createForwardSubject(s);
076:
077: assertEquals("Fwd: Subject", result);
078: }
079:
080: /**
081: * Check if "Re:" is only prepended if not already found in string
082: * <p>
083: * Note, the missing space
084: */
085: public void testReply3() {
086: String s = "Re:Subject";
087:
088: String result = MessageBuilderHelper.createReplySubject(s);
089:
090: assertEquals("Re:Subject", result);
091: }
092:
093: /**
094: * Check if "Fwd:" is only prepended if not already found in string
095: * <p>
096: * Note, the missing space
097: *
098: */
099: public void testForward3() {
100: String s = "Fwd:Subject";
101:
102: String result = MessageBuilderHelper.createForwardSubject(s);
103:
104: assertEquals("Fwd:Subject", result);
105: }
106:
107: /**
108: * Test if string is matched correctly.
109: *
110: */
111: public void testAlreadyInString() {
112: String s = "Test: Hallo";
113:
114: boolean result = MessageBuilderHelper
115: .isAlreadyReply(s, "test:");
116:
117: assertTrue(result);
118: }
119:
120: /**
121: * Test for adding the "Re" when replying to mailing list messages.
122: */
123: public void testMailingListReplies() {
124: String s = "[columba.devel] a subject";
125: String result = MessageBuilderHelper.createReplySubject(s);
126: assertEquals("The \"Re:\" was not added to the subject",
127: "Re: [columba.devel] a subject", result);
128:
129: s = "Re:[columba-devel]test-subject";
130: result = MessageBuilderHelper.createReplySubject(s);
131: assertEquals("The \"Re:\" was added to the subject",
132: "Re:[columba-devel]test-subject", result);
133:
134: s = "[columba-devel] Re:] Test";
135: result = MessageBuilderHelper.createReplySubject(s);
136: assertEquals("The \"Re:\" was added to the subject",
137: "[columba-devel] Re:] Test", result);
138:
139: s = "[columba-devel] Re: Re: re: Re: Test";
140: result = MessageBuilderHelper.createReplySubject(s);
141: assertEquals("The \"Re:\" was added to the subject",
142: "[columba-devel] Re: Re: re: Re: Test", result);
143: }
144:
145: /**
146: * Test for adding the "fwd" when forwarding messages from a mailing list.
147: */
148: public void testMailingListForwards() {
149: String s = "[columba.devel] a subject";
150: String result = MessageBuilderHelper.createForwardSubject(s);
151: assertEquals("The \"Fwd:\" was not added to the subject",
152: "Fwd: [columba.devel] a subject", result);
153:
154: s = "Fwd:[columba-devel]test-subject";
155: result = MessageBuilderHelper.createForwardSubject(s);
156: assertEquals("The \"Fwd:\" was added to the subject",
157: "Fwd:[columba-devel]test-subject", result);
158:
159: s = "[columba-devel] Fwd:] Test";
160: result = MessageBuilderHelper.createForwardSubject(s);
161: assertEquals("The \"Fwd:\" was added to the subject",
162: "[columba-devel] Fwd:] Test", result);
163:
164: s = "[columba-devel] Fwd: Re: re: Re: Test";
165: result = MessageBuilderHelper.createForwardSubject(s);
166: assertEquals("The \"Fwd:\" was added to the subject",
167: "[columba-devel] Fwd: Re: re: Re: Test", result);
168: }
169: }
|