Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A4B0298F9 for ; Sun, 26 Feb 2012 00:03:02 +0000 (UTC) Received: (qmail 1135 invoked by uid 500); 26 Feb 2012 00:03:02 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 1102 invoked by uid 500); 26 Feb 2012 00:03:02 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 1095 invoked by uid 99); 26 Feb 2012 00:03:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Feb 2012 00:03:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Feb 2012 00:02:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 08A5C23888E7 for ; Sun, 26 Feb 2012 00:02:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1293729 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent: ThreadPoolExecutorTest.cpp ThreadPoolExecutorTest.h Date: Sun, 26 Feb 2012 00:02:38 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120226000239.08A5C23888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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()); + + 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();