Author: tabish
Date: Mon Mar 16 20:26:12 2009
New Revision: 754997
URL: http://svn.apache.org/viewvc?rev=754997&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/SessionStateTest.cpp
(with props)
activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.h
(with props)
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h
activemq/activemq-cpp/trunk/src/test/Makefile.am
activemq/activemq-cpp/trunk/src/test/activemq/state/ConsumerStateTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/state/ProducerStateTest.cpp
activemq/activemq-cpp/trunk/src/test/testRegistry.cpp
Modified: activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h?rev=754997&r1=754996&r2=754997&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/state/SessionState.h Mon Mar
16 20:26:12 2009
@@ -86,14 +86,6 @@
return consumers.remove( id );
}
-// Set<commands::ConsumerId> getConsumerIds() {
-// return consumers.keySet();
-// }
-//
-// Set<commands::ProducerId> getProducerIds() {
-// return producers.keySet();
-// }
-
std::vector< Pointer<ProducerState> > getProducerStates() const {
return producers.values();
}
Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=754997&r1=754996&r2=754997&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Mon Mar 16 20:26:12 2009
@@ -37,8 +37,9 @@
activemq/cmsutil/CmsTemplateTest.cpp \
activemq/exceptions/ActiveMQExceptionTest.cpp \
activemq/state/ConsumerStateTest.cpp \
- activemq/state/TransactionStateTest.cpp \
activemq/state/ProducerStateTest.cpp \
+ activemq/state/SessionStateTest.cpp \
+ activemq/state/TransactionStateTest.cpp \
activemq/transport/TransportRegistryTest.cpp \
activemq/transport/IOTransportTest.cpp \
activemq/transport/correlator/ResponseCorrelatorTest.cpp \
@@ -142,6 +143,7 @@
activemq/exceptions/ActiveMQExceptionTest.h \
activemq/state/ConsumerStateTest.h \
activemq/state/ProducerStateTest.h \
+ activemq/state/SessionStateTest.h \
activemq/state/TransactionStateTest.h \
activemq/transport/TransportRegistryTest.h \
activemq/transport/IOTransportTest.h \
Modified:
activemq/activemq-cpp/trunk/src/test/activemq/state/ConsumerStateTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/ConsumerStateTest.cpp?rev=754997&r1=754996&r2=754997&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/ConsumerStateTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/ConsumerStateTest.cpp
Mon Mar 16 20:26:12 2009
@@ -30,7 +30,13 @@
////////////////////////////////////////////////////////////////////////////////
void ConsumerStateTest::test() {
+ Pointer<ConsumerId> id( new ConsumerId );
+ id->setConnectionId( "CONNECTION" );
+ id->setSessionId( 4096 );
+ id->setValue( 42 );
+
Pointer<ConsumerInfo> info( new ConsumerInfo() );
+ info->setConsumerId( id );
ConsumerState state( info );
CPPUNIT_ASSERT( state.toString() != "NULL" );
Modified:
activemq/activemq-cpp/trunk/src/test/activemq/state/ProducerStateTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/ProducerStateTest.cpp?rev=754997&r1=754996&r2=754997&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/ProducerStateTest.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/ProducerStateTest.cpp
Mon Mar 16 20:26:12 2009
@@ -29,7 +29,13 @@
////////////////////////////////////////////////////////////////////////////////
void ProducerStateTest::test() {
+ Pointer<ProducerId> id( new ProducerId );
+ id->setConnectionId( "CONNECTION" );
+ id->setSessionId( 42 );
+ id->setValue( 4096 );
+
Pointer<ProducerInfo> info( new ProducerInfo() );
+ info->setProducerId( id );
ProducerState state( info );
CPPUNIT_ASSERT( state.toString() != "NULL" );
Added: activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.cpp?rev=754997&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.cpp
(added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.cpp
Mon Mar 16 20:26:12 2009
@@ -0,0 +1,75 @@
+/*
+ * 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 "SessionStateTest.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 SessionStateTest::test() {
+
+ // Create a Consumer
+ Pointer<ConsumerId> cid( new ConsumerId );
+ cid->setConnectionId( "CONNECTION" );
+ cid->setSessionId( 4096 );
+ cid->setValue( 42 );
+ Pointer<ConsumerInfo> cinfo( new ConsumerInfo() );
+ cinfo->setConsumerId( cid );
+
+ // Create a Producer
+ Pointer<ProducerId> pid( new ProducerId );
+ pid->setConnectionId( "CONNECTION" );
+ pid->setSessionId( 42 );
+ pid->setValue( 4096 );
+ Pointer<ProducerInfo> pinfo( new ProducerInfo() );
+ pinfo->setProducerId( pid );
+
+ // Create a Session
+ Pointer<SessionId> id( new SessionId );
+ id->setConnectionId( "CONNECTION" );
+ id->setValue( 42 );
+ Pointer<SessionInfo> info( new SessionInfo );
+ info->setSessionId( id );
+
+ SessionState state( info );
+ CPPUNIT_ASSERT( state.getInfo() == info );
+
+ state.addProducer( pinfo );
+ state.addConsumer( cinfo );
+
+ CPPUNIT_ASSERT( state.getConsumerStates().size() == 1 );
+ CPPUNIT_ASSERT( state.getProducerStates().size() == 1 );
+
+ state.removeProducer( pinfo->getProducerId() );
+ state.removeConsumer( cinfo->getConsumerId() );
+
+ CPPUNIT_ASSERT( state.getConsumerStates().size() == 0 );
+ CPPUNIT_ASSERT( state.getProducerStates().size() == 0 );
+
+ state.addProducer( pinfo );
+ state.addProducer( pinfo );
+ CPPUNIT_ASSERT( state.getProducerStates().size() == 1 );
+
+}
Propchange:
activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.h?rev=754997&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.h
(added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.h Mon
Mar 16 20:26:12 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_SESSIONSTATETEST_H_
+#define _ACTIVEMQ_STATE_SESSIONSTATETEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace activemq {
+namespace state {
+
+ class SessionStateTest : public CppUnit::TestFixture {
+
+ CPPUNIT_TEST_SUITE( SessionStateTest );
+ CPPUNIT_TEST( test );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ SessionStateTest() {}
+ virtual ~SessionStateTest() {}
+
+ void test();
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_STATE_SESSIONSTATETEST_H_ */
Propchange:
activemq/activemq-cpp/trunk/src/test/activemq/state/SessionStateTest.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=754997&r1=754996&r2=754997&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Mon Mar 16 20:26:12
2009
@@ -80,6 +80,8 @@
CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::ConsumerStateTest );
#include <activemq/state/ProducerStateTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::ProducerStateTest );
+#include <activemq/state/SessionStateTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::SessionStateTest );
#include <activemq/state/TransactionStateTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( activemq::state::TransactionStateTest );