[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/lease/synchronization ...
Ron Sigal
ron_sigal at yahoo.com
Wed Aug 8 22:56:55 EDT 2007
User: rsigal
Date: 07/08/08 22:56:55
Modified: src/tests/org/jboss/test/remoting/lease/synchronization
Tag: remoting_2_2_0_GA
MultipleClientSynchronizationTestCase.java
Log:
JBREM-783: Uses a counter to determine if clients are disconnected.
Revision Changes Path
No revision
No revision
1.1.4.4 +56 -8 JBossRemoting/src/tests/org/jboss/test/remoting/lease/synchronization/Attic/MultipleClientSynchronizationTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MultipleClientSynchronizationTestCase.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/lease/synchronization/Attic/MultipleClientSynchronizationTestCase.java,v
retrieving revision 1.1.4.3
retrieving revision 1.1.4.4
diff -u -b -r1.1.4.3 -r1.1.4.4
--- MultipleClientSynchronizationTestCase.java 8 Aug 2007 05:49:07 -0000 1.1.4.3
+++ MultipleClientSynchronizationTestCase.java 9 Aug 2007 02:56:55 -0000 1.1.4.4
@@ -22,6 +22,7 @@
package org.jboss.test.remoting.lease.synchronization;
import java.net.InetAddress;
+import java.util.Date;
import java.util.HashMap;
import javax.management.MBeanServer;
@@ -47,7 +48,7 @@
/**
*
* @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1.4.3 $
+ * @version $Revision: 1.1.4.4 $
* <p>
* Copyright Jul 31, 2007
* </p>
@@ -61,6 +62,8 @@
protected static BooleanHolder stop1 = new BooleanHolder();
protected static BooleanHolder stop2 = new BooleanHolder();
protected static InvokerLocator locator;
+ protected static int counter;
+ protected static Object lock = new Object();
public void setUp() throws Exception
{
@@ -74,6 +77,8 @@
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
Logger.getRootLogger().addAppender(consoleAppender);
}
+
+ counter = 0;
}
@@ -118,12 +123,30 @@
// Stop clients 500..999.
stop2.value = true;
- Thread.sleep(15000);
+
+ // Wait for clients to disconnect.
+ for (int i = 0; i < 30; i++)
+ {
+ synchronized (lock)
+ {
+ log.info("counter: " + counter);
+ if (counter == INVOCATIONS)
+ break;
+ }
+
+ try
+ {
+ Thread.sleep(1000);
+ }
+ catch (Exception e)
+ {
+ }
+ }
// Verify that all clients started and stopped successfully.
for (int i = 0; i < INVOCATIONS; i++)
{
- assertTrue("failure in thread: " + i, threads[i].ok);
+ assertTrue(new Date() + ": failure in thread: " + i, threads[i].ok);
}
connector.stop();
@@ -173,12 +196,30 @@
// Stop clients 500..999.
stop2.value = true;
- Thread.sleep(15000);
+
+ // Wait for clients to disconnect.
+ for (int i = 0; i < 30; i++)
+ {
+ synchronized (lock)
+ {
+ log.info("counter: " + counter);
+ if (counter == INVOCATIONS)
+ break;
+ }
+
+ try
+ {
+ Thread.sleep(1000);
+ }
+ catch (Exception e)
+ {
+ }
+ }
// Verify that all clients started and stopped successfully.
for (int i = 0; i < INVOCATIONS; i++)
{
- assertTrue("failure in thread: " + i, threads[i].ok);
+ assertTrue(new Date() + ": failure in thread: " + threads[i], threads[i].ok);
}
connector.stop();
@@ -205,7 +246,8 @@
config.put(Client.ENABLE_LEASE, "true");
config.put(InvokerLocator.CLIENT_LEASE_PERIOD, "1000");
client = new Client(locator, config);
- log.debug("client created (" + id + "): " + client.getSessionId());
+ setName("ClientThread-" + id);
+ log.info("client created (" + id + "): " + client.getSessionId());
}
public void run()
@@ -236,8 +278,14 @@
log.debug("client got stop flag (" + id + "): " + client.getSessionId());
client.disconnect();
- log.info("client disconnected (" + id + "): " + client.getSessionId());
+// log.info("client disconnected (" + id + "): " + client.getSessionId());
ok = true;
+ log.info("client ok (" + id + "):" + client.getSessionId());
+
+ synchronized (lock)
+ {
+ counter++;
+ }
}
catch (Throwable e)
{
More information about the jboss-cvs-commits
mailing list