activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r543492 - in /activemq/activemq-cpp/trunk/src/decaf/src/test: ./ decaf/lang/ decaf/util/ decaf/util/concurrent/
Date Fri, 01 Jun 2007 14:11:33 GMT
Author: tabish
Date: Fri Jun  1 07:11:32 2007
New Revision: 543492

URL: http://svn.apache.org/viewvc?view=rev&rev=543492
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Building Decaf lib

Added:
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.h
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.h
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.h
Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am

Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am?view=diff&rev=543492&r1=543491&r2=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/Makefile.am Fri Jun  1 07:11:32 2007
@@ -19,7 +19,10 @@
   decaf/lang/BooleanTest.cpp \
   decaf/lang/IntegerTest.cpp \
   decaf/lang/LongTest.cpp \
+  decaf/lang/ThreadTest.cpp \
   decaf/util/StringTokenizerTest.cpp \
+  decaf/util/DateTest.cpp \
+  decaf/util/concurrent/CountDownLatchTest.cpp \
   main.cpp
 
 ## Compile this as part of make check

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.cpp?view=auto&rev=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.cpp Fri Jun  1 07:11:32
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.
+ */
+
+#include "ThreadTest.h"
+
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ThreadTest );
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::lang;
+
+void ThreadTest::testDelegate(){
+
+      Delegate test;
+      int initialValue = test.getStuff();
+
+      Thread thread( &test );
+      thread.start();
+      thread.join();
+
+      int finalValue = test.getStuff();
+
+      // The values should be different - this proves
+      // that the runnable was run.
+      CPPUNIT_ASSERT( finalValue != initialValue );
+}
+
+void ThreadTest::testDerived(){
+
+      Derived test;
+      int initialValue = test.getStuff();
+
+      test.start();
+      test.join();
+
+      int finalValue = test.getStuff();
+
+      // The values should be different - this proves
+      // that the runnable was run.
+      CPPUNIT_ASSERT( finalValue != initialValue );
+}
+
+void ThreadTest::testJoin(){
+
+      JoinTest test;
+
+      time_t startTime = time( NULL );
+      test.start();
+      test.join();
+      time_t endTime = time( NULL );
+
+      time_t delta = endTime - startTime;
+
+      // Should be about 5 seconds that elapsed.
+      CPPUNIT_ASSERT( delta >= 1 && delta <= 3 );
+}

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.h?view=auto&rev=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/lang/ThreadTest.h Fri Jun  1 07:11:32
2007
@@ -0,0 +1,108 @@
+/*
+ * 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 _DECAF_LANG_THREADTEST_H_
+#define _DECAF_LANG_THREADTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <decaf/lang/Thread.h>
+#include <time.h>
+
+namespace decaf{
+namespace lang{
+
+    class ThreadTest : public CppUnit::TestFixture {
+
+      CPPUNIT_TEST_SUITE( ThreadTest );
+      CPPUNIT_TEST( testDelegate );
+      CPPUNIT_TEST( testDerived );
+      CPPUNIT_TEST( testJoin );
+      CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        class Delegate : public Runnable{
+        private:
+
+            int stuff;
+
+        public:
+
+            Delegate(){ stuff = 0; }
+            virtual ~Delegate(){}
+
+            int getStuff(){
+                return stuff;
+            }
+
+            virtual void run(){
+                stuff = 1;
+            }
+
+        };
+
+        class Derived : public Thread{
+        private:
+
+            int stuff;
+
+        public:
+
+            Derived(){ stuff = 0; }
+            virtual ~Derived(){}
+
+            int getStuff(){
+                return stuff;
+            }
+
+            virtual void run(){
+                stuff = 1;
+            }
+
+        };
+
+        class JoinTest : public Thread{
+        public:
+
+            JoinTest(){}
+            virtual ~JoinTest(){}
+
+            virtual void run(){
+
+                // Sleep for 2 seconds.
+                Thread::sleep( 2000 );
+            }
+
+        };
+
+    public:
+
+        virtual ~ThreadTest(){}
+
+        virtual void setUp(){}
+        virtual void tearDown(){}
+
+        void testDelegate();
+        void testDerived();
+        void testJoin();
+    };
+
+}}
+
+#endif /*_DECAF_LANG_THREADTEST_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.cpp?view=auto&rev=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.cpp Fri Jun  1 07:11:32
2007
@@ -0,0 +1,44 @@
+/*
+ * 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 "DateTest.h"
+
+#include <decaf/util/Date.h>
+#include <decaf/lang/Thread.h>
+
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::DateTest );
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::lang;
+
+void DateTest::test(){
+
+    Date date1;
+    CPPUNIT_ASSERT( date1.getTime() != 0 );
+
+    decaf::lang::Thread::sleep(55);
+
+    Date date2;
+
+    CPPUNIT_ASSERT( date1.before(date2) == true );
+    CPPUNIT_ASSERT( date1.after(date2) == false );
+
+    Date date3 = date1;
+    CPPUNIT_ASSERT( date1.equals( date3 ) == true );
+}

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.h?view=auto&rev=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/DateTest.h Fri Jun  1 07:11:32
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.
+ */
+
+#ifndef _DECAF_UTIL_DATETEST_H_
+#define _DECAF_UTIL_DATETEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace decaf{
+namespace util{
+
+    class DateTest : public CppUnit::TestFixture
+    {
+        CPPUNIT_TEST_SUITE( DateTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+        DateTest(){};
+        virtual ~DateTest(){};
+
+        void test();
+
+    };
+
+}}
+
+#endif /*_DECAF_UTIL_DATETEST_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.cpp?view=auto&rev=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.cpp
(added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.cpp
Fri Jun  1 07:11:32 2007
@@ -0,0 +1,66 @@
+/*
+ * 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( decaf::util::concurrent::CountDownLatchTest );
+
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::util::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 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CountDownLatchTest::test2()
+{
+    CountDownLatch latch( 75 );
+
+    CPPUNIT_ASSERT( latch.getCount() == 75 );
+
+    MyThread thread;
+    thread.latch = &latch;
+    thread.start();
+
+    CPPUNIT_ASSERT( latch.await( 2 ) == false );
+
+    latch.await();
+
+    CPPUNIT_ASSERT( latch.getCount() == 0 );
+
+    thread.join();
+
+    CPPUNIT_ASSERT( true );
+}

Added: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.h?view=auto&rev=543492
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.h
(added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/concurrent/CountDownLatchTest.h
Fri Jun  1 07:11:32 2007
@@ -0,0 +1,73 @@
+/*
+ * 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 _DECAF_UTIL_CONCURRENT_COUNTDOWNLATCHTEST_H_
+#define _DECAF_UTIL_CONCURRENT_COUNTDOWNLATCHTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <decaf/lang/Thread.h>
+#include <decaf/util/concurrent/CountDownLatch.h>
+
+namespace decaf{
+namespace util{
+namespace concurrent{
+
+    class CountDownLatchTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( CountDownLatchTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST( test2 );
+        CPPUNIT_TEST_SUITE_END();
+
+    protected:
+
+        class MyThread : public lang::Thread
+        {
+        public:
+
+            CountDownLatch* latch;
+
+        public:
+
+            MyThread(){}
+            virtual ~MyThread(){}
+
+            virtual void run(){
+
+                while( latch->getCount() > 0 ) {
+                    latch->countDown();
+
+                    lang::Thread::sleep( 20 );
+                }
+            }
+
+        };
+
+    public:
+
+        CountDownLatchTest() {}
+        virtual ~CountDownLatchTest() {}
+
+        virtual void test();
+        virtual void test2();
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_CONCURRENT_COUNTDOWNLATCHTEST_H_*/



Mime
View raw message