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

« back to all changes in this revision

Viewing changes to tests/org/jboss/test/remoting/transport/socket/timeout/idle/InactiveIdleTimeoutTestServer.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.socket.timeout.idle;
2
 
 
3
 
import org.apache.log4j.Logger;
4
 
import org.jboss.jrunit.extensions.ServerTestCase;
5
 
import org.jboss.remoting.InvokerLocator;
6
 
import org.jboss.remoting.transport.Connector;
7
 
import org.jboss.remoting.transport.socket.SocketServerInvoker;
8
 
 
9
 
/**
10
 
 * This is just like IdleTimeoutTestServer except instead of
11
 
 * looking for server threads that are still in read mode waiting for
12
 
 * data from client, want to test for idle server threads that finished with
13
 
 * client/server connection and are just sitting in the thread pool waiting to
14
 
 * be re-used.
15
 
 *
16
 
 * @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
17
 
 */
18
 
public class InactiveIdleTimeoutTestServer extends ServerTestCase
19
 
{
20
 
   private Connector connector;
21
 
 
22
 
   private Logger logger = Logger.getRootLogger();
23
 
 
24
 
   protected String getTransport()
25
 
   {
26
 
      return "socket";
27
 
   }
28
 
   
29
 
   public static void main(String[] args) throws Throwable
30
 
   {
31
 
      InactiveIdleTimeoutTestServer rt = new InactiveIdleTimeoutTestServer();
32
 
      rt.setUp();
33
 
      Thread.currentThread().sleep(45000);
34
 
      rt.tearDown();
35
 
 
36
 
   }
37
 
 
38
 
   public void setUp() throws Exception
39
 
   {
40
 
      startServer();
41
 
   }
42
 
 
43
 
   public void tearDown() throws Exception
44
 
   {
45
 
      if(connector != null)
46
 
      {
47
 
         try
48
 
         {
49
 
            // check for empty thread pool
50
 
            SocketServerInvoker svrInvoker = (SocketServerInvoker)connector.getServerInvoker();
51
 
            int threadPoolSize = svrInvoker.getCurrentThreadPoolSize();
52
 
            if(threadPoolSize > 0)
53
 
            {
54
 
               System.out.println("Error - thread pool should be size of 0, but is " + threadPoolSize);
55
 
               throw new RuntimeException("Thread pool was not size of 0, but " + threadPoolSize);
56
 
            }
57
 
            else
58
 
            {
59
 
               System.out.println("Pass - thread pool size is 0");
60
 
            }
61
 
 
62
 
         }
63
 
         finally
64
 
         {
65
 
            connector.stop();
66
 
            connector.destroy();
67
 
         }
68
 
      }
69
 
   }
70
 
 
71
 
   public void startServer() throws Exception
72
 
   {
73
 
//      String locatorURI = "socket://localhost:54000/?maxPoolSize=2&timeout=60000&backlog=0";
74
 
      String locatorURI = getTransport() + "://localhost:54000/?maxPoolSize=2&backlog=0&timeout=10000&idleTimeout=15";
75
 
      InvokerLocator locator = new InvokerLocator(locatorURI);
76
 
 
77
 
      connector = new Connector();
78
 
 
79
 
      connector.setInvokerLocator(locator.getLocatorURI());
80
 
      connector.create();
81
 
 
82
 
      SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
83
 
      connector.addInvocationHandler("sample", invocationHandler);
84
 
      connector.start();
85
 
   }
86
 
 
87
 
}