01: /*
02: * RPCClientTestTest.java
03: * JUnit based test
04: *
05: * Created on 22 February 2007, 02:51
06: */
07:
08: package test.client;
09:
10: import java.util.Hashtable;
11: import javax.rmi.PortableRemoteObject;
12: import junit.framework.*;
13: import java.rmi.Remote;
14: import java.rmi.RemoteException;
15: import javax.naming.Context;
16: import javax.naming.InitialContext;
17:
18: /**
19: *
20: * @author Admin
21: */
22: public class RPCClientTestTest extends TestCase {
23:
24: public RPCClientTestTest(String testName) {
25: super (testName);
26: }
27:
28: protected void setUp() throws Exception {
29: }
30:
31: protected void tearDown() throws Exception {
32: }
33:
34: public static Test suite() {
35: TestSuite suite = new TestSuite(RPCClientTestTest.class);
36:
37: return suite;
38: }
39:
40: /**
41: * Test of runBasicTest method, of class test.client.RPCClientTest.
42: */
43: public void testRunBasicTest() throws Exception {
44: System.out.println("runBasicTest");
45: try {
46: Hashtable env = new Hashtable();
47: env.put(Context.INITIAL_CONTEXT_FACTORY,
48: "com.rift.coad.client.naming."
49: + "CoadunationInitialContextFactory");
50: env.put(Context.PROVIDER_URL, System
51: .getProperty("coadunation.master"));
52: env.put("com.rift.coad.username", "test");
53: env.put("com.rift.coad.password", "112233");
54: Context ctx = new InitialContext(env);
55:
56: Object obj = ctx.lookup(System.getProperty("test2.url"));
57: test.client.RPCClientTest beanInterface = (test.client.RPCClientTest) PortableRemoteObject
58: .narrow(obj, test.client.RPCClientTest.class);
59:
60: if (beanInterface == null) {
61: throw new Exception("narrow failed.");
62: } else {
63: beanInterface.runBasicTest("huh");
64: beanInterface
65: .runBasicMessageTest("do you think i'm sexy?");
66: }
67:
68: } catch (Exception ex) {
69: System.out.println(ex.getMessage());
70: ex.printStackTrace(System.out);
71: throw new Exception(ex);
72: }
73: }
74:
75: }
|