activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1091917 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/decaf/util/concurrent/ test/decaf/util/concurrent/
Date Wed, 13 Apr 2011 20:57:12 GMT
Author: tabish
Date: Wed Apr 13 20:57:12 2011
New Revision: 1091917

URL: http://svn.apache.org/viewvc?rev=1091917&view=rev
Log:
Adds a bunch of unit tests, fixes some bugs.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h
    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/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp?rev=1091917&r1=1091916&r2=1091917&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp Wed Apr 13 20:57:12 2011
@@ -289,6 +289,7 @@ ThreadPoolExecutor::ThreadPoolExecutor(i
         threadFactory.release();
     }
     DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_RETHROW(IllegalArgumentException)
     DECAF_CATCH_RETHROW(Exception)
     DECAF_CATCHALL_THROW(Exception)
 }
@@ -320,6 +321,7 @@ ThreadPoolExecutor::ThreadPoolExecutor(i
         handler.release();
     }
     DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_RETHROW(IllegalArgumentException)
     DECAF_CATCH_RETHROW(Exception)
     DECAF_CATCHALL_THROW(Exception)
 }
@@ -351,6 +353,7 @@ ThreadPoolExecutor::ThreadPoolExecutor(i
             threadFactory, handler);
     }
     DECAF_CATCH_RETHROW(NullPointerException)
+    DECAF_CATCH_RETHROW(IllegalArgumentException)
     DECAF_CATCH_RETHROW(Exception)
     DECAF_CATCHALL_THROW(Exception)
 }
