You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/02/10 01:35:37 UTC
svn commit: r505584 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test:
Makefile.am activemq/concurrent/CountDownLatchTest.cpp
activemq/concurrent/CountDownLatchTest.h
Author: tabish
Date: Fri Feb 9 16:35:36 2007
New Revision: 505584
URL: http://svn.apache.org/viewvc?view=rev&rev=505584
Log:
http://issues.apache.org/activemq/browse/AMQCPP-30
Adding in CountDownLatch unit test
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.h
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am?view=diff&rev=505584&r1=505583&r2=505584
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/Makefile.am Fri Feb 9 16:35:36 2007
@@ -19,6 +19,7 @@
activemq/concurrent/MutexTest.cpp \
activemq/concurrent/ThreadPoolTest.cpp \
activemq/concurrent/ThreadTest.cpp \
+ activemq/concurrent/CountDownLatchTest.cpp \
activemq/connector/ConnectorFactoryMapRegistrarTest.cpp \
activemq/connector/ConnectorFactoryMapTest.cpp \
activemq/connector/stomp/commands/AbortCommandTest.cpp \
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.cpp?view=auto&rev=505584
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.cpp Fri Feb 9 16:35:36 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CountDownLatchTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::concurrent::CountDownLatchTest );
+
+using namespace activemq;
+using namespace activemq::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+void CountDownLatchTest::test()
+{
+ CountDownLatch latch( 50 );
+
+ CPPUNIT_ASSERT( latch.getCount() == 50 );
+
+ MyThread thread;
+ thread.latch = &latch;
+ thread.start();
+
+ latch.await();
+
+ CPPUNIT_ASSERT( latch.getCount() == 0 );
+
+ thread.join();
+
+ CPPUNIT_ASSERT( true );
+}
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.h?view=auto&rev=505584
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/activemq/concurrent/CountDownLatchTest.h Fri Feb 9 16:35:36 2007
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQ_CONCURRENT_COUNTDOWNLATCHTEST_H_
+#define _ACTIVEMQ_CONCURRENT_COUNTDOWNLATCHTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/concurrent/Thread.h>
+#include <activemq/concurrent/CountDownLatch.h>
+
+namespace activemq{
+namespace concurrent{
+
+ class CountDownLatchTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( CountDownLatchTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST_SUITE_END();
+
+ protected:
+
+ class MyThread : public Thread
+ {
+ public:
+
+ CountDownLatch* latch;
+
+ public:
+
+ MyThread(){}
+ virtual ~MyThread(){}
+
+ virtual void run(){
+
+ while( latch->getCount() > 0 ) {
+ latch->countDown();
+
+ Thread::sleep( 10 );
+ }
+ }
+
+ };
+
+ public:
+
+ CountDownLatchTest() {}
+ virtual ~CountDownLatchTest() {}
+
+ virtual void test();
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_CONCURRENT_COUNTDOWNLATCHTEST_H_*/