Return-Path: Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: (qmail 12416 invoked from network); 17 Sep 2009 16:21:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Sep 2009 16:21:59 -0000 Received: (qmail 6900 invoked by uid 500); 17 Sep 2009 16:21:58 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 6866 invoked by uid 500); 17 Sep 2009 16:21:58 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 6818 invoked by uid 99); 17 Sep 2009 16:21:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Sep 2009 16:21:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Sep 2009 16:21:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 724202388993; Thu, 17 Sep 2009 16:21:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r816261 [4/8] - in /qpid/branches/java-network-refactor: ./ qpid/cpp/bindings/qmf/python/ qpid/cpp/bindings/qmf/ruby/ qpid/cpp/bindings/qmf/tests/ qpid/cpp/include/qpid/messaging/ qpid/cpp/src/ qpid/cpp/src/qmf/ qpid/cpp/src/qpid/acl/ qpid/... Date: Thu, 17 Sep 2009 16:21:21 -0000 To: commits@qpid.apache.org From: aidan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090917162128.724202388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/MessagingSessionTests.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/MessagingSessionTests.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/MessagingSessionTests.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/MessagingSessionTests.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -36,6 +36,9 @@ #include #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(MessagingSessionTests) using namespace qpid::messaging; @@ -86,7 +89,7 @@ Session session; BrokerAdmin admin; - MessagingFixture(Broker::Options opts = Broker::Options()) : + MessagingFixture(Broker::Options opts = Broker::Options()) : BrokerFixture(opts), connection(Connection::open((boost::format("amqp:tcp:localhost:%1%") % (broker->getPort(Broker::TCP_TRANSPORT))).str())), session(connection.newSession()), @@ -133,7 +136,7 @@ struct MultiQueueFixture : MessagingFixture { - typedef std::vector::const_iterator const_iterator; + typedef std::vector::const_iterator const_iterator; std::vector queues; MultiQueueFixture(const std::vector& names = boost::assign::list_of("q1")("q2")("q3")) : queues(names) @@ -161,7 +164,7 @@ } }; -std::vector fetch(Receiver& receiver, int count, qpid::sys::Duration timeout=qpid::sys::TIME_SEC*5) +std::vector fetch(Receiver& receiver, int count, qpid::sys::Duration timeout=qpid::sys::TIME_SEC*5) { std::vector data; Message message; @@ -189,13 +192,12 @@ Sender sender = fix.session.createSender(fix.queue); Message out("test-message"); for (uint i = 0; i < 10; ++i) { - out.getHeaders()["a"] = i; + out.getHeaders()["a"] = i; sender.send(out); } Receiver receiver = fix.session.createReceiver(fix.queue); Message in; for (uint i = 0; i < 10; ++i) { - //Message in = receiver.fetch(5 * qpid::sys::TIME_SEC); BOOST_CHECK(receiver.fetch(in, 5 * qpid::sys::TIME_SEC)); BOOST_CHECK_EQUAL(in.getBytes(), out.getBytes()); BOOST_CHECK_EQUAL(in.getHeaders()["a"].asUint32(), i); @@ -249,14 +251,14 @@ Message in; BOOST_CHECK(!sub2.fetch(in, 0));//TODO: or should this raise an error? - + //TODO: check pending messages... } QPID_AUTO_TEST_CASE(testSessionFetch) { MultiQueueFixture fix; - + for (uint i = 0; i < fix.queues.size(); i++) { Receiver r = fix.session.createReceiver(fix.queues[i]); r.setCapacity(10u); @@ -267,8 +269,8 @@ Sender s = fix.session.createSender(fix.queues[i]); Message msg((boost::format("Message_%1%") % (i+1)).str()); s.send(msg); - } - + } + for (uint i = 0; i < fix.queues.size(); i++) { Message msg; BOOST_CHECK(fix.session.fetch(msg, qpid::sys::TIME_SEC)); @@ -279,7 +281,7 @@ QPID_AUTO_TEST_CASE(testSessionDispatch) { MultiQueueFixture fix; - + MessageDataCollector collector; for (uint i = 0; i < fix.queues.size(); i++) { Receiver r = fix.session.createReceiver(fix.queues[i]); @@ -292,10 +294,10 @@ Sender s = fix.session.createSender(fix.queues[i]); Message msg((boost::format("Message_%1%") % (i+1)).str()); s.send(msg); - } + } while (fix.session.dispatch(qpid::sys::TIME_SEC)) ; - + BOOST_CHECK_EQUAL(collector.messageData, boost::assign::list_of("Message_1")("Message_2")("Message_3")); } @@ -309,7 +311,7 @@ out.getContent().asMap()["pi"] = 3.14f; sender.send(out); Receiver receiver = fix.session.createReceiver(fix.queue); - Message in = receiver.fetch(5 * qpid::sys::TIME_SEC); + Message in = receiver.fetch(5 * qpid::sys::TIME_SEC); BOOST_CHECK_EQUAL(in.getContent().asMap()["abc"].asString(), "def"); BOOST_CHECK_EQUAL(in.getContent().asMap()["pi"].asFloat(), 3.14f); fix.session.acknowledge(); @@ -324,11 +326,11 @@ out.getContent() << "abc"; out.getContent() << 1234; out.getContent() << "def"; - out.getContent() << 56.789; + out.getContent() << 56.789; sender.send(out); Receiver receiver = fix.session.createReceiver(fix.queue); - Message in = receiver.fetch(5 * qpid::sys::TIME_SEC); - Variant::List& list = in.getContent().asList(); + Message in = receiver.fetch(5 * qpid::sys::TIME_SEC); + Variant::List& list = in.getContent().asList(); BOOST_CHECK_EQUAL(list.size(), out.getContent().asList().size()); BOOST_CHECK_EQUAL(list.front().asString(), "abc"); list.pop_front(); @@ -354,7 +356,86 @@ fix.session.reject(in); in = receiver.fetch(5 * qpid::sys::TIME_SEC); BOOST_CHECK_EQUAL(in.getBytes(), m2.getBytes()); - fix.session.acknowledge(); + fix.session.acknowledge(); +} + +QPID_AUTO_TEST_CASE(testAvailable) +{ + MultiQueueFixture fix; + + Receiver r1 = fix.session.createReceiver(fix.queues[0]); + r1.setCapacity(100); + r1.start(); + + Receiver r2 = fix.session.createReceiver(fix.queues[1]); + r2.setCapacity(100); + r2.start(); + + Sender s1 = fix.session.createSender(fix.queues[0]); + Sender s2 = fix.session.createSender(fix.queues[1]); + + for (uint i = 0; i < 10; ++i) { + s1.send(Message((boost::format("A_%1%") % (i+1)).str())); + } + for (uint i = 0; i < 5; ++i) { + s2.send(Message((boost::format("B_%1%") % (i+1)).str())); + } + qpid::sys::sleep(1);//is there any avoid an arbitrary sleep while waiting for messages to be dispatched? + for (uint i = 0; i < 5; ++i) { + BOOST_CHECK_EQUAL(fix.session.available(), 15u - 2*i); + BOOST_CHECK_EQUAL(r1.available(), 10u - i); + BOOST_CHECK_EQUAL(r1.fetch().getBytes(), (boost::format("A_%1%") % (i+1)).str()); + BOOST_CHECK_EQUAL(r2.available(), 5u - i); + BOOST_CHECK_EQUAL(r2.fetch().getBytes(), (boost::format("B_%1%") % (i+1)).str()); + fix.session.acknowledge(); + } + for (uint i = 5; i < 10; ++i) { + BOOST_CHECK_EQUAL(fix.session.available(), 10u - i); + BOOST_CHECK_EQUAL(r1.available(), 10u - i); + BOOST_CHECK_EQUAL(r1.fetch().getBytes(), (boost::format("A_%1%") % (i+1)).str()); + } +} + +QPID_AUTO_TEST_CASE(testPendingAck) +{ + QueueFixture fix; + Sender sender = fix.session.createSender(fix.queue); + for (uint i = 0; i < 10; ++i) { + sender.send(Message((boost::format("Message_%1%") % (i+1)).str())); + } + Receiver receiver = fix.session.createReceiver(fix.queue); + for (uint i = 0; i < 10; ++i) { + BOOST_CHECK_EQUAL(receiver.fetch().getBytes(), (boost::format("Message_%1%") % (i+1)).str()); + } + BOOST_CHECK_EQUAL(fix.session.pendingAck(), 0u); + fix.session.acknowledge(); + BOOST_CHECK_EQUAL(fix.session.pendingAck(), 10u); + fix.session.sync(); + BOOST_CHECK_EQUAL(fix.session.pendingAck(), 0u); +} + +QPID_AUTO_TEST_CASE(testPendingSend) +{ + QueueFixture fix; + Sender sender = fix.session.createSender(fix.queue); + for (uint i = 0; i < 10; ++i) { + sender.send(Message((boost::format("Message_%1%") % (i+1)).str())); + } + //Note: this test relies on 'inside knowledge' of the sender + //implementation and the fact that the simple test case makes it + //possible to predict when completion information will be sent to + //the client. TODO: is there a better way of testing this? + BOOST_CHECK_EQUAL(sender.pending(), 10u); + fix.session.sync(); + BOOST_CHECK_EQUAL(sender.pending(), 0u); + + Receiver receiver = fix.session.createReceiver(fix.queue); + for (uint i = 0; i < 10; ++i) { + BOOST_CHECK_EQUAL(receiver.fetch().getBytes(), (boost::format("Message_%1%") % (i+1)).str()); + } + fix.session.acknowledge(); } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/PartialFailure.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/PartialFailure.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/PartialFailure.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/PartialFailure.cpp Thu Sep 17 16:21:13 2009 @@ -31,6 +31,9 @@ #include #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(PartialFailureTestSuite) using namespace std; @@ -257,3 +260,5 @@ #endif #endif // FIXME aconway 2009-07-30: QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/PollableCondition.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/PollableCondition.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/PollableCondition.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/PollableCondition.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -28,6 +28,8 @@ #include "qpid/sys/Thread.h" #include +namespace qpid { +namespace tests { QPID_AUTO_TEST_SUITE(PollableConditionTest) @@ -37,7 +39,7 @@ const Duration LONG = TIME_SEC/10; class Callback { - public: + public: enum Action { NONE, CLEAR }; Callback() : count(), action(NONE) {} @@ -46,7 +48,7 @@ Mutex::ScopedLock l(lock); ++count; switch(action) { - case NONE: break; + case NONE: break; case CLEAR: pc.clear(); break; } action = NONE; @@ -62,9 +64,9 @@ action = a; return wait(LONG); } - + private: - bool wait(Duration timeout) { + bool wait(Duration timeout) { int n = count; AbsTime deadline(now(), timeout); while (n == count && lock.wait(deadline)) @@ -83,7 +85,7 @@ PollableCondition pc(boost::bind(&Callback::call, &callback, _1), poller); Thread runner = Thread(*poller); - + BOOST_CHECK(callback.isNotCalling()); // condition is not set. pc.set(); @@ -104,4 +106,4 @@ QPID_AUTO_TEST_SUITE_END() - +}} //namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/ProxyTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/ProxyTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/ProxyTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/ProxyTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -28,6 +28,9 @@ using namespace qpid::framing; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(ProxyTestSuite) @@ -47,5 +50,7 @@ Proxy::ScopedSync s(p); p.send(ExecutionSyncBody(p.getVersion())); } - + QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueEvents.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueEvents.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueEvents.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueEvents.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -31,6 +31,9 @@ #include #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(QueueEventsSuite) using namespace qpid::client; @@ -156,7 +159,7 @@ fixture.session.queueDeclare(arg::queue=q, arg::arguments=options); //send and consume some messages LocalQueue incoming; - Subscription sub = fixture.subs.subscribe(incoming, q); + Subscription sub = fixture.subs.subscribe(incoming, q); for (int i = 0; i < 5; i++) { fixture.session.messageTransfer(arg::content=client::Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), q)); } @@ -177,7 +180,7 @@ SequenceNumber dequeueId(1); for (int i = 0; i < 5; i++) { listener.checkEnqueue(q, (boost::format("%1%_%2%") % "Message" % (i+1)).str(), enqueueId++); - } + } for (int i = 0; i < 3; i++) { listener.checkDequeue(q, (boost::format("%1%_%2%") % "Message" % (i+1)).str(), dequeueId++); } @@ -203,7 +206,7 @@ fixture.session.queueDeclare(arg::queue=q, arg::arguments=options); //send and consume some messages LocalQueue incoming; - Subscription sub = fixture.subs.subscribe(incoming, q); + Subscription sub = fixture.subs.subscribe(incoming, q); for (int i = 0; i < 5; i++) { fixture.session.messageTransfer(arg::content=client::Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), q)); } @@ -224,7 +227,7 @@ SequenceNumber dequeueId(1); for (int i = 0; i < 5; i++) { listener.checkEnqueue(q, (boost::format("%1%_%2%") % "Message" % (i+1)).str(), enqueueId++); - } + } for (int i = 5; i < 10; i++) { listener.checkEnqueue(q, (boost::format("%1%_%2%") % "Message" % (i+1)).str(), enqueueId++); } @@ -232,4 +235,4 @@ QPID_AUTO_TEST_SUITE_END() - +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueOptionsTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueOptionsTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueOptionsTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueOptionsTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,14 +27,17 @@ using namespace qpid::client; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(QueueOptionsTestSuite) QPID_AUTO_TEST_CASE(testSizePolicy) { QueueOptions ft; - + ft.setSizePolicy(REJECT,1,2); - + BOOST_CHECK(QueueOptions::strREJECT == ft.getAsString(QueueOptions::strTypeKey)); BOOST_CHECK(1 == ft.getAsInt(QueueOptions::strMaxSizeKey)); BOOST_CHECK(2 == ft.getAsInt(QueueOptions::strMaxCountKey)); @@ -49,7 +52,7 @@ ft.setSizePolicy(RING_STRICT,1,0); BOOST_CHECK(QueueOptions::strRING_STRICT == ft.getAsString(QueueOptions::strTypeKey)); - + ft.clearSizePolicy(); BOOST_CHECK(!ft.isSet(QueueOptions::strTypeKey)); BOOST_CHECK(!ft.isSet(QueueOptions::strMaxSizeKey)); @@ -59,13 +62,13 @@ QPID_AUTO_TEST_CASE(testFlags) { QueueOptions ft; - + ft.setPersistLastNode(); ft.setOrdering(LVQ); - + BOOST_CHECK(1 == ft.getAsInt(QueueOptions::strPersistLastNode)); BOOST_CHECK(1 == ft.getAsInt(QueueOptions::strLastValueQueue)); - + ft.clearPersistLastNode(); ft.setOrdering(FIFO); @@ -78,8 +81,8 @@ { //ensure setOrdering(FIFO) works even if not preceded by a call to //setOrdering(LVQ) - QueueOptions ft; - ft.setOrdering(FIFO); + QueueOptions ft; + ft.setOrdering(FIFO); BOOST_CHECK(!ft.isSet(QueueOptions::strLastValueQueue)); } @@ -88,10 +91,12 @@ { //ensure clear works even if not preceded by the setting on the //option - QueueOptions ft; + QueueOptions ft; ft.clearPersistLastNode(); BOOST_CHECK(!ft.isSet(QueueOptions::strPersistLastNode)); } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueuePolicyTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueuePolicyTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueuePolicyTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueuePolicyTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -32,6 +32,9 @@ using namespace qpid::client; using namespace qpid::framing; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(QueuePolicyTestSuite) QueuedMessage createMessage(uint32_t size) @@ -50,11 +53,11 @@ BOOST_CHECK_EQUAL((uint32_t) 5, policy->getMaxCount()); QueuedMessage msg = createMessage(10); - for (size_t i = 0; i < 5; i++) { + for (size_t i = 0; i < 5; i++) { policy->tryEnqueue(msg); } try { - policy->tryEnqueue(msg); + policy->tryEnqueue(msg); BOOST_FAIL("Policy did not fail on enqueuing sixth message"); } catch (const ResourceLimitExceededException&) {} @@ -62,7 +65,7 @@ policy->tryEnqueue(msg); try { - policy->tryEnqueue(msg); + policy->tryEnqueue(msg); BOOST_FAIL("Policy did not fail on enqueuing sixth message (after dequeue)"); } catch (const ResourceLimitExceededException&) {} } @@ -71,12 +74,12 @@ { std::auto_ptr policy(QueuePolicy::createQueuePolicy(0, 50)); QueuedMessage msg = createMessage(10); - - for (size_t i = 0; i < 5; i++) { + + for (size_t i = 0; i < 5; i++) { policy->tryEnqueue(msg); } try { - policy->tryEnqueue(msg); + policy->tryEnqueue(msg); BOOST_FAIL("Policy did not fail on aggregate size exceeding 50. " << *policy); } catch (const ResourceLimitExceededException&) {} @@ -84,7 +87,7 @@ policy->tryEnqueue(msg); try { - policy->tryEnqueue(msg); + policy->tryEnqueue(msg); BOOST_FAIL("Policy did not fail on aggregate size exceeding 50 (after dequeue). " << *policy); } catch (const ResourceLimitExceededException&) {} } @@ -104,7 +107,7 @@ messages.push_back(createMessage(11)); messages.push_back(createMessage(2)); messages.push_back(createMessage(7)); - for (size_t i = 0; i < messages.size(); i++) { + for (size_t i = 0; i < messages.size(); i++) { policy->tryEnqueue(messages[i]); } //size = 45 at this point, count = 5 @@ -140,7 +143,7 @@ BOOST_CHECK_EQUAL(a->getMaxSize(), b->getMaxSize()); } -QPID_AUTO_TEST_CASE(testRingPolicy) +QPID_AUTO_TEST_CASE(testRingPolicy) { FieldTable args; std::auto_ptr policy = QueuePolicy::createQueuePolicy(5, 0, QueuePolicy::RING); @@ -169,7 +172,7 @@ BOOST_CHECK(!f.subs.get(msg, q)); } -QPID_AUTO_TEST_CASE(testStrictRingPolicy) +QPID_AUTO_TEST_CASE(testStrictRingPolicy) { FieldTable args; std::auto_ptr policy = QueuePolicy::createQueuePolicy(5, 0, QueuePolicy::RING_STRICT); @@ -181,7 +184,7 @@ LocalQueue incoming; SubscriptionSettings settings(FlowControl::unlimited()); settings.autoAck = 0; // no auto ack. - Subscription sub = f.subs.subscribe(incoming, q, settings); + Subscription sub = f.subs.subscribe(incoming, q, settings); for (int i = 0; i < 5; i++) { f.session.messageTransfer(arg::content=client::Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), q)); } @@ -192,10 +195,10 @@ ScopedSuppressLogging sl; // Suppress messages for expected errors. f.session.messageTransfer(arg::content=client::Message("Message_6", q)); BOOST_FAIL("expecting ResourceLimitExceededException."); - } catch (const ResourceLimitExceededException&) {} + } catch (const ResourceLimitExceededException&) {} } -QPID_AUTO_TEST_CASE(testPolicyWithDtx) +QPID_AUTO_TEST_CASE(testPolicyWithDtx) { FieldTable args; std::auto_ptr policy = QueuePolicy::createQueuePolicy(5, 0, QueuePolicy::REJECT); @@ -207,7 +210,7 @@ LocalQueue incoming; SubscriptionSettings settings(FlowControl::unlimited()); settings.autoAck = 0; // no auto ack. - Subscription sub = f.subs.subscribe(incoming, q, settings); + Subscription sub = f.subs.subscribe(incoming, q, settings); f.session.dtxSelect(); Xid tx1(1, "test-dtx-mgr", "tx1"); f.session.dtxStart(arg::xid=tx1); @@ -244,7 +247,7 @@ ScopedSuppressLogging sl; // Suppress messages for expected errors. other.messageTransfer(arg::content=client::Message("Message_6", q)); BOOST_FAIL("expecting ResourceLimitExceededException."); - } catch (const ResourceLimitExceededException&) {} + } catch (const ResourceLimitExceededException&) {} f.session.dtxCommit(arg::xid=tx3); //now retry and this time should succeed @@ -252,7 +255,7 @@ other.messageTransfer(arg::content=client::Message("Message_6", q)); } -QPID_AUTO_TEST_CASE(testFlowToDiskWithNoStore) +QPID_AUTO_TEST_CASE(testFlowToDiskWithNoStore) { //Ensure that with no store loaded, we don't flow to disk but //fallback to rejecting messages @@ -265,7 +268,7 @@ LocalQueue incoming; SubscriptionSettings settings(FlowControl::unlimited()); settings.autoAck = 0; // no auto ack. - Subscription sub = f.subs.subscribe(incoming, q, settings); + Subscription sub = f.subs.subscribe(incoming, q, settings); for (int i = 0; i < 5; i++) { f.session.messageTransfer(arg::content=client::Message((boost::format("%1%_%2%") % "Message" % (i+1)).str(), q)); } @@ -276,8 +279,10 @@ ScopedSuppressLogging sl; // Suppress messages for expected errors. f.session.messageTransfer(arg::content=client::Message("Message_6", q)); BOOST_FAIL("expecting ResourceLimitExceededException."); - } catch (const ResourceLimitExceededException&) {} + } catch (const ResourceLimitExceededException&) {} } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueRegistryTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueRegistryTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueRegistryTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueRegistryTest.cpp Thu Sep 17 16:21:13 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,6 +23,9 @@ using namespace qpid::broker; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(QueueRegistryTest) QPID_AUTO_TEST_CASE(testDeclare) @@ -49,7 +52,7 @@ BOOST_CHECK_EQUAL(bar, q->getName()); } -QPID_AUTO_TEST_CASE(testDeclareTmp) +QPID_AUTO_TEST_CASE(testDeclareTmp) { QueueRegistry reg; std::pair qc; @@ -58,8 +61,8 @@ BOOST_CHECK(qc.second); BOOST_CHECK_EQUAL(std::string("tmp_1"), qc.first->getName()); } - -QPID_AUTO_TEST_CASE(testFind) + +QPID_AUTO_TEST_CASE(testFind) { std::string foo("foo"); std::string bar("bar"); @@ -75,7 +78,7 @@ BOOST_CHECK_EQUAL(bar, q->getName()); } -QPID_AUTO_TEST_CASE(testDestroy) +QPID_AUTO_TEST_CASE(testDestroy) { std::string foo("foo"); QueueRegistry reg; @@ -92,3 +95,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/QueueTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -39,9 +39,12 @@ using namespace qpid::framing; using namespace qpid::sys; +namespace qpid { +namespace tests { + class TestConsumer : public virtual Consumer{ public: - typedef boost::shared_ptr shared_ptr; + typedef boost::shared_ptr shared_ptr; intrusive_ptr last; bool received; @@ -82,68 +85,68 @@ QPID_AUTO_TEST_CASE(testAsyncMessage) { Queue::shared_ptr queue(new Queue("my_test_queue", true)); intrusive_ptr received; - + TestConsumer::shared_ptr c1(new TestConsumer()); queue->consume(c1); - - + + //Test basic delivery: intrusive_ptr msg1 = create_message("e", "A"); msg1->enqueueAsync(queue, 0);//this is done on enqueue which is not called from process queue->process(msg1); sleep(2); - + BOOST_CHECK(!c1->received); msg1->enqueueComplete(); - + received = queue->get().payload; - BOOST_CHECK_EQUAL(msg1.get(), received.get()); + BOOST_CHECK_EQUAL(msg1.get(), received.get()); } - - + + QPID_AUTO_TEST_CASE(testAsyncMessageCount){ Queue::shared_ptr queue(new Queue("my_test_queue", true)); intrusive_ptr msg1 = create_message("e", "A"); msg1->enqueueAsync(queue, 0);//this is done on enqueue which is not called from process - + queue->process(msg1); sleep(2); uint32_t compval=0; BOOST_CHECK_EQUAL(compval, queue->getMessageCount()); msg1->enqueueComplete(); compval=1; - BOOST_CHECK_EQUAL(compval, queue->getMessageCount()); + BOOST_CHECK_EQUAL(compval, queue->getMessageCount()); } QPID_AUTO_TEST_CASE(testConsumers){ Queue::shared_ptr queue(new Queue("my_queue", true)); - + //Test adding consumers: TestConsumer::shared_ptr c1(new TestConsumer()); TestConsumer::shared_ptr c2(new TestConsumer()); queue->consume(c1); queue->consume(c2); - + BOOST_CHECK_EQUAL(uint32_t(2), queue->getConsumerCount()); - + //Test basic delivery: intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "B"); intrusive_ptr msg3 = create_message("e", "C"); - + queue->deliver(msg1); BOOST_CHECK(queue->dispatch(c1)); BOOST_CHECK_EQUAL(msg1.get(), c1->last.get()); - + queue->deliver(msg2); BOOST_CHECK(queue->dispatch(c2)); BOOST_CHECK_EQUAL(msg2.get(), c2->last.get()); - + c1->received = false; queue->deliver(msg3); BOOST_CHECK(queue->dispatch(c1)); - BOOST_CHECK_EQUAL(msg3.get(), c1->last.get()); - + BOOST_CHECK_EQUAL(msg3.get(), c1->last.get()); + //Test cancellation: queue->cancel(c1); BOOST_CHECK_EQUAL(uint32_t(1), queue->getConsumerCount()); @@ -157,15 +160,15 @@ registry.declare("queue1", true, true); registry.declare("queue2", true, true); registry.declare("queue3", true, true); - + BOOST_CHECK(registry.find("queue1")); BOOST_CHECK(registry.find("queue2")); BOOST_CHECK(registry.find("queue3")); - + registry.destroy("queue1"); registry.destroy("queue2"); registry.destroy("queue3"); - + BOOST_CHECK(!registry.find("queue1")); BOOST_CHECK(!registry.find("queue2")); BOOST_CHECK(!registry.find("queue3")); @@ -177,13 +180,13 @@ intrusive_ptr msg2 = create_message("e", "B"); intrusive_ptr msg3 = create_message("e", "C"); intrusive_ptr received; - + queue->deliver(msg1); queue->deliver(msg2); queue->deliver(msg3); - + BOOST_CHECK_EQUAL(uint32_t(3), queue->getMessageCount()); - + received = queue->get().payload; BOOST_CHECK_EQUAL(msg1.get(), received.get()); BOOST_CHECK_EQUAL(uint32_t(2), queue->getMessageCount()); @@ -204,7 +207,7 @@ received = queue->get().payload; BOOST_CHECK(!received); BOOST_CHECK_EQUAL(uint32_t(0), queue->getMessageCount()); - + } QPID_AUTO_TEST_CASE(testBound) @@ -236,7 +239,7 @@ queue->unbind(exchanges, queue); //ensure the remaining exchanges don't still have the queue bound to them: - FailOnDeliver deliverable; + FailOnDeliver deliverable; exchange1->route(deliverable, key, &args); exchange3->route(deliverable, key, &args); } @@ -245,10 +248,10 @@ client::QueueOptions args; args.setPersistLastNode(); - + Queue::shared_ptr queue(new Queue("my-queue", true)); queue->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "B"); intrusive_ptr msg3 = create_message("e", "C"); @@ -256,13 +259,13 @@ //enqueue 2 messages queue->deliver(msg1); queue->deliver(msg2); - + //change mode queue->setLastNodeFailure(); - + //enqueue 1 message queue->deliver(msg3); - + //check all have persistent ids. BOOST_CHECK(msg1->isPersistent()); BOOST_CHECK(msg2->isPersistent()); @@ -277,7 +280,7 @@ uint enqCnt; uint deqCnt; bool error; - + virtual void dequeue(TransactionContext*, const boost::intrusive_ptr& /*msg*/, const PersistableQueue& /*queue*/) @@ -298,7 +301,7 @@ { error=true; } - + TestMessageStoreOC() : NullMessageStore(),enqCnt(0),deqCnt(0),error(false) {} ~TestMessageStoreOC(){} }; @@ -312,7 +315,7 @@ Queue::shared_ptr queue(new Queue("my-queue", true )); queue->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "B"); intrusive_ptr msg3 = create_message("e", "C"); @@ -324,27 +327,27 @@ string key; args.getLVQKey(key); BOOST_CHECK_EQUAL(key, "qpid.LVQ_key"); - + msg1->getProperties()->getApplicationHeaders().setString(key,"a"); msg2->getProperties()->getApplicationHeaders().setString(key,"b"); msg3->getProperties()->getApplicationHeaders().setString(key,"c"); msg4->getProperties()->getApplicationHeaders().setString(key,"a"); - + //enqueue 4 message queue->deliver(msg1); queue->deliver(msg2); queue->deliver(msg3); queue->deliver(msg4); - + BOOST_CHECK_EQUAL(queue->getMessageCount(), 3u); - + received = queue->get().payload; BOOST_CHECK_EQUAL(msg4.get(), received.get()); received = queue->get().payload; BOOST_CHECK_EQUAL(msg2.get(), received.get()); - + received = queue->get().payload; BOOST_CHECK_EQUAL(msg3.get(), received.get()); @@ -357,18 +360,18 @@ queue->deliver(msg5); queue->deliver(msg6); queue->deliver(msg7); - + BOOST_CHECK_EQUAL(queue->getMessageCount(), 3u); - + received = queue->get().payload; BOOST_CHECK_EQUAL(msg5.get(), received.get()); received = queue->get().payload; BOOST_CHECK_EQUAL(msg6.get(), received.get()); - + received = queue->get().payload; BOOST_CHECK_EQUAL(msg7.get(), received.get()); - + } QPID_AUTO_TEST_CASE(testLVQEmptyKey){ @@ -379,20 +382,20 @@ Queue::shared_ptr queue(new Queue("my-queue", true )); queue->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "B"); string key; args.getLVQKey(key); BOOST_CHECK_EQUAL(key, "qpid.LVQ_key"); - + msg1->getProperties()->getApplicationHeaders().setString(key,"a"); queue->deliver(msg1); queue->deliver(msg2); BOOST_CHECK_EQUAL(queue->getMessageCount(), 2u); - + } QPID_AUTO_TEST_CASE(testLVQAcquire){ @@ -403,7 +406,7 @@ Queue::shared_ptr queue(new Queue("my-queue", true )); queue->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "B"); intrusive_ptr msg3 = create_message("e", "C"); @@ -416,7 +419,7 @@ string key; args.getLVQKey(key); BOOST_CHECK_EQUAL(key, "qpid.LVQ_key"); - + msg1->getProperties()->getApplicationHeaders().setString(key,"a"); msg2->getProperties()->getApplicationHeaders().setString(key,"b"); @@ -424,13 +427,13 @@ msg4->getProperties()->getApplicationHeaders().setString(key,"a"); msg5->getProperties()->getApplicationHeaders().setString(key,"b"); msg6->getProperties()->getApplicationHeaders().setString(key,"c"); - + //enqueue 4 message queue->deliver(msg1); queue->deliver(msg2); queue->deliver(msg3); queue->deliver(msg4); - + BOOST_CHECK_EQUAL(queue->getMessageCount(), 3u); framing::SequenceNumber sequence(1); @@ -439,9 +442,9 @@ BOOST_CHECK(!queue->acquire(qmsg)); BOOST_CHECK(queue->acquire(qmsg2)); - + BOOST_CHECK_EQUAL(queue->getMessageCount(), 2u); - + queue->deliver(msg5); BOOST_CHECK_EQUAL(queue->getMessageCount(), 3u); @@ -449,11 +452,11 @@ args.setOrdering(client::LVQ_NO_BROWSE); queue->configure(args); TestConsumer::shared_ptr c1(new TestConsumer(false)); - + queue->dispatch(c1); queue->dispatch(c1); queue->dispatch(c1); - + queue->deliver(msg6); BOOST_CHECK_EQUAL(queue->getMessageCount(), 3u); @@ -474,7 +477,7 @@ intrusive_ptr received; queue1->configure(args); queue2->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "A"); @@ -484,17 +487,17 @@ msg1->getProperties()->getApplicationHeaders().setString(key,"a"); msg2->getProperties()->getApplicationHeaders().setString(key,"a"); - + queue1->deliver(msg1); queue2->deliver(msg1); queue1->deliver(msg2); - + received = queue1->get().payload; BOOST_CHECK_EQUAL(msg2.get(), received.get()); received = queue2->get().payload; BOOST_CHECK_EQUAL(msg1.get(), received.get()); - + } QPID_AUTO_TEST_CASE(testLVQRecover){ @@ -518,7 +521,7 @@ Queue::shared_ptr queue1(new Queue("my-queue", true, &testStore)); intrusive_ptr received; queue1->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); intrusive_ptr msg2 = create_message("e", "A"); // 2 @@ -544,7 +547,7 @@ BOOST_CHECK_EQUAL(testStore.deqCnt, 1u); } -void addMessagesToQueue(uint count, Queue& queue, uint oddTtl = 200, uint evenTtl = 0) +void addMessagesToQueue(uint count, Queue& queue, uint oddTtl = 200, uint evenTtl = 0) { for (uint i = 0; i < count; i++) { intrusive_ptr m = create_message("exchange", "key"); @@ -592,7 +595,7 @@ queue1->configure(args); Queue::shared_ptr queue2(new Queue("queue2", true, &testStore )); queue2->configure(args); - + intrusive_ptr msg1 = create_message("e", "A"); queue1->deliver(msg1); @@ -623,7 +626,7 @@ // check no failure messages are stored queue1->clearLastNodeFailure(); queue2->clearLastNodeFailure(); - + intrusive_ptr msg3 = create_message("e", "B"); queue1->deliver(msg3); queue2->deliver(msg3); @@ -631,7 +634,7 @@ queue1->setLastNodeFailure(); queue2->setLastNodeFailure(); BOOST_CHECK_EQUAL(testStore.enqCnt, 6u); - + // check requeue 1 intrusive_ptr msg4 = create_message("e", "C"); intrusive_ptr msg5 = create_message("e", "D"); @@ -639,17 +642,17 @@ framing::SequenceNumber sequence(1); QueuedMessage qmsg1(queue1.get(), msg4, sequence); QueuedMessage qmsg2(queue2.get(), msg5, ++sequence); - + queue1->requeue(qmsg1); BOOST_CHECK_EQUAL(testStore.enqCnt, 7u); - + // check requeue 2 queue2->clearLastNodeFailure(); queue2->requeue(qmsg2); BOOST_CHECK_EQUAL(testStore.enqCnt, 7u); queue2->setLastNodeFailure(); BOOST_CHECK_EQUAL(testStore.enqCnt, 8u); - + queue2->clearLastNodeFailure(); queue2->setLastNodeFailure(); BOOST_CHECK_EQUAL(testStore.enqCnt, 8u); @@ -664,8 +667,8 @@ 4. stop and recover remaining node 5. add another node 6. kill that new node again -make sure that an attempt to re-enqueue a message does not happen which will -result in the last man standing exiting with an error. +make sure that an attempt to re-enqueue a message does not happen which will +result in the last man standing exiting with an error. we need to make sure that recover is safe, i.e. messages are not requeued to the store. @@ -678,7 +681,7 @@ Queue::shared_ptr queue1(new Queue("my-queue", true, &testStore)); intrusive_ptr received; queue1->configure(args); - + // check requeue 1 intrusive_ptr msg1 = create_message("e", "C"); intrusive_ptr msg2 = create_message("e", "D"); @@ -711,17 +714,29 @@ Queue::shared_ptr queue1(new Queue("my-queue", true, &testStore)); intrusive_ptr received; queue1->configure(args); - + // check requeue 1 intrusive_ptr msg1 = create_message("e", "C"); queue1->deliver(msg1); testStore.createError(); - + ScopedSuppressLogging sl; // Suppress messages for expected errors. queue1->setLastNodeFailure(); BOOST_CHECK_EQUAL(testStore.enqCnt, 0u); -}QPID_AUTO_TEST_SUITE_END() +} + +intrusive_ptr mkMsg(std::string exchange, std::string routingKey) { + intrusive_ptr msg(new Message()); + AMQFrame method((MessageTransferBody(ProtocolVersion(), exchange, 0, 0))); + AMQFrame header((AMQHeaderBody())); + msg->getFrames().append(method); + msg->getFrames().append(header); + msg->getFrames().getHeaders()->get(true)->setRoutingKey(routingKey); + return msg; +} +QPID_AUTO_TEST_SUITE_END() +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/RangeSet.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/RangeSet.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/RangeSet.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/RangeSet.cpp Thu Sep 17 16:21:13 2009 @@ -24,6 +24,9 @@ using namespace std; using namespace qpid; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(RangeSetTestSuite) typedef qpid::Range TestRange; @@ -44,8 +47,8 @@ BOOST_CHECK_MESSAGE(r.contains(TestRange(3,4)), r); BOOST_CHECK(!r.empty()); r += 5; - BOOST_CHECK_MESSAGE(r.contains(5), r); - BOOST_CHECK_MESSAGE(r.contains(TestRange(5,6)), r); + BOOST_CHECK_MESSAGE(r.contains(5), r); + BOOST_CHECK_MESSAGE(r.contains(TestRange(5,6)), r); BOOST_CHECK_MESSAGE(!r.contains(TestRange(3,6)), r); r += 4; BOOST_CHECK_MESSAGE(r.contains(TestRange(3,6)), r); @@ -139,3 +142,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/RateFlowcontrolTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/RateFlowcontrolTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/RateFlowcontrolTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/RateFlowcontrolTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,25 +27,28 @@ using namespace qpid::broker; using namespace qpid::sys; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(RateFlowcontrolTestSuite) QPID_AUTO_TEST_CASE(RateFlowcontrolTest) { // BOOST_CHECK(predicate); // BOOST_CHECK_EQUAL(a, b); - + RateFlowcontrol fc(100); AbsTime n=AbsTime::now(); - + BOOST_CHECK_EQUAL( fc.receivedMessage(n, 0), 0U ); - + fc.sentCredit(n, 0); - + BOOST_CHECK_EQUAL( fc.receivedMessage(n, 0), 0U ); fc.sentCredit(n, 50); Duration d=250*TIME_MSEC; - + n = AbsTime(n,d); BOOST_CHECK_EQUAL( fc.receivedMessage(n, 25), 0U ); BOOST_CHECK_EQUAL( fc.availableCredit(n), 25U ); @@ -64,3 +67,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/RefCounted.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/RefCounted.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/RefCounted.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/RefCounted.cpp Thu Sep 17 16:21:13 2009 @@ -27,6 +27,9 @@ using namespace std; using namespace qpid; +namespace qpid { +namespace tests { + struct CountMe : public RefCounted { static int instances; CountMe() { ++instances; } @@ -48,3 +51,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/ReplicationTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/ReplicationTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/ReplicationTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/ReplicationTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -42,6 +42,9 @@ using namespace qpid::replication::constants; using boost::assign::list_of; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(ReplicationTestSuite) // The CMake-based build passes in the module suffix; if it's not there, this @@ -63,7 +66,7 @@ return opts; } -QPID_AUTO_TEST_CASE(testReplicationExchange) +QPID_AUTO_TEST_CASE(testReplicationExchange) { qpid::broker::Broker::Options brokerOpts(getBrokerOpts(list_of("qpidd") ("--replication-exchange-name=qpid.replication"))); @@ -79,7 +82,7 @@ f.session.queueDeclare(arg::queue=eventQ, arg::exclusive=true, arg::autoDelete=true, arg::arguments=eventQopts); f.session.exchangeBind(arg::exchange="qpid.replication", arg::queue=eventQ, arg::bindingKey=dataQ); - + f.session.queueDeclare(arg::queue=eventQ2, arg::exclusive=true, arg::autoDelete=true, arg::arguments=eventQopts); f.session.exchangeBind(arg::exchange="qpid.replication", arg::queue=eventQ2, arg::bindingKey=dataQ2); @@ -133,3 +136,5 @@ QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/RetryList.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/RetryList.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/RetryList.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/RetryList.cpp Thu Sep 17 16:21:13 2009 @@ -24,6 +24,9 @@ using namespace qpid; using namespace qpid::broker; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(RetryListTestSuite) struct RetryListFixture @@ -36,7 +39,7 @@ { urls.push_back(Url(s)); } - + void addExpectation(const std::string& host, uint16_t port) { expected.push_back(TcpAddress(host, port)); @@ -57,7 +60,7 @@ } }; -QPID_AUTO_TEST_CASE(testWithSingleAddress) +QPID_AUTO_TEST_CASE(testWithSingleAddress) { RetryListFixture test; test.addUrl("amqp:host:5673"); @@ -65,7 +68,7 @@ test.check(); } -QPID_AUTO_TEST_CASE(testWithSingleUrlOfMultipleAddresses) +QPID_AUTO_TEST_CASE(testWithSingleUrlOfMultipleAddresses) { RetryListFixture test; test.addUrl("amqp:host1,host2:2222,tcp:host3:5673,host4:1"); @@ -78,7 +81,7 @@ test.check(); } -QPID_AUTO_TEST_CASE(testWithMultipleUrlsOfMultipleAddresses) +QPID_AUTO_TEST_CASE(testWithMultipleUrlsOfMultipleAddresses) { RetryListFixture test; test.addUrl("amqp:my-host"); @@ -97,10 +100,12 @@ test.check(); } -QPID_AUTO_TEST_CASE(testEmptyList) +QPID_AUTO_TEST_CASE(testEmptyList) { RetryListFixture test; test.check(); } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceNumberTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceNumberTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceNumberTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceNumberTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -26,6 +26,8 @@ using namespace qpid::framing; +namespace qpid { +namespace tests { void checkDifference(SequenceNumber& a, SequenceNumber& b, int gap) { @@ -54,7 +56,7 @@ BOOST_CHECK(++a < ++b);//test prefix } //keep incrementing until a also wraps around - for (int i = 0; i < (gap + 2); i++) { + for (int i = 0; i < (gap + 2); i++) { BOOST_CHECK(a++ < b++);//test postfix } //let a 'catch up' @@ -91,7 +93,7 @@ BOOST_CHECK(b != c); } -QPID_AUTO_TEST_CASE(testIncrementPrefix) +QPID_AUTO_TEST_CASE(testIncrementPrefix) { SequenceNumber a; SequenceNumber b; @@ -203,3 +205,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceSet.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceSet.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceSet.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/SequenceSet.cpp Thu Sep 17 16:21:13 2009 @@ -20,6 +20,9 @@ #include "unit_test.h" #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(SequenceSetTestSuite) using namespace qpid::framing; @@ -72,7 +75,7 @@ BOOST_CHECK(!s.contains(i)); RangeExpectations().expect(2, 5).expect(8, 8).check(s); - + SequenceSet t; t.add(6, 10); t.add(s); @@ -90,7 +93,7 @@ SequenceSet s; s.add(7,6); s.add(4,4); - s.add(3,10); + s.add(3,10); s.add(2); RangeExpectations().expect(2, 10).check(s); } @@ -137,4 +140,4 @@ QPID_AUTO_TEST_SUITE_END() - +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/SessionState.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/SessionState.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/SessionState.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/SessionState.cpp Thu Sep 17 16:21:13 2009 @@ -28,6 +28,9 @@ #include #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(SessionStateTestSuite) using namespace std; @@ -94,7 +97,7 @@ size_t transfer1Char(qpid::SessionState& s, char content) { return transfer1(s, string(1,content)); } - + // Send transfer frame with multiple single-byte content frames. size_t transferN(qpid::SessionState& s, string content) { size_t size=send(s, transferFrame(!content.empty())); @@ -134,7 +137,7 @@ BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(0,0))),"CabcCdCeCfCxyz"); // Ignore controls. s.senderRecord(AMQFrame(new SessionFlushBody())); - BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(2,0))),"CeCfCxyz"); + BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(2,0))),"CeCfCxyz"); } QPID_AUTO_TEST_CASE(testNeedFlush) { @@ -185,7 +188,7 @@ s.senderConfirmed(SessionPoint(5)); BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(5,0))), "CxCy"); BOOST_CHECK(s.senderNeedFlush()); - + s.senderConfirmed(SessionPoint(6)); BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(6,0))), "Cy"); BOOST_CHECK(!s.senderNeedFlush()); @@ -195,7 +198,7 @@ qpid::SessionState s; s.setTimeout(1); s.senderGetCommandPoint(); - // Completion implies confirmation + // Completion implies confirmation transfers(s, "abc"); BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(0,0))), "CaCbCc"); SequenceSet set(SequenceSet() + 0 + 1); @@ -205,7 +208,7 @@ transfers(s, "def"); // We dont do out-of-order confirmation, so this will only confirm up to 3: set = SequenceSet(SequenceSet() + 2 + 3 + 5); - s.senderCompleted(set); + s.senderCompleted(set); BOOST_CHECK_EQUAL(str(s.senderExpected(SessionPoint(4,0))), "CeCf"); } @@ -215,11 +218,11 @@ s.receiverSetCommandPoint(SessionPoint()); BOOST_CHECK_EQUAL(s.receiverGetExpected(), SessionPoint(0)); BOOST_CHECK_EQUAL(s.receiverGetReceived(), SessionPoint(0)); - + BOOST_CHECK(s.receiverRecord(transferFrame(false))); BOOST_CHECK_EQUAL(s.receiverGetExpected(), SessionPoint(1)); BOOST_CHECK_EQUAL(s.receiverGetReceived(), SessionPoint(1)); - + BOOST_CHECK(s.receiverRecord(transferFrame(true))); SessionPoint point = SessionPoint(1, transferFrameSize()); BOOST_CHECK_EQUAL(s.receiverGetExpected(), point); @@ -297,3 +300,5 @@ QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/Shlib.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/Shlib.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/Shlib.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/Shlib.cpp Thu Sep 17 16:21:13 2009 @@ -24,6 +24,9 @@ #include "unit_test.h" +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(ShlibTestSuite) using namespace qpid::sys; @@ -51,7 +54,7 @@ } catch (const qpid::Exception&) {} } - + QPID_AUTO_TEST_CASE(testAutoShlib) { int unloaded = 0; { @@ -66,6 +69,8 @@ } BOOST_CHECK_EQUAL(42, unloaded); } - + QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/SocketProxy.h URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/SocketProxy.h?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/SocketProxy.h (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/SocketProxy.h Thu Sep 17 16:21:13 2009 @@ -35,8 +35,11 @@ #include "qpid/sys/Mutex.h" #include "qpid/log/Statement.h" +namespace qpid { +namespace tests { + /** - * A simple socket proxy that forwards to another socket. + * A simple socket proxy that forwards to another socket. * Used between client & local broker to simulate network failures. */ class SocketProxy : private qpid::sys::Runnable @@ -59,7 +62,7 @@ joined = false; thread = qpid::sys::Thread(static_cast(this)); } - + ~SocketProxy() { close(); if (!joined) thread.join(); } /** Simulate a network disconnect. */ @@ -88,7 +91,7 @@ } uint16_t getPort() const { return port; } - + private: static void throwErrno(const std::string& msg) { throw qpid::Exception(msg+":"+qpid::sys::strError(errno)); @@ -153,7 +156,7 @@ } try { if (server.get()) server->close(); - close(); + close(); } catch (const std::exception& e) { QPID_LOG(debug, "SocketProxy::run exception in client/server close()" << e.what()); @@ -169,4 +172,6 @@ bool dropClient, dropServer; }; +}} // namespace qpid::tests + #endif Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestMessageStore.h URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestMessageStore.h?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestMessageStore.h (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestMessageStore.h Thu Sep 17 16:21:13 2009 @@ -10,9 +10,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -28,6 +28,9 @@ using namespace qpid::broker; using namespace qpid::framing; +namespace qpid { +namespace tests { + typedef std::pair > msg_queue_pair; class TestMessageStore : public NullMessageStore @@ -35,7 +38,7 @@ public: std::vector > dequeued; std::vector enqueued; - + void dequeue(TransactionContext*, const boost::intrusive_ptr& msg, const PersistableQueue& /*queue*/) @@ -47,7 +50,7 @@ const boost::intrusive_ptr& msg, const PersistableQueue& queue) { - msg->enqueueComplete(); + msg->enqueueComplete(); enqueued.push_back(msg_queue_pair(queue.getName(), msg)); } @@ -55,4 +58,6 @@ ~TestMessageStore(){} }; +}} // namespace qpid::tests + #endif Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestOptions.h URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestOptions.h?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestOptions.h (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TestOptions.h Thu Sep 17 16:21:13 2009 @@ -9,9 +9,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -67,7 +67,7 @@ connection.open(con); } - + bool help; ConnectionOptions con; qpid::log::Options log; Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TimerTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TimerTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TimerTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TimerTest.cpp Thu Sep 17 16:21:13 2009 @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -32,6 +32,9 @@ using boost::intrusive_ptr; using boost::dynamic_pointer_cast; +namespace qpid { +namespace tests { + class Counter { Mutex lock; @@ -44,7 +47,7 @@ return ++counter; } }; - + class TestTask : public TimerTask { const AbsTime start; @@ -56,7 +59,7 @@ Counter& counter; public: - TestTask(Duration timeout, Counter& _counter) + TestTask(Duration timeout, Counter& _counter) : TimerTask(timeout), start(now()), expected(timeout), end(start), fired(false), counter(_counter) {} void fire() @@ -106,14 +109,14 @@ intrusive_ptr task2(new TestTask(Duration(1 * TIME_SEC), counter)); intrusive_ptr task3(new TestTask(Duration(4 * TIME_SEC), counter)); intrusive_ptr task4(new TestTask(Duration(2 * TIME_SEC), counter)); - + timer.add(task1); timer.add(task2); timer.add(task3); timer.add(task4); - + dynamic_pointer_cast(task3)->wait(Duration(6 * TIME_SEC)); - + dynamic_pointer_cast(task1)->check(3); dynamic_pointer_cast(task2)->check(1); dynamic_pointer_cast(task3)->check(4); @@ -121,3 +124,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TopicExchangeTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TopicExchangeTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TopicExchangeTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TopicExchangeTest.cpp Thu Sep 17 16:21:13 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,11 +22,15 @@ using namespace qpid::broker; using namespace std; + +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(TopicExchangeTestSuite) #define CHECK_NORMALIZED(expect, pattern) BOOST_CHECK_EQUAL(expect, TopicExchange::normalize(pattern)); -QPID_AUTO_TEST_CASE(testNormalize) +QPID_AUTO_TEST_CASE(testNormalize) { CHECK_NORMALIZED("", ""); CHECK_NORMALIZED("a.b.c", "a.b.c"); @@ -38,8 +42,8 @@ CHECK_NORMALIZED("a.*.*.*.#", "a.*.#.*.#.*"); CHECK_NORMALIZED("*.*.*.#", "*.#.#.*.*.#"); } - -QPID_AUTO_TEST_CASE(testPlain) + +QPID_AUTO_TEST_CASE(testPlain) { string pattern("ab.cd.e"); BOOST_CHECK(TopicExchange::match(pattern, "ab.cd.e")); @@ -57,7 +61,7 @@ } -QPID_AUTO_TEST_CASE(testStar) +QPID_AUTO_TEST_CASE(testStar) { string pattern("a.*.b"); BOOST_CHECK(TopicExchange::match(pattern, "a.xx.b")); @@ -75,7 +79,7 @@ BOOST_CHECK(!TopicExchange::match(pattern, "q.x.y")); } -QPID_AUTO_TEST_CASE(testHash) +QPID_AUTO_TEST_CASE(testHash) { string pattern("a.#.b"); BOOST_CHECK(TopicExchange::match(pattern, "a.b")); @@ -99,7 +103,7 @@ BOOST_CHECK(TopicExchange::match(pattern, "a.x.x.b.y.y.c")); } -QPID_AUTO_TEST_CASE(testMixed) +QPID_AUTO_TEST_CASE(testMixed) { string pattern("*.x.#.y"); BOOST_CHECK(TopicExchange::match(pattern, "a.x.y")); @@ -119,3 +123,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxBufferTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxBufferTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxBufferTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxBufferTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -27,6 +27,9 @@ using namespace qpid::broker; using boost::static_pointer_cast; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(TxBufferTestSuite) QPID_AUTO_TEST_CASE(testCommitLocal) @@ -174,3 +177,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxMocks.h URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxMocks.h?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxMocks.h (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxMocks.h Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -32,6 +32,9 @@ using boost::static_pointer_cast; using std::string; +namespace qpid { +namespace tests { + template void assertEqualVector(std::vector& expected, std::vector& actual){ unsigned int i = 0; while(i < expected.size() && i < actual.size()){ @@ -62,15 +65,15 @@ string debugName; public: typedef boost::shared_ptr shared_ptr; - + MockTxOp() : failOnPrepare(false) {} MockTxOp(bool _failOnPrepare) : failOnPrepare(_failOnPrepare) {} - + void setDebugName(string name){ debugName = name; } - void printExpected(){ + void printExpected(){ std::cout << std::endl << "MockTxOp[" << debugName << "] expects: "; for (std::vector::iterator i = expected.begin(); i < expected.end(); i++) { if(i != expected.begin()) std::cout << ", "; @@ -79,7 +82,7 @@ std::cout << std::endl; } - void printActual(){ + void printActual(){ std::cout << std::endl << "MockTxOp[" << debugName << "] actual: "; for (std::vector::iterator i = actual.begin(); i < actual.end(); i++) { if(i != actual.begin()) std::cout << ", "; @@ -87,7 +90,7 @@ } std::cout << std::endl; } - + bool prepare(TransactionContext*) throw(){ actual.push_back(PREPARE); return !failOnPrepare; @@ -116,8 +119,8 @@ } void accept(TxOpConstVisitor&) const {} - - ~MockTxOp(){} + + ~MockTxOp(){} }; class MockTransactionalStore : public TransactionalStore{ @@ -128,10 +131,10 @@ const string ABORT; std::vector expected; std::vector actual; - + enum states {OPEN = 1, PREPARED = 2, COMMITTED = 3, ABORTED = 4}; int state; - + class TestTransactionContext : public TPCTransactionContext{ MockTransactionalStore* store; public: @@ -145,29 +148,29 @@ if(!store->isOpen() && !store->isPrepared()) throw "txn already completed"; store->state = COMMITTED; } - + void abort(){ if(!store->isOpen() && !store->isPrepared()) throw "txn already completed"; store->state = ABORTED; } ~TestTransactionContext(){} }; - + public: MockTransactionalStore() : BEGIN("BEGIN"), BEGIN2PC("BEGIN2PC"), PREPARE("PREPARE"), COMMIT("COMMIT"), ABORT("ABORT"), state(OPEN){} void collectPreparedXids(std::set&) { - throw "Operation not supported"; + throw "Operation not supported"; } - - std::auto_ptr begin(const std::string&){ + + std::auto_ptr begin(const std::string&){ actual.push_back(BEGIN2PC); std::auto_ptr txn(new TestTransactionContext(this)); return txn; } - std::auto_ptr begin(){ + std::auto_ptr begin(){ actual.push_back(BEGIN); std::auto_ptr txn(new TestTransactionContext(this)); return txn; @@ -183,7 +186,7 @@ void abort(TransactionContext& ctxt){ actual.push_back(ABORT); dynamic_cast(ctxt).abort(); - } + } MockTransactionalStore& expectBegin(){ expected.push_back(BEGIN); return *this; @@ -207,23 +210,25 @@ void check(){ assertEqualVector(expected, actual); } - + bool isPrepared(){ return state == PREPARED; } - + bool isCommitted(){ return state == COMMITTED; } - + bool isAborted(){ return state == ABORTED; } - + bool isOpen() const{ return state == OPEN; } ~MockTransactionalStore(){} }; +}} // namespace qpid::tests + #endif Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxPublishTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxPublishTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxPublishTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/TxPublishTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -35,30 +35,33 @@ using namespace qpid::broker; using namespace qpid::framing; +namespace qpid { +namespace tests { + struct TxPublishTest { - + TestMessageStore store; Queue::shared_ptr queue1; Queue::shared_ptr queue2; intrusive_ptr msg; TxPublish op; - + TxPublishTest() : - queue1(new Queue("queue1", false, &store, 0)), - queue2(new Queue("queue2", false, &store, 0)), + queue1(new Queue("queue1", false, &store, 0)), + queue2(new Queue("queue2", false, &store, 0)), msg(MessageUtils::createMessage("exchange", "routing_key", "id")), op(msg) { msg->getProperties()->setDeliveryMode(PERSISTENT); op.deliverTo(queue1); op.deliverTo(queue2); - } + } }; QPID_AUTO_TEST_SUITE(TxPublishTestSuite) - + QPID_AUTO_TEST_CASE(testPrepare) { TxPublishTest t; @@ -88,7 +91,9 @@ BOOST_CHECK_EQUAL(t.msg, msg_dequeue); BOOST_CHECK_EQUAL((uint32_t) 1, t.queue2->getMessageCount()); - BOOST_CHECK_EQUAL(t.msg, t.queue2->get().payload); + BOOST_CHECK_EQUAL(t.msg, t.queue2->get().payload); } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/Url.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/Url.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/Url.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/Url.cpp Thu Sep 17 16:21:13 2009 @@ -26,6 +26,9 @@ using namespace qpid; using namespace boost::assign; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(UrlTestSuite) #define URL_CHECK_STR(STR) BOOST_CHECK_EQUAL(Url(STR).str(), STR) @@ -65,3 +68,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/Uuid.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/Uuid.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/Uuid.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/Uuid.cpp Thu Sep 17 16:21:13 2009 @@ -24,6 +24,9 @@ #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(UuidTestSuite) using namespace std; @@ -77,3 +80,5 @@ } QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/Variant.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/Variant.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/Variant.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/Variant.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -25,6 +25,9 @@ using namespace qpid::messaging; +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(VariantSuite) QPID_AUTO_TEST_CASE(testConversions) @@ -94,11 +97,11 @@ const uint32_t i(1000); value = i; BOOST_CHECK_EQUAL(VAR_UINT32, value.getType()); - BOOST_CHECK_EQUAL(VAR_STRING, other.getType()); + BOOST_CHECK_EQUAL(VAR_STRING, other.getType()); } QPID_AUTO_TEST_CASE(testList) -{ +{ const std::string s("abc"); const float f(9.876f); const int16_t x(1000); @@ -108,7 +111,7 @@ value.asList().push_back(Variant(f)); value.asList().push_back(Variant(x)); BOOST_CHECK_EQUAL(3u, value.asList().size()); - Variant::List::const_iterator i = value.asList().begin(); + Variant::List::const_iterator i = value.asList().begin(); BOOST_CHECK(i != value.asList().end()); BOOST_CHECK_EQUAL(VAR_STRING, i->getType()); @@ -129,7 +132,7 @@ } QPID_AUTO_TEST_CASE(testMap) -{ +{ const std::string red("red"); const float pi(3.14f); const int16_t x(1000); @@ -145,7 +148,7 @@ BOOST_CHECK_EQUAL(VAR_FLOAT, value.asMap()["pi"].getType()); BOOST_CHECK_EQUAL(pi, value.asMap()["pi"].asFloat()); - + BOOST_CHECK_EQUAL(VAR_INT16, value.asMap()["my-key"].getType()); BOOST_CHECK_EQUAL(x, value.asMap()["my-key"].asInt16()); @@ -153,5 +156,7 @@ BOOST_CHECK_EQUAL(VAR_STRING, value.asMap()["my-key"].getType()); BOOST_CHECK_EQUAL(std::string("now it's a string"), value.asMap()["my-key"].asString()); } - + QPID_AUTO_TEST_SUITE_END() + +}} // namespace qpid::tests Modified: qpid/branches/java-network-refactor/qpid/cpp/src/tests/XmlClientSessionTest.cpp URL: http://svn.apache.org/viewvc/qpid/branches/java-network-refactor/qpid/cpp/src/tests/XmlClientSessionTest.cpp?rev=816261&r1=816260&r2=816261&view=diff ============================================================================== --- qpid/branches/java-network-refactor/qpid/cpp/src/tests/XmlClientSessionTest.cpp (original) +++ qpid/branches/java-network-refactor/qpid/cpp/src/tests/XmlClientSessionTest.cpp Thu Sep 17 16:21:13 2009 @@ -7,9 +7,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -39,6 +39,9 @@ #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(XmlClientSessionTest) using namespace qpid::client; @@ -118,10 +121,10 @@ FieldTable binding; binding.setString("xquery", "declare variable $color external;" "(./message/id mod 2 = 1) and ($color = 'blue')"); - f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); Message message; - message.getDeliveryProperties().setRoutingKey("query_name"); + message.getDeliveryProperties().setRoutingKey("query_name"); message.getHeaders().setString("color", "blue"); string m = "1"; @@ -130,7 +133,7 @@ f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); Message m2 = localQueue.get(); - BOOST_CHECK_EQUAL(m, m2.getData()); + BOOST_CHECK_EQUAL(m, m2.getData()); } /** @@ -146,10 +149,10 @@ FieldTable blue; blue.setString("xquery", "./colour = 'blue'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-colour", arg::arguments=blue); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-colour", arg::arguments=blue); FieldTable red; red.setString("xquery", "./colour = 'red'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-colour", arg::arguments=red); + f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-colour", arg::arguments=red); Message sent1("blue", "by-colour"); f.session.messageTransfer(arg::content=sent1, arg::destination="xml"); @@ -223,3 +226,4 @@ QPID_AUTO_TEST_SUITE_END() +}} // namespace qpid::tests --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscribe@qpid.apache.org