Author: nmittler
Date: Wed Jan 9 19:48:33 2008
New Revision: 610662
URL: http://svn.apache.org/viewvc?rev=610662&view=rev
Log:
AMQCPP-152 - Adding classes for support of CmsTemplate
Added:
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp
activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.h
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp
activemq/activemq-cpp/trunk/src/test/Makefile.am
Modified: activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp?rev=610662&r1=610661&r2=610662&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/cmsutil/SessionPool.cpp Wed
Jan 9 19:48:33 2008
@@ -40,6 +40,7 @@
delete *iter;
}
sessions.clear();
+ available.clear();
}
////////////////////////////////////////////////////////////////////////////////
Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?rev=610662&r1=610661&r2=610662&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Wed Jan 9 19:48:33 2008
@@ -63,6 +63,7 @@
activemq/cmsutil/DynamicDestinationResolverTest.cpp \
activemq/cmsutil/CmsAccessorTest.cpp \
activemq/cmsutil/CmsDestinationAccessorTest.cpp \
+ activemq/cmsutil/SessionPoolTest.cpp \
activemq/exceptions/ActiveMQExceptionTest.cpp \
activemq/transport/IOTransportTest.cpp \
activemq/transport/filters/ResponseCorrelatorTest.cpp \
Added: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp?rev=610662&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp
(added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.cpp
Wed Jan 9 19:48:33 2008
@@ -0,0 +1,89 @@
+/*
+ * 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 "SessionPoolTest.h"
+#include "DummyConnection.h"
+#include <activemq/cmsutil/SessionPool.h>
+#include <activemq/cmsutil/ResourceLifecycleManager.h>
+
+using namespace activemq::cmsutil;
+
+////////////////////////////////////////////////////////////////////////////////
+void SessionPoolTest::testTakeSession() {
+
+ DummyConnection connection;
+ ResourceLifecycleManager mgr;
+
+ SessionPool pool(&connection, cms::Session::AUTO_ACKNOWLEDGE, &mgr);
+
+ // Take a session.
+ PooledSession* pooledSession1 = pool.takeSession();
+ CPPUNIT_ASSERT(pooledSession1 != NULL);
+
+ // Take a second session.
+ PooledSession* pooledSession2 = pool.takeSession();
+ CPPUNIT_ASSERT(pooledSession2 != NULL );
+
+ // Make sure they're different objects.
+ CPPUNIT_ASSERT(pooledSession1 != pooledSession2);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SessionPoolTest::testReturnSession() {
+
+ DummyConnection connection;
+ ResourceLifecycleManager mgr;
+
+ SessionPool pool(&connection, cms::Session::AUTO_ACKNOWLEDGE, &mgr);
+
+ // Take a session.
+ PooledSession* pooledSession1 = pool.takeSession();
+ CPPUNIT_ASSERT(pooledSession1 != NULL);
+
+ // Return the session to the pool
+ pool.returnSession(pooledSession1);
+
+ // Take a second session.
+ PooledSession* pooledSession2 = pool.takeSession();
+ CPPUNIT_ASSERT(pooledSession2 != NULL );
+
+ // Make sure they're the same object.
+ CPPUNIT_ASSERT(pooledSession1 == pooledSession2);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SessionPoolTest::testCloseSession() {
+
+ DummyConnection connection;
+ ResourceLifecycleManager mgr;
+
+ SessionPool pool(&connection, cms::Session::AUTO_ACKNOWLEDGE, &mgr);
+
+ // Take a session.
+ PooledSession* pooledSession1 = pool.takeSession();
+ CPPUNIT_ASSERT(pooledSession1 != NULL);
+
+ // Return the session to the pool
+ pooledSession1->close();
+
+ // Take a second session.
+ PooledSession* pooledSession2 = pool.takeSession();
+ CPPUNIT_ASSERT(pooledSession2 != NULL );
+
+ // Make sure they're the same object.
+ CPPUNIT_ASSERT(pooledSession1 == pooledSession2);
+}
Added: activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.h
URL:
http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.h?rev=610662&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.h
(added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/cmsutil/SessionPoolTest.h Wed
Jan 9 19:48:33 2008
@@ -0,0 +1,48 @@
+/*
+ * 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_CMSUTIL_SESSIONPOOLEST_H_
+#define _ACTIVEMQ_CMSUTIL_SESSIONPOOLEST_H_
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+
+namespace activemq{
+namespace cmsutil{
+
+ class SessionPoolTest : public CppUnit::TestFixture
+ {
+ CPPUNIT_TEST_SUITE( SessionPoolTest );
+ CPPUNIT_TEST( testTakeSession );
+ CPPUNIT_TEST( testReturnSession );
+ CPPUNIT_TEST( testCloseSession );
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ SessionPoolTest() {}
+ virtual ~SessionPoolTest() {}
+
+ void testTakeSession();
+ void testReturnSession();
+ void testCloseSession();
+ };
+
+}}
+
+#endif /*_ACTIVEMQ_CMSUTIL_SESSIONPOOLEST_H_*/