KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > client > RPCClientTestTest


1 /*
2  * RPCClientTestTest.java
3  * JUnit based test
4  *
5  * Created on 22 February 2007, 02:51
6  */

7
8 package test.client;
9
10 import java.util.Hashtable JavaDoc;
11 import javax.rmi.PortableRemoteObject JavaDoc;
12 import junit.framework.*;
13 import java.rmi.Remote JavaDoc;
14 import java.rmi.RemoteException JavaDoc;
15 import javax.naming.Context JavaDoc;
16 import javax.naming.InitialContext JavaDoc;
17 /**
18  *
19  * @author Admin
20  */

21 public class RPCClientTestTest extends TestCase {
22     
23     public RPCClientTestTest(String JavaDoc testName) {
24         super(testName);
25     }
26
27     protected void setUp() throws Exception JavaDoc {
28     }
29
30     protected void tearDown() throws Exception JavaDoc {
31     }
32
33     public static Test suite() {
34         TestSuite suite = new TestSuite(RPCClientTestTest.class);
35         
36         return suite;
37     }
38
39     /**
40      * Test of runBasicTest method, of class test.client.RPCClientTest.
41      */

42     public void testRunBasicTest() throws Exception JavaDoc {
43         System.out.println("runBasicTest");
44         try {
45             Hashtable JavaDoc env = new Hashtable JavaDoc();
46             env.put(Context.INITIAL_CONTEXT_FACTORY,
47                     "com.rift.coad.client.naming." +
48                     "CoadunationInitialContextFactory");
49             env.put(Context.PROVIDER_URL,System.getProperty("coadunation.master"));
50             env.put("com.rift.coad.username","test");
51             env.put("com.rift.coad.password","112233");
52             Context JavaDoc ctx = new InitialContext JavaDoc(env);
53             
54             Object JavaDoc obj = ctx.lookup(System.getProperty("test2.url"));
55             test.client.RPCClientTest beanInterface =
56                     (test.client.RPCClientTest)
57                     PortableRemoteObject.narrow(obj,
58                     test.client.RPCClientTest.class);
59             
60             if (beanInterface == null) {
61                 throw new Exception JavaDoc("narrow failed.");
62             } else {
63                 beanInterface.runBasicTest("huh");
64                 beanInterface.runBasicMessageTest("do you think i'm sexy?");
65             }
66             
67         } catch (Exception JavaDoc ex) {
68             System.out.println(ex.getMessage());
69             ex.printStackTrace(System.out);
70             throw new Exception JavaDoc(ex);
71         }
72     }
73
74     
75 }
76
Popular Tags