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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transport/rmi/timeout/TimeoutServerTest.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: package-import@ubuntu.com-20110909140103-o8ucrolqt5g25k57
Tags: upstream-2.5.3.SP1
ImportĀ upstreamĀ versionĀ 2.5.3.SP1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.jboss.test.remoting.transport.rmi.timeout;
 
2
 
 
3
import javax.management.MBeanServer;
 
4
import org.jboss.jrunit.extensions.ServerTestCase;
 
5
import org.jboss.remoting.transport.Connector;
 
6
import org.jboss.remoting.InvokerLocator;
 
7
import org.jboss.remoting.ServerInvocationHandler;
 
8
import org.jboss.remoting.ServerInvoker;
 
9
import org.jboss.remoting.InvocationRequest;
 
10
import org.jboss.remoting.callback.InvokerCallbackHandler;
 
11
 
 
12
/**
 
13
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
14
 */
 
15
public class TimeoutServerTest extends ServerTestCase
 
16
{
 
17
   private String locatorURI = "rmi://localhost:8899/?timeout=3000";
 
18
   private Connector connector = null;
 
19
 
 
20
   public void setUp() throws Exception
 
21
   {
 
22
      connector = new Connector();
 
23
      InvokerLocator locator = new InvokerLocator(locatorURI);
 
24
      connector.setInvokerLocator(locator.getLocatorURI());
 
25
      connector.create();
 
26
      connector.addInvocationHandler("test", new org.jboss.test.remoting.transport.rmi.timeout.TimeoutServerTest.TimeoutHandler());
 
27
      connector.start();
 
28
   }
 
29
 
 
30
   protected void tearDown() throws Exception
 
31
   {
 
32
      if(connector != null)
 
33
      {
 
34
         connector.stop();
 
35
         connector.destroy();
 
36
      }
 
37
   }
 
38
 
 
39
   public static void main(String[] args)
 
40
   {
 
41
      org.jboss.test.remoting.transport.rmi.timeout.TimeoutServerTest server = new org.jboss.test.remoting.transport.rmi.timeout.TimeoutServerTest();
 
42
      try
 
43
      {
 
44
         server.setUp();
 
45
      }
 
46
      catch(Exception e)
 
47
      {
 
48
         e.printStackTrace();
 
49
      }
 
50
   }
 
51
 
 
52
   private class TimeoutHandler implements ServerInvocationHandler
 
53
   {
 
54
 
 
55
      /**
 
56
       * set the mbean server that the handler can reference
 
57
       *
 
58
       * @param server
 
59
       */
 
60
      public void setMBeanServer(MBeanServer server)
 
61
      {
 
62
         //TODO: -TME Implement
 
63
      }
 
64
 
 
65
      /**
 
66
       * set the invoker that owns this handler
 
67
       *
 
68
       * @param invoker
 
69
       */
 
70
      public void setInvoker(ServerInvoker invoker)
 
71
      {
 
72
         //TODO: -TME Implement
 
73
      }
 
74
 
 
75
      /**
 
76
       * called to handle a specific invocation.  Please take care to make sure
 
77
       * implementations are thread safe and can, and often will, receive concurrent
 
78
       * calls on this method.
 
79
       *
 
80
       * @param invocation
 
81
       * @return
 
82
       * @throws Throwable
 
83
       */
 
84
      public Object invoke(InvocationRequest invocation) throws Throwable
 
85
      {
 
86
         Object obj = invocation.getParameter();
 
87
         if(obj instanceof String && "timeout".equals(obj))
 
88
         {
 
89
            Thread.currentThread().sleep(30000);
 
90
         }
 
91
         return null;  //TODO: -TME Implement
 
92
      }
 
93
 
 
94
      /**
 
95
       * Adds a callback handler that will listen for callbacks from
 
96
       * the server invoker handler.
 
97
       *
 
98
       * @param callbackHandler
 
99
       */
 
100
      public void addListener(InvokerCallbackHandler callbackHandler)
 
101
      {
 
102
         //TODO: -TME Implement
 
103
      }
 
104
 
 
105
      /**
 
106
       * Removes the callback handler that was listening for callbacks
 
107
       * from the server invoker handler.
 
108
       *
 
109
       * @param callbackHandler
 
110
       */
 
111
      public void removeListener(InvokerCallbackHandler callbackHandler)
 
112
      {
 
113
         //TODO: -TME Implement
 
114
      }
 
115
   }
 
116
}