activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r816772 - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/decaf/util/concurrent/Mutex.cpp test/decaf/util/concurrent/MutexTest.cpp
Date Fri, 18 Sep 2009 20:21:59 GMT
Author: tabish
Date: Fri Sep 18 20:21:59 2009
New Revision: 816772

URL: http://svn.apache.org/viewvc?rev=816772&view=rev
Log:
Add more tests, fix an error check condition in the Mutex

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp?rev=816772&r1=816771&r2=816772&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp Fri
Sep 18 20:21:59 2009
@@ -29,6 +29,7 @@
 using namespace decaf::internal::util::concurrent;
 using namespace decaf::util;
 using namespace decaf::util::concurrent;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 namespace decaf{
@@ -106,6 +107,16 @@
            decaf::lang::exceptions::IllegalMonitorStateException,
            decaf::lang::exceptions::InterruptedException ) {
 
+    if( millisecs < 0 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__, "Milliseconds value cannot be negative." );
+    }
+
+    if( nanos < 0 || nanos > 999999 ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__, "Nanoseconds value must be in the range [0..999999]." );
+    }
+
     ConditionImpl::wait( this->properties->condition.get(), millisecs, nanos );
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp?rev=816772&r1=816771&r2=816772&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/MutexTest.cpp
Fri Sep 18 20:21:59 2009
@@ -30,6 +30,7 @@
 using namespace std;
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 using namespace decaf::util;
 using namespace decaf::util::concurrent;
 using namespace decaf::internal::util::concurrent;
@@ -179,6 +180,27 @@
 
         CPPUNIT_ASSERT( delta >= 1 && delta <= 2 );
 
+        {
+            Mutex test;
+            test.lock();
+
+            CPPUNIT_ASSERT_THROW_MESSAGE(
+                "Should Throw an IllegalArgumentException",
+                test.wait( -1, -1 ),
+                IllegalArgumentException );
+
+            CPPUNIT_ASSERT_THROW_MESSAGE(
+                "Should Throw an IllegalArgumentException",
+                test.wait( 1, 9999999 ),
+                IllegalArgumentException );
+
+            CPPUNIT_ASSERT_THROW_MESSAGE(
+                "Should Throw an IllegalArgumentException",
+                test.wait( 0, -1 ),
+                IllegalArgumentException );
+
+        }
+
     } catch(lang::Exception& ex) {
         std::cout << ex.getMessage() << std::endl;
         CPPUNIT_ASSERT( false );



Mime
View raw message