diff options
Diffstat (limited to 'cpp/src/tests')
-rw-r--r-- | cpp/src/tests/Cluster.cpp | 30 | ||||
-rw-r--r-- | cpp/src/tests/FramingTest.cpp | 1 | ||||
-rw-r--r-- | cpp/src/tests/Makefile.am | 6 |
3 files changed, 32 insertions, 5 deletions
diff --git a/cpp/src/tests/Cluster.cpp b/cpp/src/tests/Cluster.cpp index 2ec140b924..95cd607979 100644 --- a/cpp/src/tests/Cluster.cpp +++ b/cpp/src/tests/Cluster.cpp @@ -22,13 +22,14 @@ #include "Cluster.h" #include "qpid/framing/ChannelPingBody.h" #include "qpid/framing/ChannelOkBody.h" +#include "qpid/cluster/ClassifierHandler.h" static const ProtocolVersion VER; using namespace qpid::log; /** Verify membership in a cluster with one member. */ -BOOST_AUTO_TEST_CASE(clusterOne) { +BOOST_AUTO_TEST_CASE(testClusterOne) { TestCluster cluster("clusterOne", "amqp:one:1"); AMQFrame frame(VER, 1, new ChannelPingBody(VER)); cluster.getToChains().in->handle(frame); @@ -43,7 +44,7 @@ BOOST_AUTO_TEST_CASE(clusterOne) { } /** Fork a process to test a cluster with two members */ -BOOST_AUTO_TEST_CASE(clusterTwo) { +BOOST_AUTO_TEST_CASE(testClusterTwo) { pid_t pid=fork(); BOOST_REQUIRE(pid >= 0); if (pid) { // Parent, see Cluster_child.cpp for child. @@ -69,3 +70,28 @@ BOOST_AUTO_TEST_CASE(clusterTwo) { BOOST_REQUIRE(execl("./Cluster_child", "./Cluster_child", NULL)); } } + +struct CountHandler : public FrameHandler { + CountHandler() : count(0) {} + void handle(AMQFrame&) { count++; } + size_t count; +}; + +/** Test the ClassifierHandler */ +BOOST_AUTO_TEST_CASE(testClassifierHandlerWiring) { + AMQFrame queueDecl(VER, 0, new QueueDeclareBody(VER)); + AMQFrame messageTrans(VER, 0, new MessageTransferBody(VER)); + shared_ptr<CountHandler> wiring(new CountHandler()); + shared_ptr<CountHandler> other(new CountHandler()); + + ClassifierHandler classify(wiring, other); + + classify.handle(queueDecl); + BOOST_CHECK_EQUAL(1u, wiring->count); + BOOST_CHECK_EQUAL(0u, other->count); + + classify.handle(messageTrans); + BOOST_CHECK_EQUAL(1u, wiring->count); + BOOST_CHECK_EQUAL(1u, other->count); +} + diff --git a/cpp/src/tests/FramingTest.cpp b/cpp/src/tests/FramingTest.cpp index 9c60af7866..cac2ce986a 100644 --- a/cpp/src/tests/FramingTest.cpp +++ b/cpp/src/tests/FramingTest.cpp @@ -352,6 +352,7 @@ class FramingTest : public CppUnit::TestCase void print(std::ostream&) const {} MethodId amqpMethodId() const { return 0; } ClassId amqpClassId() const { return 0; } + FullMethodId getFullMethodId() const { return 0; } void encodeContent(Buffer& ) const {} void decodeContent(Buffer& ) {} }; diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index 5bb2c80b2c..3adf8818db 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -87,9 +87,9 @@ testprogs= \ client_test \ echo_service \ topic_listener \ - topic_publisher \ - interop_runner -check_PROGRAMS += $(testprogs) + topic_publisher + +check_PROGRAMS += $(testprogs) interop_runner TESTS_ENVIRONMENT = VALGRIND=$(VALGRIND) srcdir=$(srcdir) $(srcdir)/run_test |