activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r755006 - in /activemq/activemq-cpp/trunk/src: main/activemq/state/ test/ test/activemq/state/
Date Mon, 16 Mar 2009 21:14:31 GMT
Author: tabish
Date: Mon Mar 16 21:14:30 2009
New Revision: 755006

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

Adding in unit tests for the State Tracker to try and help find some bugs and make platform
testing easier.

Added:
    activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.cpp   (with
props)
    activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.h   (with
props)
Modified:
    activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionState.h
    activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h
    activemq/activemq-cpp/trunk/src/test/Makefile.am
    activemq/activemq-cpp/trunk/src/test/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionState.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionState.h?rev=755006&r1=755005&r2=755006&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionState.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionState.h Mon Mar 16 21:14:30
2009
@@ -125,10 +125,6 @@
             return sessions.get( id );
         }
 
-//        Set<SessionId> getSessionIds() {
-//            return sessions.keySet();
-//        }
-
         const StlList< Pointer<DestinationInfo> >& getTempDesinations() const
{
             return tempDestinations;
         }

Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h?rev=755006&r1=755005&r2=755006&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/ConnectionStateTracker.h Mon Mar 16
21:14:30 2009
@@ -30,7 +30,7 @@
 #include <activemq/state/Tracked.h>
 #include <activemq/transport/Transport.h>
 
-#include <decaf/util/StlMap.h>
+#include <decaf/util/concurrent/ConcurrentStlMap.h>
 #include <decaf/lang/Pointer.h>
 
 namespace activemq {
@@ -38,6 +38,7 @@
 
     class RemoveTransactionAction;
     using decaf::lang::Pointer;
+    using decaf::util::concurrent::ConcurrentStlMap;
 
     class AMQCPP_API ConnectionStateTracker : public CommandVisitorAdapter {
     private:
@@ -45,16 +46,16 @@
         /** Creates a unique marker for this state tracker */
         const Pointer<Tracked> TRACKED_RESPONSE_MARKER;
 
-        // TODO - Create a Thread Safe impl of Map.
-        decaf::util::StlMap< Pointer<ConnectionId>, Pointer<ConnectionState>,
-                             ConnectionId::COMPARATOR > connectionStates;
+        /** Map holding the ConnectionStates, indexed by the ConnectionId */
+        ConcurrentStlMap< Pointer<ConnectionId>, Pointer<ConnectionState>,
+                          ConnectionId::COMPARATOR > connectionStates;
 
         // TODO - The Map doesn't have a way to automatically remove the eldest Entry
         //        Either we need to implement something similar to LinkedHashMap or find
         //        some other way of tracking the eldest entry into the map and removing it
         //        if the cache size is exceeded.
-        decaf::util::StlMap< Pointer<MessageId>, Pointer<Message>,
-                             MessageId::COMPARATOR > messageCache;
+        ConcurrentStlMap< Pointer<MessageId>, Pointer<Message>,
+                          MessageId::COMPARATOR > messageCache;
 
         bool trackTransactions;
         bool restoreSessions;

Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=755006&r1=755005&r2=755006&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Mon Mar 16 21:14:30 2009
@@ -36,6 +36,8 @@
   activemq/cmsutil/SessionPoolTest.cpp \
   activemq/cmsutil/CmsTemplateTest.cpp \
   activemq/exceptions/ActiveMQExceptionTest.cpp \
+  activemq/state/ConnectionStateTest.cpp \
+  activemq/state/ConnectionStateTrackerTest.cpp \
   activemq/state/ConsumerStateTest.cpp \
   activemq/state/ProducerStateTest.cpp \
   activemq/state/SessionStateTest.cpp \
@@ -141,6 +143,8 @@
   activemq/cmsutil/SessionPoolTest.h \
   activemq/cmsutil/CmsTemplateTest.h \
   activemq/exceptions/ActiveMQExceptionTest.h \
+  activemq/state/ConnectionStateTest.h \
+  activemq/state/ConnectionStateTrackerTest.h \
   activemq/state/ConsumerStateTest.h \
   activemq/state/ProducerStateTest.h \
   activemq/state/SessionStateTest.h \

Added: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.cpp?rev=755006&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.cpp Mon Mar 16
21:14:30 2009
@@ -0,0 +1,53 @@
+/*
+ * 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 "ConnectionStateTest.h"
+
+#include <activemq/state/ConnectionState.h>
+#include <activemq/state/SessionState.h>
+#include <activemq/commands/SessionInfo.h>
+#include <decaf/lang/Pointer.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::state;
+using namespace activemq::commands;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+void ConnectionStateTest::test() {
+
+    // Create a Session
+    Pointer<SessionId> sid( new SessionId );
+    sid->setConnectionId( "CONNECTION" );
+    sid->setValue( 42 );
+    Pointer<SessionInfo> sinfo( new SessionInfo );
+    sinfo->setSessionId( sid );
+
+    Pointer<ConnectionInfo> info( new ConnectionInfo );
+    ConnectionState state( info );
+
+    state.addSession( sinfo );
+    CPPUNIT_ASSERT( state.getSessionStates().size() == 1 );
+    state.removeSession( sinfo->getSessionId() );
+    CPPUNIT_ASSERT( state.getSessionStates().size() == 0 );
+
+    state.addSession( sinfo );
+    state.addSession( sinfo );
+    CPPUNIT_ASSERT( state.getSessionStates().size() == 1 );
+
+}

Propchange: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.h?rev=755006&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.h Mon Mar 16 21:14:30
2009
@@ -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.
+ */
+
+#ifndef _ACTIVEMQ_STATE_CONNECTIONSTATETEST_H_
+#define _ACTIVEMQ_STATE_CONNECTIONSTATETEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace state {
+
+    class ConnectionStateTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( ConnectionStateTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        ConnectionStateTest() {}
+        virtual ~ConnectionStateTest() {}
+
+        void test();
+
+    };
+
+}}
+
+#endif /* _ACTIVEMQ_STATE_CONNECTIONSTATETEST_H_ */

