summaryrefslogtreecommitdiff
path: root/cpp/src/tests/ExchangeTest.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-05-30 08:13:21 +0000
committerGordon Sim <gsim@apache.org>2008-05-30 08:13:21 +0000
commit5d2f67ee3918516feebc4994d5b21a893ef97a5b (patch)
tree4c13e462ca37f7ce5e8a9564cec5f1e92410e5ab /cpp/src/tests/ExchangeTest.cpp
parent162cb3879f3e25cbd13a777b40e374196ab531c9 (diff)
downloadqpid-python-5d2f67ee3918516feebc4994d5b21a893ef97a5b.tar.gz
Convert remaining cppunit tests to boost test framework to reduce dependencies.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@661587 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/ExchangeTest.cpp')
-rw-r--r--cpp/src/tests/ExchangeTest.cpp261
1 files changed, 125 insertions, 136 deletions
diff --git a/cpp/src/tests/ExchangeTest.cpp b/cpp/src/tests/ExchangeTest.cpp
index 0b69f76a76..e496f0c478 100644
--- a/cpp/src/tests/ExchangeTest.cpp
+++ b/cpp/src/tests/ExchangeTest.cpp
@@ -29,7 +29,7 @@
#include "qpid/broker/HeadersExchange.h"
#include "qpid/broker/TopicExchange.h"
#include "qpid/framing/reply_exceptions.h"
-#include "qpid_test_plugin.h"
+#include "unit_test.h"
#include <iostream>
#include "MessageUtils.h"
@@ -39,141 +39,130 @@ using namespace qpid::framing;
using namespace qpid::sys;
using namespace qpid;
-class ExchangeTest : public CppUnit::TestCase
+QPID_AUTO_TEST_SUITE(ExchangeTestSuite)
+
+QPID_AUTO_TEST_CASE(testMe)
{
- CPPUNIT_TEST_SUITE(ExchangeTest);
- CPPUNIT_TEST(testMe);
- CPPUNIT_TEST(testIsBound);
- CPPUNIT_TEST(testDeleteGetAndRedeclare);
- CPPUNIT_TEST_SUITE_END();
-
- public:
-
- void testMe()
- {
- Queue::shared_ptr queue(new Queue("queue", true));
- Queue::shared_ptr queue2(new Queue("queue2", true));
-
- TopicExchange topic("topic");
- topic.bind(queue, "abc", 0);
- topic.bind(queue2, "abc", 0);
-
- DirectExchange direct("direct");
- direct.bind(queue, "abc", 0);
- direct.bind(queue2, "abc", 0);
-
- queue.reset();
- queue2.reset();
-
- intrusive_ptr<Message> msgPtr(MessageUtils::createMessage("exchange", "key", "id"));
- DeliverableMessage msg(msgPtr);
- topic.route(msg, "abc", 0);
- direct.route(msg, "abc", 0);
-
- }
-
- void testIsBound()
- {
- Queue::shared_ptr a(new Queue("a", true));
- Queue::shared_ptr b(new Queue("b", true));
- Queue::shared_ptr c(new Queue("c", true));
- Queue::shared_ptr d(new Queue("d", true));
+ Queue::shared_ptr queue(new Queue("queue", true));
+ Queue::shared_ptr queue2(new Queue("queue2", true));
+
+ TopicExchange topic("topic");
+ topic.bind(queue, "abc", 0);
+ topic.bind(queue2, "abc", 0);
+
+ DirectExchange direct("direct");
+ direct.bind(queue, "abc", 0);
+ direct.bind(queue2, "abc", 0);
+
+ queue.reset();
+ queue2.reset();
+
+ intrusive_ptr<Message> msgPtr(MessageUtils::createMessage("exchange", "key", "id"));
+ DeliverableMessage msg(msgPtr);
+ topic.route(msg, "abc", 0);
+ direct.route(msg, "abc", 0);
+
+}
+
+QPID_AUTO_TEST_CASE(testIsBound)
+{
+ Queue::shared_ptr a(new Queue("a", true));
+ Queue::shared_ptr b(new Queue("b", true));
+ Queue::shared_ptr c(new Queue("c", true));
+ Queue::shared_ptr d(new Queue("d", true));
- string k1("abc");
- string k2("def");
- string k3("xyz");
-
- FanOutExchange fanout("fanout");
- fanout.bind(a, "", 0);
- fanout.bind(b, "", 0);
- fanout.bind(c, "", 0);
-
- CPPUNIT_ASSERT(fanout.isBound(a, 0, 0));
- CPPUNIT_ASSERT(fanout.isBound(b, 0, 0));
- CPPUNIT_ASSERT(fanout.isBound(c, 0, 0));
- CPPUNIT_ASSERT(!fanout.isBound(d, 0, 0));
-
- DirectExchange direct("direct");
- direct.bind(a, k1, 0);
- direct.bind(a, k3, 0);
- direct.bind(b, k2, 0);
- direct.bind(c, k1, 0);
-
- CPPUNIT_ASSERT(direct.isBound(a, 0, 0));
- CPPUNIT_ASSERT(direct.isBound(a, &k1, 0));
- CPPUNIT_ASSERT(direct.isBound(a, &k3, 0));
- CPPUNIT_ASSERT(!direct.isBound(a, &k2, 0));
- CPPUNIT_ASSERT(direct.isBound(b, 0, 0));
- CPPUNIT_ASSERT(direct.isBound(b, &k2, 0));
- CPPUNIT_ASSERT(direct.isBound(c, &k1, 0));
- CPPUNIT_ASSERT(!direct.isBound(d, 0, 0));
- CPPUNIT_ASSERT(!direct.isBound(d, &k1, 0));
- CPPUNIT_ASSERT(!direct.isBound(d, &k2, 0));
- CPPUNIT_ASSERT(!direct.isBound(d, &k3, 0));
-
- TopicExchange topic("topic");
- topic.bind(a, k1, 0);
- topic.bind(a, k3, 0);
- topic.bind(b, k2, 0);
- topic.bind(c, k1, 0);
-
- CPPUNIT_ASSERT(topic.isBound(a, 0, 0));
- CPPUNIT_ASSERT(topic.isBound(a, &k1, 0));
- CPPUNIT_ASSERT(topic.isBound(a, &k3, 0));
- CPPUNIT_ASSERT(!topic.isBound(a, &k2, 0));
- CPPUNIT_ASSERT(topic.isBound(b, 0, 0));
- CPPUNIT_ASSERT(topic.isBound(b, &k2, 0));
- CPPUNIT_ASSERT(topic.isBound(c, &k1, 0));
- CPPUNIT_ASSERT(!topic.isBound(d, 0, 0));
- CPPUNIT_ASSERT(!topic.isBound(d, &k1, 0));
- CPPUNIT_ASSERT(!topic.isBound(d, &k2, 0));
- CPPUNIT_ASSERT(!topic.isBound(d, &k3, 0));
-
- HeadersExchange headers("headers");
- FieldTable args1;
- args1.setString("x-match", "all");
- args1.setString("a", "A");
- args1.setInt("b", 1);
- FieldTable args2;
- args2.setString("x-match", "any");
- args2.setString("a", "A");
- args2.setInt("b", 1);
- FieldTable args3;
- args3.setString("x-match", "any");
- args3.setString("c", "C");
- args3.setInt("b", 6);
-
- headers.bind(a, "", &args1);
- headers.bind(a, "", &args3);
- headers.bind(b, "", &args2);
- headers.bind(c, "", &args1);
+ string k1("abc");
+ string k2("def");
+ string k3("xyz");
+
+ FanOutExchange fanout("fanout");
+ fanout.bind(a, "", 0);
+ fanout.bind(b, "", 0);
+ fanout.bind(c, "", 0);
+
+ BOOST_CHECK(fanout.isBound(a, 0, 0));
+ BOOST_CHECK(fanout.isBound(b, 0, 0));
+ BOOST_CHECK(fanout.isBound(c, 0, 0));
+ BOOST_CHECK(!fanout.isBound(d, 0, 0));
+
+ DirectExchange direct("direct");
+ direct.bind(a, k1, 0);
+ direct.bind(a, k3, 0);
+ direct.bind(b, k2, 0);
+ direct.bind(c, k1, 0);
+
+ BOOST_CHECK(direct.isBound(a, 0, 0));
+ BOOST_CHECK(direct.isBound(a, &k1, 0));
+ BOOST_CHECK(direct.isBound(a, &k3, 0));
+ BOOST_CHECK(!direct.isBound(a, &k2, 0));
+ BOOST_CHECK(direct.isBound(b, 0, 0));
+ BOOST_CHECK(direct.isBound(b, &k2, 0));
+ BOOST_CHECK(direct.isBound(c, &k1, 0));
+ BOOST_CHECK(!direct.isBound(d, 0, 0));
+ BOOST_CHECK(!direct.isBound(d, &k1, 0));
+ BOOST_CHECK(!direct.isBound(d, &k2, 0));
+ BOOST_CHECK(!direct.isBound(d, &k3, 0));
+
+ TopicExchange topic("topic");
+ topic.bind(a, k1, 0);
+ topic.bind(a, k3, 0);
+ topic.bind(b, k2, 0);
+ topic.bind(c, k1, 0);
+
+ BOOST_CHECK(topic.isBound(a, 0, 0));
+ BOOST_CHECK(topic.isBound(a, &k1, 0));
+ BOOST_CHECK(topic.isBound(a, &k3, 0));
+ BOOST_CHECK(!topic.isBound(a, &k2, 0));
+ BOOST_CHECK(topic.isBound(b, 0, 0));
+ BOOST_CHECK(topic.isBound(b, &k2, 0));
+ BOOST_CHECK(topic.isBound(c, &k1, 0));
+ BOOST_CHECK(!topic.isBound(d, 0, 0));
+ BOOST_CHECK(!topic.isBound(d, &k1, 0));
+ BOOST_CHECK(!topic.isBound(d, &k2, 0));
+ BOOST_CHECK(!topic.isBound(d, &k3, 0));
+
+ HeadersExchange headers("headers");
+ FieldTable args1;
+ args1.setString("x-match", "all");
+ args1.setString("a", "A");
+ args1.setInt("b", 1);
+ FieldTable args2;
+ args2.setString("x-match", "any");
+ args2.setString("a", "A");
+ args2.setInt("b", 1);
+ FieldTable args3;
+ args3.setString("x-match", "any");
+ args3.setString("c", "C");
+ args3.setInt("b", 6);
+
+ headers.bind(a, "", &args1);
+ headers.bind(a, "", &args3);
+ headers.bind(b, "", &args2);
+ headers.bind(c, "", &args1);
- CPPUNIT_ASSERT(headers.isBound(a, 0, 0));
- CPPUNIT_ASSERT(headers.isBound(a, 0, &args1));
- CPPUNIT_ASSERT(headers.isBound(a, 0, &args3));
- CPPUNIT_ASSERT(!headers.isBound(a, 0, &args2));
- CPPUNIT_ASSERT(headers.isBound(b, 0, 0));
- CPPUNIT_ASSERT(headers.isBound(b, 0, &args2));
- CPPUNIT_ASSERT(headers.isBound(c, 0, &args1));
- CPPUNIT_ASSERT(!headers.isBound(d, 0, 0));
- CPPUNIT_ASSERT(!headers.isBound(d, 0, &args1));
- CPPUNIT_ASSERT(!headers.isBound(d, 0, &args2));
- CPPUNIT_ASSERT(!headers.isBound(d, 0, &args3));
- }
-
- void testDeleteGetAndRedeclare() {
- ExchangeRegistry exchanges;
- exchanges.declare("my-exchange", "direct", false, FieldTable());
- exchanges.destroy("my-exchange");
- try {
- exchanges.get("my-exchange");
- } catch (const NotFoundException&) {}
- std::pair<Exchange::shared_ptr, bool> response = exchanges.declare("my-exchange", "direct", false, FieldTable());
- CPPUNIT_ASSERT_EQUAL(string("direct"), response.first->getType());
-
- }
-};
-
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(ExchangeTest);
+ BOOST_CHECK(headers.isBound(a, 0, 0));
+ BOOST_CHECK(headers.isBound(a, 0, &args1));
+ BOOST_CHECK(headers.isBound(a, 0, &args3));
+ BOOST_CHECK(!headers.isBound(a, 0, &args2));
+ BOOST_CHECK(headers.isBound(b, 0, 0));
+ BOOST_CHECK(headers.isBound(b, 0, &args2));
+ BOOST_CHECK(headers.isBound(c, 0, &args1));
+ BOOST_CHECK(!headers.isBound(d, 0, 0));
+ BOOST_CHECK(!headers.isBound(d, 0, &args1));
+ BOOST_CHECK(!headers.isBound(d, 0, &args2));
+ BOOST_CHECK(!headers.isBound(d, 0, &args3));
+}
+
+QPID_AUTO_TEST_CASE(testDeleteGetAndRedeclare)
+{
+ ExchangeRegistry exchanges;
+ exchanges.declare("my-exchange", "direct", false, FieldTable());
+ exchanges.destroy("my-exchange");
+ try {
+ exchanges.get("my-exchange");
+ } catch (const NotFoundException&) {}
+ std::pair<Exchange::shared_ptr, bool> response = exchanges.declare("my-exchange", "direct", false, FieldTable());
+ BOOST_CHECK_EQUAL(string("direct"), response.first->getType());
+}
+
+QPID_AUTO_TEST_SUITE_END()