activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1150232 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test: decaf/util/concurrent/ExecutorsTest.cpp decaf/util/concurrent/ExecutorsTest.h testRegistry.cpp
Date Sat, 23 Jul 2011 22:26:26 GMT
Author: tabish
Date: Sat Jul 23 22:26:25 2011
New Revision: 1150232

URL: http://svn.apache.org/viewvc?rev=1150232&view=rev
Log:
Adds some more unit tests

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

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp?rev=1150232&r1=1150231&r2=1150232&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.cpp
Sat Jul 23 22:26:25 2011
@@ -64,6 +64,52 @@ ExecutorsTest::~ExecutorsTest() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testNewSingleThreadExecutor1() {
+
+    Pointer<ExecutorService> e(Executors::newSingleThreadExecutor());
+
+    e->execute(new NoOpRunnable());
+    e->execute(new NoOpRunnable());
+    e->execute(new NoOpRunnable());
+
+    joinPool(e.get());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testNewSingleThreadExecutor2() {
+
+    Pointer<ExecutorService> e(Executors::newSingleThreadExecutor(new SimpleThreadFactory()));
+
+    e->execute(new NoOpRunnable());
+    e->execute(new NoOpRunnable());
+    e->execute(new NoOpRunnable());
+
+    joinPool(e.get());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testNewSingleThreadExecutor3() {
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a NullPointerException",
+        Executors::newSingleThreadExecutor(NULL),
+        NullPointerException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testCastNewSingleThreadExecutor() {
+
+    Pointer<ExecutorService> e(Executors::newSingleThreadExecutor());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a ClassCastException",
+        e.dynamicCast<ThreadPoolExecutor>(),
+        ClassCastException);
+
+    joinPool(e.get());
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void ExecutorsTest::testDefaultThreadFactory() {
 
     CountDownLatch shutdown(1);
@@ -127,3 +173,56 @@ void ExecutorsTest::testNewFixedThreadPo
         Executors::newFixedThreadPool(0),
         IllegalArgumentException);
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testUnconfigurableExecutorService() {
+
+    Pointer<ExecutorService> e(Executors::unconfigurableExecutorService(Executors::newFixedThreadPool(2)));
+
+    e->execute(new NoOpRunnable());
+    e->execute(new NoOpRunnable());
+    e->execute(new NoOpRunnable());
+
+    joinPool(e.get());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testUnconfigurableExecutorServiceNPE() {
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a NullPointerException",
+        Executors::unconfigurableExecutorService(NULL),
+        NullPointerException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testCallable1() {
+
+    Pointer< Callable<int> > c(Executors::callable<int>(new NoOpRunnable()));
+    CPPUNIT_ASSERT_EQUAL(0, c->call());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testCallable2() {
+
+    Pointer< Callable<int> > c(Executors::callable<int>(new NoOpRunnable(),
42));
+    CPPUNIT_ASSERT_EQUAL(42, c->call());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testCallableNPE1() {
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a NullPointerException",
+        Executors::callable<int>(NULL),
+        NullPointerException);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExecutorsTest::testCallableNPE2() {
+
+    CPPUNIT_ASSERT_THROW_MESSAGE(
+        "Should throw a NullPointerException",
+        Executors::callable<int>(NULL, 42),
+        NullPointerException);
+}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.h?rev=1150232&r1=1150231&r2=1150232&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTest.h
Sat Jul 23 22:26:25 2011
@@ -32,6 +32,16 @@ namespace concurrent {
         CPPUNIT_TEST( testNewFixedThreadPool2 );
         CPPUNIT_TEST( testNewFixedThreadPool3 );
         CPPUNIT_TEST( testNewFixedThreadPool4 );
+        CPPUNIT_TEST( testNewSingleThreadExecutor1 );
+        CPPUNIT_TEST( testNewSingleThreadExecutor2 );
+        CPPUNIT_TEST( testNewSingleThreadExecutor3 );
+        CPPUNIT_TEST( testCastNewSingleThreadExecutor );
+        CPPUNIT_TEST( testUnconfigurableExecutorService );
+        CPPUNIT_TEST( testUnconfigurableExecutorServiceNPE );
+        CPPUNIT_TEST( testCallable1 );
+        CPPUNIT_TEST( testCallable2 );
+        CPPUNIT_TEST( testCallableNPE1 );
+        CPPUNIT_TEST( testCallableNPE2 );
         CPPUNIT_TEST_SUITE_END();
 
     public:
@@ -44,6 +54,16 @@ namespace concurrent {
         void testNewFixedThreadPool2();
         void testNewFixedThreadPool3();
         void testNewFixedThreadPool4();
+        void testNewSingleThreadExecutor1();
+        void testNewSingleThreadExecutor2();
+        void testNewSingleThreadExecutor3();
+        void testCastNewSingleThreadExecutor();
+        void testUnconfigurableExecutorService();
+        void testUnconfigurableExecutorServiceNPE();
+        void testCallable1();
+        void testCallable2();
+        void testCallableNPE1();
+        void testCallableNPE2();
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp?rev=1150232&r1=1150231&r2=1150232&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/testRegistry.cpp Sat Jul 23 22:26:25
2011
@@ -275,8 +275,8 @@
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::MutexTest );
 //#include <decaf/util/concurrent/ThreadPoolExecutorTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ThreadPoolExecutorTest );
-//#include <decaf/util/concurrent/ExecutorsTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ExecutorsTest );
+#include <decaf/util/concurrent/ExecutorsTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::ExecutorsTest );
 //#include <decaf/util/concurrent/TimeUnitTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::concurrent::TimeUnitTest );
 //#include <decaf/util/concurrent/LinkedBlockingQueueTest.h>



Mime
View raw message