@@ -378,8 +381,10 @@ void ThreadPoolExecutor::execute(Runnabl
 
         this->kernel->enQueueTask(task);
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( RejectedExecutionException )
+    DECAF_CATCH_RETHROW( NullPointerException )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -388,8 +393,8 @@ void ThreadPoolExecutor::shutdown() {
     try{
         this->kernel->shutdown();
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -401,8 +406,8 @@ ArrayList<Runnable*> ThreadPoolExecutor:
         this->kernel->shutdownNow(result);
         return result;
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -411,8 +416,8 @@ bool ThreadPoolExecutor::awaitTerminatio
     try{
         return this->kernel->awaitTermination(timeout, unit);
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -736,10 +741,13 @@ void ExecutorKernel::onTaskStarted(Worke
             if( freeThreads.get() == 0 && !workQueue->isEmpty() ) {
                 addWorker();
             }
+
+            // TODO - Get actual values for these.
+            this->parent->beforeExecute(thread, NULL);
         }
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -749,10 +757,13 @@ void ExecutorKernel::onTaskCompleted(Wor
         synchronized(&mainLock) {
             freeThreads.incrementAndGet();
             completedTasks++;
+
+            // TODO - Get actual values for these.
+            this->parent->afterExecute(NULL, NULL);
         }
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -799,6 +810,7 @@ void ExecutorKernel::enQueueTask(Runnabl
             }
         }
     }
+    DECAF_CATCH_RETHROW( RejectedExecutionException )
     DECAF_CATCH_RETHROW( Exception )
     DECAF_CATCHALL_THROW( Exception )
 }
@@ -833,8 +845,8 @@ Runnable* ExecutorKernel::deQueueTask() 
 
         return task;
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -842,6 +854,10 @@ bool ExecutorKernel::addWorker() {
 
     try{
 
+        if( this->isStoppedOrStopping() ) {
+            return false;
+        }
+
         if( this->workers.size() >= this->maxPoolSize ) {
             return false;
         }
@@ -856,8 +872,8 @@ bool ExecutorKernel::addWorker() {
 
         return true;
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -865,6 +881,10 @@ int ExecutorKernel::addAllWorkers() {
 
     try{
 
+        if( this->isStoppedOrStopping() ) {
+            return 0;
+        }
+
         if( this->workers.size() >= this->maxPoolSize ) {
             return 0;
         }
@@ -886,8 +906,8 @@ int ExecutorKernel::addAllWorkers() {
 
         return delta;
     }
-    DECAF_CATCH_RETHROW( lang::Exception )
-    DECAF_CATCHALL_THROW( lang::Exception )
+    DECAF_CATCH_RETHROW( Exception )
+    DECAF_CATCHALL_THROW( Exception )
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h?rev=1091917&r1=1091916&r2=1091917&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.h Wed Apr 13 20:57:12 2011
@@ -542,72 +542,73 @@ namespace concurrent{
 
                 try{
                     task->run();
+                    delete task;
                 } catch(decaf::lang::Exception& ex) {
                     delete task;
                     throw ex;
                 }
             }
+        };
 
-            /**
-             * Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute
-             * this class always destroys the rejected task and returns quietly.
-             *
-             * @since 1.0
-             */
-            class DiscardPolicy : public RejectedExecutionHandler {
-            public:
+        /**
+         * Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute
+         * this class always destroys the rejected task and returns quietly.
+         *
+         * @since 1.0
+         */
+        class DiscardPolicy : public RejectedExecutionHandler {
+        public:
 
-                DiscardPolicy() : RejectedExecutionHandler() {
-                }
+            DiscardPolicy() : RejectedExecutionHandler() {
+            }
 
-                virtual ~DiscardPolicy() {
-                }
+            virtual ~DiscardPolicy() {
+            }
 
-                virtual void rejectedExecution(decaf::lang::Runnable* task, ThreadPoolExecutor* executer DECAF_UNUSED) {
-                    delete task;
-                }
+            virtual void rejectedExecution(decaf::lang::Runnable* task, ThreadPoolExecutor* executer DECAF_UNUSED) {
+                delete task;
+            }
 
-            };
+        };
 
-            /**
-             * Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute
-             * this class always destroys the oldest unexecuted task in the Queue and then attempts
-             * to execute the rejected task using the passed in executor..
-             *
-             * @since 1.0
-             */
-            class DiscardOldestPolicy : public RejectedExecutionHandler {
-            public:
+        /**
+         * Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute
+         * this class always destroys the oldest unexecuted task in the Queue and then attempts
+         * to execute the rejected task using the passed in executor..
+         *
+         * @since 1.0
+         */
+        class DiscardOldestPolicy : public RejectedExecutionHandler {
+        public:
 
-                DiscardOldestPolicy() : RejectedExecutionHandler() {
-                }
+            DiscardOldestPolicy() : RejectedExecutionHandler() {
+            }
 
-                virtual ~DiscardOldestPolicy() {
-                }
+            virtual ~DiscardOldestPolicy() {
+            }
 
-                virtual void rejectedExecution( decaf::lang::Runnable* task, ThreadPoolExecutor* executer ) {
+            virtual void rejectedExecution( decaf::lang::Runnable* task, ThreadPoolExecutor* executer ) {
 
-                    if (executer->isShutdown()) {
-                        delete task;
-                        return;
-                    }
-
-                    try{
-
-                        decaf::lang::Runnable* oldest = NULL;
-                        executer->getQueue()->poll(oldest);
-                        delete oldest;
-
-                        executer->execute(task);
-                    } catch(decaf::lang::Exception& ex) {
-                        delete task;
-                        throw ex;
-                    }
+                if (executer->isShutdown()) {
+                    delete task;
+                    return;
                 }
 
-            };
+                try{
+
+                    decaf::lang::Runnable* oldest = NULL;
+                    executer->getQueue()->poll(oldest);
+                    delete oldest;
+
+                    executer->execute(task);
+                } catch(decaf::lang::Exception& ex) {
+                    delete task;
+                    throw ex;
+                }
+            }
 
         };
+
     };
 
 }}}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp?rev=1091917&r1=1091916&r2=1091917&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.cpp Wed Apr 13 20:57:12 2011
@@ -81,7 +81,7 @@ void ExecutorsTestSupport::joinPool(Exec
 
     try {
         exec.shutdown();
-        CPPUNIT_ASSERT(exec.awaitTermination(LONG_DELAY_MS, TimeUnit::MILLISECONDS));
+        CPPUNIT_ASSERT(exec.awaitTermination(LONG_DELAY_MS * 2, TimeUnit::MILLISECONDS));
     } catch(InterruptedException& ie) {
         CPPUNIT_FAIL("Unexpected exception");
     }
@@ -97,3 +97,16 @@ void ExecutorsTestSupport::joinPool(Exec
         CPPUNIT_FAIL("Unexpected exception");
     }
 }
+
+///////////////////////////////////////////////////////////////////////////////
+void ExecutorsTestSupport::destroyRemaining(ArrayList<Runnable*> leftovers) {
+
+    try {
+        Pointer< Iterator<Runnable*> > iter( leftovers.iterator() );
+        while(iter->hasNext()) {
+            delete iter->next();
+        }
+    } catch(Exception& e) {
+        CPPUNIT_FAIL("Unexpected exception");
+    }
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h?rev=1091917&r1=1091916&r2=1091917&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h Wed Apr 13 20:57:12 2011
@@ -68,6 +68,8 @@ namespace concurrent {
         void joinPool(ExecutorService* exec);
         void joinPool(ExecutorService& exec);
 
+        void destroyRemaining(ArrayList<decaf::lang::Runnable*> leftovers);
+
     public:
 
         class NoOpRunnable : public decaf::lang::Runnable {
@@ -145,6 +147,27 @@ namespace concurrent {
             }
         };
 
+        class LongRunnable : public decaf::lang::Runnable {
+        private:
+
+            ExecutorsTestSupport* parent;
+
+        public:
+
+            LongRunnable(ExecutorsTestSupport* parent) : decaf::lang::Runnable() {
+            }
+
+            virtual ~LongRunnable() {}
+
+            virtual void run() {
+                try {
+                    Thread::sleep(LONG_DELAY_MS);
+                } catch(decaf::lang::Exception& e) {
+                    parent->threadUnexpectedException(e);
+                }
+            }
+        };
+
         class SimpleThreadFactory : public ThreadFactory {
         public:
 
@@ -170,6 +193,44 @@ namespace concurrent {
             }
         };
 
+        class TrackedNoOpRunnable : public Runnable {
+        private:
+
+            bool* done;
+
+        public:
+
+            TrackedNoOpRunnable(bool* done) : decaf::lang::Runnable(), done(done) {
+            }
+
+            virtual ~TrackedNoOpRunnable() {}
+
+            virtual void run() {
+                *done = true;
+            }
+        };
+
+        class TrackedLongRunnable : public decaf::lang::Runnable {
+        private:
+
+            bool* done;
+
+        public:
+
+            TrackedLongRunnable(bool* done) : decaf::lang::Runnable(), done(done) {
+            }
+
+            virtual ~TrackedLongRunnable() {}
+
+            virtual void run() {
+                try {
+                    Thread::sleep(LONG_DELAY_MS);
+                    *done = true;
+                } catch(decaf::lang::Exception& e) {
+                }
+            }
+        };
+
     };
 
 }}}

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=1091917&r1=1091916&r2=1091917&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 Apr 13 20:57:12 2011
@@ -121,10 +121,40 @@ namespace {
         }
     };
 
