[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/oneway ...
Ron Sigal
ron_sigal at yahoo.com
Fri Jul 6 23:17:17 EDT 2007
User: rsigal
Date: 07/07/06 23:17:17
Modified: src/tests/org/jboss/test/remoting/oneway Tag: remoting_2_x
OnewayThreadPoolTestCase.java
Log:
JBREM-706: Adjusted testThreadPoolSocketClientSide() to conform to new treatment of socket transport client side oneway invocations.
Revision Changes Path
No revision
No revision
1.1.2.3 +57 -16 JBossRemoting/src/tests/org/jboss/test/remoting/oneway/Attic/OnewayThreadPoolTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: OnewayThreadPoolTestCase.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/oneway/Attic/OnewayThreadPoolTestCase.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- OnewayThreadPoolTestCase.java 15 Feb 2007 21:06:02 -0000 1.1.2.2
+++ OnewayThreadPoolTestCase.java 7 Jul 2007 03:17:17 -0000 1.1.2.3
@@ -54,7 +54,7 @@
* See JBREM-658.
*
* @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1.2.2 $
+ * @version $Revision: 1.1.2.3 $
* <p>
* Copyright Feb 6, 2007
* </p>
@@ -201,8 +201,7 @@
/**
* This test exercises the client side thread pool using the socket transport
- * The socket client invoker returns immediately after the invocation object
- * has been marshalled.
+ * The socket client invoker waits for a response. See JBREM-706.
*/
public void testThreadPoolSocketClientSide() throws Throwable
{
@@ -229,37 +228,79 @@
long start = System.currentTimeMillis();
- // The following four invocations are quite nondeterministic. In the best
- // case, two will execute in the thread pool and two will execute simultaneously
- // in ServerThreads. In the worst case, the last three invocations will
- // find a pooled connection and connect to a ServerThread busy with the
- // previous invocation.
+ // NOTE. The following commented code precedes the fix to JBREM-706. The four
+ // slow invocations were expected to take up to 16 seconds to start.
+
+// // The following four invocations are quite nondeterministic. In the best
+// // case, two will execute in the thread pool and two will execute simultaneously
+// // in ServerThreads. In the worst case, the last three invocations will
+// // find a pooled connection and connect to a ServerThread busy with the
+// // previous invocation.
+//
+// // Will execute in first thread pool thread.
+// log.info("making 1st oneway invocation");
+// client.invokeOneway(SLOW + "1", null, true);
+// poolCounter++;
+//
+// // Will execute in first or second thread pool thread.
+// log.info("making 2nd oneway invocation");
+// client.invokeOneway(SLOW + "2", null, true);
+//
+// // Could execute in a thread pool thread or go on the queue.
+// log.info("making 3rd oneway invocation");
+// client.invokeOneway(SLOW + "3", null, true);
+// assertTrue((System.currentTimeMillis() - start < 1000));
+//
+// // Could execute in a thread pool thread, go on the queue, or execute
+// // in the main thread.
+// log.info("making 4th oneway invocation");
+// client.invokeOneway(SLOW + "4", null, true);
+// log.info("made 4th oneway invocation");
+// log.info("wait: " + (System.currentTimeMillis() - start));
+// assertTrue((System.currentTimeMillis() - start < 1000));
+//
+// // In the worst case, the four invocations could take as much as 15 seconds
+// // to all start.
+// Thread.sleep(16000);
+// assertEquals(5, handler.startedCount);
+
+
+ // The following code replaces the commented code just above. After the fix
+ // to JBREM-706, all four slow invocations should start within just over two
+ // seconds.
// Will execute in first thread pool thread.
log.info("making 1st oneway invocation");
client.invokeOneway(SLOW + "1", null, true);
poolCounter++;
- // Will execute in first or second thread pool thread.
+ // Will execute in second thread pool thread.
log.info("making 2nd oneway invocation");
client.invokeOneway(SLOW + "2", null, true);
- // Could execute in a thread pool thread or go on the queue.
+ // Will go on the queue. The attempt to read the response to the first
+ // invocation will fail after two seconds, and the first thread will be
+ // available to execute this invocation.
log.info("making 3rd oneway invocation");
client.invokeOneway(SLOW + "3", null, true);
assertTrue((System.currentTimeMillis() - start < 1000));
+ Thread.sleep(500);
+
+ // At this point, slow invocations 1 and 2 should have started.
+ assertEquals(3, handler.startedCount);
- // Could execute in a thread pool thread, go on the queue, or execute
- // in the main thread.
+ // Will execute on the main thread. The call to client.invokeOneway() will
+ // time out and return after two seconds.
log.info("making 4th oneway invocation");
client.invokeOneway(SLOW + "4", null, true);
log.info("made 4th oneway invocation");
log.info("wait: " + (System.currentTimeMillis() - start));
- assertTrue((System.currentTimeMillis() - start < 1000));
+ assertTrue((System.currentTimeMillis() - start < 3000));
+
+ // Give slow invocation 3 time to start.
+ Thread.sleep(500);
- // In the worst case, the four invocations could take as much as 15 seconds
- // to all start.
- Thread.sleep(16000);
+ // At this point, all invocations should have started.
assertEquals(5, handler.startedCount);
client.disconnect();
More information about the jboss-cvs-commits
mailing list