1 package org.apache.commons.jcs3.auxiliary.remote;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.rmi.registry.Registry;
23
24 import junit.framework.TestCase;
25
26
27
28
29 public class RemoteUtilsUnitTest
30 extends TestCase
31 {
32
33
34
35
36
37
38 public void testCreateRegistry()
39 {
40 final Registry registry = RemoteUtils.createRegistry( 1102 );
41 assertNotNull("Registry should not be null", registry);
42 }
43
44 public void testGetNamingURL()
45 {
46 assertEquals("//host:1/servicename", RemoteUtils.getNamingURL("host",1,"servicename"));
47 assertEquals("//127.0.0.1:2/servicename", RemoteUtils.getNamingURL("127.0.0.1",2,"servicename"));
48 assertEquals("//[0:0:0:0:0:0:0:1%251]:3/servicename", RemoteUtils.getNamingURL("0:0:0:0:0:0:0:1%1",3,"servicename"));
49 }
50
51 public void testParseServerAndPort()
52 {
53 RemoteLocation loc = RemoteLocation.parseServerAndPort("server1:1234");
54 assertEquals("server1", loc.getHost());
55 assertEquals(1234, loc.getPort());
56
57 loc = RemoteLocation.parseServerAndPort(" server2 : 4567 ");
58 assertEquals("server2", loc.getHost());
59 assertEquals(4567, loc.getPort());
60
61 loc = RemoteLocation.parseServerAndPort("server2 : port");
62 assertNull(loc);
63 }
64 }