+    class MyThreadPoolExecutor : public ThreadPoolExecutor {
+    public:
+
+        volatile bool beforeCalled;
+        volatile bool afterCalled;
+        volatile bool terminatedCalled;
+
+    public:
+
+        MyThreadPoolExecutor() : ThreadPoolExecutor(1, 1, ThreadPoolExecutorTest::LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>()),
+                                 beforeCalled(false), afterCalled(false), terminatedCalled(false) {
+        }
+
+        virtual ~MyThreadPoolExecutor() {}
+
+    protected:
+
+        void beforeExecute(Thread* t, Runnable* r) {
+            beforeCalled = true;
+        }
+
+        void afterExecute(Runnable* r, Throwable* t) {
+            afterCalled = true;
+        }
+
+        void terminated() {
+            terminatedCalled = true;
+        }
+    };
+
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-void ThreadPoolExecutorTest::testConstructor1() {
+void ThreadPoolExecutorTest::testConstructor() {
 
     ThreadPoolExecutor pool(1, 3, 5, TimeUnit::SECONDS, new LinkedBlockingQueue<Runnable*>());
 
@@ -521,3 +551,722 @@ void ThreadPoolExecutorTest::testIsTermi
         unexpectedException();
     }
 }
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testGetQueue() {
+
+    BlockingQueue<Runnable*>* q = new LinkedBlockingQueue<Runnable*>();
+    ThreadPoolExecutor p1(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, q);
+    Runnable* tasks[5];
+    for (int i = 0; i < 5; i++){
+        tasks[i] = new MediumRunnable(this);
+        p1.execute(tasks[i]);
+    }
+    try {
+        Thread::sleep(SHORT_DELAY_MS);
+        BlockingQueue<Runnable*>* wq = p1.getQueue();
+        CPPUNIT_ASSERT_EQUAL(q, wq);
+        CPPUNIT_ASSERT(!wq->contains(tasks[0]));
+        CPPUNIT_ASSERT(wq->contains(tasks[4]));
+        p1.shutdown();
+    } catch(Exception& e) {
+        unexpectedException();
+    }
+
+    joinPool(p1);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testRemove() {
+
+    BlockingQueue<Runnable*>* q = new LinkedBlockingQueue<Runnable*>();
+    ThreadPoolExecutor p1(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, q);
+    Runnable* tasks[5];
+    for (int i = 0; i < 5; i++){
+        tasks[i] = new MediumRunnable(this);
+        p1.execute(tasks[i]);
+    }
+
+    try {
+
+        Thread::sleep(SHORT_DELAY_MS);
+        CPPUNIT_ASSERT(!p1.remove(tasks[0]));
+        CPPUNIT_ASSERT(q->contains(tasks[4]));
+        CPPUNIT_ASSERT(q->contains(tasks[3]));
+        CPPUNIT_ASSERT(p1.remove(tasks[4]));
+        CPPUNIT_ASSERT(!p1.remove(tasks[4]));
+        CPPUNIT_ASSERT(!q->contains(tasks[4]));
+        CPPUNIT_ASSERT(q->contains(tasks[3]));
+        CPPUNIT_ASSERT(p1.remove(tasks[3]));
+        CPPUNIT_ASSERT(!q->contains(tasks[3]));
+
+        delete tasks[3];
+        delete tasks[4];
+
+    } catch(Exception& e) {
+        unexpectedException();
+    }
+
+    joinPool(p1);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testShutDownNow() {
+
+    ThreadPoolExecutor p1(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>());
+    ArrayList<Runnable*> list;
+
+    try {
+
+        for (int i = 0; i < 5; i++) {
+            p1.execute(new MediumRunnable(this));
+        }
+    }
+    catch(...) {
+    }
+
+    Thread::sleep(SHORT_DELAY_MS);
+    list = p1.shutdownNow();
+
+    CPPUNIT_ASSERT(p1.isShutdown());
+    CPPUNIT_ASSERT(list.size() <= 4);
+
+    Pointer< Iterator<Runnable*> > iter(list.iterator());
+    while(iter->hasNext()) {
+        delete iter->next();
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor1() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(-1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor2() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, -1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor3() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 0, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor4() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 2, -1LL, TimeUnit::MILLISECONDS, queue.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor5() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(2, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor6() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(-1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor7() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, -1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor8() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 0, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor9() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 2, -1LL, TimeUnit::MILLISECONDS, queue.get(), factory.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor10() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(2, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor11() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(-1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor12() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, -1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor13() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 0, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor14() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 2, -1LL, TimeUnit::MILLISECONDS, queue.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor15() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(2, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor16() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(-1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor17() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, -1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor18() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 0, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor19() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(1, 2, -1LL, TimeUnit::MILLISECONDS, queue.get(), factory.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructor20() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        new ThreadPoolExecutor(2, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get(), handler.get()),
+        IllegalArgumentException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException1() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, NULL),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException2() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, NULL, factory.get()),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException3() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), (ThreadFactory*)NULL),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException4() {
+
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, NULL, handler.get()),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException5() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), (RejectedExecutionHandler*)NULL),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException6() {
+
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, NULL, factory.get(), handler.get()),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException7() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<ThreadFactory> factory(new SimpleThreadFactory());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), factory.get(), (RejectedExecutionHandler*)NULL),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testConstructorNullPointerException8() {
+
+    Pointer< BlockingQueue<Runnable*> > queue(new LinkedBlockingQueue<Runnable*>());
+    Pointer<RejectedExecutionHandler> handler(new NoOpREHandler());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        new ThreadPoolExecutor(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, queue.get(), (ThreadFactory*)NULL, handler.get()),
+        NullPointerException );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testSaturatedExecute1() {
+
+    ThreadPoolExecutor p(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1));
+    try {
+
+        for(int i = 0; i < 5; ++i) {
+            p.execute(new MediumRunnable(this));
+        }
+
+        shouldThrow();
+    } catch(RejectedExecutionException& success) {
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testSaturatedExecute2() {
+
+    RejectedExecutionHandler* h = new ThreadPoolExecutor::CallerRunsPolicy();
+    ThreadPoolExecutor p(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1), h);
+    try {
+
+        bool trackTokens[5] = {};
+        TrackedNoOpRunnable* tasks[5];
+
+        for(int i = 0; i < 5; ++i){
+            tasks[i] = new TrackedNoOpRunnable(&trackTokens[i]);
+        }
+
+        bool longTrackedToken = false;
+        TrackedLongRunnable* mr = new TrackedLongRunnable(&longTrackedToken);
+        p.execute(mr);
+
+        for(int i = 0; i < 5; ++i) {
+            p.execute(tasks[i]);
+        }
+
+        for(int i = 1; i < 5; ++i) {
+            CPPUNIT_ASSERT(trackTokens[i]);
+        }
+
+        destroyRemaining(p.shutdownNow());
+
+    } catch(RejectedExecutionException& ex){
+        unexpectedException();
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testSaturatedExecute3() {
+
+    RejectedExecutionHandler* h = new ThreadPoolExecutor::DiscardPolicy;
+    ThreadPoolExecutor p(1,1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1), h);
+    try {
+
+        bool trackTokens[5] = {};
+        TrackedNoOpRunnable* tasks[5];
+        for(int i = 0; i < 5; ++i){
+            tasks[i] = new TrackedNoOpRunnable(&trackTokens[i]);
+        }
+
+        bool longTrackedToken = false;
+        p.execute(new TrackedLongRunnable(&longTrackedToken));
+
+        for(int i = 0; i < 5; ++i) {
+            p.execute(tasks[i]);
+        }
+
+        for(int i = 0; i < 5; ++i) {
+            CPPUNIT_ASSERT(!trackTokens[i]);
+        }
+
+        destroyRemaining(p.shutdownNow());
+
+    } catch(RejectedExecutionException& ex){
+        unexpectedException();
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testSaturatedExecute4() {
+
+    RejectedExecutionHandler* h = new ThreadPoolExecutor::DiscardOldestPolicy();
+    ThreadPoolExecutor p(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1), h);
+
+    try {
+
+        bool longTrackedToken1 = false;
+        bool longTrackedToken2 = false;
+        bool longTrackedToken3 = false;
+
+        p.execute(new TrackedLongRunnable(&longTrackedToken1));
+        Thread::sleep(SHORT_DELAY_MS);
+
+        TrackedLongRunnable* r2 = new TrackedLongRunnable(&longTrackedToken2);
+        p.execute(r2);
+
+        CPPUNIT_ASSERT(p.getQueue()->contains(r2));
+        TrackedNoOpRunnable* r3 = new TrackedNoOpRunnable(&longTrackedToken3);
+        p.execute(r3);
+
+        CPPUNIT_ASSERT(!p.getQueue()->contains(r2));
+        CPPUNIT_ASSERT(p.getQueue()->contains(r3));
+
+        destroyRemaining(p.shutdownNow());
+
+    } catch(RejectedExecutionException& ex){
+        unexpectedException();
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testRejectedExecutionExceptionOnShutdown() {
+
+    ThreadPoolExecutor tpe(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1));
+    tpe.shutdown();
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a RejectedExecutionException",
+        tpe.execute(new NoOpRunnable()),
+        RejectedExecutionException );
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testCallerRunsOnShutdown() {
+
+    RejectedExecutionHandler* h = new ThreadPoolExecutor::CallerRunsPolicy();
+    ThreadPoolExecutor p(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1), h);
+
+    p.shutdown();
+
+    try {
+        bool tracker = false;
+        TrackedNoOpRunnable* r = new TrackedNoOpRunnable(&tracker);
+        p.execute(r);
+        CPPUNIT_ASSERT(!tracker);
+    } catch(RejectedExecutionException& success) {
+        unexpectedException();
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testDiscardOnShutdown() {
+
+    RejectedExecutionHandler* h = new ThreadPoolExecutor::DiscardPolicy();
+    ThreadPoolExecutor p(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1), h);
+
+    p.shutdown();
+
+    try {
+        bool tracker = false;
+        TrackedNoOpRunnable* r = new TrackedNoOpRunnable(&tracker);
+        p.execute(r);
+        CPPUNIT_ASSERT(!tracker);
+    } catch(RejectedExecutionException& success) {
+        unexpectedException();
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testDiscardOldestOnShutdown() {
+
+    RejectedExecutionHandler* h = new ThreadPoolExecutor::DiscardOldestPolicy();
+    ThreadPoolExecutor p(1, 1, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>(1), h);
+
+    p.shutdown();
+
+    try {
+        bool tracker = false;
+        TrackedNoOpRunnable* r = new TrackedNoOpRunnable(&tracker);
+        p.execute(r);
+        CPPUNIT_ASSERT(!tracker);
+    } catch(RejectedExecutionException& success) {
+        unexpectedException();
+    }
+
+    joinPool(p);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testExecuteNull() {
+
+    ThreadPoolExecutor tpe(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a NullPointerException",
+        tpe.execute(NULL),
+        NullPointerException );
+
+    tpe.shutdown();
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testCorePoolSizeIllegalArgumentException() {
+
+    ThreadPoolExecutor tpe(1, 2, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        tpe.setCorePoolSize(-1),
+        IllegalArgumentException );
+
+    tpe.shutdown();
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testMaximumPoolSizeIllegalArgumentException1() {
+
+    ThreadPoolExecutor tpe(2, 3, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        tpe.setMaximumPoolSize(1),
+        IllegalArgumentException );
+
+    tpe.shutdown();
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testMaximumPoolSizeIllegalArgumentException2() {
+
+    ThreadPoolExecutor tpe(2, 3, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        tpe.setMaximumPoolSize(-1),
+        IllegalArgumentException );
+
+    tpe.shutdown();
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testKeepAliveTimeIllegalArgumentException() {
+
+    ThreadPoolExecutor tpe(2, 3, LONG_DELAY_MS, TimeUnit::MILLISECONDS, new LinkedBlockingQueue<Runnable*>());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should have thrown a IllegalArgumentException",
+        tpe.setKeepAliveTime(-1,TimeUnit::MILLISECONDS),
+        IllegalArgumentException );
+
+    tpe.shutdown();
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testTerminated() {
+
+    MyThreadPoolExecutor tpe;
+
+    tpe.shutdown();
+    CPPUNIT_ASSERT(tpe.terminatedCalled);
+
+    joinPool(tpe);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+void ThreadPoolExecutorTest::testBeforeAfter() {
+
+    MyThreadPoolExecutor tpe;
+
+    try {
+
+        bool tracker = false;
+        TrackedNoOpRunnable* r = new TrackedNoOpRunnable(&tracker);
+        tpe.execute(r);
+        Thread::sleep(SHORT_DELAY_MS);
+        CPPUNIT_ASSERT(tracker);
+        CPPUNIT_ASSERT(tpe.beforeCalled);
+        CPPUNIT_ASSERT(tpe.afterCalled);
+        tpe.shutdown();
+
+    } catch(Exception& ex) {
+        unexpectedException();
+    }
+
+    joinPool(tpe);
+}

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=1091917&r1=1091916&r2=1091917&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 Apr 13 20:57:12 2011
@@ -34,7 +34,7 @@ namespace concurrent{
     private:
 
         CPPUNIT_TEST_SUITE( ThreadPoolExecutorTest );
-        CPPUNIT_TEST( testConstructor1 );
+        CPPUNIT_TEST( testConstructor );
         CPPUNIT_TEST( testSimpleTasks );
         CPPUNIT_TEST( testMoreTasksThanMaxPoolSize );
         CPPUNIT_TEST( testTasksThatThrow );
@@ -57,6 +57,52 @@ namespace concurrent{
         CPPUNIT_TEST( testIsShutdown );
         CPPUNIT_TEST( testIsTerminated );
         CPPUNIT_TEST( testIsTerminating );
+        CPPUNIT_TEST( testGetQueue );
+        CPPUNIT_TEST( testRemove );
+        CPPUNIT_TEST( testShutDownNow );
+        CPPUNIT_TEST( testConstructor1 );
+        CPPUNIT_TEST( testConstructor2 );
+        CPPUNIT_TEST( testConstructor3 );
+        CPPUNIT_TEST( testConstructor4 );
+        CPPUNIT_TEST( testConstructor5 );
+        CPPUNIT_TEST( testConstructor6 );
+        CPPUNIT_TEST( testConstructor7 );
+        CPPUNIT_TEST( testConstructor8 );
+        CPPUNIT_TEST( testConstructor9 );
+        CPPUNIT_TEST( testConstructor10 );
+        CPPUNIT_TEST( testConstructor11 );
+        CPPUNIT_TEST( testConstructor12 );
+        CPPUNIT_TEST( testConstructor13 );
+        CPPUNIT_TEST( testConstructor14 );
+        CPPUNIT_TEST( testConstructor15 );
+        CPPUNIT_TEST( testConstructor16 );
+        CPPUNIT_TEST( testConstructor17 );
+        CPPUNIT_TEST( testConstructor18 );
+        CPPUNIT_TEST( testConstructor19 );
+        CPPUNIT_TEST( testConstructor20 );
+        CPPUNIT_TEST( testConstructorNullPointerException1 );
+        CPPUNIT_TEST( testConstructorNullPointerException2 );
+        CPPUNIT_TEST( testConstructorNullPointerException3 );
+        CPPUNIT_TEST( testConstructorNullPointerException4 );
+        CPPUNIT_TEST( testConstructorNullPointerException5 );
+        CPPUNIT_TEST( testConstructorNullPointerException6 );
+        CPPUNIT_TEST( testConstructorNullPointerException7 );
+        CPPUNIT_TEST( testConstructorNullPointerException8 );
+        CPPUNIT_TEST( testSaturatedExecute1 );
+        CPPUNIT_TEST( testSaturatedExecute2 );
+        CPPUNIT_TEST( testSaturatedExecute3 );
+        CPPUNIT_TEST( testSaturatedExecute4 );
+        CPPUNIT_TEST( testRejectedExecutionExceptionOnShutdown );
+        CPPUNIT_TEST( testCallerRunsOnShutdown );
+        CPPUNIT_TEST( testDiscardOnShutdown );
+        CPPUNIT_TEST( testDiscardOldestOnShutdown );
+        CPPUNIT_TEST( testExecuteNull );
+        CPPUNIT_TEST( testCorePoolSizeIllegalArgumentException );
+        CPPUNIT_TEST( testMaximumPoolSizeIllegalArgumentException1 );
+        CPPUNIT_TEST( testMaximumPoolSizeIllegalArgumentException2 );
+        CPPUNIT_TEST( testKeepAliveTimeIllegalArgumentException );
+        CPPUNIT_TEST( testTerminated );
+        CPPUNIT_TEST( testBeforeAfter );
         CPPUNIT_TEST_SUITE_END();
 
     private:
@@ -68,7 +114,7 @@ namespace concurrent{
         ThreadPoolExecutorTest() {}
         virtual ~ThreadPoolExecutorTest() {}
 
-        void testConstructor1();
+        void testConstructor();
         void testSimpleTasks();
         void testMoreTasksThanMaxPoolSize();
         void testTasksThatThrow();
@@ -91,6 +137,52 @@ namespace concurrent{
         void testIsShutdown();
         void testIsTerminated();
         void testIsTerminating();
+        void testGetQueue();
+        void testRemove();
+        void testShutDownNow();
+        void testConstructor1();
+        void testConstructor2();
+        void testConstructor3();
+        void testConstructor4();
+        void testConstructor5();
+        void testConstructor6();
+        void testConstructor7();
+        void testConstructor8();
+        void testConstructor9();
+        void testConstructor10();
+        void testConstructor11();
+        void testConstructor12();
+        void testConstructor13();
+        void testConstructor14();
+        void testConstructor15();
+        void testConstructor16();
+        void testConstructor17();
+        void testConstructor18();
+        void testConstructor19();
+        void testConstructor20();
+        void testConstructorNullPointerException1();
+        void testConstructorNullPointerException2();
+        void testConstructorNullPointerException3();
+        void testConstructorNullPointerException4();
+        void testConstructorNullPointerException5();
+        void testConstructorNullPointerException6();
+        void testConstructorNullPointerException7();
+        void testConstructorNullPointerException8();
+        void testSaturatedExecute1();
+        void testSaturatedExecute2();
+        void testSaturatedExecute3();
+        void testSaturatedExecute4();
+        void testRejectedExecutionExceptionOnShutdown();
+        void testCallerRunsOnShutdown();
+        void testDiscardOnShutdown();
+        void testDiscardOldestOnShutdown();
+        void testExecuteNull();
+        void testCorePoolSizeIllegalArgumentException();
+        void testMaximumPoolSizeIllegalArgumentException1();
+        void testMaximumPoolSizeIllegalArgumentException2();
+        void testKeepAliveTimeIllegalArgumentException();
+        void testTerminated();
+        void testBeforeAfter();
 
     };
 



Mime
View raw message