1 7 8 package test.client.named; 9 10 import java.util.Hashtable ; 11 import javax.naming.Context ; 12 import javax.naming.InitialContext ; 13 import javax.rmi.PortableRemoteObject ; 14 import junit.framework.*; 15 import java.rmi.Remote ; 16 import java.rmi.RemoteException ; 17 18 22 public class NamedClientTest extends TestCase { 23 24 public NamedClientTest(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(NamedClientTest.class); 36 37 return suite; 38 } 39 40 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.getProperty("coadunation.master")); 51 env.put("com.rift.coad.username","test"); 52 env.put("com.rift.coad.password","112233"); 53 Context ctx = new InitialContext (env); 54 55 Object 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 ("narrow failed."); 63 } else { 64 beanInterface.runBasicTest("huh"); 65 } 66 67 } catch (Exception ex) { 68 System.out.println(ex.getMessage()); 69 ex.printStackTrace(System.out); 70 throw new Exception (ex); 71 } 72 } 73 74 77 private class NamedClientImpl implements NamedClient { 78 79 public void runBasicTest(java.lang.String text) { 80 82 } 83 } 84 85 86 } 87 | Popular Tags |