Propchange: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.cpp?rev=755006&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.cpp Mon
Mar 16 21:14:30 2009
@@ -0,0 +1,38 @@
+/*
+ * 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 "ConnectionStateTrackerTest.h"
+
+#include <activemq/state/ConnectionStateTracker.h>
+#include <activemq/state/ConsumerState.h>
+#include <activemq/state/SessionState.h>
+#include <activemq/commands/ConnectionInfo.h>
+#include <activemq/commands/SessionInfo.h>
+#include <decaf/lang/Pointer.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::state;
+using namespace activemq::commands;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+void ConnectionStateTrackerTest::test() {
+
+    ConnectionStateTracker tracker;
+
+}

Propchange: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.h?rev=755006&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.h Mon Mar
16 21:14:30 2009
@@ -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 _ACTIVEMQ_STATE_CONNECTIONSTATETRACKERTEST_H_
+#define _ACTIVEMQ_STATE_CONNECTIONSTATETRACKERTEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace state {
+
+    class ConnectionStateTrackerTest : public CppUnit::TestFixture {
+
+        CPPUNIT_TEST_SUITE( ConnectionStateTrackerTest );
+        CPPUNIT_TEST( test );
+        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        ConnectionStateTrackerTest() {}
+        virtual ~ConnectionStateTrackerTest() {}
+
+        void test();
+    };
+
+}}
+
+#endif /* _ACTIVEMQ_STATE_CONNECTIONSTATETRACKERTEST_H_ */

Propchange: activemq/activemq-cpp/trunk/src/test/activemq/state/ConnectionStateTrackerTest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=755006&r1=755005&r2=755006&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Mon Mar 16 21:14:30 2009
@@ -75,7 +75,11 @@
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQConnectionTest );
 //#include <activemq/core/ActiveMQSessionTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::core::ActiveMQSessionTest );
-//
+
+#include <activemq/state/ConnectionStateTrackerTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::ConnectionStateTrackerTest );
+#include <activemq/state/ConnectionStateTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::ConnectionStateTest );
 #include <activemq/state/ConsumerStateTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::ConsumerStateTest );
 #include <activemq/state/ProducerStateTest.h>
@@ -85,8 +89,8 @@
 #include <activemq/state/TransactionStateTest.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::TransactionStateTest );
 
-#include <activemq/transport/failover/FailoverTransportTest.h>
-CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::failover::FailoverTransportTest );
+//#include <activemq/transport/failover/FailoverTransportTest.h>
+//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::failover::FailoverTransportTest );
 //
 //#include <activemq/transport/correlator/ResponseCorrelatorTest.h>
 //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::correlator::ResponseCorrelatorTest
);



Mime
View raw message