diff options
author | Robert Greig <rgreig@apache.org> | 2006-10-20 21:21:29 +0000 |
---|---|---|
committer | Robert Greig <rgreig@apache.org> | 2006-10-20 21:21:29 +0000 |
commit | 53da5dbacf15a717760552de283519babd7e4736 (patch) | |
tree | 3c3e45125a5ad9be256001583eab1c490badfb2b | |
parent | a136ea713f4d365115f6840cb1748aea025da972 (diff) | |
download | qpid-python-53da5dbacf15a717760552de283519babd7e4736.tar.gz |
Merge from trunk up to revision 466241
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/new_persistence@466268 13f79535-47bb-0310-9956-ffa450edef68
21 files changed, 71 insertions, 112 deletions
diff --git a/cpp/Makefile b/cpp/Makefile index ce65a150b2..269fb75de5 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -44,7 +44,7 @@ include options.mk .PHONY: test all all-nogen generate unittest pythontest -test: all unittest pythontest +test: unittest pythontest # Must run this as two separate make processes to pick up generated files. all: @@ -81,41 +81,42 @@ UNITTESTS := $(UNITTESTS) $(wildcard $(COMMON_DIRS:%=test/unit/%/*Test.cpp)) # Client library. CLIENT_LIB := lib/libqpid_client.so.1.0 CLIENT_SRC := $(wildcard src/qpid/client/*.cpp) -$(CLIENT_LIB): $(CLIENT_SRC:.cpp=.o) - $(LIB_CMD) $^ $(CURDIR)/$(COMMON_LIB) +$(CLIENT_LIB): $(CLIENT_SRC:.cpp=.o) $(CURDIR)/$(COMMON_LIB) + $(LIB_CMD) $^ all-nogen: $(CLIENT_LIB) UNITTESTS := $(UNITTESTS) $(wildcard $(COMMON_DIRS:%=test/unit/%/*Test.cpp)) # Broker library. BROKER_LIB := lib/libqpid_broker.so.1.0 BROKER_SRC := $(wildcard src/qpid/broker/*.cpp) -$(BROKER_LIB): $(BROKER_SRC:.cpp=.o) - $(LIB_CMD) $^ $(CURDIR)/$(COMMON_LIB) +$(BROKER_LIB): $(BROKER_SRC:.cpp=.o) $(CURDIR)/$(COMMON_LIB) + $(LIB_CMD) $^ all-nogen: $(BROKER_LIB) UNITTESTS := $(UNITTESTS) $(wildcard test/unit/qpid/broker/*Test.cpp) # Implicit rule for unit test plugin libraries. -%Test.so: %Test.cpp +%Test.so: %Test.cpp $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB) $(CXX) -shared -o $@ $< $($(LIB)_FLAGS) -Itest/include $(CXXFLAGS) $(LDFLAGS) -lapr-1 -lcppunit $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB) ## Client tests - -all-nogen: $(wildcard test/client/*.cpp:.cpp=) +CLIENT_TEST_SRC := $(wildcard test/client/*.cpp) +all-nogen: $(CLIENT_TEST_SRC:.cpp=) test/client/%: test/client/%.cpp - $(CXX) -o $@ $< $($(LIB)_FLAGS) -Itest/include $(CXXFLAGS) $(LDFLAGS) -lapr-1 $(LINK_WITH_$(LIB)) $(LINK_WITH_$(LIB)_DEPS) + $(CXX) -o $@ $< $($(LIB)_FLAGS) -Itest/include $(CXXFLAGS) $(LDFLAGS) -lapr-1 $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(CLIENT_LIB) ## Daemon executable -bin/qpidd: src/qpidd.o $(CURDIR)/$(COMMON_LIB) - $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) -lapr-1 $^ $(CURDIR)/$(BROKER_LIB) +bin/qpidd: src/qpidd.o $(CURDIR)/$(COMMON_LIB) $(CURDIR)/$(BROKER_LIB) + $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) -lapr-1 $^ all-nogen: bin/qpidd ## Run unit tests. -unittest: $(UNITTESTS:.cpp=.so) +unittest: all DllPlugInTester -c -b $(UNITTESTS:.cpp=.so) +all-nogen: $(UNITTESTS:.cpp=.so) ## Run python tests -pythontest: bin/qpidd +pythontest: all bin/qpidd > qpidd.log & cd ../python ; ./run-tests -v -I cpp_failing.txt @@ -123,6 +124,9 @@ pythontest: bin/qpidd doxygen: doxygen/doxygen.cfg $(SOURCES) cd doxygen && doxygen doxygen.cfg +## #include dependencies +-include $(shell find src test -name '*.d') + ## Cleanup clean:: rm -f bin/* lib/* qpidd.log diff --git a/cpp/etc/stylesheets/utils.xsl b/cpp/etc/stylesheets/utils.xsl index 70743112a9..54b2e56f23 100644 --- a/cpp/etc/stylesheets/utils.xsl +++ b/cpp/etc/stylesheets/utils.xsl @@ -28,7 +28,7 @@ <xsl:when test="$t='bit'">bool</xsl:when> <xsl:when test="$t='long'">u_int32_t</xsl:when> <xsl:when test="$t='longlong'">u_int64_t</xsl:when> - <xsl:when test="$t='table'">FieldTable&</xsl:when> + <xsl:when test="$t='table'">const FieldTable&</xsl:when> <xsl:otherwise>Object /*WARNING: undefined type*/</xsl:otherwise> </xsl:choose> </xsl:function> diff --git a/cpp/src/qpid/broker/HeadersExchange.cpp b/cpp/src/qpid/broker/HeadersExchange.cpp index 12827da26b..96365e2130 100644 --- a/cpp/src/qpid/broker/HeadersExchange.cpp +++ b/cpp/src/qpid/broker/HeadersExchange.cpp @@ -41,7 +41,6 @@ namespace { HeadersExchange::HeadersExchange(const string& _name) : Exchange(_name) { } void HeadersExchange::bind(Queue::shared_ptr queue, const string& routingKey, FieldTable* args){ - std::cout << "HeadersExchange::bind" << std::endl; Locker locker(lock); std::string what = args->getString("x-match"); if (what != all && what != any) { @@ -60,7 +59,6 @@ void HeadersExchange::unbind(Queue::shared_ptr queue, const string& /*routingKey void HeadersExchange::route(Message::shared_ptr& msg, const string& /*routingKey*/, FieldTable* args){ - std::cout << "route: " << *args << std::endl; Locker locker(lock);; for (Bindings::iterator i = bindings.begin(); i != bindings.end(); ++i) { if (match(i->first, *args)) i->second->deliver(msg); diff --git a/cpp/src/qpid/broker/SessionHandlerImpl.cpp b/cpp/src/qpid/broker/SessionHandlerImpl.cpp index 157fca5acb..0713b84164 100644 --- a/cpp/src/qpid/broker/SessionHandlerImpl.cpp +++ b/cpp/src/qpid/broker/SessionHandlerImpl.cpp @@ -48,14 +48,7 @@ SessionHandlerImpl::SessionHandlerImpl(SessionContext* _context, framemax(65536), heartbeat(0) {} -SessionHandlerImpl::~SessionHandlerImpl(){ - // TODO aconway 2006-09-07: Should be auto_ptr or plain members. - delete channelHandler; - delete connectionHandler; - delete basicHandler; - delete exchangeHandler; - delete queueHandler; -} +SessionHandlerImpl::~SessionHandlerImpl(){} Channel* SessionHandlerImpl::getChannel(u_int16_t channel){ channel_iterator i = channels.find(channel); diff --git a/cpp/src/qpid/broker/SessionHandlerImpl.h b/cpp/src/qpid/broker/SessionHandlerImpl.h index 4504541623..afaae74d97 100644 --- a/cpp/src/qpid/broker/SessionHandlerImpl.h +++ b/cpp/src/qpid/broker/SessionHandlerImpl.h @@ -71,11 +71,11 @@ class SessionHandlerImpl : public virtual qpid::io::SessionHandler, AutoDelete* const cleaner; const u_int32_t timeout;//timeout for auto-deleted queues (in ms) - ConnectionHandler* connectionHandler; - ChannelHandler* channelHandler; - BasicHandler* basicHandler; - ExchangeHandler* exchangeHandler; - QueueHandler* queueHandler; + std::auto_ptr<ConnectionHandler> connectionHandler; + std::auto_ptr<ChannelHandler> channelHandler; + std::auto_ptr<BasicHandler> basicHandler; + std::auto_ptr<ExchangeHandler> exchangeHandler; + std::auto_ptr<QueueHandler> queueHandler; std::map<u_int16_t, Channel*> channels; std::vector<Queue::shared_ptr> exclusiveQueues; @@ -212,11 +212,11 @@ class SessionHandlerImpl : public virtual qpid::io::SessionHandler, virtual ~BasicHandlerImpl(){} }; - inline virtual ChannelHandler* getChannelHandler(){ return channelHandler; } - inline virtual ConnectionHandler* getConnectionHandler(){ return connectionHandler; } - inline virtual BasicHandler* getBasicHandler(){ return basicHandler; } - inline virtual ExchangeHandler* getExchangeHandler(){ return exchangeHandler; } - inline virtual QueueHandler* getQueueHandler(){ return queueHandler; } + inline virtual ChannelHandler* getChannelHandler(){ return channelHandler.get(); } + inline virtual ConnectionHandler* getConnectionHandler(){ return connectionHandler.get(); } + inline virtual BasicHandler* getBasicHandler(){ return basicHandler.get(); } + inline virtual ExchangeHandler* getExchangeHandler(){ return exchangeHandler.get(); } + inline virtual QueueHandler* getQueueHandler(){ return queueHandler.get(); } inline virtual AccessHandler* getAccessHandler(){ return 0; } inline virtual FileHandler* getFileHandler(){ return 0; } diff --git a/cpp/src/qpid/client/Channel.cpp b/cpp/src/qpid/client/Channel.cpp index 0563dbaaba..99e827488c 100644 --- a/cpp/src/qpid/client/Channel.cpp +++ b/cpp/src/qpid/client/Channel.cpp @@ -119,9 +119,7 @@ void Channel::deleteQueue(Queue& queue, bool ifunused, bool ifempty, bool synch) void Channel::bind(const Exchange& exchange, const Queue& queue, const std::string& key, const FieldTable& args, bool synch){ string e = exchange.getName(); string q = queue.getName(); - // TODO aconway 2006-10-10: not const correct, get rid of const_cast. - // - AMQFrame* frame = new AMQFrame(id, new QueueBindBody(0, q, e, key,!synch, const_cast<FieldTable&>(args))); + AMQFrame* frame = new AMQFrame(id, new QueueBindBody(0, q, e, key,!synch, args)); if(synch){ sendAndReceive(frame, queue_bind_ok); }else{ diff --git a/cpp/src/qpid/concurrent/APRThread.cpp b/cpp/src/qpid/concurrent/APRThread.cpp index f1bfa6c7da..d4d073cac6 100644 --- a/cpp/src/qpid/concurrent/APRThread.cpp +++ b/cpp/src/qpid/concurrent/APRThread.cpp @@ -27,7 +27,7 @@ void* APR_THREAD_FUNC ExecRunnable(apr_thread_t* thread, void *data){ return NULL; } -APRThread::APRThread(apr_pool_t* _pool, Runnable* _runnable) : runnable(_runnable), pool(_pool) {} +APRThread::APRThread(apr_pool_t* _pool, Runnable* _runnable) : runnable(_runnable), pool(_pool), runner(0) {} APRThread::~APRThread(){ } @@ -38,11 +38,11 @@ void APRThread::start(){ void APRThread::join(){ apr_status_t status; - CHECK_APR_SUCCESS(apr_thread_join(&status, runner)); + if (runner) CHECK_APR_SUCCESS(apr_thread_join(&status, runner)); } void APRThread::interrupt(){ - CHECK_APR_SUCCESS(apr_thread_exit(runner, APR_SUCCESS)); + if (runner) CHECK_APR_SUCCESS(apr_thread_exit(runner, APR_SUCCESS)); } unsigned int qpid::concurrent::APRThread::currentThread(){ diff --git a/cpp/src/qpid/concurrent/APRThread.h b/cpp/src/qpid/concurrent/APRThread.h index 6d3fc0a285..6328765a06 100644 --- a/cpp/src/qpid/concurrent/APRThread.h +++ b/cpp/src/qpid/concurrent/APRThread.h @@ -26,7 +26,7 @@ namespace qpid { namespace concurrent { - class APRThread : public virtual Thread + class APRThread : public Thread { const Runnable* runnable; apr_pool_t* pool; diff --git a/cpp/src/qpid/framing/AMQHeaderBody.cpp b/cpp/src/qpid/framing/AMQHeaderBody.cpp index eb360d8bc8..6bb24e67c7 100644 --- a/cpp/src/qpid/framing/AMQHeaderBody.cpp +++ b/cpp/src/qpid/framing/AMQHeaderBody.cpp @@ -63,11 +63,7 @@ void qpid::framing::AMQHeaderBody::print(std::ostream& out) const { out << "header, content_size=" << getContentSize() << " (" << size() << " bytes)" << ", headers=" ; - // TODO aconway 2006-09-26: Hack to see headers. - // Should write proper op << for BasicHeaderProperties. - // const BasicHeaderProperties* props = dynamic_cast<const BasicHeaderProperties*>(getProperties()); - // TODO aconway 2006-09-26: Lose the static cast, fix BasicHeaderProperties if (props) out << const_cast<BasicHeaderProperties*>(props)->getHeaders(); } diff --git a/cpp/src/qpid/io/APRSocket.cpp b/cpp/src/qpid/io/APRSocket.cpp index c142b04df3..824c376c3b 100644 --- a/cpp/src/qpid/io/APRSocket.cpp +++ b/cpp/src/qpid/io/APRSocket.cpp @@ -44,9 +44,7 @@ void APRSocket::write(qpid::framing::Buffer& buffer){ apr_size_t bytes; do{ bytes = buffer.available(); - apr_status_t s = apr_socket_send(socket, buffer.start(), &bytes); - // TODO aconway 2006-10-05: better error handling - assert(s == 0); + apr_socket_send(socket, buffer.start(), &bytes); buffer.move(bytes); }while(bytes > 0); } diff --git a/cpp/src/qpid/io/BlockingAPRSessionContext.cpp b/cpp/src/qpid/io/BlockingAPRSessionContext.cpp index aee223ca3b..88e6b6b0fc 100644 --- a/cpp/src/qpid/io/BlockingAPRSessionContext.cpp +++ b/cpp/src/qpid/io/BlockingAPRSessionContext.cpp @@ -122,8 +122,7 @@ void BlockingAPRSessionContext::write(){ int written = 0; apr_size_t bytes = available; while(available > written){ - apr_status_t s = apr_socket_send(socket, data + written, &bytes); - assert(s == 0); // TODO aconway 2006-10-05: Error Handling. + apr_socket_send(socket, data + written, &bytes); written += bytes; bytes = available - written; } diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp index 293380d46d..e93676513a 100644 --- a/cpp/src/qpidd.cpp +++ b/cpp/src/qpidd.cpp @@ -41,7 +41,7 @@ int main(int argc, char** argv) broker->run(); } return 0; - } catch(std::exception e) { + } catch(const std::exception& e) { std::cout << e.what() << std::endl; } return 1; diff --git a/cpp/test/client/client_test.cpp b/cpp/test/client/client_test.cpp index b899d494d7..e1c7d56573 100644 --- a/cpp/test/client/client_test.cpp +++ b/cpp/test/client/client_test.cpp @@ -17,15 +17,13 @@ */ #include <iostream> -#include "QpidError.h" -#include "Channel.h" -#include "Connection.h" -#include "FieldTable.h" -#include "Message.h" -#include "MessageListener.h" - -#include "MonitorImpl.h" - +#include "qpid/QpidError.h" +#include "qpid/client/Channel.h" +#include "qpid/client/Connection.h" +#include "qpid/client/Message.h" +#include "qpid/client/MessageListener.h" +#include "qpid/concurrent/MonitorImpl.h" +#include "qpid/framing/FieldTable.h" using namespace qpid::client; using namespace qpid::concurrent; diff --git a/cpp/test/client/topic_listener.cpp b/cpp/test/client/topic_listener.cpp index a1b8e383a0..0f383134b5 100644 --- a/cpp/test/client/topic_listener.cpp +++ b/cpp/test/client/topic_listener.cpp @@ -15,15 +15,15 @@ * limitations under the License. * */ +#include "qpid/QpidError.h" +#include "qpid/client/Channel.h" +#include "qpid/client/Connection.h" +#include "qpid/client/Exchange.h" +#include "qpid/client/MessageListener.h" +#include "qpid/client/Queue.h" +#include <apr-1/apr_time.h> #include <iostream> #include <sstream> -#include "apr_time.h" -#include "QpidError.h" -#include "Channel.h" -#include "Connection.h" -#include "Exchange.h" -#include "MessageListener.h" -#include "Queue.h" using namespace qpid::client; diff --git a/cpp/test/client/topic_publisher.cpp b/cpp/test/client/topic_publisher.cpp index fc6b7f3b30..9652c6450f 100644 --- a/cpp/test/client/topic_publisher.cpp +++ b/cpp/test/client/topic_publisher.cpp @@ -15,17 +15,17 @@ * limitations under the License. * */ -#include <iostream> -#include <cstdlib> +#include "qpid/QpidError.h" +#include "qpid/client/Channel.h" +#include "qpid/client/Connection.h" +#include "qpid/client/Exchange.h" +#include "qpid/client/MessageListener.h" +#include "qpid/client/Queue.h" +#include "qpid/concurrent/MonitorImpl.h" #include "unistd.h" -#include "apr_time.h" -#include "MonitorImpl.h" -#include "QpidError.h" -#include "Channel.h" -#include "Connection.h" -#include "Exchange.h" -#include "MessageListener.h" -#include "Queue.h" +#include <apr-1/apr_time.h> +#include <cstdlib> +#include <iostream> using namespace qpid::client; using namespace qpid::concurrent; diff --git a/cpp/test/unit/qpid/broker/ExchangeTest.cpp b/cpp/test/unit/qpid/broker/ExchangeTest.cpp index adebc87422..40fa9cb032 100644 --- a/cpp/test/unit/qpid/broker/ExchangeTest.cpp +++ b/cpp/test/unit/qpid/broker/ExchangeTest.cpp @@ -34,8 +34,6 @@ class ExchangeTest : public CppUnit::TestCase public: - // TODO aconway 2006-09-12: Need more detailed tests. - void testMe() { Queue::shared_ptr queue(new Queue("queue", true, true)); @@ -56,7 +54,6 @@ class ExchangeTest : public CppUnit::TestCase topic.route(msg, "abc", 0); direct.route(msg, "abc", 0); - // TODO aconway 2006-09-12: TODO Why no assertions? } }; diff --git a/cpp/test/unit/qpid/broker/MessageTest.cpp b/cpp/test/unit/qpid/broker/MessageTest.cpp index 210cd63934..9b4040a8ca 100644 --- a/cpp/test/unit/qpid/broker/MessageTest.cpp +++ b/cpp/test/unit/qpid/broker/MessageTest.cpp @@ -32,9 +32,6 @@ class MessageTest : public CppUnit::TestCase public: - // TODO aconway 2006-09-12: Need more detailed tests, - // need tests to assert something! - // void testMe() { APRBase::increment(); diff --git a/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp b/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp index 8d7903c4ac..6a15573e51 100644 --- a/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp +++ b/cpp/test/unit/qpid/broker/TopicExchangeTest.cpp @@ -17,8 +17,6 @@ Tokens makeTokens(char** begin, char** end) #define TOKENS(a) makeTokens(a, a + LEN(a)) // Allow CPPUNIT_EQUALS to print a Tokens. -// TODO aconway 2006-09-19: Make it a template and put it in a shared test lib. -// CppUnit::OStringStream& operator <<(CppUnit::OStringStream& out, const Tokens& v) { out << "[ "; diff --git a/cpp/test/unit/qpid/broker/ValueTest.cpp b/cpp/test/unit/qpid/broker/ValueTest.cpp index 2cb2563b46..8ea536f59f 100644 --- a/cpp/test/unit/qpid/broker/ValueTest.cpp +++ b/cpp/test/unit/qpid/broker/ValueTest.cpp @@ -4,18 +4,6 @@ using namespace qpid::framing; -// Allow CPPUNIT_EQUALS to print a Tokens. -// TODO aconway 2006-09-19: Make it a template and put it in a shared test lib. -// -template <class T> -CppUnit::OStringStream& operator <<(CppUnit::OStringStream& out, - const ValueOps<T>& v) -{ - out << v.getValue(); - return out; -} - - class ValueTest : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(ValueTest); diff --git a/cpp/test/unit/qpid/framing/FramingTest.cpp b/cpp/test/unit/qpid/framing/FramingTest.cpp index 950d1e045a..ad2d651fe0 100644 --- a/cpp/test/unit/qpid/framing/FramingTest.cpp +++ b/cpp/test/unit/qpid/framing/FramingTest.cpp @@ -15,17 +15,15 @@ * limitations under the License. * */ -#include "qpid/framing/amqp_framing.h" #include "qpid/framing/ConnectionRedirectBody.h" +#include "qpid/framing/amqp_framing.h" #include <iostream> -#include <sstream> #include <qpid_test_plugin.h> +#include <sstream> #include <typeinfo> using namespace qpid::framing; -// TODO aconway 2006-09-12: Why do we need explicit qpid::framing:: below? - template <class T> std::string tostring(const T& x) { @@ -42,8 +40,8 @@ class FramingTest : public CppUnit::TestCase CPPUNIT_TEST(testConnectionRedirectBody); CPPUNIT_TEST(testAccessRequestBody); CPPUNIT_TEST(testBasicConsumeBody); - CPPUNIT_TEST(ConnectionRedirectBody); - CPPUNIT_TEST(BasicConsumeOkBody); + CPPUNIT_TEST(testConnectionRedirectBodyFrame); + CPPUNIT_TEST(testBasicConsumeOkBodyFrame); CPPUNIT_TEST_SUITE_END(); private: @@ -78,10 +76,10 @@ class FramingTest : public CppUnit::TestCase { std::string a = "hostA"; std::string b = "hostB"; - qpid::framing::ConnectionRedirectBody in(a, b); + ConnectionRedirectBody in(a, b); in.encodeContent(buffer); buffer.flip(); - qpid::framing::ConnectionRedirectBody out; + ConnectionRedirectBody out; out.decodeContent(buffer); CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); } @@ -110,11 +108,11 @@ class FramingTest : public CppUnit::TestCase } - void ConnectionRedirectBody() + void testConnectionRedirectBodyFrame() { std::string a = "hostA"; std::string b = "hostB"; - AMQFrame in(999, new qpid::framing::ConnectionRedirectBody(a, b)); + AMQFrame in(999, new ConnectionRedirectBody(a, b)); in.encode(buffer); buffer.flip(); AMQFrame out; @@ -122,10 +120,10 @@ class FramingTest : public CppUnit::TestCase CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out)); } - void BasicConsumeOkBody() + void testBasicConsumeOkBodyFrame() { std::string s = "hostA"; - AMQFrame in(999, new qpid::framing::BasicConsumeOkBody(s)); + AMQFrame in(999, new BasicConsumeOkBody(s)); in.encode(buffer); buffer.flip(); AMQFrame out; diff --git a/cpp/test/unit/qpid/framing/HeaderTest.cpp b/cpp/test/unit/qpid/framing/HeaderTest.cpp index cf0d9fe5bd..8b613127b1 100644 --- a/cpp/test/unit/qpid/framing/HeaderTest.cpp +++ b/cpp/test/unit/qpid/framing/HeaderTest.cpp @@ -31,9 +31,6 @@ class HeaderTest : public CppUnit::TestCase public: - // TODO aconway 2006-09-12: Need more detailed tests, - // need tests to assert something! - // void testGenericProperties() { AMQHeaderBody body(BASIC); |