KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > client > named > NamedClientTest


1 /*
2  * NamedClientTest.java
3  * JUnit based test
4  *
5  * Created on 27 February 2007, 09:04
6  */

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

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

43     public void testRunBasicTest() throws Exception JavaDoc {
44         System.out.println("runBasicTest");
45         try {
46             Hashtable JavaDoc env = new Hashtable JavaDoc();
47             env.put(Context.INITIAL_CONTEXT_FACTORY,
48                     "com.rift.coad.client.naming." +
49                     "CoadunationInitialContextFactory");
50             env.put(Context.PROVIDER_URL,System.getProperty("coadunation.master"));
51             env.put("com.rift.coad.username","test");
52             env.put("com.rift.coad.password","112233");
53             Context JavaDoc ctx = new InitialContext JavaDoc(env);
54             
55             Object JavaDoc obj = ctx.lookup(System.getProperty("test.url"));
56             test.client.named.NamedClient beanInterface =
57                     (test.client.named.NamedClient)
58                     PortableRemoteObject.narrow(obj,
59                     test.client.named.NamedClient.class);
60             
61             if (beanInterface == null) {
62                 throw new Exception JavaDoc("narrow failed.");
63             } else {
64                 beanInterface.runBasicTest("huh");
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      * Generated implementation of abstract class test.client.named.NamedClient. Please fill dummy bodies of generated methods.
76      */

77     private class NamedClientImpl implements NamedClient {
78
79         public void runBasicTest(java.lang.String JavaDoc text) {
80             // TODO fill the body in order to provide useful implementation
81

82         }
83     }
84
85     
86 }
87
Popular Tags