diff options
author | Alan Conway <aconway@apache.org> | 2007-07-03 23:51:17 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-07-03 23:51:17 +0000 |
commit | c601e5c7ea901afc71a6a82f61b3945022ae9e28 (patch) | |
tree | d6ce165deaa024fcfaa381eda59bca0ca9609873 /cpp/src/tests/Cluster.cpp | |
parent | 653f0ed6cb89b0b38d295139c102c94352fb8a97 (diff) | |
download | qpid-python-c601e5c7ea901afc71a6a82f61b3945022ae9e28.tar.gz |
* cluster/ClasifierHandler: classifies frames for clustering treatment.
Currently classifies wiring separately from everything else.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@553024 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Cluster.cpp')
-rw-r--r-- | cpp/src/tests/Cluster.cpp | 30 |
1 files changed, 28 insertions, 2 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); +} + |