diff options
Diffstat (limited to 'cpp/src')
26 files changed, 265 insertions, 83 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index b3c6b8a13d..08d2e7b1d9 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -236,6 +236,7 @@ nobase_include_HEADERS = \ qpid/Msg.h \ qpid/Options.h \ qpid/Plugin.h \ + qpid/ptr_map.h \ qpid/RefCounted.h \ qpid/SharedObject.h \ qpid/Url.h \ diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index f981d47ef7..26146e80d4 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -18,24 +18,26 @@ * under the License. * */ -#include "qpid/log/Statement.h" -#include <iostream> -#include <assert.h> - #include "Connection.h" #include "SessionState.h" -#include "qpid/framing/AMQP_ClientProxy.h" #include "BrokerAdapter.h" #include "SemanticHandler.h" +#include "qpid/log/Statement.h" +#include "qpid/ptr_map.h" +#include "qpid/framing/AMQP_ClientProxy.h" + #include <boost/bind.hpp> #include <algorithm> +#include <iostream> +#include <assert.h> using namespace boost; using namespace qpid::sys; using namespace qpid::framing; using namespace qpid::sys; +using namespace qpid::ptr_map; namespace qpid { namespace broker { @@ -77,9 +79,8 @@ void Connection::idleIn(){} void Connection::closed(){ // Physically closed, suspend open sessions. try { - std::for_each( - channels.begin(), channels.end(), - boost::bind(&SessionHandler::localSuspend, _1)); + for (ChannelMap::iterator i = channels.begin(); i != channels.end(); ++i) + get_pointer(i)->localSuspend(); while (!exclusiveQueues.empty()) { Queue::shared_ptr q(exclusiveQueues.front()); q->releaseExclusiveOwnership(); @@ -105,7 +106,7 @@ SessionHandler& Connection::getChannel(ChannelId id) { if (i == channels.end()) { i = channels.insert(id, new SessionHandler(*this, id)).first; } - return *i; + return *get_pointer(i); } }} diff --git a/cpp/src/qpid/broker/DtxManager.cpp b/cpp/src/qpid/broker/DtxManager.cpp index 7ac89d3a4e..1d8b64eb5b 100644 --- a/cpp/src/qpid/broker/DtxManager.cpp +++ b/cpp/src/qpid/broker/DtxManager.cpp @@ -22,10 +22,13 @@ #include "DtxTimeout.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/log/Statement.h" +#include "qpid/ptr_map.h" + #include <boost/format.hpp> #include <iostream> -using qpid::sys::Mutex; +using qpid::sys::Mutex; +using namespace qpid::ptr_map; using namespace qpid::broker; using namespace qpid::framing; @@ -81,14 +84,14 @@ void DtxManager::rollback(const std::string& xid) } } -DtxManager::WorkMap::iterator DtxManager::getWork(const std::string& xid) +DtxWorkRecord* DtxManager::getWork(const std::string& xid) { Mutex::ScopedLock locker(lock); WorkMap::iterator i = work.find(xid); if (i == work.end()) { throw InvalidArgumentException(QPID_MSG("Unrecognised xid " << xid)); } - return i; + return get_pointer(i); } void DtxManager::remove(const std::string& xid) @@ -102,20 +105,20 @@ void DtxManager::remove(const std::string& xid) } } -DtxManager::WorkMap::iterator DtxManager::createWork(std::string xid) +DtxWorkRecord* DtxManager::createWork(std::string xid) { Mutex::ScopedLock locker(lock); WorkMap::iterator i = work.find(xid); if (i != work.end()) { throw CommandInvalidException(QPID_MSG("Xid " << xid << " is already known (use 'join' to add work to an existing xid)")); } else { - return work.insert(xid, new DtxWorkRecord(xid, store)).first; + return get_pointer(work.insert(xid, new DtxWorkRecord(xid, store)).first); } } void DtxManager::setTimeout(const std::string& xid, uint32_t secs) { - WorkMap::iterator record = getWork(xid); + DtxWorkRecord* record = getWork(xid); DtxTimeout::shared_ptr timeout = record->getTimeout(); if (timeout.get()) { if (timeout->timeout == secs) return;//no need to do anything further if timeout hasn't changed @@ -140,7 +143,7 @@ void DtxManager::timedout(const std::string& xid) if (i == work.end()) { QPID_LOG(warning, "Transaction timeout failed: no record for xid"); } else { - i->timedout(); + get_pointer(i)->timedout(); //TODO: do we want to have a timed task to cleanup, or can we rely on an explicit completion? //timer.add(TimerTask::shared_ptr(new DtxCleanup(60*30/*30 mins*/, *this, xid))); } diff --git a/cpp/src/qpid/broker/DtxManager.h b/cpp/src/qpid/broker/DtxManager.h index 3db3f70685..64eae1488d 100644 --- a/cpp/src/qpid/broker/DtxManager.h +++ b/cpp/src/qpid/broker/DtxManager.h @@ -35,7 +35,6 @@ namespace broker { class DtxManager{ typedef boost::ptr_map<std::string, DtxWorkRecord> WorkMap; - struct DtxCleanup : public TimerTask { DtxManager& mgr; @@ -51,8 +50,8 @@ class DtxManager{ Timer timer; void remove(const std::string& xid); - WorkMap::iterator getWork(const std::string& xid); - WorkMap::iterator createWork(std::string xid); + DtxWorkRecord* getWork(const std::string& xid); + DtxWorkRecord* createWork(std::string xid); public: DtxManager(TransactionalStore* const store); diff --git a/cpp/src/qpid/ptr_map.h b/cpp/src/qpid/ptr_map.h new file mode 100644 index 0000000000..c33f63767d --- /dev/null +++ b/cpp/src/qpid/ptr_map.h @@ -0,0 +1,116 @@ +#ifndef QPID_PTR_MAP +#define QPID_PTR_MAP + +/* + * + * 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 <boost/ptr_container/ptr_map.hpp> +#include <boost/version.hpp> + +namespace qpid { +namespace ptr_map { + +/** @file + * Workaround for API change between boost 1.33 and 1.34. + * + * To be portable across these versions, code using boost::ptr_map + * iterators should use get_pointer(i) to get the pointer from + * a boost::ptr_map iterator. + * + * Can be removed when we no longer support platforms on 1.33. + * + * @see http://www.boost.org/libs/ptr_container/doc/ptr_container.html#upgrading-from-boost-v-1-33 + */ +#if (BOOST_VERSION < 103400) + +template <class PtrMapIter> +typename PtrMapIter::pointer get_pointer(const PtrMapIter& i) +{ return &*i; } + +#else + +template <class PtrMapIter> +typename PtrMapIter::value_type::second_type get_pointer(const PtrMapIter& i) +{ return i->second; } + +#endif + +}} // namespace qpid::ptr_map + +#endif /*!QPID_PTR_MAP*/ +#ifndef QPID_PTR_MAP +#define QPID_PTR_MAP + +/* + * + * 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 <boost/ptr_container/ptr_map.hpp> +#include <boost/version.hpp> + +namespace qpid { +namespace ptr_map { + +/** @file + * Workaround for API change between boost 1.33 and 1.34. + * + * To be portable across these versions, code using boost::ptr_map + * iterators should use get_pointer(i) to get the pointer from + * a boost::ptr_map iterator. + * + * Can be removed when we no longer support platforms on 1.33. + * + * @see http://www.boost.org/libs/ptr_container/doc/ptr_container.html#upgrading-from-boost-v-1-33 + */ +#if (BOOST_VERSION < 103400) + +template <class PtrMapIter> +typename PtrMapIter::pointer get_pointer(const PtrMapIter& i) +{ return &*i; } + +#else + +template <class PtrMapIter> +typename PtrMapIter::value_type::second_type get_pointer(const PtrMapIter& i) +{ return i->second; } + +#endif + +}} // namespace qpid::ptr_map + +#endif /*!QPID_PTR_MAP*/ diff --git a/cpp/src/tests/Array.cpp b/cpp/src/tests/Array.cpp index 5bf7fadce0..336e57b485 100644 --- a/cpp/src/tests/Array.cpp +++ b/cpp/src/tests/Array.cpp @@ -23,8 +23,9 @@ #include "qpid/framing/Array.h" #include "qpid/framing/FieldValue.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Array); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(ArrayTestSuite) using namespace qpid::framing; @@ -75,4 +76,4 @@ BOOST_AUTO_TEST_CASE(testAssignment) BOOST_CHECK(data == data2); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Blob.cpp b/cpp/src/tests/Blob.cpp index d10cbf20c0..d27c0bbd85 100644 --- a/cpp/src/tests/Blob.cpp +++ b/cpp/src/tests/Blob.cpp @@ -18,9 +18,9 @@ */ #include "qpid/framing/Blob.h" -#include <boost/test/auto_unit_test.hpp> +#include "unit_test.h" -BOOST_AUTO_TEST_SUITE(Blob); +QPID_AUTO_TEST_SUITE(BlobTestSuite) using namespace std; using namespace qpid::framing; @@ -125,4 +125,4 @@ BOOST_AUTO_TEST_CASE(testClear) { BOOST_CHECK_EQUAL(0, Foo::instances); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Cluster.cpp b/cpp/src/tests/Cluster.cpp index 635126053f..b448128620 100644 --- a/cpp/src/tests/Cluster.cpp +++ b/cpp/src/tests/Cluster.cpp @@ -24,11 +24,12 @@ #include "qpid/framing/all_method_bodies.h" #include "qpid/cluster/ClassifierHandler.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Cluster); +#include "unit_test.h" #include <sys/wait.h> +QPID_AUTO_TEST_SUITE(ClusterTestSuite) + static const ProtocolVersion VER; /** Verify membership in a cluster with one member. */ @@ -107,4 +108,4 @@ BOOST_AUTO_TEST_CASE(testClassifierHandlerWiring) { BOOST_CHECK_EQUAL(1u, other.count); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Cpg.cpp b/cpp/src/tests/Cpg.cpp index 06c8aec9ef..fddfe9ef05 100644 --- a/cpp/src/tests/Cpg.cpp +++ b/cpp/src/tests/Cpg.cpp @@ -22,8 +22,7 @@ #include "qpid/framing/AMQBody.h" #include <boost/bind.hpp> -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Cpg); +#include "unit_test.h" #include <string> #include <iostream> @@ -31,6 +30,9 @@ BOOST_AUTO_TEST_SUITE(Cpg); #include <vector> #include <algorithm> +QPID_AUTO_TEST_SUITE(CpgTestSuite) + + using namespace std; using namespace qpid::cluster; using namespace qpid::framing; @@ -106,4 +108,4 @@ BOOST_AUTO_TEST_CASE(CpgBasic) { } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/FieldTable.cpp b/cpp/src/tests/FieldTable.cpp index ee23360d9a..db4c4906fa 100644 --- a/cpp/src/tests/FieldTable.cpp +++ b/cpp/src/tests/FieldTable.cpp @@ -22,11 +22,12 @@ #include "qpid/framing/FieldTable.h" #include "qpid/framing/FieldValue.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(FieldTable); +#include "unit_test.h" using namespace qpid::framing; +QPID_AUTO_TEST_SUITE(FieldTableTestSuite) + BOOST_AUTO_TEST_CASE(testMe) { FieldTable ft; @@ -80,4 +81,4 @@ BOOST_AUTO_TEST_CASE(testAssignment) BOOST_CHECK(IntegerValue(1234) == *d.get("B")); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/FieldValue.cpp b/cpp/src/tests/FieldValue.cpp index a852a07327..a820ae57bd 100644 --- a/cpp/src/tests/FieldValue.cpp +++ b/cpp/src/tests/FieldValue.cpp @@ -18,8 +18,9 @@ */ #include "qpid/framing/FieldValue.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(FieldValue); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(FieldValueTestSuite) using namespace qpid::framing; @@ -86,4 +87,4 @@ BOOST_AUTO_TEST_CASE(testFieldTableValueEquals) } #endif -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Frame.cpp b/cpp/src/tests/Frame.cpp index c0839b67d7..0484dc4b2a 100644 --- a/cpp/src/tests/Frame.cpp +++ b/cpp/src/tests/Frame.cpp @@ -21,8 +21,9 @@ #include "qpid/framing/Frame.h" #include <boost/lexical_cast.hpp> -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Frame); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(FrameTestSuite) using namespace std; using namespace qpid::framing; @@ -76,4 +77,4 @@ BOOST_AUTO_TEST_CASE(testLoop) { } } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/InlineVector.cpp b/cpp/src/tests/InlineVector.cpp index a213f24809..d1b3ebf7de 100644 --- a/cpp/src/tests/InlineVector.cpp +++ b/cpp/src/tests/InlineVector.cpp @@ -20,8 +20,9 @@ */ #include "qpid/InlineVector.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(InlineVector); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(InlineVectorTestSuite) using namespace qpid; using namespace std; @@ -85,4 +86,4 @@ BOOST_AUTO_TEST_CASE(testInsert) { } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index 5265411b54..c3f48b0366 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) $(APR_CXXFLAGS) +AM_CXXFLAGS = $(WARNING_CFLAGS) $(CPPUNIT_CXXFLAGS) $(APR_CXXFLAGS) -DBOOST_TEST_DYN_LINK INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../gen -I$(top_builddir)/src/gen abs_builddir=@abs_builddir@ diff --git a/cpp/src/tests/RefCounted.cpp b/cpp/src/tests/RefCounted.cpp index 1d453aedd1..d111d58712 100644 --- a/cpp/src/tests/RefCounted.cpp +++ b/cpp/src/tests/RefCounted.cpp @@ -18,8 +18,9 @@ #include "qpid/RefCounted.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(RefCounted); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(RefCountedTestSuiteTestSuite) using namespace std; using namespace qpid; @@ -69,4 +70,4 @@ BOOST_AUTO_TEST_CASE(testRefCounted) { BOOST_CHECK_EQUAL(0, CountMe::instances); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/RefCountedMap.cpp b/cpp/src/tests/RefCountedMap.cpp index ba98401b92..1875b8161c 100644 --- a/cpp/src/tests/RefCountedMap.cpp +++ b/cpp/src/tests/RefCountedMap.cpp @@ -18,10 +18,10 @@ #include "qpid/sys/RefCountedMap.h" -#include <boost/test/auto_unit_test.hpp> +#include "unit_test.h" #include <boost/bind.hpp> -BOOST_AUTO_TEST_SUITE(RefCountedMap); +QPID_AUTO_TEST_SUITE(RefCountedMapTestSuite) using namespace std; using namespace qpid; @@ -121,3 +121,5 @@ BOOST_AUTO_TEST_CASE(testRefCountedMapAttachClose) { BOOST_CHECK_EQUAL(0, Data::instances); BOOST_CHECK_EQUAL(0, Attachment::instances); } + +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Serializer.cpp b/cpp/src/tests/Serializer.cpp index 0d52eef711..51b739218d 100644 --- a/cpp/src/tests/Serializer.cpp +++ b/cpp/src/tests/Serializer.cpp @@ -26,13 +26,15 @@ #include <boost/bind.hpp> #include <boost/utility/value_init.hpp> -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Serializer); +#include "unit_test.h" #include <set> #include <unistd.h> +QPID_AUTO_TEST_SUITE(SerializerTestSuite) + + using namespace qpid; using namespace qpid::sys; using namespace qpid::framing; @@ -152,4 +154,4 @@ BOOST_AUTO_TEST_CASE(testExternalDispatch) { BOOST_CHECK(Thread::logId() != *tester.threads.begin()); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/SessionState.cpp b/cpp/src/tests/SessionState.cpp index b8d0560c48..56d0055ed8 100644 --- a/cpp/src/tests/SessionState.cpp +++ b/cpp/src/tests/SessionState.cpp @@ -17,10 +17,12 @@ */ #include "qpid/framing/SessionState.h" +#include "qpid/Exception.h" #include <boost/bind.hpp> -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(SessionState); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(SessionStateTestSuite) using namespace std; using namespace qpid::framing; @@ -119,7 +121,7 @@ BOOST_AUTO_TEST_CASE(testReplay) { try { session.receivedAck(6); BOOST_FAIL("expected exception"); - } catch(const qpid::Exception&) {} + } catch(const std::exception&) {} } @@ -141,4 +143,4 @@ BOOST_AUTO_TEST_CASE(testReceived) { BOOST_CHECK_EQUAL(5u, *s3.received(f)); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Shlib.cpp b/cpp/src/tests/Shlib.cpp index f394f7c795..3adc33aac9 100644 --- a/cpp/src/tests/Shlib.cpp +++ b/cpp/src/tests/Shlib.cpp @@ -22,8 +22,9 @@ #include "qpid/sys/Shlib.h" #include "qpid/Exception.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Shlib); +#include "unit_test.h" + +QPID_AUTO_TEST_SUITE(ShlibTestSuite) using namespace qpid::sys; typedef void (*CallMe)(int*); @@ -56,4 +57,4 @@ BOOST_AUTO_TEST_CASE(testAutoShlib) { } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Url.cpp b/cpp/src/tests/Url.cpp index a1ce2b8cf5..5d376e3439 100644 --- a/cpp/src/tests/Url.cpp +++ b/cpp/src/tests/Url.cpp @@ -17,7 +17,7 @@ */ -#include <boost/test/auto_unit_test.hpp> +#include "unit_test.h" #include "test_tools.h" #include "qpid/Url.h" #include <boost/assign.hpp> @@ -26,7 +26,7 @@ using namespace std; using namespace qpid; using namespace boost::assign; -BOOST_AUTO_TEST_SUITE(Url); +QPID_AUTO_TEST_SUITE(UrlTestSuite) BOOST_AUTO_TEST_CASE(testUrl_str) { Url url; @@ -61,4 +61,4 @@ BOOST_AUTO_TEST_CASE(testUrl_parse) { } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/Uuid.cpp b/cpp/src/tests/Uuid.cpp index 6926077d30..c158cf53d2 100644 --- a/cpp/src/tests/Uuid.cpp +++ b/cpp/src/tests/Uuid.cpp @@ -19,11 +19,12 @@ #include "qpid/framing/Uuid.h" #include "qpid/framing/Buffer.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(Uuid); +#include "unit_test.h" #include <set> +QPID_AUTO_TEST_SUITE(UuidTestSuite) + using namespace std; using namespace qpid::framing; @@ -74,4 +75,4 @@ BOOST_AUTO_TEST_CASE(testUuidEncodeDecode) { string(decoded.begin(), decoded.end())); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/cluster_client.cpp b/cpp/src/tests/cluster_client.cpp index d3ce25540d..c74d7329f0 100644 --- a/cpp/src/tests/cluster_client.cpp +++ b/cpp/src/tests/cluster_client.cpp @@ -19,14 +19,15 @@ #include "qpid/client/Connection.h" #include "qpid/shared_ptr.h" -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(cluster_client); +#include "unit_test.h" #include <fstream> #include <vector> #include <functional> +QPID_AUTO_TEST_SUITE(cluster_clientTestSuite) + using namespace std; using namespace qpid; using namespace qpid::client; @@ -78,4 +79,4 @@ BOOST_AUTO_TEST_CASE(testWiringReplication) { } } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/interop_runner.cpp b/cpp/src/tests/interop_runner.cpp index 56f9cbf3d2..824af7f3b7 100644 --- a/cpp/src/tests/interop_runner.cpp +++ b/cpp/src/tests/interop_runner.cpp @@ -20,6 +20,7 @@ */ #include "qpid/Options.h" +#include "qpid/ptr_map.h" #include "qpid/Exception.h" #include "qpid/client/Channel.h" #include "qpid/client/Connection.h" @@ -71,7 +72,7 @@ class Listener : public MessageListener, private Runnable{ TestMap tests; const string name; const string topic; - TestMap::iterator test; + TestCase* test; auto_ptr<Thread> runner; ReplyTo reportTo; string reportCorrelator; @@ -186,7 +187,7 @@ void Listener::received(Message& message) test->stop(); sendReport(); } else if (type == "TERMINATE") { - if (test != tests.end()) test->stop(); + if (test) test->stop(); shutdown(); } else { cerr <<"ERROR!: Received unknown control message: " << type << endl; @@ -201,8 +202,9 @@ void Listener::shutdown() bool Listener::invite(const string& name) { - test = tests.find(name); - return test != tests.end(); + TestMap::iterator i = tests.find(name); + test = (i != tests.end()) ? qpid::ptr_map::get_pointer(i) : 0; + return test; } void Listener::run() diff --git a/cpp/src/tests/logging.cpp b/cpp/src/tests/logging.cpp index 0f7ad3f4d5..2065b031e7 100644 --- a/cpp/src/tests/logging.cpp +++ b/cpp/src/tests/logging.cpp @@ -16,7 +16,6 @@ * */ - #include "test_tools.h" #include "qpid/log/Logger.h" #include "qpid/log/Options.h" @@ -25,14 +24,15 @@ #include <boost/test/floating_point_comparison.hpp> #include <boost/format.hpp> -#include <boost/test/auto_unit_test.hpp> -BOOST_AUTO_TEST_SUITE(logging); +#include "unit_test.h" #include <exception> #include <fstream> #include <time.h> +QPID_AUTO_TEST_SUITE(loggingTestSuite) + using namespace std; using namespace boost; using namespace qpid::log; @@ -42,7 +42,6 @@ BOOST_AUTO_TEST_CASE(testStatementInit) { BOOST_CHECK(!s.enabled); BOOST_CHECK_EQUAL(string(__FILE__), s.file); BOOST_CHECK_EQUAL(line, s.line); - BOOST_CHECK_EQUAL(string("void testStatementInit()"), s.function); BOOST_CHECK_EQUAL(debug, s.level); } @@ -141,7 +140,6 @@ BOOST_AUTO_TEST_CASE(testMacro) { vector<string> expect=list_of("foo\n"); BOOST_CHECK_EQUAL(expect, out->msg); BOOST_CHECK_EQUAL(__FILE__, out->stmt.front().file); - BOOST_CHECK_EQUAL("void testMacro()", out->stmt.front().function); // Not enabled: QPID_LOG(debug, "bar"); @@ -173,7 +171,6 @@ BOOST_AUTO_TEST_CASE(testLoggerFormat) { l.format(Logger::FUNCTION); QPID_LOG(critical, "foo"); - BOOST_CHECK_EQUAL("void testLoggerFormat(): foo\n", out->last()); l.format(Logger::LEVEL); QPID_LOG(critical, "foo"); @@ -181,7 +178,7 @@ BOOST_AUTO_TEST_CASE(testLoggerFormat) { l.format(~0); // Everything QPID_LOG(critical, "foo"); - re=".* critical \\[[0-9a-f]*] "+string(__FILE__)+":\\d+:void testLoggerFormat\\(\\): foo\n"; + re=".* critical \\[[0-9a-f]*] "+string(__FILE__)+":\\d+:void .*testLoggerFormat.*\\(\\): foo\n"; BOOST_CHECK_REGEX(re, out->last()); } @@ -370,4 +367,4 @@ BOOST_AUTO_TEST_CASE(testLoggerConfigure) { unlink("logging.tmp"); } -BOOST_AUTO_TEST_SUITE_END(); +QPID_AUTO_TEST_SUITE_END() diff --git a/cpp/src/tests/unit_test.cpp b/cpp/src/tests/unit_test.cpp index aed6f6a4af..00c61242e4 100644 --- a/cpp/src/tests/unit_test.cpp +++ b/cpp/src/tests/unit_test.cpp @@ -16,7 +16,8 @@ * */ -#define BOOST_AUTO_TEST_MAIN // Must come before #include<boost/test/*> -#include <boost/test/auto_unit_test.hpp> - // Defines test_main function to link with actual unit test code. +#define BOOST_AUTO_TEST_MAIN // Boost 1.33 +#define BOOST_TEST_MAIN +#include "unit_test.h" + diff --git a/cpp/src/tests/unit_test.h b/cpp/src/tests/unit_test.h new file mode 100644 index 0000000000..83e2ce39f8 --- /dev/null +++ b/cpp/src/tests/unit_test.h @@ -0,0 +1,44 @@ +#ifndef QPIPD_TEST_UNIT_TEST_H_ +#define QPIPD_TEST_UNIT_TEST_H_ + +/* + * + * 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. + * + */ + +// Workaround so we can build against boost 1.33 and boost 1.34. +// Remove when we no longer need to support 1.33. +// + +#if (BOOST_VERSION < 103400) + +# include <boost/test/auto_unit_test.hpp> + +# define QPID_AUTO_TEST_SUITE(name) BOOST_AUTO_TEST_SUITE(name); +# define QPID_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END(); + +#else + +# define QPID_AUTO_TEST_SUITE(name) BOOST_AUTO_TEST_SUITE(name) +# define QPID_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END() + +# include <boost/test/unit_test.hpp> +#endif + +#endif /*!QPIPD_TEST_UNIT_TEST_H_*/ |