summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/Cluster.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-07-03 23:51:17 +0000
committerAlan Conway <aconway@apache.org>2007-07-03 23:51:17 +0000
commit25cb687fb0079dc3021742e01bcb5ab54855e579 (patch)
treeb509caa5501346b1c42e15d72f2657d10ab51aee /qpid/cpp/src/tests/Cluster.cpp
parent3ca9356209361677fc3de22b92ee0b4c4333ef7f (diff)
downloadqpid-python-25cb687fb0079dc3021742e01bcb5ab54855e579.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@553024 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/Cluster.cpp')
-rw-r--r--qpid/cpp/src/tests/Cluster.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/qpid/cpp/src/tests/Cluster.cpp b/qpid/cpp/src/tests/Cluster.cpp
index 2ec140b924..95cd607979 100644
--- a/qpid/cpp/src/tests/Cluster.cpp
+++ b/qpid/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);
+}
+