[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/lease/socket/multiple ...
Ron Sigal
ron_sigal at yahoo.com
Sat Feb 24 04:14:31 EST 2007
User: rsigal
Date: 07/02/24 04:14:31
Modified: src/tests/org/jboss/test/remoting/lease/socket/multiple
Tag: remoting_2_x SocketLeaseTestClient.java
Log:
JBREM-709: Replaced 10 jgroups clients with 1 client running 10 threads.
Revision Changes Path
No revision
No revision
1.3.2.1 +104 -28 JBossRemoting/src/tests/org/jboss/test/remoting/lease/socket/multiple/SocketLeaseTestClient.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SocketLeaseTestClient.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/lease/socket/multiple/SocketLeaseTestClient.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -b -r1.3 -r1.3.2.1
--- SocketLeaseTestClient.java 20 Sep 2006 04:22:26 -0000 1.3
+++ SocketLeaseTestClient.java 24 Feb 2007 09:14:31 -0000 1.3.2.1
@@ -1,6 +1,8 @@
package org.jboss.test.remoting.lease.socket.multiple;
import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.Callback;
@@ -15,6 +17,7 @@
*/
public class SocketLeaseTestClient extends TestCase
{
+ private static Logger log = Logger.getLogger(SocketLeaseTestClient.class);
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
@@ -23,6 +26,10 @@
private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true";
private String callbackLocatorURI = transport + "://" + host + ":" + (port + 1);
+ private int COUNT = 50;
+ private boolean[] success = new boolean[COUNT];
+ private boolean[] done = new boolean[COUNT];
+
// public void setUp()
// {
// org.apache.log4j.BasicConfigurator.configure();
@@ -31,6 +38,10 @@
// org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL);
// }
+ public void setUp()
+ {
+ log.info("entering setUp()");
+ }
protected String getLocatorUri()
{
return locatorURI;
@@ -38,6 +49,69 @@
public void testMultipleLeases() throws Throwable
{
+ log.info("entering " + getName());
+
+ class CallerThread extends Thread
+ {
+ int id;
+
+ CallerThread(int id)
+ {
+ this.id = id;
+ }
+
+ public void run()
+ {
+ try
+ {
+ log.info("calling runClient(" + id + ")");
+ runClient(id);
+ log.info("runClient(" + id + ") returns");
+ done[id] = true;
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ for (int i = 0; i < COUNT; i++)
+ {
+ Thread t = new CallerThread(i);
+ t.setName("client: " + i);
+ t.start();
+ log.info("started client thread " + i);
+ }
+
+ Thread.sleep(35000);
+
+ boolean allDone = false;
+ while (!allDone)
+ {
+ allDone = true;
+ for (int i = 0; i < COUNT; i++)
+ {
+ allDone &= done[i];
+ log.info("done[" + i + "]: " + done[i]);
+ }
+ Thread.sleep(1000);
+ }
+
+ boolean allSuccess = true;
+ for (int i = 0; i < COUNT; i++)
+ {
+ allSuccess &= success[i];
+ }
+
+ log.info("success: " + allSuccess);
+ assertTrue(allSuccess);
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void runClient(int id) throws Throwable
+ {
InvokerLocator locator = new InvokerLocator(getLocatorUri());
System.out.println("Calling remoting server with locator uri of: " + getLocatorUri());
@@ -81,7 +155,7 @@
remotingClient1.disconnect();
}
- System.out.println("remoting client 1 disconnected");
+ System.out.println("remoting client 1 (thread " + id + ") disconnected");
//Thread.currentThread().sleep(10000);
Thread.currentThread().sleep(30000);
@@ -95,6 +169,8 @@
remotingClient2.disconnect();
}
+ success[id] = true;
+ log.info("thread " + id + " successful");
}
public class TestCallbackHandler implements InvokerCallbackHandler
More information about the jboss-cvs-commits
mailing list