KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > regis > remote > RemoteRegistryTest


1 package org.sapia.regis.remote;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Map JavaDoc;
5 import java.util.Properties JavaDoc;
6
7 import junit.framework.TestCase;
8
9 import org.sapia.regis.Path;
10 import org.sapia.regis.RegisSession;
11 import org.sapia.regis.Registry;
12 import org.sapia.regis.RegistryContext;
13 import org.sapia.ubik.rmi.Consts;
14 import org.sapia.ubik.rmi.server.Hub;
15 import org.sapia.ubik.util.Localhost;
16
17 public class RemoteRegistryTest extends TestCase{
18
19   public RemoteRegistryTest(String JavaDoc arg0) {
20     super(arg0);
21   }
22   
23   public void testServer() throws Exception JavaDoc{
24     System.setProperty(Consts.IP_PATTERN_KEY, "localhost");
25     RegistryServer.startThread = false;
26     RegistryServer.main(new String JavaDoc[]{"etc/server.properties"});
27     
28     Thread.sleep(2000);
29     
30     Properties JavaDoc props = new Properties JavaDoc();
31     props.setProperty("registry.address", Localhost.getLocalAddress().getHostAddress());
32     props.setProperty(RegistryContext.BOOTSTRAP, "etc/client.properties");
33     RegistryContext ctx = new RegistryContext(props);
34     Registry reg = ctx.connect();
35     RegisSession s = reg.open();
36     assertEquals("jsmith", reg.getRoot().getChild(Path.parse("databases/000")).getProperty("username").asString());
37     Map JavaDoc params = new HashMap JavaDoc();
38     params.put("param1", "value1");
39     reg.getRoot().getChild(Path.parse("databases/000")).getProperties(params);
40     s.close();
41     Hub.shutdown(3000);
42   }
43
44   
45 }
46
Popular Tags