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

« back to all changes in this revision

Viewing changes to .pc/0001-convert-to-official-Java-concurrent-packages.patch/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/InactiveIdleTimeoutClientTest.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 EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
 
4
import junit.framework.TestCase;
 
5
import org.apache.log4j.Logger;
 
6
import org.jboss.remoting.Client;
 
7
import org.jboss.remoting.InvokerLocator;
 
8
 
 
9
/**
 
10
 * @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
 
11
 */
 
12
public class InactiveIdleTimeoutClientTest extends TestCase
 
13
{
 
14
 
 
15
//   private static int numOfRunnerThreads = 10;
 
16
   private static int numOfRunnerThreads = 2;
 
17
   private static SynchronizedInt responseCount = new SynchronizedInt(0);
 
18
 
 
19
   private Logger logger = Logger.getRootLogger();
 
20
   
 
21
   protected String getTransport()
 
22
   {
 
23
      return "socket";
 
24
   }
 
25
 
 
26
   public static void main(String[] args) throws Throwable
 
27
   {
 
28
      InactiveIdleTimeoutClientTest rt = new InactiveIdleTimeoutClientTest();
 
29
//      rt.runMultipleClients(Integer.parseInt(args[1]));
 
30
      rt.runMultipleClients(numOfRunnerThreads);
 
31
   }
 
32
 
 
33
   public void testRunClients() throws Throwable
 
34
   {
 
35
      runMultipleClients(numOfRunnerThreads);
 
36
      Thread.currentThread().sleep(60000);
 
37
   }
 
38
 
 
39
   public void runClient(String clientId) throws Throwable
 
40
   {
 
41
      String locatorURI = getTransport() + "://localhost:54000/?clientMaxPoolSize=50&timeout=10000";
 
42
      InvokerLocator locator = new InvokerLocator(locatorURI);
 
43
      Client client = new Client(locator);
 
44
      client.connect();
 
45
      String req = clientId;
 
46
      Object resp = client.invoke(req);
 
47
      responseCount.increment();
 
48
      System.out.println("Received response of: " + resp + ".  Response count = " + responseCount);
 
49
   }
 
50
 
 
51
      public void runMultipleClients(int cnt) throws Throwable {
 
52
      for (int i = 0; i < cnt; i++) {
 
53
         Thread t = new Thread(new Runnable() {
 
54
            public void run() {
 
55
               try {
 
56
                  Thread.sleep(1000);
 
57
                  runClient(Thread.currentThread().getName());
 
58
               } catch (Throwable e) {
 
59
                  logger.error(e);
 
60
                  e.printStackTrace();
 
61
               }
 
62
            }
 
63
         }, Integer.toString(i));
 
64
         t.start();
 
65
      }
 
66
   }
 
67
}