Author: tabish
Date: Sun Feb 26 00:02:38 2012
New Revision: 1293729
URL: http://svn.apache.org/viewvc?rev=1293729&view=rev
Log:
Add some more unit tests.
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=1293729&r1=1293728&r2=1293729&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
Sun Feb 26 00:02:38 2012
@@ -197,6 +197,38 @@ void ThreadPoolExecutorTest::testSimpleT
}
///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testSimpleTasksCallerOwns()
+{
+ CountDownLatch myLatch( 3 );
+
+ int taskValue1 = 1;
+ int taskValue2 = 2;
+ int taskValue3 = 3;
+
+ MyTask task1(&myLatch, &taskValue1);
+ MyTask task2(&myLatch, &taskValue2);
+ MyTask task3(&myLatch, &taskValue3);
+
+ ThreadPoolExecutor pool(1, 3, 5, TimeUnit::SECONDS, new
LinkedBlockingQueue<Runnable*>());
+
+ pool.execute(&task1, false);
+ pool.execute(&task2, false);
+ pool.execute(&task3, false);
+
+ // Wait for them to finish, if we can't do this in 30 seconds then
+ // there's probably something really wrong.
+ CPPUNIT_ASSERT( myLatch.await( 30000 ) );
+
+ CPPUNIT_ASSERT( taskValue1 == 101 );
+ CPPUNIT_ASSERT( taskValue2 == 102 );
+ CPPUNIT_ASSERT( taskValue3 == 103 );
+
+ CPPUNIT_ASSERT( pool.getMaximumPoolSize() == 3 );
+
+ pool.shutdown();
+}
+
+///////////////////////////////////////////////////////////////////////////////
void ThreadPoolExecutorTest::testAwaitTermination()
{
CountDownLatch myLatch( 3 );
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=1293729&r1=1293728&r2=1293729&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
Sun Feb 26 00:02:38 2012
@@ -36,6 +36,7 @@ namespace concurrent{
CPPUNIT_TEST_SUITE( ThreadPoolExecutorTest );
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testSimpleTasks );
+ CPPUNIT_TEST( testSimpleTasksCallerOwns );
CPPUNIT_TEST( testMoreTasksThanMaxPoolSize );
CPPUNIT_TEST( testTasksThatThrow );
CPPUNIT_TEST( testAwaitTermination );
@@ -116,6 +117,7 @@ namespace concurrent{
void testConstructor();
void testSimpleTasks();
+ void testSimpleTasksCallerOwns();
void testMoreTasksThanMaxPoolSize();
void testTasksThatThrow();
void testAwaitTermination();