activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r723374 [1/3] - in /activemq/activemq-cpp/trunk/src/test-integration: ./ activemq/ activemq/test/ activemq/test/openwire/ activemq/test/stomp/ activemq/util/ integration/
Date Thu, 04 Dec 2008 16:56:23 GMT
Author: tabish
Date: Thu Dec  4 08:56:21 2008
New Revision: 723374

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

Major refactoring of the integration tests, most of the test code is now common for both Stomp and Openwire.  Only those tests that test features or functionality specific to either protocol are broken out into their own test cases.  Some additional tests have been added as well along with cleanups to tests that were poorly implemented or had timing issues.

Added:
    activemq/activemq-cpp/trunk/src/test-integration/TestRegistry.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CMSTestFixture.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireAsyncSenderTest.cpp
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireAsyncSenderTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireCmsTemplateTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireCmsTemplateTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireDurableTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireDurableTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireExpirationTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireExpirationTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireSimpleRollbackTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireSimpleRollbackTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireSimpleTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireSlowListenerTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireSlowListenerTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireTempDestinationTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireTempDestinationTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/openwire/OpenwireTransactionTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompAsyncSenderTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompAsyncSenderTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompCmsTemplateTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompCmsTemplateTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompDurableTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompDurableTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompExpirationTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompExpirationTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompSimpleRollbackTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompSimpleRollbackTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompSimpleTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompSimpleTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompSlowListenerTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompSlowListenerTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompTransactionTest.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/test/stomp/StompTransactionTest.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSListener.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSListener.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/CMSProvider.h   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/IntegrationCommon.cpp   (with props)
    activemq/activemq-cpp/trunk/src/test-integration/activemq/util/IntegrationCommon.h   (with props)
Removed:
    activemq/activemq-cpp/trunk/src/test-integration/integration/
Modified:
    activemq/activemq-cpp/trunk/src/test-integration/Makefile.am

Modified: activemq/activemq-cpp/trunk/src/test-integration/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/Makefile.am?rev=723374&r1=723373&r2=723374&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test-integration/Makefile.am Thu Dec  4 08:56:21 2008
@@ -16,26 +16,35 @@
 # ---------------------------------------------------------------------------
 
 cc_sources = \
-  integration/IntegrationCommon.cpp \
-  integration/TestSupport.cpp \
-  integration/TestRegistry.cpp \
-  integration/connector/openwire/OpenwireAsyncSenderTest.cpp \
-  integration/connector/openwire/OpenwireCmsTemplateTest.cpp \
-  integration/connector/openwire/OpenwireDurableTest.cpp \
-  integration/connector/openwire/OpenwireExpirationTest.cpp \
-  integration/connector/openwire/OpenwireSimpleRollbackTest.cpp \
-  integration/connector/openwire/OpenwireSimpleTest.cpp \
-  integration/connector/openwire/OpenwireSlowListenerTest.cpp \
-  integration/connector/openwire/OpenwireTransactionTest.cpp \
-  integration/connector/openwire/OpenwireTempDestinationTest.cpp \
-  integration/connector/stomp/AsyncSenderTest.cpp \
-  integration/connector/stomp/CmsTemplateTest.cpp \
-  integration/connector/stomp/DurableTest.cpp \
-  integration/connector/stomp/ExpirationTest.cpp \
-  integration/connector/stomp/SimpleRollbackTest.cpp \
-  integration/connector/stomp/SimpleTest.cpp \
-  integration/connector/stomp/TransactionTest.cpp \
-  integration/connector/stomp/StompStressTests.cpp \
+  activemq/util/CMSListener.cpp \
+  activemq/util/CMSProvider.cpp \
+  activemq/util/IntegrationCommon.cpp \
+  activemq/test/AsyncSenderTest.cpp \
+  activemq/test/CmsTemplateTest.cpp \
+  activemq/test/DurableTest.cpp \
+  activemq/test/ExpirationTest.cpp \
+  activemq/test/SimpleRollbackTest.cpp \
+  activemq/test/SimpleTest.cpp \
+  activemq/test/TransactionTest.cpp \
+  activemq/test/SlowListenerTest.cpp \
+  activemq/test/stomp/StompAsyncSenderTest.cpp \
+  activemq/test/stomp/StompCmsTemplateTest.cpp \
+  activemq/test/stomp/StompDurableTest.cpp \
+  activemq/test/stomp/StompExpirationTest.cpp \
+  activemq/test/stomp/StompSimpleRollbackTest.cpp \
+  activemq/test/stomp/StompSimpleTest.cpp \
+  activemq/test/stomp/StompTransactionTest.cpp \
+  activemq/test/stomp/StompSlowListenerTest.cpp \
+  activemq/test/openwire/OpenwireAsyncSenderTest.cpp \
+  activemq/test/openwire/OpenwireCmsTemplateTest.cpp \
+  activemq/test/openwire/OpenwireDurableTest.cpp \
+  activemq/test/openwire/OpenwireExpirationTest.cpp \
+  activemq/test/openwire/OpenwireSimpleRollbackTest.cpp \
+  activemq/test/openwire/OpenwireSimpleTest.cpp \
+  activemq/test/openwire/OpenwireTransactionTest.cpp \
+  activemq/test/openwire/OpenwireTempDestinationTest.cpp \
+  activemq/test/openwire/OpenwireSlowListenerTest.cpp \
+  TestRegistry.cpp \
   main.cpp
 
 ## Compile this as part of make check

