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

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/transport/http/timeout/TimeoutServerTest.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.transport.http.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 = "http://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.http.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.http.timeout.TimeoutServerTest server = new org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest();
 
42
      try
 
43
      {
 
44
         server.setUp();
 
45
 
 
46
         Thread.currentThread().sleep(30000);
 
47
      }
 
48
      catch(Exception e)
 
49
      {
 
50
         e.printStackTrace();
 
51
      }
 
52
   }
 
53
 
 
54
   private class TimeoutHandler implements ServerInvocationHandler
 
55
   {
 
56
 
 
57
      /**
 
58
       * set the mbean server that the handler can reference
 
59
       *
 
60
       * @param server
 
61
       */
 
62
      public void setMBeanServer(MBeanServer server)
 
63
      {
 
64
         //TODO: -TME Implement
 
65
      }
 
66
 
 
67
      /**
 
68
       * set the invoker that owns this handler
 
69
       *
 
70
       * @param invoker
 
71
       */
 
72
      public void setInvoker(ServerInvoker invoker)
 
73
      {
 
74
         //TODO: -TME Implement
 
75
      }
 
76
 
 
77
      /**
 
78
       * called to handle a specific invocation.  Please take care to make sure
 
79
       * implementations are thread safe and can, and often will, receive concurrent
 
80
       * calls on this method.
 
81
       *
 
82
       * @param invocation
 
83
       * @return
 
84
       * @throws Throwable
 
85
       */
 
86
      public Object invoke(InvocationRequest invocation) throws Throwable
 
87
      {
 
88
         Object obj = invocation.getParameter();
 
89
         if(obj instanceof String && "timeout".equals(obj))
 
90
         {
 
91
            System.out.println("server got 'timeout' invocation... sleeping 30 seconds.");
 
92
            Thread.currentThread().sleep(30000);
 
93
         }
 
94
         return null;  //TODO: -TME Implement
 
95
      }
 
96
 
 
97
      /**
 
98
       * Adds a callback handler that will listen for callbacks from
 
99
       * the server invoker handler.
 
100
       *
 
101
       * @param callbackHandler
 
102
       */
 
103
      public void addListener(InvokerCallbackHandler callbackHandler)
 
104
      {
 
105
         //TODO: -TME Implement
 
106
      }
 
107
 
 
108
      /**
 
109
       * Removes the callback handler that was listening for callbacks
 
110
       * from the server invoker handler.
 
111
       *
 
112
       * @param callbackHandler
 
113
       */
 
114
      public void removeListener(InvokerCallbackHandler callbackHandler)
 
115
      {
 
116
         //TODO: -TME Implement
 
117
      }
 
118
   }
 
119
}