KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > registry > InvokerRegistryTestCase


1 /**
2  * JBoss, the OpenSource J2EE WebOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.remoting.registry;
8
9 import javax.management.MBeanServer JavaDoc;
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 /**
24  * @author <a HREF="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
25  *
26  * @version <tt>$Revision: 1.3 $</tt>
27  *
28  * $Id: InvokerRegistryTestCase.java,v 1.3 2005/06/20 03:38:45 telrod Exp $
29  */

30 public class InvokerRegistryTestCase extends TestCase
31 {
32    // Constants -----------------------------------------------------
33

34    // Static --------------------------------------------------------
35

36    // Attributes ----------------------------------------------------
37

38    // Constructors --------------------------------------------------
39

40    public InvokerRegistryTestCase(String JavaDoc name)
41    {
42       super(name);
43    }
44
45    // Public --------------------------------------------------------
46

47    public void setUp() throws Exception JavaDoc
48    {
49       super.setUp();
50    }
51
52    public void tearDown() throws Exception JavaDoc
53    {
54       super.tearDown();
55    }
56
57    public void testEmptyInvokerRegistry() throws Throwable JavaDoc
58    {
59       ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers();
60       assertEquals(0, clientInvokers.length);
61    }
62
63    public void testInvokerRegistry() throws Throwable JavaDoc
64    {
65       String JavaDoc 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    // Package protected ---------------------------------------------
87

88    // Protected -----------------------------------------------------
89

90    // Private -------------------------------------------------------
91

92    // Inner classes -------------------------------------------------
93

94    private class ServerInvocationHandlerImpl implements ServerInvocationHandler
95    {
96       public void setMBeanServer(MBeanServer JavaDoc server)
97       {
98       }
99
100       public void setInvoker(ServerInvoker invoker)
101       {
102       }
103
104       public Object JavaDoc invoke(InvocationRequest invocation) throws Throwable JavaDoc
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