1
package org.jboss.test.remoting.transport.rmi.timeout;
3
import junit.framework.TestCase;
4
import org.jboss.remoting.Client;
5
import org.jboss.remoting.InvokerLocator;
8
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
10
public class TimeoutClientTest extends TestCase
12
private String locatorURI = "rmi://localhost:8899/?timeout=3000";
14
public void testTimeout() throws Exception
16
Client client = new Client(new InvokerLocator(locatorURI));
19
//test for client timeout
24
Thread.currentThread().sleep(5000);
26
System.out.println("Done making all calls after sleeping.");
28
catch(Throwable throwable)
30
if(throwable instanceof Exception)
32
throw (Exception) throwable;
36
throw new Exception(throwable);
41
long start = System.currentTimeMillis();
47
client.invoke("timeout");
48
end = System.currentTimeMillis();
52
System.out.println("Caught exception: " + t.getMessage());
53
end = System.currentTimeMillis();
56
long executionTime = end - start;
57
System.out.println("execution time was " + executionTime);
58
boolean timedOut = (executionTime < 10000);
59
assertTrue("Socket did not timeout within expected time", timedOut);