1
package org.jboss.test.remoting.transport.socket.timeout.idle;
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;
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
16
* @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
18
public class InactiveIdleTimeoutTestServer extends ServerTestCase
20
private Connector connector;
22
private Logger logger = Logger.getRootLogger();
24
protected String getTransport()
29
public static void main(String[] args) throws Throwable
31
InactiveIdleTimeoutTestServer rt = new InactiveIdleTimeoutTestServer();
33
Thread.currentThread().sleep(45000);
38
public void setUp() throws Exception
43
public void tearDown() throws Exception
49
// check for empty thread pool
50
SocketServerInvoker svrInvoker = (SocketServerInvoker)connector.getServerInvoker();
51
int threadPoolSize = svrInvoker.getCurrentThreadPoolSize();
52
if(threadPoolSize > 0)
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);
59
System.out.println("Pass - thread pool size is 0");
71
public void startServer() throws Exception
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);
77
connector = new Connector();
79
connector.setInvokerLocator(locator.getLocatorURI());
82
SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
83
connector.addInvocationHandler("sample", invocationHandler);