~ubuntu-branches/ubuntu/wily/libjboss-remoting-java/wily

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/lease/local/LocalLeaseTestCase.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.test.remoting.lease.local;
 
2
 
 
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;
 
12
 
 
13
import javax.management.MBeanServer;
 
14
 
 
15
/**
 
16
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
17
 */
 
18
public class LocalLeaseTestCase extends TestCase implements ConnectionListener
 
19
{
 
20
   private Client client = null;
 
21
   private Connector connector = null;
 
22
 
 
23
   private boolean connectionFailure = false;
 
24
 
 
25
   public void setUp() throws Exception
 
26
   {
 
27
      String locatorUri = "socket://localhost:8888" + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true";
 
28
 
 
29
      connector = new Connector();
 
30
      connector.setInvokerLocator(locatorUri);
 
31
      connector.create();
 
32
      connector.addInvocationHandler("test", new TestInvocationHandler());
 
33
      connector.start();
 
34
      connector.addConnectionListener(this);
 
35
 
 
36
      client = new Client(new InvokerLocator(locatorUri));
 
37
   }
 
38
 
 
39
   public void testConnection() throws Throwable
 
40
   {
 
41
      client.connect();
 
42
      client.invoke("foobar");
 
43
      Thread.sleep(5000);
 
44
 
 
45
      client.disconnect();
 
46
      Thread.sleep(20000);
 
47
 
 
48
      assertFalse(connectionFailure);
 
49
 
 
50
      connector.removeConnectionListener(this);
 
51
   }
 
52
 
 
53
   public void tearDown()
 
54
   {
 
55
      if(client != null)
 
56
      {
 
57
         client.disconnect();
 
58
      }
 
59
      if(connector != null)
 
60
      {
 
61
         connector.stop();
 
62
         connector.destroy();
 
63
      }
 
64
   }
 
65
 
 
66
   public void handleConnectionException(Throwable throwable, Client client)
 
67
   {
 
68
      System.out.println("got connection exception.");
 
69
      connectionFailure = true;
 
70
   }
 
71
 
 
72
   public class TestInvocationHandler implements ServerInvocationHandler
 
73
   {
 
74
 
 
75
      public void setMBeanServer(MBeanServer server)
 
76
      {
 
77
         //TODO: -TME Implement
 
78
      }
 
79
 
 
80
      public void setInvoker(ServerInvoker invoker)
 
81
      {
 
82
         //TODO: -TME Implement
 
83
      }
 
84
 
 
85
      public Object invoke(InvocationRequest invocation) throws Throwable
 
86
      {
 
87
         return null;  //TODO: -TME Implement
 
88
      }
 
89
 
 
90
      public void addListener(InvokerCallbackHandler callbackHandler)
 
91
      {
 
92
         //TODO: -TME Implement
 
93
      }
 
94
 
 
95
      public void removeListener(InvokerCallbackHandler callbackHandler)
 
96
      {
 
97
         //TODO: -TME Implement
 
98
      }
 
99
   }
 
100
}