01: /*
02: * Created on Jul 3, 2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.columba.mail.parser;
08:
09: import java.util.Map;
10:
11: import junit.framework.TestCase;
12:
13: import org.columba.ristretto.parser.ParserException;
14:
15: public class MailUrlParserTest extends TestCase {
16:
17: public MailUrlParserTest(String arg0) {
18: super (arg0);
19: }
20:
21: public void testParser1() throws ParserException {
22: String testData = "mailto:chris@example.com";
23: Map result = MailUrlParser.parse(testData);
24:
25: assertEquals("chris@example.com",
26: ((String[]) result.get("to"))[0]);
27: }
28:
29: public void testParser2() throws ParserException {
30: String testData = "mailto:infobot@example.com?subject=current-issue";
31: Map result = MailUrlParser.parse(testData);
32:
33: assertEquals("infobot@example.com", ((String[]) result
34: .get("to"))[0]);
35: assertEquals("current-issue", result.get("subject"));
36: }
37:
38: public void testParser3() throws ParserException {
39: String testData = "mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index";
40: Map result = MailUrlParser.parse(testData);
41:
42: assertEquals("infobot@example.com", ((String[]) result
43: .get("to"))[0]);
44: assertEquals("send current-issue\r\nsend index", result
45: .get("body"));
46: }
47:
48: public void testParser4() throws ParserException {
49: String testData = "mailto:joe@example.com?cc=bob@example.com&body=hello";
50: Map result = MailUrlParser.parse(testData);
51:
52: assertEquals("joe@example.com",
53: ((String[]) result.get("to"))[0]);
54: assertEquals("bob@example.com",
55: ((String[]) result.get("cc"))[0]);
56: assertEquals("hello", result.get("body"));
57: }
58:
59: public void testParser5() throws ParserException {
60: String testData = "mailto:?to=joe@example.com&cc=bob@example.com&body=hello";
61: Map result = MailUrlParser.parse(testData);
62:
63: assertEquals("joe@example.com",
64: ((String[]) result.get("to"))[0]);
65: assertEquals("bob@example.com",
66: ((String[]) result.get("cc"))[0]);
67: assertEquals("hello", result.get("body"));
68: }
69:
70: public void testParser6() throws ParserException {
71: String testData = "mailto:gorby%25kremvax@example.com";
72: Map result = MailUrlParser.parse(testData);
73:
74: assertEquals("gorby%kremvax@example.com", ((String[]) result
75: .get("to"))[0]);
76: }
77:
78: }
|