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

« back to all changes in this revision

Viewing changes to tests/org/jboss/test/remoting/transport/rmi/timeout/TimeoutClientTest.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.rmi.timeout;
2
 
 
3
 
import junit.framework.TestCase;
4
 
import org.jboss.remoting.Client;
5
 
import org.jboss.remoting.InvokerLocator;
6
 
 
7
 
/**
8
 
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
9
 
 */
10
 
public class TimeoutClientTest extends TestCase
11
 
{
12
 
   private String locatorURI = "rmi://localhost:8899/?timeout=3000";
13
 
 
14
 
   public void testTimeout() throws Exception
15
 
   {
16
 
      Client client = new Client(new InvokerLocator(locatorURI));
17
 
      client.connect();
18
 
 
19
 
      //test for client timeout
20
 
      try
21
 
      {
22
 
         client.invoke("foo");
23
 
 
24
 
         Thread.currentThread().sleep(5000);
25
 
         client.invoke("bar");
26
 
         System.out.println("Done making all calls after sleeping.");
27
 
      }
28
 
      catch(Throwable throwable)
29
 
      {
30
 
         if(throwable instanceof Exception)
31
 
         {
32
 
            throw (Exception) throwable;
33
 
         }
34
 
         else
35
 
         {
36
 
            throw new Exception(throwable);
37
 
         }
38
 
      }
39
 
 
40
 
 
41
 
      long start = System.currentTimeMillis();
42
 
 
43
 
      long end = 0;
44
 
 
45
 
      try
46
 
      {
47
 
         client.invoke("timeout");
48
 
         end = System.currentTimeMillis();
49
 
      }
50
 
      catch(Throwable t)
51
 
      {
52
 
         System.out.println("Caught exception: " + t.getMessage());
53
 
         end = System.currentTimeMillis();
54
 
      }
55
 
 
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);
60
 
   }
61
 
 
62
 
}