activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1336362 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent: ThreadPoolExecutorTest.cpp ThreadPoolExecutorTest.h
Date Wed, 09 May 2012 19:28:03 GMT
Author: tabish
Date: Wed May  9 19:28:02 2012
New Revision: 1336362

URL: http://svn.apache.org/viewvc?rev=1336362&view=rev
Log:
Add new unit test

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp?rev=1336362&r1=1336361&r2=1336362&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.cpp
Wed May  9 19:28:02 2012
@@ -17,6 +17,7 @@
 
 #include "ThreadPoolExecutorTest.h"
 
+#include <decaf/util/Random.h>
 #include <decaf/util/concurrent/ThreadPoolExecutor.h>
 #include <decaf/util/concurrent/LinkedBlockingQueue.h>
 
@@ -1302,3 +1303,58 @@ void ThreadPoolExecutorTest::testBeforeA
 
     joinPool(tpe);
 }
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    class CreateSessionRunnable : public Runnable {
+    private:
+
+        Random rand;
+
+    public:
+
+        CreateSessionRunnable() : Runnable(), rand() {
+        }
+
+        virtual ~CreateSessionRunnable() {}
+
+        virtual void run() {
+            TimeUnit::MILLISECONDS.sleep(rand.nextInt(75));
+        }
+    };
+
+    class StartStopRunnable : public Runnable {
+    private:
+
+        Random rand;
+
+    public:
+
+        StartStopRunnable() : Runnable(), rand() {
+        }
+
+        virtual ~StartStopRunnable() {}
+
+        virtual void run() {
+            TimeUnit::MILLISECONDS.sleep(rand.nextInt(100));
+        }
+    };
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConcurrentRandomDelayedThreads() {
+
+    ThreadPoolExecutor executor(50, Integer::MAX_VALUE, 60LL, TimeUnit::SECONDS, new LinkedBlockingQueue<Runnable*>());
+
+    Random rand;
+
+    for (int i = 0; i < 3000; i++) {
+        executor.execute(new CreateSessionRunnable());
+        executor.execute(new StartStopRunnable());
+    }
+
+    executor.shutdown();
+    CPPUNIT_ASSERT_MESSAGE("executor terminated", executor.awaitTermination(45, TimeUnit::SECONDS));
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.h?rev=1336362&r1=1336361&r2=1336362&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ThreadPoolExecutorTest.h
Wed May  9 19:28:02 2012
@@ -104,6 +104,7 @@ namespace concurrent{
         CPPUNIT_TEST( testKeepAliveTimeIllegalArgumentException );
         CPPUNIT_TEST( testTerminated );
         CPPUNIT_TEST( testBeforeAfter );
+        CPPUNIT_TEST( testConcurrentRandomDelayedThreads );
         CPPUNIT_TEST_SUITE_END();
 
     private:
@@ -185,6 +186,7 @@ namespace concurrent{
         void testKeepAliveTimeIllegalArgumentException();
         void testTerminated();
         void testBeforeAfter();
+        void testConcurrentRandomDelayedThreads();
 
     };
 



Mime
View raw message