1 7 package org.jboss.test.remoting.invoker; 8 9 import org.jboss.logging.Logger; 10 import org.jboss.remoting.Client; 11 import org.jboss.remoting.InvokerLocator; 12 import org.jboss.remoting.InvokerRegistry; 13 import org.jboss.remoting.RemoteClientInvoker; 14 import org.jboss.remoting.transport.ClientInvoker; 15 import org.jboss.remoting.transport.Connector; 16 import org.jboss.remoting.transport.local.LocalClientInvoker; 17 18 import junit.framework.TestCase; 19 20 27 public class ClientInvokerDisconnectTestCase extends TestCase 28 { 29 31 private static final Logger log = Logger.getLogger(ClientInvokerDisconnectTestCase.class); 32 33 35 37 private String serverURI = "socket://127.0.0.1:5555/"; 38 private Connector server; 39 40 42 public ClientInvokerDisconnectTestCase(String name) 43 { 44 super(name); 45 } 46 47 49 public void setUp() throws Exception 50 { 51 super.setUp(); 52 53 server = new Connector(); 54 server.setInvokerLocator(serverURI); 55 server.start(); 56 log.info("Server " + serverURI + " started"); 57 } 58 59 public void tearDown() throws Exception 60 { 61 server.stop(); 62 server = null; 63 log.info("Server " + serverURI + " stopped"); 64 65 super.tearDown(); 66 } 67 68 public void testLocalClientInvokerDisconnect() throws Throwable 69 { 70 Client client = new Client(new InvokerLocator(serverURI)); 71 72 ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers(); 73 assertEquals(1, clientInvokers.length); 74 75 LocalClientInvoker clientInvoker = (LocalClientInvoker)clientInvokers[0]; 76 assertEquals(serverURI, clientInvoker.getLocator().getLocatorURI()); 77 78 79 client.disconnect(); 80 81 82 clientInvokers = InvokerRegistry.getClientInvokers(); 83 assertEquals(0, clientInvokers.length); 84 } 85 86 public void testRemoteClientInvokerDisconnect() throws Throwable 87 { 88 String passByValueServerURI = serverURI + "?byvalue=true"; 89 Client client = new Client(new InvokerLocator(passByValueServerURI)); 90 91 ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers(); 92 assertEquals(1, clientInvokers.length); 93 94 RemoteClientInvoker clientInvoker = (RemoteClientInvoker)clientInvokers[0]; 95 assertEquals(passByValueServerURI, clientInvoker.getLocator().getLocatorURI()); 96 97 98 client.disconnect(); 99 100 101 clientInvokers = InvokerRegistry.getClientInvokers(); 102 assertEquals(0, clientInvokers.length); 103 } 104 105 106 108 110 112 114 } 115 | Popular Tags |