1 7 package org.jboss.test.remoting.registry; 8 9 import javax.management.MBeanServer ; 10 import org.jboss.remoting.Client; 11 import org.jboss.remoting.InvocationRequest; 12 import org.jboss.remoting.InvokerLocator; 13 import org.jboss.remoting.InvokerRegistry; 14 import org.jboss.remoting.ServerInvocationHandler; 15 import org.jboss.remoting.ServerInvoker; 16 import org.jboss.remoting.callback.InvokerCallbackHandler; 17 import org.jboss.remoting.transport.ClientInvoker; 18 import org.jboss.remoting.transport.Connector; 19 import org.jboss.remoting.transport.local.LocalClientInvoker; 20 21 import junit.framework.TestCase; 22 23 30 public class InvokerRegistryTestCase extends TestCase 31 { 32 34 36 38 40 public InvokerRegistryTestCase(String name) 41 { 42 super(name); 43 } 44 45 47 public void setUp() throws Exception 48 { 49 super.setUp(); 50 } 51 52 public void tearDown() throws Exception 53 { 54 super.tearDown(); 55 } 56 57 public void testEmptyInvokerRegistry() throws Throwable 58 { 59 ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers(); 60 assertEquals(0, clientInvokers.length); 61 } 62 63 public void testInvokerRegistry() throws Throwable 64 { 65 String serverlocatorURI = "socket://127.0.0.1:5555"; 66 67 Connector server = new Connector(); 68 server.setInvokerLocator(serverlocatorURI); 69 server.start(); 70 server.addInvocationHandler("TEST", new ServerInvocationHandlerImpl()); 71 72 new Client(new InvokerLocator(serverlocatorURI), "TEST"); 73 74 ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers(); 75 assertEquals(1, clientInvokers.length); 76 77 LocalClientInvoker clientInvoker = (LocalClientInvoker)clientInvokers[0]; 78 InvokerLocator locator = clientInvoker.getLocator(); 79 80 assertEquals("socket", locator.getProtocol()); 81 assertEquals("127.0.0.1", locator.getHost()); 82 assertEquals(5555, locator.getPort()); 83 84 } 85 86 88 90 92 94 private class ServerInvocationHandlerImpl implements ServerInvocationHandler 95 { 96 public void setMBeanServer(MBeanServer server) 97 { 98 } 99 100 public void setInvoker(ServerInvoker invoker) 101 { 102 } 103 104 public Object invoke(InvocationRequest invocation) throws Throwable 105 { 106 return null; 107 } 108 109 public void addListener(InvokerCallbackHandler callbackHandler) 110 { 111 } 112 113 public void removeListener(InvokerCallbackHandler callbackHandler) 114 { 115 } 116 } 117 } 118 | Popular Tags |