Added: activemq/activemq-cpp/trunk/src/test-integration/TestRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/TestRegistry.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/TestRegistry.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/TestRegistry.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,56 @@
+/*
+ * 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 "activemq/test/openwire/OpenwireAsyncSenderTest.h"
+#include "activemq/test/openwire/OpenwireCmsTemplateTest.h"
+#include "activemq/test/openwire/OpenwireDurableTest.h"
+#include "activemq/test/openwire/OpenwireExpirationTest.h"
+#include "activemq/test/openwire/OpenwireSimpleRollbackTest.h"
+#include "activemq/test/openwire/OpenwireSimpleTest.h"
+#include "activemq/test/openwire/OpenwireTransactionTest.h"
+#include "activemq/test/openwire/OpenwireTempDestinationTest.h"
+#include "activemq/test/openwire/OpenwireSlowListenerTest.h"
+
+#include "activemq/test/stomp/StompAsyncSenderTest.h"
+#include "activemq/test/stomp/StompCmsTemplateTest.h"
+#include "activemq/test/stomp/StompDurableTest.h"
+#include "activemq/test/stomp/StompExpirationTest.h"
+#include "activemq/test/stomp/StompSimpleRollbackTest.h"
+#include "activemq/test/stomp/StompSimpleTest.h"
+#include "activemq/test/stomp/StompSlowListenerTest.h"
+#include "activemq/test/stomp/StompTransactionTest.h"
+
+// Openwire Tests
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireAsyncSenderTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireCmsTemplateTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireDurableTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireExpirationTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireSimpleRollbackTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireSimpleTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireTransactionTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireSlowListenerTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::openwire::OpenwireTempDestinationTest );
+
+// Stomp Tests
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompAsyncSenderTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompCmsTemplateTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompDurableTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompExpirationTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompSimpleRollbackTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompSimpleTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompTransactionTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::test::stomp::StompSlowListenerTest );

Propchange: activemq/activemq-cpp/trunk/src/test-integration/TestRegistry.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,72 @@
+/*
+ * 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 "AsyncSenderTest.h"
+
+#include <activemq/util/CMSListener.h>
+#include <activemq/util/IntegrationCommon.h>
+
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace std;
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+AsyncSenderTest::AsyncSenderTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+AsyncSenderTest::~AsyncSenderTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AsyncSenderTest::testAsyncSends() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+
+        CMSListener listener( session );
+
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        consumer->setMessageListener( &listener );
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+        auto_ptr<cms::BytesMessage> bytesMessage( session->createBytesMessage() );
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            producer->send( txtMessage.get() );
+        }
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            producer->send( bytesMessage.get() );
+        }
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( IntegrationCommon::defaultMsgCount * 2 );
+
+        unsigned int numReceived = listener.getNumReceived();
+        CPPUNIT_ASSERT( numReceived == IntegrationCommon::defaultMsgCount * 2 );
+
+    } catch(...) {
+        CPPUNIT_ASSERT( false );
+    }
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/AsyncSenderTest.h Thu Dec  4 08:56:21 2008
@@ -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.
+ */
+
+#ifndef _ACTIVEMQ_TEST_ASYNCSENDERTEST_H_
+#define _ACTIVEMQ_TEST_ASYNCSENDERTEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+
+namespace activemq{
+namespace test{
+
+    class AsyncSenderTest : public CMSTestFixture {
+    public:
+
+        AsyncSenderTest();
+        virtual ~AsyncSenderTest();
+
+        virtual void testAsyncSends();
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_ASYNCSENDERTEST_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CMSTestFixture.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CMSTestFixture.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CMSTestFixture.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CMSTestFixture.h Thu Dec  4 08:56:21 2008
@@ -0,0 +1,59 @@
+/*
+ * 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_TEST_CMSTESTFIXTURE_H_
+#define _ACTIVEMQ_TEST_CMSTESTFIXTURE_H_
+
+#include <memory>
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <activemq/util/CMSProvider.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq {
+namespace test {
+
+    class CMSTestFixture : public CppUnit::TestFixture {
+    protected:
+
+        std::auto_ptr<util::CMSProvider> cmsProvider;
+
+    public:
+
+        virtual ~CMSTestFixture() {
+        }
+
+        /**
+         * Return the URL for the Broker that is customized for the
+         * test in question.
+         * @returns the BrokerURL string for this test.
+         */
+        virtual std::string getBrokerURL() const = 0;
+
+        virtual void setUp() {
+            cmsProvider.reset( new util::CMSProvider( getBrokerURL() ) );
+        };
+
+        virtual void tearDown() { cmsProvider.reset( NULL ); };
+
+    };
+
+}}
+
+#endif /* _ACTIVEMQ_TEST_CMSTESTFIXTURE_H_ */

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,150 @@
+/*
+ * 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 "CmsTemplateTest.h"
+
+#include <activemq/util/IntegrationCommon.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+#include <decaf/lang/Thread.h>
+
+#include <cms/Connection.h>
+#include <cms/MessageConsumer.h>
+#include <cms/MessageProducer.h>
+#include <cms/MessageListener.h>
+#include <cms/Startable.h>
+#include <cms/Closeable.h>
+#include <cms/MessageListener.h>
+#include <cms/ExceptionListener.h>
+#include <cms/Topic.h>
+#include <cms/Queue.h>
+#include <cms/TemporaryTopic.h>
+#include <cms/TemporaryQueue.h>
+#include <cms/Session.h>
+#include <cms/BytesMessage.h>
+#include <cms/TextMessage.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::core;
+using namespace activemq::exceptions;
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::testBasics() {
+
+    try {
+
+        const unsigned int NUM_MESSAGES = IntegrationCommon::defaultMsgCount;
+
+        Receiver receiver( this->getBrokerURL(), false, "testBasics1", NUM_MESSAGES);
+        Thread rt( &receiver );
+        rt.start();
+
+        // Wait for receiver thread to start.
+        receiver.waitUntilReady();
+
+        Sender sender( this->getBrokerURL(), false, "testBasics1", NUM_MESSAGES);
+        Thread st( &sender );
+        st.start();
+
+        st.join();
+        rt.join();
+
+        unsigned int numReceived = receiver.getNumReceived();
+        CPPUNIT_ASSERT( numReceived == NUM_MESSAGES );
+
+    } catch ( ActiveMQException e ) {
+        e.printStackTrace();
+        throw e;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::testReceiveException() {
+
+    try {
+
+        // First, try receiving from a bad url
+        activemq::core::ActiveMQConnectionFactory cf("tcp://localhost:61666");
+        activemq::cmsutil::CmsTemplate cmsTemplate(&cf);
+        cmsTemplate.setDefaultDestinationName("testReceive1");
+
+        try {
+            cmsTemplate.receive();
+            CPPUNIT_FAIL("failed to throw expected exception");
+        } catch( ActiveMQException& ex ) {
+            // Expected.
+        }
+
+        // Now change to a good url and verify that we can reuse the same
+        // CmsTemplate successfully.
+        activemq::core::ActiveMQConnectionFactory cf2( this->getBrokerURL() );
+        cmsTemplate.setConnectionFactory(&cf2);
+
+        // Send 1 message.
+        Sender sender( this->getBrokerURL(), false, "testReceive1", 1);
+        Thread st( &sender );
+        st.start();
+        st.join();
+
+        // Receive the message.
+        cms::Message* message = cmsTemplate.receive();
+        CPPUNIT_ASSERT( message != NULL );
+        delete message;
+
+    } catch ( ActiveMQException e ) {
+        e.printStackTrace();
+        CPPUNIT_ASSERT( false );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CmsTemplateTest::testSendException() {
+
+    try {
+
+        // First, try sending to a bad url.
+        activemq::core::ActiveMQConnectionFactory cf( "tcp://localhost:61666" );
+        activemq::cmsutil::CmsTemplate cmsTemplate( &cf );
+        cmsTemplate.setDefaultDestinationName( "testSend1" );
+        try {
+            TextMessageCreator msgCreator( "hello world" );
+            cmsTemplate.send( &msgCreator );
+            CPPUNIT_FAIL( "failed to throw expected exception" );
+        } catch( ActiveMQException& ex ) {
+            // Expected.
+        }
+
+        // Now change to a good url and verify that we can reuse the same
+        // CmsTemplate successfully.
+        activemq::core::ActiveMQConnectionFactory cf2( this->getBrokerURL() );
+        cmsTemplate.setConnectionFactory( &cf2 );
+        TextMessageCreator msgCreator( "hello world" );
+        cmsTemplate.send( &msgCreator );
+
+    } catch ( ActiveMQException e ) {
+        e.printStackTrace();
+        throw e;
+    }
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/CmsTemplateTest.h Thu Dec  4 08:56:21 2008
@@ -0,0 +1,149 @@
+/*
+ * 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_TEST_CMSTEMPLATETEST_H_
+#define _ACTIVEMQ_TEST_CMSTEMPLATETEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+
+#include <activemq/cmsutil/CmsTemplate.h>
+#include <activemq/cmsutil/MessageCreator.h>
+#include <activemq/core/ActiveMQConnectionFactory.h>
+#include <decaf/util/concurrent/CountDownLatch.h>
+
+namespace activemq{
+namespace test{
+
+    class CmsTemplateTest : public CMSTestFixture {
+
+        class TextMessageCreator : public activemq::cmsutil::MessageCreator {
+        private:
+            std::string text;
+        public:
+            TextMessageCreator( const std::string& text) {
+                this->text = text;
+            }
+            virtual ~TextMessageCreator() {}
+
+            std::string getText() const {
+                return text;
+            }
+
+            virtual cms::Message* createMessage(cms::Session* session )
+                        throw (cms::CMSException) {
+                return session->createTextMessage(text);
+            }
+        };
+
+        class Sender : public decaf::lang::Runnable {
+        private:
+
+            activemq::core::ActiveMQConnectionFactory cf;
+            activemq::cmsutil::CmsTemplate cmsTemplate;
+            int count;
+
+        public:
+
+            Sender( const std::string& url, bool pubSub, const std::string& destName, int count ) {
+                cf.setBrokerURL(url);
+                cmsTemplate.setConnectionFactory(&cf);
+                cmsTemplate.setPubSubDomain(pubSub);
+                cmsTemplate.setDefaultDestinationName(destName);
+                cmsTemplate.setDeliveryPersistent(false);
+                this->count = count;
+            }
+
+            virtual ~Sender(){
+            }
+
+            virtual void run() {
+                try {
+
+                    // Send a batch of messages.
+                    TextMessageCreator tmc("hello world");
+                    for( int ix=0; ix<count; ++ix ) {
+                        cmsTemplate.send(&tmc);
+                    }
+
+                } catch( cms::CMSException& ex) {
+                    ex.printStackTrace();
+                }
+            }
+        };
+
+        class Receiver : public decaf::lang::Runnable {
+        private:
+
+            activemq::core::ActiveMQConnectionFactory cf;
+            activemq::cmsutil::CmsTemplate cmsTemplate;
+            int count;
+            int numReceived;
+            decaf::util::concurrent::CountDownLatch ready;
+
+        public:
+
+            Receiver( const std::string& url, bool pubSub, const std::string& destName, int count )
+                : ready(1) {
+
+                cf.setBrokerURL(url);
+                cmsTemplate.setConnectionFactory(&cf);
+                cmsTemplate.setPubSubDomain(pubSub);
+                cmsTemplate.setDefaultDestinationName(destName);
+                cmsTemplate.setDeliveryPersistent(false);
+                this->count = count;
+            }
+            virtual ~Receiver(){
+            }
+            int getNumReceived() const {
+                return numReceived;
+            }
+            virtual void waitUntilReady() {
+                ready.await();
+            }
+
+            virtual void run() {
+
+                try {
+                    numReceived = 0;
+
+                    ready.countDown();
+                    // Receive a batch of messages.
+                    for( int ix=0; ix<count; ++ix ) {
+                        cms::Message* message = cmsTemplate.receive();
+                        numReceived++;
+                        delete message;
+                    }
+                } catch( cms::CMSException& ex) {
+                    ex.printStackTrace();
+                }
+            }
+        };
+
+    public:
+
+        CmsTemplateTest(){}
+        virtual ~CmsTemplateTest(){}
+
+        virtual void testBasics();
+        virtual void testReceiveException();
+        virtual void testSendException();
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_CMSTEMPLATETEST_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,85 @@
+/*
+ * 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 "DurableTest.h"
+
+#include <activemq/util/IntegrationCommon.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+#include <decaf/util/UUID.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::util;
+using namespace activemq::test;
+using namespace activemq::exceptions;
+
+using namespace decaf;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+void DurableTest::testDurableConsumer() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+        cmsProvider->setSubscription( UUID::randomUUID().toString() );
+        cmsProvider->setDurable( true );
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        //CMSListener listener( session );
+        //consumer->setMessageListener( &listener );
+
+        // Send a text message to the consumer while its active
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+        producer->send( txtMessage.get() );
+        auto_ptr<cms::Message> received( consumer->receive( 3000 ) );
+
+        CPPUNIT_ASSERT( received.get() != NULL );
+
+        cmsProvider->reconnectSession();
+        session = cmsProvider->getSession();
+        producer = cmsProvider->getProducer();
+
+        // Send some messages while there is no consumer active.
+        for( int i = 0; i < MSG_COUNT; ++i ) {
+            producer->send( txtMessage.get() );
+        }
+
+        consumer = cmsProvider->getConsumer();
+
+        // Send some messages while there is no consumer active.
+        for( int i = 0; i < MSG_COUNT; ++i ) {
+            producer->send( txtMessage.get() );
+        }
+
+        for( int i = 0; i < MSG_COUNT * 2; i++ ) {
+            received.reset( consumer->receive( 1000 * 5 ) );
+
+            CPPUNIT_ASSERT_MESSAGE(
+                "Failed to receive all messages in batch", received.get() != NULL );
+        }
+
+        // Remove the subscription after the consumer is forcibly closed.
+        cmsProvider->unsubscribe();
+    }
+    catch( ActiveMQException& ex ) {
+        CPPUNIT_ASSERT_MESSAGE( ex.getStackTraceString(), false );
+    }
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/DurableTest.h Thu Dec  4 08:56:21 2008
@@ -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_TEST_DURABLETESTER_H_
+#define _ACTIVEMQ_TEST_DURABLETESTER_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq{
+namespace test{
+
+    class DurableTest : public CMSTestFixture {
+    private:
+
+        static const int MSG_COUNT = 10;
+
+    public:
+
+        DurableTest() {}
+        virtual ~DurableTest() {}
+
+        virtual void testDurableConsumer();
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_DURABLETESTER_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,182 @@
+/*
+ * 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 "ExpirationTest.h"
+
+#include <decaf/lang/Runnable.h>
+#include <decaf/lang/Thread.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/util/UUID.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace activemq {
+namespace test {
+
+    class Producer : public decaf::lang::Runnable {
+    private:
+
+        auto_ptr<CMSProvider> cmsProvider;
+        int numMessages;
+        long long timeToLive;
+        bool disableTimeStamps;
+
+    public:
+
+        Producer( const std::string& brokerURL, const std::string& topic,
+                  int numMessages, long long timeToLive ) {
+            this->cmsProvider.reset( new CMSProvider( brokerURL ) );
+            this->cmsProvider->setDestinationName( topic );
+            this->numMessages = numMessages;
+            this->timeToLive = timeToLive;
+            this->disableTimeStamps = false;
+        }
+
+        virtual ~Producer(){
+        }
+
+        virtual bool getDisableTimeStamps() const {
+            return this->disableTimeStamps;
+        }
+
+        virtual void setDisableTimeStamps( bool value ){
+            this->disableTimeStamps = value;
+        }
+
+        virtual void run() {
+            try {
+
+                cms::Session* session = cmsProvider->getSession();
+                cms::MessageProducer* producer = cmsProvider->getProducer();
+                producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+                producer->setDisableMessageTimeStamp( disableTimeStamps );
+                producer->setTimeToLive( 1 );
+
+                // Create the Thread Id String
+                string threadIdStr = Integer::toString( Thread::getId() );
+
+                // Create a messages
+                string text = (string)"Hello world! from thread " + threadIdStr;
+
+                for( int ix=0; ix<numMessages; ++ix ){
+                    TextMessage* message = session->createTextMessage( text );
+                    producer->send( message );
+                    delete message;
+                }
+
+            } catch ( CMSException& e ) {
+                e.printStackTrace();
+            }
+        }
+    };
+
+    class Consumer : public cms::MessageListener, public decaf::lang::Runnable {
+    private:
+
+        auto_ptr<CMSProvider> cmsProvider;
+        long waitMillis;
+        int numReceived;
+
+    public:
+
+        Consumer( const std::string& brokerURL, const std::string& topic, long waitMillis ) {
+            this->cmsProvider.reset( new CMSProvider( brokerURL ) );
+            this->cmsProvider->setDestinationName( topic + "?consumer.retroactive=true" );
+            this->waitMillis = waitMillis;
+            this->numReceived = 0;
+        }
+
+        virtual ~Consumer(){
+        }
+
+        virtual int getNumReceived() const{
+            return numReceived;
+        }
+
+        virtual void run(){
+
+            try {
+
+                cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+                consumer->setMessageListener( this );
+
+                // Sleep while asynchronous messages come in.
+                Thread::sleep( waitMillis );
+
+            } catch (CMSException& e) {
+                e.printStackTrace();
+            }
+        }
+
+        virtual void onMessage( const cms::Message* message ){
+
+            try{
+                const TextMessage* textMessage =
+                    dynamic_cast< const TextMessage* >( message );
+                textMessage->getText();
+                numReceived++;
+            } catch( CMSException& e ) {
+                e.printStackTrace();
+            }
+        }
+    };
+}}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExpirationTest::testExpired() {
+
+    string topic = UUID::randomUUID().toString();
+    Producer producer( this->getBrokerURL(), topic, 1, 1 );
+    Thread producerThread( &producer );
+    producerThread.start();
+    producerThread.join();
+
+    Consumer consumer( this->getBrokerURL(), topic, 2000 );
+    Thread consumerThread( &consumer );
+    consumerThread.start();
+    consumerThread.join();
+
+    CPPUNIT_ASSERT_EQUAL( 0, consumer.getNumReceived() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ExpirationTest::testNotExpired() {
+
+    string topic = UUID::randomUUID().toString();
+    Producer producer( this->getBrokerURL(), topic, 2, 2000 );
+    producer.setDisableTimeStamps( true );
+    Thread producerThread( &producer );
+    producerThread.start();
+    producerThread.join();
+
+    Consumer consumer( this->getBrokerURL(), topic, 3000 );
+    Thread consumerThread( &consumer );
+    consumerThread.start();
+    consumerThread.join();
+
+    CPPUNIT_ASSERT_EQUAL( 2, consumer.getNumReceived() );
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/ExpirationTest.h Thu Dec  4 08:56:21 2008
@@ -0,0 +1,47 @@
+/*
+ * 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_TEST_EXPIRATIONTEST_H_
+#define _ACTIVEMQ_TEST_EXPIRATIONTEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq{
+namespace test{
+
+    class ExpirationTest : public CMSTestFixture {
+    public:
+
+        static std::string messageTag;
+
+    public:
+
+        ExpirationTest(){}
+        virtual ~ExpirationTest(){}
+
+        virtual void setUp() {}
+        virtual void tearDown() {}
+
+        virtual void testExpired();
+        virtual void testNotExpired();
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_EXPIRATIONTEST_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,114 @@
+/*
+ * 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 "SimpleRollbackTest.h"
+
+#include <activemq/util/CMSListener.h>
+#include <activemq/util/IntegrationCommon.h>
+#include <activemq/exceptions/ActiveMQException.h>
+#include <decaf/lang/Thread.h>
+#include <decaf/util/UUID.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+SimpleRollbackTest::SimpleRollbackTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SimpleRollbackTest::~SimpleRollbackTest() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleRollbackTest::testRollbacks() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+
+        CMSListener listener( session );
+
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        consumer->setMessageListener( &listener );
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage() );
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            ostringstream lcStream;
+            lcStream << "SimpleTest - Message #" << i << ends;
+            txtMessage->setText( lcStream.str() );
+            producer->send( txtMessage.get() );
+        }
+
+        session->commit();
+        Thread::sleep( 50 );
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( IntegrationCommon::defaultMsgCount );
+        unsigned int numReceived = listener.getNumReceived();
+        CPPUNIT_ASSERT( numReceived == IntegrationCommon::defaultMsgCount );
+
+        for( unsigned int i = 0; i < 5; ++i ) {
+            ostringstream lcStream;
+            lcStream << "SimpleTest - Message #" << i << ends;
+            txtMessage->setText( lcStream.str() );
+            producer->send( txtMessage.get() );
+        }
+
+        listener.reset();
+        session->rollback();
+        Thread::sleep( 50 );
+
+        // TODO - Should we get anything here?
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( 5 );
+        //CPPUNIT_ASSERT( listener.getNumReceived() == 0 );
+
+        listener.reset();
+        txtMessage->setText( "SimpleTest - Message after Rollback" );
+        producer->send( txtMessage.get() );
+        session->commit();
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( 1 );
+        CPPUNIT_ASSERT( listener.getNumReceived() == 1 );
+
+        listener.reset();
+        txtMessage->setText( "SimpleTest - Message after Rollback" );
+        producer->send( txtMessage.get() );
+        session->commit();
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( 1 );
+        CPPUNIT_ASSERT( listener.getNumReceived() == 1 );
+
+    } catch( ... ) {
+        CPPUNIT_ASSERT( false );
+    }
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleRollbackTest.h Thu Dec  4 08:56:21 2008
@@ -0,0 +1,45 @@
+/*
+ * 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_TEST_SIMPLEROLLBACKTEST_H_
+#define _ACTIVEMQ_TEST_SIMPLEROLLBACKTEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+#include <cms/Session.h>
+
+namespace activemq{
+namespace test{
+
+    class SimpleRollbackTest : public CMSTestFixture {
+    public:
+
+        SimpleRollbackTest();
+        virtual ~SimpleRollbackTest();
+
+        virtual void setUp() {
+            cmsProvider.reset(
+                new util::CMSProvider( getBrokerURL(), cms::Session::SESSION_TRANSACTED ) );
+        };
+
+        virtual void testRollbacks();
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_SIMPLEROLLBACKTEST_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,321 @@
+/*
+ * 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 "SimpleTest.h"
+
+#include <activemq/util/CMSListener.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+#include <decaf/lang/Thread.h>
+#include <decaf/util/UUID.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testAutoAck() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+
+        CMSListener listener( session );
+
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        consumer->setMessageListener( &listener );
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+        auto_ptr<cms::BytesMessage> bytesMessage( session->createBytesMessage() );
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            producer->send( txtMessage.get() );
+        }
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            producer->send( bytesMessage.get() );
+        }
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( IntegrationCommon::defaultMsgCount * 2 );
+
+        unsigned int numReceived = listener.getNumReceived();
+        CPPUNIT_ASSERT( numReceived == IntegrationCommon::defaultMsgCount * 2 );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testClientAck() {
+
+    try {
+
+        cmsProvider->setAckMode( cms::Session::CLIENT_ACKNOWLEDGE );
+        cmsProvider->reconnectSession();
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+
+        CMSListener listener( session );
+
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        consumer->setMessageListener( &listener );
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+        auto_ptr<cms::BytesMessage> bytesMessage( session->createBytesMessage() );
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            producer->send( txtMessage.get() );
+        }
+
+        for( unsigned int i = 0; i < IntegrationCommon::defaultMsgCount; ++i ) {
+            producer->send( bytesMessage.get() );
+        }
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( IntegrationCommon::defaultMsgCount * 2 );
+
+        unsigned int numReceived = listener.getNumReceived();
+        CPPUNIT_ASSERT( numReceived == IntegrationCommon::defaultMsgCount * 2 );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testProducerWithNullDestination() {
+
+    try{
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+
+        CMSListener listener( session );
+
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        consumer->setMessageListener( &listener );
+        cms::MessageProducer* producer = cmsProvider->getNoDestProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+
+        producer->send( cmsProvider->getDestination(), txtMessage.get() );
+
+        // Wait for the messages to get here
+        listener.asyncWaitForMessages( 1 );
+
+        unsigned int numReceived = listener.getNumReceived();
+        CPPUNIT_ASSERT( numReceived == 1 );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testSyncReceive() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+
+        // Send some text messages
+        producer->send( txtMessage.get() );
+
+        auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testSyncReceiveClientAck() {
+
+    try {
+
+        cmsProvider->setAckMode( cms::Session::CLIENT_ACKNOWLEDGE );
+        cmsProvider->reconnectSession();
+
+        // Create CMS Object for Comms
+        cms::Session* session( cmsProvider->getSession() );
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> txtMessage( session->createTextMessage( "TEST MESSAGE" ) );
+
+        // Send some text messages
+        producer->send( txtMessage.get() );
+
+        auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testMultipleConnections() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::ConnectionFactory* factory = cmsProvider->getConnectionFactory();
+        auto_ptr<cms::Connection> connection1( factory->createConnection() );
+        connection1->start();
+
+        auto_ptr<cms::Connection> connection2( factory->createConnection() );
+        connection2->start();
+
+        CPPUNIT_ASSERT( connection1->getClientID() != connection2->getClientID() );
+
+        auto_ptr<cms::Session> session1( connection1->createSession() );
+        auto_ptr<cms::Session> session2( connection1->createSession() );
+
+        auto_ptr<cms::Topic> topic( session1->createTopic( UUID::randomUUID().toString() ) );
+
+        auto_ptr<cms::MessageConsumer> consumer1( session1->createConsumer( topic.get() ) );
+        auto_ptr<cms::MessageConsumer> consumer2( session2->createConsumer( topic.get() ) );
+
+        auto_ptr<cms::MessageProducer> producer( session2->createProducer( topic.get() ) );
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> textMessage( session2->createTextMessage() );
+
+        // Send some text messages
+        producer->send( textMessage.get() );
+
+        auto_ptr<cms::Message> message( consumer1->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+
+        message.reset( consumer2->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testMultipleSessions() {
+    try {
+
+        // Create CMS Object for Comms
+        auto_ptr<cms::Session> session1( cmsProvider->getConnection()->createSession() );
+        auto_ptr<cms::Session> session2( cmsProvider->getConnection()->createSession() );
+
+        auto_ptr<cms::Topic> topic( session1->createTopic( UUID::randomUUID().toString() ) );
+
+        auto_ptr<cms::MessageConsumer> consumer1( session1->createConsumer( topic.get() ) );
+        auto_ptr<cms::MessageConsumer> consumer2( session2->createConsumer( topic.get() ) );
+
+        auto_ptr<cms::MessageProducer> producer( session2->createProducer( topic.get() ) );
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<cms::TextMessage> textMessage( session2->createTextMessage() );
+
+        // Send some text messages
+        producer->send( textMessage.get() );
+
+        auto_ptr<cms::Message> message( consumer1->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+
+        message.reset( consumer2->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testReceiveAlreadyInQueue() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::ConnectionFactory* factory = cmsProvider->getConnectionFactory();
+        auto_ptr<cms::Connection> connection( factory->createConnection() );
+
+        auto_ptr<cms::Session> session( connection->createSession() );
+        auto_ptr<cms::Topic> topic( session->createTopic( UUID::randomUUID().toString() ) );
+        auto_ptr<cms::MessageConsumer> consumer( session->createConsumer( topic.get() ) );
+        auto_ptr<cms::MessageProducer> producer( session->createProducer( topic.get() ) );
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+        auto_ptr<cms::TextMessage> textMessage( session->createTextMessage() );
+
+        // Send some text messages
+        producer->send( textMessage.get() );
+
+        Thread::sleep( 250 );
+
+        connection->start();
+
+        auto_ptr<cms::Message> message( consumer->receive( 2000 ) );
+        CPPUNIT_ASSERT( message.get() != NULL );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SimpleTest::testQuickCreateAndDestroy() {
+
+    try{
+
+        cms::ConnectionFactory* factory = cmsProvider->getConnectionFactory();
+        auto_ptr<cms::Connection> connection( factory->createConnection() );
+        auto_ptr<cms::Session> session( connection->createSession() );
+
+        session.reset( NULL );
+        connection.reset( NULL );
+
+        connection.reset( factory->createConnection() );
+        session.reset( connection->createSession() );
+        connection->start();
+
+        session.reset( NULL );
+        connection.reset( NULL );
+
+        for( int i = 0; i < 50; ++i ) {
+            CMSProvider lcmsProvider( this->getBrokerURL() );
+            lcmsProvider.getSession();
+            lcmsProvider.getConsumer();
+            lcmsProvider.getProducer();
+        }
+
+    } catch ( CMSException& e ) {
+        e.printStackTrace();
+        CPPUNIT_ASSERT( false );
+    }
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SimpleTest.h Thu Dec  4 08:56:21 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_TEST_SIMPLETESTER_H_
+#define _ACTIVEMQ_TEST_SIMPLETESTER_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq{
+namespace test{
+
+    class SimpleTest : public CMSTestFixture {
+    public:
+
+        SimpleTest() {}
+        virtual ~SimpleTest() {}
+
+        virtual void testAutoAck();
+        virtual void testClientAck();
+        virtual void testProducerWithNullDestination();
+        virtual void testSyncReceive();
+        virtual void testSyncReceiveClientAck();
+        virtual void testMultipleConnections();
+        virtual void testMultipleSessions();
+        virtual void testReceiveAlreadyInQueue();
+        virtual void testQuickCreateAndDestroy();
+
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_SIMPLETESTER_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,130 @@
+/*
+ * 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 "SlowListenerTest.h"
+
+#include <decaf/lang/Thread.h>
+#include <decaf/util/concurrent/Mutex.h>
+#include <decaf/util/Date.h>
+#include <decaf/util/Set.h>
+
+#include <activemq/exceptions/ActiveMQException.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace activemq{
+namespace test{
+
+    class SlowListener: public cms::MessageListener {
+    public:
+
+        unsigned int count;
+        decaf::util::Set<long long> threadIds;
+
+        SlowListener() { count = 0; }
+
+        void onMessage( const cms::Message* message ) {
+
+            synchronized( &threadIds ) {
+                count++;
+                threadIds.add( Thread::getId() );
+            }
+
+            Thread::sleep( 20 );
+        }
+    };
+
+}}
+
+////////////////////////////////////////////////////////////////////////////////
+void SlowListenerTest::testSlowListener() {
+
+    try {
+
+        SlowListener listener;
+
+        cms::Session* session = cmsProvider->getSession();
+
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        const unsigned int numConsumers = 5;
+        cms::MessageConsumer* consumers[numConsumers];
+
+        // Create several consumers for the same destination.
+        for( unsigned int i = 0; i < numConsumers; i++ ) {
+            consumers[i] = session->createConsumer( cmsProvider->getDestination() );
+            consumers[i]->setMessageListener( &listener );
+        }
+
+        auto_ptr<cms::BytesMessage> message( session->createBytesMessage() );
+
+        unsigned int msgCount = 50;
+        for( unsigned int i = 0; i < msgCount; i++ ) {
+            producer->send( message.get() );
+        }
+
+        // Wait no more than 10 seconds for all the messages to come in.
+        waitForMessages( msgCount * numConsumers, 10000, &listener );
+
+        synchronized( &listener.threadIds ) {
+
+            // Make sure that the listener was always accessed by the same thread
+            // and that it received all the messages from all consumers.
+            CPPUNIT_ASSERT_EQUAL( 1, (int)listener.threadIds.size() );
+            CPPUNIT_ASSERT_EQUAL( (msgCount * numConsumers), listener.count );
+        }
+
+        for( unsigned int i = 0; i < numConsumers; i++ ) {
+            delete consumers[i];
+        }
+
+    } catch( ActiveMQException& ex ) {
+        ex.printStackTrace();
+        throw ex;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SlowListenerTest::waitForMessages(
+    unsigned int count, long long maxWaitTime, SlowListener* l ) {
+
+    long long startTime = Date::getCurrentTimeMilliseconds();
+
+    synchronized( &( l->threadIds ) ) {
+
+        while( l->count < count ) {
+
+            long long curTime = Date::getCurrentTimeMilliseconds();
+            if( ( curTime - startTime ) >= maxWaitTime ) {
+                return;
+            }
+
+            l->threadIds.wait( 500 );
+        }
+    }
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/SlowListenerTest.h Thu Dec  4 08:56:21 2008
@@ -0,0 +1,50 @@
+/*
+ * 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_TEST_OPENWIRESLOWLISTENERTEST_H_
+#define _ACTIVEMQ_TEST_OPENWIRESLOWLISTENERTEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq{
+namespace test{
+
+    class SlowListener;
+
+    class SlowListenerTest : public CMSTestFixture {
+
+//        CPPUNIT_TEST_SUITE( SlowListenerTest );
+//        CPPUNIT_TEST( testSlowListener );
+//        CPPUNIT_TEST_SUITE_END();
+
+    public:
+
+        SlowListenerTest() {}
+        virtual ~SlowListenerTest() {}
+
+        virtual void testSlowListener();
+
+    protected:
+
+        void waitForMessages( unsigned int count, long long maxWaitTime, SlowListener* listener );
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_OPENWIRESLOWLISTENERTEST_H_*/

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

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.cpp?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.cpp Thu Dec  4 08:56:21 2008
@@ -0,0 +1,158 @@
+/*
+ * 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 "TransactionTest.h"
+
+#include <activemq/util/CMSListener.h>
+#include <activemq/exceptions/ActiveMQException.h>
+
+using namespace std;
+using namespace cms;
+using namespace activemq;
+using namespace activemq::test;
+using namespace activemq::util;
+using namespace activemq::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+void TransactionTest::testSendReceiveTransactedBatches() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session = cmsProvider->getSession();
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<TextMessage> message( session->createTextMessage( "Batch Message" ) );
+
+        for( int j = 0; j < batchCount; j++ ) {
+
+            for( int i = 0; i < batchSize; i++ ) {
+                producer->send( message.get() );
+            }
+
+            session->commit();
+
+            for( int i = 0; i < batchSize; i++ ) {
+                message.reset( dynamic_cast<TextMessage*>( consumer->receive( 1000 * 5 ) ) );
+
+                CPPUNIT_ASSERT_MESSAGE(
+                    "Failed to receive all messages in batch", message.get() != NULL );
+                CPPUNIT_ASSERT( string("Batch Message") == message->getText() );
+            }
+
+            session->commit();
+        }
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TransactionTest::testSendRollback() {
+
+    try {
+
+        // Create CMS Object for Comms
+        cms::Session* session = cmsProvider->getSession();
+        cms::MessageConsumer* consumer = cmsProvider->getConsumer();
+        cms::MessageProducer* producer = cmsProvider->getProducer();
+
+        producer->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<TextMessage> outbound1( session->createTextMessage( "First Message" ) );
+        auto_ptr<TextMessage> outbound2( session->createTextMessage( "Second Message" ) );
+
+        // sends a message
+        producer->send( outbound1.get() );
+        session->commit();
+
+        // sends a message that gets rollbacked
+        auto_ptr<Message> rollback(
+            session->createTextMessage( "I'm going to get rolled back." ) );
+        producer->send( rollback.get() );
+        session->rollback();
+
+        // sends a message
+        producer->send( outbound2.get() );
+        session->commit();
+
+        // receives the first message
+        auto_ptr<TextMessage> inbound1(
+            dynamic_cast<TextMessage*>( consumer->receive( 1500 ) ) );
+
+        // receives the second message
+        auto_ptr<TextMessage> inbound2(
+            dynamic_cast<TextMessage*>( consumer->receive( 4000 ) ) );
+
+        // validates that the rollbacked was not consumed
+        session->commit();
+
+        CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+        CPPUNIT_ASSERT( outbound2->getText() == inbound2->getText() );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void TransactionTest::testSendSessionClose() {
+
+    try {
+
+        cmsProvider->getProducer()->setDeliveryMode( DeliveryMode::NON_PERSISTENT );
+
+        auto_ptr<TextMessage> outbound1(
+            cmsProvider->getSession()->createTextMessage( "First Message" ) );
+        auto_ptr<TextMessage> outbound2(
+            cmsProvider->getSession()->createTextMessage( "Second Message" ) );
+
+        // sends a message
+        cmsProvider->getProducer()->send( outbound1.get() );
+        cmsProvider->getSession()->commit();
+
+        // sends a message that gets rollbacked
+        auto_ptr<cms::Message> rollback(
+            cmsProvider->getSession()->createTextMessage( "I'm going to get rolled back." ) );
+        cmsProvider->getProducer()->send( rollback.get() );
+        cmsProvider->getConsumer()->close();
+
+        cmsProvider->reconnectSession();
+
+        // sends a message
+        cmsProvider->getProducer()->send( outbound2.get() );
+        cmsProvider->getSession()->commit();
+
+        // receives the first message
+        auto_ptr<TextMessage> inbound1(
+            dynamic_cast<TextMessage*>( cmsProvider->getConsumer()->receive( 1500 ) ) );
+
+        // receives the second message
+        auto_ptr<cms::TextMessage> inbound2(
+            dynamic_cast<TextMessage*>( cmsProvider->getConsumer()->receive( 4000 ) ) );
+
+        // validates that the rollbacked was not consumed
+        cmsProvider->getSession()->commit();
+
+        CPPUNIT_ASSERT( outbound1->getText() == inbound1->getText() );
+        CPPUNIT_ASSERT( outbound2->getText() == inbound2->getText() );
+    }
+    AMQ_CATCH_RETHROW( ActiveMQException )
+    AMQ_CATCHALL_THROW( ActiveMQException )
+}

Propchange: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.h?rev=723374&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.h (added)
+++ activemq/activemq-cpp/trunk/src/test-integration/activemq/test/TransactionTest.h Thu Dec  4 08:56:21 2008
@@ -0,0 +1,51 @@
+/*
+ * 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_TEST_TRANSACTIONTEST_H_
+#define _ACTIVEMQ_TEST_TRANSACTIONTEST_H_
+
+#include <activemq/test/CMSTestFixture.h>
+#include <activemq/util/IntegrationCommon.h>
+
+namespace activemq{
+namespace test{
+
+    class TransactionTest : public CMSTestFixture {
+    private:
+
+        static const int batchCount = 10;
+        static const int batchSize = 20;
+
+    public:
+
+        TransactionTest() {}
+        virtual ~TransactionTest() {}
+
+        virtual void setUp() {
+            cmsProvider.reset(
+                new util::CMSProvider( getBrokerURL(), cms::Session::SESSION_TRANSACTED ) );
+        };
+
+        void testSendReceiveTransactedBatches();
+        void testSendRollback();
+        void testSendSessionClose();
+
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_TEST_TRANSACTIONTEST_H_*/

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



Mime
View raw message