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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPollTestServer.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.callback.push.unidirectional;
 
2
 
 
3
import org.jboss.jrunit.extensions.ServerTestCase;
 
4
import org.jboss.remoting.InvocationRequest;
 
5
import org.jboss.remoting.ServerInvocationHandler;
 
6
import org.jboss.remoting.ServerInvoker;
 
7
import org.jboss.remoting.callback.Callback;
 
8
import org.jboss.remoting.callback.InvokerCallbackHandler;
 
9
import org.jboss.remoting.transport.Connector;
 
10
 
 
11
import javax.management.MBeanServer;
 
12
import java.util.ArrayList;
 
13
import java.util.List;
 
14
 
 
15
/**
 
16
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
17
 */
 
18
public abstract class CallbackPollTestServer extends ServerTestCase
 
19
{
 
20
   private Connector connector = null;
 
21
 
 
22
   public void setUp() throws Exception
 
23
   {
 
24
      connector = new Connector(getLocatorUri());
 
25
      connector.create();
 
26
      connector.addInvocationHandler("test", new TestInvocationHandler());
 
27
      connector.start();
 
28
   }
 
29
 
 
30
   public void tearDown() throws Exception
 
31
   {
 
32
      if (connector != null)
 
33
      {
 
34
         connector.stop();
 
35
         connector.destroy();
 
36
      }
 
37
   }
 
38
 
 
39
   private String getLocatorUri()
 
40
   {
 
41
      return getTransport() + "://" + getHost() + ":" + getPort();
 
42
   }
 
43
 
 
44
   public abstract String getTransport();
 
45
 
 
46
   public String getHost()
 
47
   {
 
48
      return "localhost";
 
49
   }
 
50
 
 
51
   public int getPort()
 
52
   {
 
53
      return 6999;
 
54
   }
 
55
 
 
56
 
 
57
   public class TestInvocationHandler implements ServerInvocationHandler
 
58
   {
 
59
 
 
60
      private List listeners = new ArrayList();
 
61
 
 
62
      public void setMBeanServer(MBeanServer server)
 
63
      {
 
64
         //TODO: -TME Implement
 
65
      }
 
66
 
 
67
      public void setInvoker(ServerInvoker invoker)
 
68
      {
 
69
         //TODO: -TME Implement
 
70
      }
 
71
 
 
72
      public Object invoke(InvocationRequest invocation) throws Throwable
 
73
      {
 
74
         for (int x = 0; x < listeners.size(); x++)
 
75
         {
 
76
            InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x);
 
77
            callbackHandler.handleCallback(new Callback("This is callback payload"));
 
78
         }
 
79
         return "barfoo";
 
80
      }
 
81
 
 
82
      public void addListener(InvokerCallbackHandler callbackHandler)
 
83
      {
 
84
         listeners.add(callbackHandler);
 
85
      }
 
86
 
 
87
      public void removeListener(InvokerCallbackHandler callbackHandler)
 
88
      {
 
89
         listeners.remove(callbackHandler);
 
90
      }
 
91
   }
 
92
 
 
93
}