1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package org.objectledge.im;
30
31 import org.jcontainer.dna.Configuration;
32 import org.objectledge.filesystem.FileSystem;
33 import org.objectledge.parameters.DefaultParameters;
34 import org.objectledge.parameters.Parameters;
35 import org.objectledge.utils.LedgeTestCase;
36
37 /***
38 *
39 *
40 * @author <a href="rafal@caltha.pl">RafaĆ Krzewski</a>
41 * @version $Id: InstantMessagingTest.java,v 1.2 2005/07/29 05:32:53 rafal Exp $
42 */
43 public class InstantMessagingTest
44 extends LedgeTestCase
45 {
46 private InstantMessaging im;
47
48 public void setUp() throws Exception
49 {
50 super.setUp();
51
52 FileSystem fs = getFileSystem();
53 Configuration config = getConfig(fs, "config/org.objectledge.im.InstantMessaging.xml");
54 im = new InstantMessaging(config);
55 }
56
57 public void testConfig()
58 {
59
60 }
61
62 public void testProtocolRegistry()
63 {
64 assertEquals(4, im.getProtocols().size());
65 assertEquals(4, im.getProtocolsById().size());
66 assertNotNull(im.getProtocol("icq"));
67 assertTrue(im.getProtocolsById().containsKey("icq"));
68 }
69
70 public void testProtocolMethods()
71 {
72 InstantMessagingProtocol icq = im.getProtocol("icq");
73 assertEquals("ICQ", icq.getName());
74 assertEquals(null, icq.getIconUrl());
75 assertEquals("http://icq.com/", icq.getInfoUrl());
76 assertEquals("http://status.icq.com/online.gif?icq=3657252&img=5", icq.getStatusUrl("3657252"));
77 assertEquals(true, icq.isValidScreenName("3657252"));
78 assertEquals(false, icq.isValidScreenName("filem0n"));
79 }
80
81 public void testContacts()
82 {
83 Parameters pd = new DefaultParameters();
84 InstantMessagingProtocol icq = im.getProtocol("icq");
85 InstantMessagingProtocol tlen = im.getProtocol("tlen");
86 im.addContact(pd, new InstantMessagingContact(icq, "3657252"));
87 im.addContact(pd, new InstantMessagingContact(tlen, "filem0n"));
88 assertEquals(2, im.getContacts(pd).size());
89 for(InstantMessagingContact contact : im.getContacts(pd))
90 {
91 if(contact.getProtocol().getId().equals("icq"))
92 {
93 assertEquals(contact.getScreenName(), "3657252");
94 }
95 if(contact.getProtocol().getId().equals("tlen"))
96 {
97 assertEquals(contact.getScreenName(), "filem0n");
98 }
99 }
100 im.removeContact(pd, new InstantMessagingContact(tlen, "filem0n"));
101 assertEquals(1, im.getContacts(pd).size());
102 }
103 }