1
package org.jboss.test.remoting.lease.local;
3
import junit.framework.TestCase;
4
import org.jboss.remoting.Client;
5
import org.jboss.remoting.ConnectionListener;
6
import org.jboss.remoting.InvocationRequest;
7
import org.jboss.remoting.InvokerLocator;
8
import org.jboss.remoting.ServerInvocationHandler;
9
import org.jboss.remoting.ServerInvoker;
10
import org.jboss.remoting.callback.InvokerCallbackHandler;
11
import org.jboss.remoting.transport.Connector;
13
import javax.management.MBeanServer;
16
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
18
public class LocalLeaseTestCase extends TestCase implements ConnectionListener
20
private Client client = null;
21
private Connector connector = null;
23
private boolean connectionFailure = false;
25
public void setUp() throws Exception
27
String locatorUri = "socket://localhost:8888" + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true";
29
connector = new Connector();
30
connector.setInvokerLocator(locatorUri);
32
connector.addInvocationHandler("test", new TestInvocationHandler());
34
connector.addConnectionListener(this);
36
client = new Client(new InvokerLocator(locatorUri));
39
public void testConnection() throws Throwable
42
client.invoke("foobar");
48
assertFalse(connectionFailure);
50
connector.removeConnectionListener(this);
53
public void tearDown()
66
public void handleConnectionException(Throwable throwable, Client client)
68
System.out.println("got connection exception.");
69
connectionFailure = true;
72
public class TestInvocationHandler implements ServerInvocationHandler
75
public void setMBeanServer(MBeanServer server)
77
//TODO: -TME Implement
80
public void setInvoker(ServerInvoker invoker)
82
//TODO: -TME Implement
85
public Object invoke(InvocationRequest invocation) throws Throwable
87
return null; //TODO: -TME Implement
90
public void addListener(InvokerCallbackHandler callbackHandler)
92
//TODO: -TME Implement
95
public void removeListener(InvokerCallbackHandler callbackHandler)
97
//TODO: -TME Implement