From 6201c9e3a33e0c75958dc0b3466953ff0152531b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 6 Sep 2007 20:27:33 +0000 Subject: Implementation of execution.result on the client side git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@573359 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 71 ++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 qpid/cpp/src/tests/ClientSessionTest.cpp (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp new file mode 100644 index 0000000000..1acac9c980 --- /dev/null +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -0,0 +1,71 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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 + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#include +#include "qpid_test_plugin.h" +#include "InProcessBroker.h" +#include "qpid/client/Session.h" + +using namespace qpid::client; +using namespace qpid::framing; + +class ClientSessionTest : public CppUnit::TestCase +{ + CPPUNIT_TEST_SUITE(ClientSessionTest); + CPPUNIT_TEST(testQueueQuery);; + CPPUNIT_TEST_SUITE_END(); + + boost::shared_ptr broker; + Connection connection; + Session session; + + public: + + ClientSessionTest() : broker(new qpid::broker::InProcessBroker()), connection(broker) + { + connection.open(""); + session = connection.newSession(); + } + + void testQueueQuery() + { + std::string name("my-queue"); + std::string alternate("amq.fanout"); + session.queueDeclare(0, name, alternate, false, false, true, true, FieldTable()); + TypedResult result = session.queueQuery(name); + CPPUNIT_ASSERT_EQUAL(false, result.get().getDurable()); + CPPUNIT_ASSERT_EQUAL(true, result.get().getExclusive()); + CPPUNIT_ASSERT_EQUAL(alternate, result.get().getAlternateExchange()); + } + + void testCompletion() + { + std::string queue("my-queue"); + std::string dest("my-dest"); + session.queueDeclare(0, queue, "", false, false, true, true, FieldTable()); + //subcribe to the queue with confirm_mode = 1 + session.messageSubscribe(0, queue, dest, false, 1, 0, false, FieldTable()); + //publish some messages + } +}; + +// Make this test suite a plugin. +CPPUNIT_PLUGIN_IMPLEMENT(); +CPPUNIT_TEST_SUITE_REGISTRATION(ClientSessionTest); -- cgit v1.2.1 From ddd56802f65dfea1743d8dd55f6911bfafd1c778 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 10 Sep 2007 08:41:05 +0000 Subject: Client side support for message and delivery properties in header segments. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@574176 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 1acac9c980..a3d50d0ae9 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -22,6 +22,7 @@ #include "qpid_test_plugin.h" #include "InProcessBroker.h" #include "qpid/client/Session.h" +#include "qpid/framing/TransferContent.h" using namespace qpid::client; using namespace qpid::framing; @@ -29,7 +30,8 @@ using namespace qpid::framing; class ClientSessionTest : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(ClientSessionTest); - CPPUNIT_TEST(testQueueQuery);; + CPPUNIT_TEST(testQueueQuery); + CPPUNIT_TEST(testTransfer); CPPUNIT_TEST_SUITE_END(); boost::shared_ptr broker; @@ -55,14 +57,24 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_ASSERT_EQUAL(alternate, result.get().getAlternateExchange()); } - void testCompletion() + void testTransfer() { std::string queue("my-queue"); std::string dest("my-dest"); + std::string data("my message"); session.queueDeclare(0, queue, "", false, false, true, true, FieldTable()); - //subcribe to the queue with confirm_mode = 1 + //subcribe to the queue with confirm_mode = 1: session.messageSubscribe(0, queue, dest, false, 1, 0, false, FieldTable()); - //publish some messages + //publish a message: + TransferContent content(data); + content.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer(0, "", 0, 0, content); + //get & test the message: + FrameSet::shared_ptr msg = session.get(); + CPPUNIT_ASSERT(msg->isA()); + CPPUNIT_ASSERT_EQUAL(data, msg->getContent()); + //confirm receipt: + session.execution().completed(msg->getId(), true, true); } }; -- cgit v1.2.1 From 14fffae30f6157a79c79ff4908d2eb68baf2143f Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 10 Sep 2007 18:37:36 +0000 Subject: Support for keyword args in session interface git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@574323 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index a3d50d0ae9..9f68716104 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -50,7 +50,7 @@ class ClientSessionTest : public CppUnit::TestCase { std::string name("my-queue"); std::string alternate("amq.fanout"); - session.queueDeclare(0, name, alternate, false, false, true, true, FieldTable()); + session.queueDeclare((queue=name, alternateExchange=alternate, exclusive=true, autoDelete=true)); TypedResult result = session.queueQuery(name); CPPUNIT_ASSERT_EQUAL(false, result.get().getDurable()); CPPUNIT_ASSERT_EQUAL(true, result.get().getExclusive()); @@ -59,16 +59,16 @@ class ClientSessionTest : public CppUnit::TestCase void testTransfer() { - std::string queue("my-queue"); + std::string queueName("my-queue"); std::string dest("my-dest"); std::string data("my message"); - session.queueDeclare(0, queue, "", false, false, true, true, FieldTable()); + session.queueDeclare_(queue=queueName, exclusive=true, autoDelete=true); //subcribe to the queue with confirm_mode = 1: - session.messageSubscribe(0, queue, dest, false, 1, 0, false, FieldTable()); + session.messageSubscribe_(queue=queueName, destination=dest, acquireMode=1); //publish a message: - TransferContent content(data); - content.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(0, "", 0, 0, content); + TransferContent _content(data); + _content.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer_(content=_content); //get & test the message: FrameSet::shared_ptr msg = session.get(); CPPUNIT_ASSERT(msg->isA()); -- cgit v1.2.1 From 813499376e288db736428c2eb6b4634dde40a34c Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 12 Sep 2007 14:49:12 +0000 Subject: In ClientChannel: Use subscribe and flush in place of get; use per-subscriber flow control for managing prefetches. In brokers Session: set credit to 0 when subscription is created (modified python tests accordingly) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@574979 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 9f68716104..7c58708974 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -65,6 +65,8 @@ class ClientSessionTest : public CppUnit::TestCase session.queueDeclare_(queue=queueName, exclusive=true, autoDelete=true); //subcribe to the queue with confirm_mode = 1: session.messageSubscribe_(queue=queueName, destination=dest, acquireMode=1); + session.messageFlow((destination=dest, unit=0, value=1));//messages + session.messageFlow((destination=dest, unit=1, value=0xFFFFFFFF));//bytes //publish a message: TransferContent _content(data); _content.getDeliveryProperties().setRoutingKey("my-queue"); -- cgit v1.2.1 From 3b5f41a9be87c29f9c4c5b7f2d28744a55b29cf1 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 18 Sep 2007 14:45:33 +0000 Subject: Added Dispatcher class (plus test). This converts incoming MessageTransfer framesets to Messages and pumps them to registered listeners. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@576935 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 63 +++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 7c58708974..12b50485e4 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -18,27 +18,55 @@ * under the License. * */ -#include +#include #include "qpid_test_plugin.h" #include "InProcessBroker.h" +#include "qpid/client/Dispatcher.h" #include "qpid/client/Session.h" #include "qpid/framing/TransferContent.h" using namespace qpid::client; using namespace qpid::framing; +struct DummyListener : public MessageListener +{ + std::list messages; + std::string name; + uint expected; + uint count; + Dispatcher dispatcher; + + DummyListener(Session& session, const std::string& _name, uint _expected) : name(_name), expected(_expected), count(0), + dispatcher(session) {} + + void listen() + { + dispatcher.listen(name, this, true, 1); + dispatcher.run(); + } + + void received(Message& msg) + { + messages.push_back(msg); + if (++count == expected) { + dispatcher.stop(); + } + } +}; + class ClientSessionTest : public CppUnit::TestCase { CPPUNIT_TEST_SUITE(ClientSessionTest); CPPUNIT_TEST(testQueueQuery); CPPUNIT_TEST(testTransfer); + CPPUNIT_TEST(testDispatcher); CPPUNIT_TEST_SUITE_END(); boost::shared_ptr broker; Connection connection; Session session; - public: +public: ClientSessionTest() : broker(new qpid::broker::InProcessBroker()), connection(broker) { @@ -78,6 +106,37 @@ class ClientSessionTest : public CppUnit::TestCase //confirm receipt: session.execution().completed(msg->getId(), true, true); } + + void testDispatcher() + { + session.queueDeclare_(queue="my-queue", exclusive=true, autoDelete=true); + + TransferContent msg1("One"); + msg1.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer_(content=msg1); + + TransferContent msg2("Two"); + msg2.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer_(content=msg2); + + TransferContent msg3("Three"); + msg3.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer_(content=msg3); + + session.messageSubscribe_(queue="my-queue", destination="my-dest", acquireMode=1); + session.messageFlow((destination="my-dest", unit=0, value=1));//messages + session.messageFlow((destination="my-dest", unit=1, value=0xFFFFFFFF));//bytes + DummyListener listener(session, "my-dest", 3); + listener.listen(); + CPPUNIT_ASSERT_EQUAL((size_t) 3, listener.messages.size()); + CPPUNIT_ASSERT_EQUAL(std::string("One"), listener.messages.front().getData()); + listener.messages.pop_front(); + CPPUNIT_ASSERT_EQUAL(std::string("Two"), listener.messages.front().getData()); + listener.messages.pop_front(); + CPPUNIT_ASSERT_EQUAL(std::string("Three"), listener.messages.front().getData()); + listener.messages.pop_front(); + + } }; // Make this test suite a plugin. -- cgit v1.2.1 From 0bd4da2ecbf28c95b9c9263ea21f710bcae558ab Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 24 Sep 2007 21:15:46 +0000 Subject: 2007-09-24 Alan Conway * cpp/src/qpid/broker/SessionManager.cpp: Manage suspended sessions. Replaces SuspendedSessions. * cpp/src/qpid/broker/SessionState.cpp: Work with SessionManager. * cpp/src/qpid/broker/SessionHandler.cpp: Owns SessionState. * cpp/src/qpid/broker/Connection.h, .cpp: Owns session handlers. * cpp/src/qpid/broker/Broker.h: Added SessionManager member. * cpp/src/Makefile.am: Added broker/SessionManager.cpp * amqp.0-10-preview.xml: Added session-busy and channel-busy constants. * cpp/src/tests/.valgrind.supp-default: Added suppresssions for F7. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@578975 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 12b50485e4..1d59fbed33 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -137,6 +137,9 @@ public: listener.messages.pop_front(); } + + void testSuspendResume() { + } }; // Make this test suite a plugin. -- cgit v1.2.1 From d20f8aab6bb42dfb668452ea0d916344034eb29c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 28 Sep 2007 16:21:34 +0000 Subject: * src/tests/ClientSessionTest.cpp: Suspend/resume tests. * broker/SessionManager.cpp, broker/SessionHandler.cpp: Implement suspend/resume * client/ScopedAssociation.h, SessionCore.h, SessionHandler.h: Simplified relationships. - Removed ScopedAssociation. - SessionHandler: is now a member of SessionCore. - SessionCore: shared_ptr ownership by Session(s) and ConnectionImpl. - Using framing::FrameHandler interfaces. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@580403 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 1d59fbed33..2495a06fa4 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -60,6 +60,8 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_TEST(testQueueQuery); CPPUNIT_TEST(testTransfer); CPPUNIT_TEST(testDispatcher); + CPPUNIT_TEST(testSuspendResume); + CPPUNIT_TEST(testSuspendResumeErrors); CPPUNIT_TEST_SUITE_END(); boost::shared_ptr broker; @@ -139,6 +141,28 @@ public: } void testSuspendResume() { + session = connection.newSession(60); + session.suspend(); + try { + session.exchangeQuery_(name="amq.fanout"); + CPPUNIT_FAIL("Expected session suspended exception"); + } catch(...) {} + connection.resume(session); + session.exchangeQuery_(name="amq.fanout"); + // FIXME aconway 2007-09-25: build up session state and confirm + //it survives the resume + } + + void testSuspendResumeErrors() { + session.suspend(); // session has 0 timeout. + try { + session.exchangeQuery_(name="amq.fanout"); + CPPUNIT_FAIL("Expected suspended session exception"); + } catch(...) {} + try { + connection.resume(session); + CPPUNIT_FAIL("Expected no such session exception."); + } catch(...) {} } }; -- cgit v1.2.1 From 00168f2176602f8bad18984031c910bb625ad80c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 26 Oct 2007 19:48:31 +0000 Subject: Session resume support in client & broker: Client can resume a session after voluntary suspend() or network failure. Frames lost in network failure are automatically re-transmitted for transparent re-connection. client::Session improvements: - Locking to avoid races between network & user threads. - Replaced client::StateManager with sys::StateMonitor - avoid heap allocation. qpid::Exception clean up: - use QPID_MSG consistently to format exception messages. - throw typed exceptions (in reply_exceptions.h) for AMQP exceptions. - re-throw correct typed exception on client for exceptions from broker. - Removed QpidError.h rubygen/templates/constants.rb: - constants.h: Added FOO_CLASS_ID and FOO_BAR_METHOD_ID constants. - reply_constants.h: Added throwReplyException(code, text) log::Logger: - Fixed shutdown race in Statement::~Initializer() git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@588761 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 151 +++++++++++++++++++++---------- 1 file changed, 105 insertions(+), 46 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 2495a06fa4..db2cd62b0a 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -18,15 +18,21 @@ * under the License. * */ -#include #include "qpid_test_plugin.h" #include "InProcessBroker.h" #include "qpid/client/Dispatcher.h" #include "qpid/client/Session.h" #include "qpid/framing/TransferContent.h" +#include "qpid/framing/reply_exceptions.h" + +#include + +#include using namespace qpid::client; using namespace qpid::framing; +using namespace qpid; +using namespace boost; struct DummyListener : public MessageListener { @@ -60,58 +66,77 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_TEST(testQueueQuery); CPPUNIT_TEST(testTransfer); CPPUNIT_TEST(testDispatcher); + CPPUNIT_TEST(testResumeExpiredError); + CPPUNIT_TEST(testUseSuspendedError); CPPUNIT_TEST(testSuspendResume); - CPPUNIT_TEST(testSuspendResumeErrors); + CPPUNIT_TEST(testDisconnectResume); + CPPUNIT_TEST(testAutoDelete); CPPUNIT_TEST_SUITE_END(); - boost::shared_ptr broker; - Connection connection; + shared_ptr broker; Session session; + // Defer construction & thread creation to setUp + boost::optional c; + boost::optional c2; public: - ClientSessionTest() : broker(new qpid::broker::InProcessBroker()), connection(broker) + void setUp() { + broker = broker::Broker::create(); + c=boost::in_place(broker); + c2=boost::in_place(broker); + } + + void tearDown() { + c2.reset(); + c.reset(); + broker.reset(); + } + + void declareSubscribe(const std::string& q="my-queue", + const std::string& dest="my-dest") { - connection.open(""); - session = connection.newSession(); + // FIXME aconway 2007-10-18: autoDelete queues are destroyed on channel close, not session. + // Fix & make all test queues exclusive, autoDelete + session.queueDeclare_(queue=q); // FIXME aconway 2007-10-01: exclusive=true, autoDelete=true); + session.messageSubscribe_(queue=q, destination=dest, acquireMode=1); + session.messageFlow_(destination=dest, unit=0, value=0xFFFFFFFF);//messages + session.messageFlow_(destination=dest, unit=1, value=0xFFFFFFFF);//bytes } + bool queueExists(const std::string& q) { + TypedResult result = session.queueQuery_(q); + return result.get().getQueue() == q; + } + void testQueueQuery() { - std::string name("my-queue"); - std::string alternate("amq.fanout"); - session.queueDeclare((queue=name, alternateExchange=alternate, exclusive=true, autoDelete=true)); - TypedResult result = session.queueQuery(name); + session = c->newSession(); + session.queueDeclare_(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); + TypedResult result = session.queueQuery_(std::string("my-queue")); CPPUNIT_ASSERT_EQUAL(false, result.get().getDurable()); CPPUNIT_ASSERT_EQUAL(true, result.get().getExclusive()); - CPPUNIT_ASSERT_EQUAL(alternate, result.get().getAlternateExchange()); + CPPUNIT_ASSERT_EQUAL(std::string("amq.fanout"), + result.get().getAlternateExchange()); } void testTransfer() { - std::string queueName("my-queue"); - std::string dest("my-dest"); - std::string data("my message"); - session.queueDeclare_(queue=queueName, exclusive=true, autoDelete=true); - //subcribe to the queue with confirm_mode = 1: - session.messageSubscribe_(queue=queueName, destination=dest, acquireMode=1); - session.messageFlow((destination=dest, unit=0, value=1));//messages - session.messageFlow((destination=dest, unit=1, value=0xFFFFFFFF));//bytes - //publish a message: - TransferContent _content(data); - _content.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer_(content=_content); + session = c->newSession(); + declareSubscribe(); + session.messageTransfer_(content=TransferContent("my-message", "my-queue")); //get & test the message: FrameSet::shared_ptr msg = session.get(); CPPUNIT_ASSERT(msg->isA()); - CPPUNIT_ASSERT_EQUAL(data, msg->getContent()); + CPPUNIT_ASSERT_EQUAL(std::string("my-message"), msg->getContent()); //confirm receipt: session.execution().completed(msg->getId(), true, true); } void testDispatcher() { - session.queueDeclare_(queue="my-queue", exclusive=true, autoDelete=true); + session = c->newSession(); + declareSubscribe(); TransferContent msg1("One"); msg1.getDeliveryProperties().setRoutingKey("my-queue"); @@ -125,9 +150,6 @@ public: msg3.getDeliveryProperties().setRoutingKey("my-queue"); session.messageTransfer_(content=msg3); - session.messageSubscribe_(queue="my-queue", destination="my-dest", acquireMode=1); - session.messageFlow((destination="my-dest", unit=0, value=1));//messages - session.messageFlow((destination="my-dest", unit=1, value=0xFFFFFFFF));//bytes DummyListener listener(session, "my-dest", 3); listener.listen(); CPPUNIT_ASSERT_EQUAL((size_t) 3, listener.messages.size()); @@ -140,29 +162,66 @@ public: } - void testSuspendResume() { - session = connection.newSession(60); + void testResumeExpiredError() { + session = c->newSession(0); + session.suspend(); // session has 0 timeout. + try { + c->resume(session); + CPPUNIT_FAIL("Expected InvalidArgumentException."); + } catch(const InvalidArgumentException&) {} + } + + void testUseSuspendedError() { + session = c->newSession(60); session.suspend(); try { session.exchangeQuery_(name="amq.fanout"); CPPUNIT_FAIL("Expected session suspended exception"); - } catch(...) {} - connection.resume(session); - session.exchangeQuery_(name="amq.fanout"); - // FIXME aconway 2007-09-25: build up session state and confirm - //it survives the resume + } catch(const CommandInvalidException&) {} } - void testSuspendResumeErrors() { - session.suspend(); // session has 0 timeout. - try { - session.exchangeQuery_(name="amq.fanout"); - CPPUNIT_FAIL("Expected suspended session exception"); - } catch(...) {} - try { - connection.resume(session); - CPPUNIT_FAIL("Expected no such session exception."); - } catch(...) {} + void testSuspendResume() { + session = c->newSession(60); + declareSubscribe(); + session.suspend(); + // Make sure we are still subscribed after resume. + c->resume(session); + session.messageTransfer_(content=TransferContent("my-message", "my-queue")); + FrameSet::shared_ptr msg = session.get(); + CPPUNIT_ASSERT_EQUAL(string("my-message"), msg->getContent()); + } + + void testDisconnectResume() { + session = c->newSession(60); + session.queueDeclare_(queue="before"); + CPPUNIT_ASSERT(queueExists("before")); + // Simulate lost frames. + c->discard(); + session.queueDeclare_(queue=string("after")); + c->disconnect(); // Simulate disconnect, resume on a new connection. + c2->resume(session); + CPPUNIT_ASSERT(queueExists("after")); + } + + void testAutoDelete() { + // Verify that autoDelete queues survive suspend/resume. + session = c->newSession(60); + session.queueDeclare_(queue="my-queue", exclusive=true, autoDelete=true); + CPPUNIT_ASSERT(queueExists("my-queue")); + session.suspend(); + c->resume(session); + CPPUNIT_ASSERT(queueExists("my-queue")); + + // Verify they survive disconnect/resume on new Connection + c->disconnect(); + c2->resume(session); + + try { + // FIXME aconway 2007-10-23: Negative test, need to + // fix auto-delete queues to clean up with session, not channel. + CPPUNIT_ASSERT(queueExists("my-queue")); + CPPUNIT_FAIL("Negative test passed unexpectedly"); + } catch(const ChannelException&) {} } }; -- cgit v1.2.1 From 36b42cd7921cae46f99cc6bf1c83f2ddacf21395 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 29 Oct 2007 18:35:29 +0000 Subject: Rename client::Session as client::Session_0_10 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@589794 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index db2cd62b0a..149cbd8e3d 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -21,7 +21,7 @@ #include "qpid_test_plugin.h" #include "InProcessBroker.h" #include "qpid/client/Dispatcher.h" -#include "qpid/client/Session.h" +#include "qpid/client/Session_0_10.h" #include "qpid/framing/TransferContent.h" #include "qpid/framing/reply_exceptions.h" @@ -42,7 +42,7 @@ struct DummyListener : public MessageListener uint count; Dispatcher dispatcher; - DummyListener(Session& session, const std::string& _name, uint _expected) : name(_name), expected(_expected), count(0), + DummyListener(Session_0_10& session, const std::string& _name, uint _expected) : name(_name), expected(_expected), count(0), dispatcher(session) {} void listen() @@ -74,7 +74,7 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_TEST_SUITE_END(); shared_ptr broker; - Session session; + Session_0_10 session; // Defer construction & thread creation to setUp boost::optional c; boost::optional c2; -- cgit v1.2.1 From 32bfb737f530e983876fc4d39d6a07b22368800e Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 30 Oct 2007 22:39:46 +0000 Subject: Client API: fix keyword parameter ambiguities for beta client API. Classes: - client::no_keyword::Session_0_10 - plain defaulted signatures - client::Session_0_10 - keyword API. Keyword API changes: - keywords in client::arg namespace, user says: s.bind(arg::queue="x"...) - user can omit with: using namespace client::arg; s.bind(queue="x"...) - No trailing "_" required on session functions. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@590498 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 33 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 149cbd8e3d..ed3d733c20 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -30,6 +30,7 @@ #include using namespace qpid::client; +using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; using namespace boost; @@ -98,22 +99,22 @@ public: { // FIXME aconway 2007-10-18: autoDelete queues are destroyed on channel close, not session. // Fix & make all test queues exclusive, autoDelete - session.queueDeclare_(queue=q); // FIXME aconway 2007-10-01: exclusive=true, autoDelete=true); - session.messageSubscribe_(queue=q, destination=dest, acquireMode=1); - session.messageFlow_(destination=dest, unit=0, value=0xFFFFFFFF);//messages - session.messageFlow_(destination=dest, unit=1, value=0xFFFFFFFF);//bytes + session.queueDeclare(queue=q); // FIXME aconway 2007-10-01: exclusive=true, autoDelete=true); + session.messageSubscribe(queue=q, destination=dest, acquireMode=1); + session.messageFlow(destination=dest, unit=0, value=0xFFFFFFFF);//messages + session.messageFlow(destination=dest, unit=1, value=0xFFFFFFFF);//bytes } bool queueExists(const std::string& q) { - TypedResult result = session.queueQuery_(q); + TypedResult result = session.queueQuery(q); return result.get().getQueue() == q; } void testQueueQuery() { session = c->newSession(); - session.queueDeclare_(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); - TypedResult result = session.queueQuery_(std::string("my-queue")); + session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); + TypedResult result = session.queueQuery(std::string("my-queue")); CPPUNIT_ASSERT_EQUAL(false, result.get().getDurable()); CPPUNIT_ASSERT_EQUAL(true, result.get().getExclusive()); CPPUNIT_ASSERT_EQUAL(std::string("amq.fanout"), @@ -124,7 +125,7 @@ public: { session = c->newSession(); declareSubscribe(); - session.messageTransfer_(content=TransferContent("my-message", "my-queue")); + session.messageTransfer(content=TransferContent("my-message", "my-queue")); //get & test the message: FrameSet::shared_ptr msg = session.get(); CPPUNIT_ASSERT(msg->isA()); @@ -140,15 +141,15 @@ public: TransferContent msg1("One"); msg1.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer_(content=msg1); + session.messageTransfer(content=msg1); TransferContent msg2("Two"); msg2.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer_(content=msg2); + session.messageTransfer(content=msg2); TransferContent msg3("Three"); msg3.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer_(content=msg3); + session.messageTransfer(content=msg3); DummyListener listener(session, "my-dest", 3); listener.listen(); @@ -175,7 +176,7 @@ public: session = c->newSession(60); session.suspend(); try { - session.exchangeQuery_(name="amq.fanout"); + session.exchangeQuery(name="amq.fanout"); CPPUNIT_FAIL("Expected session suspended exception"); } catch(const CommandInvalidException&) {} } @@ -186,18 +187,18 @@ public: session.suspend(); // Make sure we are still subscribed after resume. c->resume(session); - session.messageTransfer_(content=TransferContent("my-message", "my-queue")); + session.messageTransfer(content=TransferContent("my-message", "my-queue")); FrameSet::shared_ptr msg = session.get(); CPPUNIT_ASSERT_EQUAL(string("my-message"), msg->getContent()); } void testDisconnectResume() { session = c->newSession(60); - session.queueDeclare_(queue="before"); + session.queueDeclare(queue="before"); CPPUNIT_ASSERT(queueExists("before")); // Simulate lost frames. c->discard(); - session.queueDeclare_(queue=string("after")); + session.queueDeclare(queue=string("after")); c->disconnect(); // Simulate disconnect, resume on a new connection. c2->resume(session); CPPUNIT_ASSERT(queueExists("after")); @@ -206,7 +207,7 @@ public: void testAutoDelete() { // Verify that autoDelete queues survive suspend/resume. session = c->newSession(60); - session.queueDeclare_(queue="my-queue", exclusive=true, autoDelete=true); + session.queueDeclare(queue="my-queue", exclusive=true, autoDelete=true); CPPUNIT_ASSERT(queueExists("my-queue")); session.suspend(); c->resume(session); -- cgit v1.2.1 From 2e45c6ba10c0a5b2100197fc33472eea5df5ba05 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 7 Nov 2007 19:57:46 +0000 Subject: client::SubscriptionManager: - Added autoStop support. - Added LocalQueue subscriptions. - Expose AckPolicy settings to user. client::Message: - incoming Messages carry their session for acknowledge perftest: (see perftest --help for details...) - allow multiple consumers. - 3 queue modes: shared, fanout, topic. - set size of messages git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@592869 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index ed3d733c20..369477131c 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -48,7 +48,7 @@ struct DummyListener : public MessageListener void listen() { - dispatcher.listen(name, this, true, 1); + dispatcher.listen(name, this); dispatcher.run(); } -- cgit v1.2.1 From 2e75ce2a7bc1a94c294def9f70789c49770c2470 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 22 Nov 2007 23:55:39 +0000 Subject: Added framing::BodyHolder: - Uniform holder for all body types, replaces MethodHolder. - Uses in_place constructors to avoid avoid body copy. framing::AMQFrame: - Holds body in heap-allocated intrusive_ptr - Uses in_place constructors to avoid avoid body copy. Removed/downgraded to TODO many redundant FIXME comments. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@597513 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 369477131c..5d87e1f76b 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -71,7 +71,6 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_TEST(testUseSuspendedError); CPPUNIT_TEST(testSuspendResume); CPPUNIT_TEST(testDisconnectResume); - CPPUNIT_TEST(testAutoDelete); CPPUNIT_TEST_SUITE_END(); shared_ptr broker; @@ -97,9 +96,7 @@ public: void declareSubscribe(const std::string& q="my-queue", const std::string& dest="my-dest") { - // FIXME aconway 2007-10-18: autoDelete queues are destroyed on channel close, not session. - // Fix & make all test queues exclusive, autoDelete - session.queueDeclare(queue=q); // FIXME aconway 2007-10-01: exclusive=true, autoDelete=true); + session.queueDeclare(queue=q); session.messageSubscribe(queue=q, destination=dest, acquireMode=1); session.messageFlow(destination=dest, unit=0, value=0xFFFFFFFF);//messages session.messageFlow(destination=dest, unit=1, value=0xFFFFFFFF);//bytes @@ -203,27 +200,6 @@ public: c2->resume(session); CPPUNIT_ASSERT(queueExists("after")); } - - void testAutoDelete() { - // Verify that autoDelete queues survive suspend/resume. - session = c->newSession(60); - session.queueDeclare(queue="my-queue", exclusive=true, autoDelete=true); - CPPUNIT_ASSERT(queueExists("my-queue")); - session.suspend(); - c->resume(session); - CPPUNIT_ASSERT(queueExists("my-queue")); - - // Verify they survive disconnect/resume on new Connection - c->disconnect(); - c2->resume(session); - - try { - // FIXME aconway 2007-10-23: Negative test, need to - // fix auto-delete queues to clean up with session, not channel. - CPPUNIT_ASSERT(queueExists("my-queue")); - CPPUNIT_FAIL("Negative test passed unexpectedly"); - } catch(const ChannelException&) {} - } }; // Make this test suite a plugin. -- cgit v1.2.1 From 408b7835d66f6c46bfd91094f3f21dafc2568953 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 28 Nov 2007 13:28:21 +0000 Subject: Disable recoding of frames for replay where replay will not be required. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@598992 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 5d87e1f76b..ac2cf155f4 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -166,7 +166,7 @@ public: try { c->resume(session); CPPUNIT_FAIL("Expected InvalidArgumentException."); - } catch(const InvalidArgumentException&) {} + } catch(const InternalErrorException&) {} } void testUseSuspendedError() { -- cgit v1.2.1 From 93a87010ba58b42e2fe153504b4781978d128a6c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 7 Dec 2007 19:13:09 +0000 Subject: Summary: - Replaced InProcessBroker with BrokerFixture, uses a full loopback broker for more realistic tests. - Extracted non-generated parts of Session_0_10 into SessionBase. - Sundry small fixes. src/tests/BrokerFixture.h - in process broker with loopback connections. - tests can force a disorderly disconnect. src/qpid/client/Connector.h - back door to private members for BrokerFixture. - close() in destructor to avoid leaks. src/qpid/client/ConnectionImpl.h,cpp: - close() in destructor, to fix hang when destroyed without being closed. src/qpid/client/CompletionTracker.h,.cpp: - Fixed race in close/add. src/qpid/client/SessionBase.h,cpp: - Extracted all non-generated code from Session_0_10 into SessionBase - Added sync() src/tests/exception_test.cpp: Converted to boost & BrokerFixture src/tests/ClientChannelTest.cpp, ClientSessionTest.cpp: Use BrokerFixture git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@602182 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 44 +++++++++++++------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index ac2cf155f4..70e8a41074 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -19,7 +19,7 @@ * */ #include "qpid_test_plugin.h" -#include "InProcessBroker.h" +#include "BrokerFixture.h" #include "qpid/client/Dispatcher.h" #include "qpid/client/Session_0_10.h" #include "qpid/framing/TransferContent.h" @@ -61,7 +61,7 @@ struct DummyListener : public MessageListener } }; -class ClientSessionTest : public CppUnit::TestCase +class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture { CPPUNIT_TEST_SUITE(ClientSessionTest); CPPUNIT_TEST(testQueueQuery); @@ -74,23 +74,14 @@ class ClientSessionTest : public CppUnit::TestCase CPPUNIT_TEST_SUITE_END(); shared_ptr broker; - Session_0_10 session; - // Defer construction & thread creation to setUp - boost::optional c; - boost::optional c2; -public: + public: void setUp() { broker = broker::Broker::create(); - c=boost::in_place(broker); - c2=boost::in_place(broker); } void tearDown() { - c2.reset(); - c.reset(); - broker.reset(); } void declareSubscribe(const std::string& q="my-queue", @@ -109,7 +100,7 @@ public: void testQueueQuery() { - session = c->newSession(); + session =connection.newSession(); session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); TypedResult result = session.queueQuery(std::string("my-queue")); CPPUNIT_ASSERT_EQUAL(false, result.get().getDurable()); @@ -120,7 +111,7 @@ public: void testTransfer() { - session = c->newSession(); + session =connection.newSession(); declareSubscribe(); session.messageTransfer(content=TransferContent("my-message", "my-queue")); //get & test the message: @@ -128,12 +119,12 @@ public: CPPUNIT_ASSERT(msg->isA()); CPPUNIT_ASSERT_EQUAL(std::string("my-message"), msg->getContent()); //confirm receipt: - session.execution().completed(msg->getId(), true, true); + session.getExecution().completed(msg->getId(), true, true); } void testDispatcher() { - session = c->newSession(); + session =connection.newSession(); declareSubscribe(); TransferContent msg1("One"); @@ -161,16 +152,16 @@ public: } void testResumeExpiredError() { - session = c->newSession(0); + session =connection.newSession(0); session.suspend(); // session has 0 timeout. try { - c->resume(session); + connection.resume(session); CPPUNIT_FAIL("Expected InvalidArgumentException."); } catch(const InternalErrorException&) {} } void testUseSuspendedError() { - session = c->newSession(60); + session =connection.newSession(60); session.suspend(); try { session.exchangeQuery(name="amq.fanout"); @@ -179,26 +170,27 @@ public: } void testSuspendResume() { - session = c->newSession(60); + session =connection.newSession(60); declareSubscribe(); session.suspend(); // Make sure we are still subscribed after resume. - c->resume(session); + connection.resume(session); session.messageTransfer(content=TransferContent("my-message", "my-queue")); FrameSet::shared_ptr msg = session.get(); CPPUNIT_ASSERT_EQUAL(string("my-message"), msg->getContent()); } void testDisconnectResume() { - session = c->newSession(60); + session =connection.newSession(60); session.queueDeclare(queue="before"); CPPUNIT_ASSERT(queueExists("before")); - // Simulate lost frames. - c->discard(); session.queueDeclare(queue=string("after")); - c->disconnect(); // Simulate disconnect, resume on a new connection. - c2->resume(session); + disconnect(connection); + Connection c2; + open(c2); + c2.resume(session); CPPUNIT_ASSERT(queueExists("after")); + c2.close(); } }; -- cgit v1.2.1 From ef19d923c46c43e937f1d4dd91c906bda08d64bd Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 10 Dec 2007 17:57:49 +0000 Subject: src/tests/SocketProxy.h: proxy between local client & server to simulate network disconnect. src/qpid/client/Connector.h: remove friend hack for previous flawed disconnect approach. src/tests/BrokerFixture.h: "" src/tests/ClientSessionTest.cpp, exception_test.cpp: use ProxyConnection git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@602980 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 70e8a41074..a960cea230 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -20,6 +20,7 @@ */ #include "qpid_test_plugin.h" #include "BrokerFixture.h" +#include "SocketProxy.h" #include "qpid/client/Dispatcher.h" #include "qpid/client/Session_0_10.h" #include "qpid/framing/TransferContent.h" @@ -181,14 +182,15 @@ class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture } void testDisconnectResume() { - session =connection.newSession(60); - session.queueDeclare(queue="before"); + ProxyConnection c(broker->getPort()); + Session_0_10 s = c.session; + s.queueDeclare(queue="before"); CPPUNIT_ASSERT(queueExists("before")); - session.queueDeclare(queue=string("after")); - disconnect(connection); + s.queueDeclare(queue=string("after")); + c.proxy.client.close(); // Disconnect the client. Connection c2; open(c2); - c2.resume(session); + c2.resume(s); CPPUNIT_ASSERT(queueExists("after")); c2.close(); } -- cgit v1.2.1 From a1ac9e3af90d2f3ec06fc1bf510d3e1d963ca4aa Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 11 Dec 2007 15:29:54 +0000 Subject: src/tests/ClientSessionTest.cpp: Disabled hanging test: testDisconnectResume. src/tests/SocketProxy.h: fixed exception handling. src/tests/exception_test.cpp: fixed compile error. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@603273 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index a960cea230..5f45e1f938 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -74,17 +74,8 @@ class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture CPPUNIT_TEST(testDisconnectResume); CPPUNIT_TEST_SUITE_END(); - shared_ptr broker; - public: - void setUp() { - broker = broker::Broker::create(); - } - - void tearDown() { - } - void declareSubscribe(const std::string& q="my-queue", const std::string& dest="my-dest") { @@ -182,17 +173,18 @@ class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture } void testDisconnectResume() { - ProxyConnection c(broker->getPort()); - Session_0_10 s = c.session; - s.queueDeclare(queue="before"); - CPPUNIT_ASSERT(queueExists("before")); - s.queueDeclare(queue=string("after")); - c.proxy.client.close(); // Disconnect the client. - Connection c2; - open(c2); - c2.resume(s); - CPPUNIT_ASSERT(queueExists("after")); - c2.close(); + // FIXME aconway 2007-12-11: Test hanging. +// ProxyConnection c(broker->getPort()); +// Session_0_10 s = c.session; +// s.queueDeclare(queue="before"); +// CPPUNIT_ASSERT(queueExists("before")); +// s.queueDeclare(queue=string("after")); +// c.proxy.client.close(); // Disconnect the client. +// Connection c2; +// open(c2); +// c2.resume(s); +// CPPUNIT_ASSERT(queueExists("after")); +// c2.close(); } }; -- cgit v1.2.1 From 21929425a5e5f62b74c67b20641f5e029551770f Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 24 Jan 2008 22:26:12 +0000 Subject: Improved/additional client API tests. - Replaced InProcessBroker with a more accurate loopback BrokerFixture. - Added asserts for mutex/condition/thread errors in debug build. - Added client tests for several exception conditions. - Added peer address to log ouput, client/server distinguished by (addr) or [addr] - Fixed various deadlocks & races exposed by the new asserts & tests. File-by-file: New BrokerFixture replaces InProcessBroker D src/tests/InProcessBroker.h M src/tests/BrokerFixture.h M src/tests/SocketProxy.h M src/tests/Makefile.am Made it run a bit faster. M src/tests/quick_perftest Redundant D src/tests/APRBaseTest.cpp Updated tests to use BrokerFixture M src/tests/ClientChannelTest.cpp M src/tests/exception_test.cpp M src/tests/ClientSessionTest.cpp Print thread IDs in decimal, same as GDB. M src/qpid/log/Logger.cpp Assert mutex/condition ops in debug build. M src/qpid/sys/posix/check.h M src/qpid/sys/posix/Mutex.h M src/qpid/sys/posix/Condition.h M src/qpid/sys/posix/Thread.h Added toFd() so SocketProxy can use ::select() M src/qpid/sys/Socket.h M src/qpid/sys/posix/Socket.cpp Fixes for races & deadlocks shown up by new tests & asserts. Mostly shutdown/close issues. M src/qpid/client/ConnectionHandler.h M src/qpid/client/ConnectionImpl.cpp M src/qpid/client/Demux.h M src/qpid/client/SessionCore.cpp M src/qpid/client/ConnectionHandler.cpp M src/qpid/client/Connector.h M src/qpid/client/Demux.cpp M src/qpid/client/Dispatcher.cpp M src/qpid/client/ConnectionImpl.h Logging peer address. M src/qpid/sys/AsynchIOAcceptor.cpp git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@615063 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 5f45e1f938..82db7b9545 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -20,7 +20,6 @@ */ #include "qpid_test_plugin.h" #include "BrokerFixture.h" -#include "SocketProxy.h" #include "qpid/client/Dispatcher.h" #include "qpid/client/Session_0_10.h" #include "qpid/framing/TransferContent.h" @@ -62,7 +61,7 @@ struct DummyListener : public MessageListener } }; -class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture +class ClientSessionTest : public CppUnit::TestCase, public ProxySessionFixture { CPPUNIT_TEST_SUITE(ClientSessionTest); CPPUNIT_TEST(testQueueQuery); @@ -71,7 +70,6 @@ class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture CPPUNIT_TEST(testResumeExpiredError); CPPUNIT_TEST(testUseSuspendedError); CPPUNIT_TEST(testSuspendResume); - CPPUNIT_TEST(testDisconnectResume); CPPUNIT_TEST_SUITE_END(); public: @@ -85,11 +83,6 @@ class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture session.messageFlow(destination=dest, unit=1, value=0xFFFFFFFF);//bytes } - bool queueExists(const std::string& q) { - TypedResult result = session.queueQuery(q); - return result.get().getQueue() == q; - } - void testQueueQuery() { session =connection.newSession(); @@ -166,26 +159,11 @@ class ClientSessionTest : public CppUnit::TestCase, public BrokerFixture declareSubscribe(); session.suspend(); // Make sure we are still subscribed after resume. - connection.resume(session); + connection.resume(session); session.messageTransfer(content=TransferContent("my-message", "my-queue")); FrameSet::shared_ptr msg = session.get(); CPPUNIT_ASSERT_EQUAL(string("my-message"), msg->getContent()); } - - void testDisconnectResume() { - // FIXME aconway 2007-12-11: Test hanging. -// ProxyConnection c(broker->getPort()); -// Session_0_10 s = c.session; -// s.queueDeclare(queue="before"); -// CPPUNIT_ASSERT(queueExists("before")); -// s.queueDeclare(queue=string("after")); -// c.proxy.client.close(); // Disconnect the client. -// Connection c2; -// open(c2); -// c2.resume(s); -// CPPUNIT_ASSERT(queueExists("after")); -// c2.close(); - } }; // Make this test suite a plugin. -- cgit v1.2.1 From bdbf9ebf5b41d070eb200644d5c2f39f0175ecef Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 28 Jan 2008 17:17:06 +0000 Subject: Convert ClientSessionTest to boost. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@615958 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 204 +++++++++++++++---------------- 1 file changed, 98 insertions(+), 106 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 82db7b9545..320d3afd27 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -18,35 +18,42 @@ * under the License. * */ -#include "qpid_test_plugin.h" +#include "unit_test.h" #include "BrokerFixture.h" #include "qpid/client/Dispatcher.h" +#include "qpid/sys/Thread.h" +#include "qpid/sys/Runnable.h" #include "qpid/client/Session_0_10.h" #include "qpid/framing/TransferContent.h" #include "qpid/framing/reply_exceptions.h" #include +#include -#include +#include + +QPID_AUTO_TEST_SUITE(ClientSessionTest) using namespace qpid::client; using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; +using std::string; +using std::cout; +using std::endl; using namespace boost; -struct DummyListener : public MessageListener -{ - std::list messages; - std::string name; + +struct DummyListener : public sys::Runnable, public MessageListener { + std::vector messages; + string name; uint expected; - uint count; Dispatcher dispatcher; - DummyListener(Session_0_10& session, const std::string& _name, uint _expected) : name(_name), expected(_expected), count(0), - dispatcher(session) {} + DummyListener(Session_0_10& session, const string& n, uint ex) : + name(n), expected(ex), dispatcher(session) {} - void listen() + void run() { dispatcher.listen(name, this); dispatcher.run(); @@ -55,117 +62,102 @@ struct DummyListener : public MessageListener void received(Message& msg) { messages.push_back(msg); - if (++count == expected) { + if (--expected == 0) dispatcher.stop(); - } } }; -class ClientSessionTest : public CppUnit::TestCase, public ProxySessionFixture +struct ClientSessionFixture : public ProxySessionFixture { - CPPUNIT_TEST_SUITE(ClientSessionTest); - CPPUNIT_TEST(testQueueQuery); - CPPUNIT_TEST(testTransfer); - CPPUNIT_TEST(testDispatcher); - CPPUNIT_TEST(testResumeExpiredError); - CPPUNIT_TEST(testUseSuspendedError); - CPPUNIT_TEST(testSuspendResume); - CPPUNIT_TEST_SUITE_END(); - - public: - - void declareSubscribe(const std::string& q="my-queue", - const std::string& dest="my-dest") + void declareSubscribe(const string& q="my-queue", + const string& dest="my-dest") { session.queueDeclare(queue=q); session.messageSubscribe(queue=q, destination=dest, acquireMode=1); session.messageFlow(destination=dest, unit=0, value=0xFFFFFFFF);//messages session.messageFlow(destination=dest, unit=1, value=0xFFFFFFFF);//bytes } +}; - void testQueueQuery() - { - session =connection.newSession(); - session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); - TypedResult result = session.queueQuery(std::string("my-queue")); - CPPUNIT_ASSERT_EQUAL(false, result.get().getDurable()); - CPPUNIT_ASSERT_EQUAL(true, result.get().getExclusive()); - CPPUNIT_ASSERT_EQUAL(std::string("amq.fanout"), - result.get().getAlternateExchange()); - } - - void testTransfer() - { - session =connection.newSession(); - declareSubscribe(); - session.messageTransfer(content=TransferContent("my-message", "my-queue")); - //get & test the message: - FrameSet::shared_ptr msg = session.get(); - CPPUNIT_ASSERT(msg->isA()); - CPPUNIT_ASSERT_EQUAL(std::string("my-message"), msg->getContent()); - //confirm receipt: - session.getExecution().completed(msg->getId(), true, true); - } - - void testDispatcher() - { - session =connection.newSession(); - declareSubscribe(); +BOOST_FIXTURE_TEST_CASE(testQueueQuery, ClientSessionFixture) { + session =connection.newSession(); + session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); + TypedResult result = session.queueQuery(string("my-queue")); + BOOST_CHECK_EQUAL(false, result.get().getDurable()); + BOOST_CHECK_EQUAL(true, result.get().getExclusive()); + BOOST_CHECK_EQUAL(string("amq.fanout"), + result.get().getAlternateExchange()); +} + +BOOST_FIXTURE_TEST_CASE(testTransfer, ClientSessionFixture) +{ + session=connection.newSession(); + declareSubscribe(); + session.messageTransfer(content=TransferContent("my-message", "my-queue")); + //get & test the message: + FrameSet::shared_ptr msg = session.get(); + BOOST_CHECK(msg->isA()); + BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); + //confirm receipt: + session.getExecution().completed(msg->getId(), true, true); +} + +BOOST_FIXTURE_TEST_CASE(testDispatcher, ClientSessionFixture) +{ + session =connection.newSession(); + declareSubscribe(); - TransferContent msg1("One"); - msg1.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(content=msg1); + TransferContent msg1("One"); + msg1.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer(content=msg1); - TransferContent msg2("Two"); - msg2.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(content=msg2); + TransferContent msg2("Two"); + msg2.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer(content=msg2); - TransferContent msg3("Three"); - msg3.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(content=msg3); + TransferContent msg3("Three"); + msg3.getDeliveryProperties().setRoutingKey("my-queue"); + session.messageTransfer(content=msg3); - DummyListener listener(session, "my-dest", 3); - listener.listen(); - CPPUNIT_ASSERT_EQUAL((size_t) 3, listener.messages.size()); - CPPUNIT_ASSERT_EQUAL(std::string("One"), listener.messages.front().getData()); - listener.messages.pop_front(); - CPPUNIT_ASSERT_EQUAL(std::string("Two"), listener.messages.front().getData()); - listener.messages.pop_front(); - CPPUNIT_ASSERT_EQUAL(std::string("Three"), listener.messages.front().getData()); - listener.messages.pop_front(); - - } - - void testResumeExpiredError() { - session =connection.newSession(0); - session.suspend(); // session has 0 timeout. - try { - connection.resume(session); - CPPUNIT_FAIL("Expected InvalidArgumentException."); - } catch(const InternalErrorException&) {} - } - - void testUseSuspendedError() { - session =connection.newSession(60); - session.suspend(); - try { - session.exchangeQuery(name="amq.fanout"); - CPPUNIT_FAIL("Expected session suspended exception"); - } catch(const CommandInvalidException&) {} - } - - void testSuspendResume() { - session =connection.newSession(60); - declareSubscribe(); - session.suspend(); - // Make sure we are still subscribed after resume. + DummyListener listener(session, "my-dest", 3); + listener.run(); + BOOST_CHECK_EQUAL((size_t) 3, listener.messages.size()); + BOOST_CHECK_EQUAL(std::string("One"), listener.messages[0].getData()); + BOOST_CHECK_EQUAL(std::string("Two"), listener.messages[1].getData()); + BOOST_CHECK_EQUAL(std::string("Three"), listener.messages[2].getData()); +} + +BOOST_FIXTURE_TEST_CASE(_FIXTURE, ClientSessionFixture) +{ + session =connection.newSession(0); + session.suspend(); // session has 0 timeout. + try { connection.resume(session); - session.messageTransfer(content=TransferContent("my-message", "my-queue")); - FrameSet::shared_ptr msg = session.get(); - CPPUNIT_ASSERT_EQUAL(string("my-message"), msg->getContent()); - } -}; + BOOST_FAIL("Expected InvalidArgumentException."); + } catch(const InternalErrorException&) {} +} + +BOOST_FIXTURE_TEST_CASE(testUseSuspendedError, ClientSessionFixture) +{ + session =connection.newSession(60); + session.suspend(); + try { + session.exchangeQuery(name="amq.fanout"); + BOOST_FAIL("Expected session suspended exception"); + } catch(const CommandInvalidException&) {} +} + +BOOST_FIXTURE_TEST_CASE(testSuspendResume, ClientSessionFixture) +{ + session =connection.newSession(60); + declareSubscribe(); + session.suspend(); + // Make sure we are still subscribed after resume. + connection.resume(session); + session.messageTransfer(content=TransferContent("my-message", "my-queue")); + FrameSet::shared_ptr msg = session.get(); + BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); +} + +QPID_AUTO_TEST_SUITE_END() -// Make this test suite a plugin. -CPPUNIT_PLUGIN_IMPLEMENT(); -CPPUNIT_TEST_SUITE_REGISTRATION(ClientSessionTest); -- cgit v1.2.1 From 71953a76caba28be5083ed2ec1bf01dfe4b3a97b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 28 Jan 2008 17:42:22 +0000 Subject: Added disabled test and FIXME note to fix client-side race. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@615968 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 44 +++++++++++++++++++------------- 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 320d3afd27..f9de3b7619 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -106,26 +106,34 @@ BOOST_FIXTURE_TEST_CASE(testDispatcher, ClientSessionFixture) { session =connection.newSession(); declareSubscribe(); - - TransferContent msg1("One"); - msg1.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(content=msg1); - - TransferContent msg2("Two"); - msg2.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(content=msg2); - - TransferContent msg3("Three"); - msg3.getDeliveryProperties().setRoutingKey("my-queue"); - session.messageTransfer(content=msg3); - - DummyListener listener(session, "my-dest", 3); + size_t count = 100; + for (size_t i = 0; i < count; ++i) + session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); + DummyListener listener(session, "my-dest", count); listener.run(); - BOOST_CHECK_EQUAL((size_t) 3, listener.messages.size()); - BOOST_CHECK_EQUAL(std::string("One"), listener.messages[0].getData()); - BOOST_CHECK_EQUAL(std::string("Two"), listener.messages[1].getData()); - BOOST_CHECK_EQUAL(std::string("Three"), listener.messages[2].getData()); + BOOST_REQUIRE_EQUAL(count, listener.messages.size()); + for (size_t i = 0; i < count; ++i) + BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); +} + +/* FIXME aconway 2008-01-28: hangs +BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) +{ + session =connection.newSession(); + declareSubscribe(); + size_t count = 10000; + DummyListener listener(session, "my-dest", count); + sys::Thread t(listener); + for (size_t i = 0; i < count; ++i) { + session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); + if (i%100 == 0) cout << "T" << i << std::flush; + } + t.join(); + BOOST_REQUIRE_EQUAL(count, listener.messages.size()); + for (size_t i = 0; i < count; ++i) + BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } +*/ BOOST_FIXTURE_TEST_CASE(_FIXTURE, ClientSessionFixture) { -- cgit v1.2.1 From 363794a568ee719e226c5c116d386277e784d3c5 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 5 Feb 2008 20:44:14 +0000 Subject: Added testSendToSelf for https://bugzilla.redhat.com/show_bug.cgi?id=410551 M src/tests/ClientSessionTest.cpp Disabled management for BrokerFixture - management singleton assumes only one broker per process, causes shutdown races with fixtures. M src/tests/BrokerFixture.h Made Timer::stop() idempotent M src/qpid/broker/Timer.cpp M src/qpid/broker/Timer.h Added STL-style size() and empty() M src/qpid/sys/BlockingQueue.h M src/qpid/client/LocalQueue.cpp M src/qpid/client/LocalQueue.h git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@618770 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index f9de3b7619..60cfe04510 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -167,5 +167,22 @@ BOOST_FIXTURE_TEST_CASE(testSuspendResume, ClientSessionFixture) BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } +BOOST_FIXTURE_TEST_CASE(testSendToSelf, SessionFixture) { + // https://bugzilla.redhat.com/show_bug.cgi?id=410551 + // Deadlock if SubscriptionManager run() concurrent with session ack. + LocalQueue myq; + session.queueDeclare(queue="myq", exclusive=true, autoDelete=true); + subs.subscribe(myq, "myq"); + string data("msg"); + Message msg(data, "myq"); + const int count=100; // Verified with count=100000 in a loop. + for (int i = 0; i < count; ++i) + session.messageTransfer(content=msg); + for (int j = 0; j < count; ++j) { + Message m=myq.pop(); + BOOST_CHECK_EQUAL(m.getData(), data); + } +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 2bc8de1cf167758a79e424222567450b0dd5b6f3 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 11 Feb 2008 13:10:38 +0000 Subject: Added a test (currently disabled) that highlights a deadlock in the client when commands are sent to the broker concurrently with acks (e.g. when the dispatcher thread is running with auto-acking and messages are sent on another thread). git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@620481 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 48 ++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 60cfe04510..87a4f59999 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -21,6 +21,7 @@ #include "unit_test.h" #include "BrokerFixture.h" #include "qpid/client/Dispatcher.h" +#include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" #include "qpid/client/Session_0_10.h" @@ -38,6 +39,7 @@ using namespace qpid::client; using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; +using qpid::sys::Monitor; using std::string; using std::cout; using std::endl; @@ -67,6 +69,27 @@ struct DummyListener : public sys::Runnable, public MessageListener { } }; +struct SimpleListener : public MessageListener +{ + Monitor lock; + std::vector messages; + + void received(Message& msg) + { + Monitor::ScopedLock l(lock); + messages.push_back(msg); + lock.notifyAll(); + } + + void waitFor(const uint n) + { + Monitor::ScopedLock l(lock); + while (messages.size() < n) { + lock.wait(); + } + } +}; + struct ClientSessionFixture : public ProxySessionFixture { void declareSubscribe(const string& q="my-queue", @@ -167,22 +190,31 @@ BOOST_FIXTURE_TEST_CASE(testSuspendResume, ClientSessionFixture) BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } +/** + * Currently broken due to a deadlock in SessionCore + * BOOST_FIXTURE_TEST_CASE(testSendToSelf, SessionFixture) { - // https://bugzilla.redhat.com/show_bug.cgi?id=410551 // Deadlock if SubscriptionManager run() concurrent with session ack. - LocalQueue myq; + SimpleListener mylistener; session.queueDeclare(queue="myq", exclusive=true, autoDelete=true); - subs.subscribe(myq, "myq"); + subs.subscribe(mylistener, "myq", "myq"); + sys::Thread runner(subs);//start dispatcher thread string data("msg"); Message msg(data, "myq"); - const int count=100; // Verified with count=100000 in a loop. - for (int i = 0; i < count; ++i) + const uint count=10000; + for (uint i = 0; i < count; ++i) { session.messageTransfer(content=msg); - for (int j = 0; j < count; ++j) { - Message m=myq.pop(); - BOOST_CHECK_EQUAL(m.getData(), data); + } + mylistener.waitFor(count); + subs.cancel("myq"); + subs.stop(); + session.close(); + BOOST_CHECK_EQUAL(mylistener.messages.size(), count); + for (uint j = 0; j < count; ++j) { + BOOST_CHECK_EQUAL(mylistener.messages[j].getData(), data); } } +*/ QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 8310d511e4a52d52b431cfc514b574dc13b09ae1 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 20 Feb 2008 15:26:05 +0000 Subject: Added non-optional enum { SYNC, ASYNC } parameter to newSession. Updated API doc in client/SessionBase.h git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@629503 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 87a4f59999..c299837f86 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -103,7 +103,7 @@ struct ClientSessionFixture : public ProxySessionFixture }; BOOST_FIXTURE_TEST_CASE(testQueueQuery, ClientSessionFixture) { - session =connection.newSession(); + session =connection.newSession(ASYNC); session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); TypedResult result = session.queueQuery(string("my-queue")); BOOST_CHECK_EQUAL(false, result.get().getDurable()); @@ -114,7 +114,7 @@ BOOST_FIXTURE_TEST_CASE(testQueueQuery, ClientSessionFixture) { BOOST_FIXTURE_TEST_CASE(testTransfer, ClientSessionFixture) { - session=connection.newSession(); + session=connection.newSession(ASYNC); declareSubscribe(); session.messageTransfer(content=TransferContent("my-message", "my-queue")); //get & test the message: @@ -127,7 +127,7 @@ BOOST_FIXTURE_TEST_CASE(testTransfer, ClientSessionFixture) BOOST_FIXTURE_TEST_CASE(testDispatcher, ClientSessionFixture) { - session =connection.newSession(); + session =connection.newSession(ASYNC); declareSubscribe(); size_t count = 100; for (size_t i = 0; i < count; ++i) @@ -142,7 +142,7 @@ BOOST_FIXTURE_TEST_CASE(testDispatcher, ClientSessionFixture) /* FIXME aconway 2008-01-28: hangs BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) { - session =connection.newSession(); + session =connection.newSession(ASYNC); declareSubscribe(); size_t count = 10000; DummyListener listener(session, "my-dest", count); @@ -160,7 +160,7 @@ BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) BOOST_FIXTURE_TEST_CASE(_FIXTURE, ClientSessionFixture) { - session =connection.newSession(0); + session =connection.newSession(ASYNC, 0); session.suspend(); // session has 0 timeout. try { connection.resume(session); @@ -170,7 +170,7 @@ BOOST_FIXTURE_TEST_CASE(_FIXTURE, ClientSessionFixture) BOOST_FIXTURE_TEST_CASE(testUseSuspendedError, ClientSessionFixture) { - session =connection.newSession(60); + session =connection.newSession(ASYNC, 60); session.suspend(); try { session.exchangeQuery(name="amq.fanout"); @@ -180,7 +180,7 @@ BOOST_FIXTURE_TEST_CASE(testUseSuspendedError, ClientSessionFixture) BOOST_FIXTURE_TEST_CASE(testSuspendResume, ClientSessionFixture) { - session =connection.newSession(60); + session =connection.newSession(ASYNC, 60); declareSubscribe(); session.suspend(); // Make sure we are still subscribed after resume. -- cgit v1.2.1 From f054d72c87c3646042c2d4ee91a44fe30523594e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 21 Feb 2008 17:40:42 +0000 Subject: Start moving towards final 0-10 spec: * marked preview spec as 99-0 to distinguish it from 0-10 (which will now be used for the final version) * modified python client to treat 99-0 as 0-10 for now * modified broker to have two paths for the two different versions: 99-0 uses PreviewConnection, PreviewConnectionHandler and PreviewSessionHandler which are straight copy & pastes of the Connection, ConnectionHandler and SessionHandler now associated with 0-10 (so we can migrate the 0-10 path to the final spec without affecting clients working with the preview version) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@629883 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index c299837f86..7a997db327 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -24,7 +24,7 @@ #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" -#include "qpid/client/Session_0_10.h" +#include "qpid/client/Session.h" #include "qpid/framing/TransferContent.h" #include "qpid/framing/reply_exceptions.h" @@ -52,7 +52,7 @@ struct DummyListener : public sys::Runnable, public MessageListener { uint expected; Dispatcher dispatcher; - DummyListener(Session_0_10& session, const string& n, uint ex) : + DummyListener(Session& session, const string& n, uint ex) : name(n), expected(ex), dispatcher(session) {} void run() -- cgit v1.2.1 From 1b4a961ec807e5e61cd232b08020a935a4f76f4c Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 17 Apr 2008 21:46:22 +0000 Subject: Patch for improved compatibility with gcc 3.4 and boost 1.33 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@649294 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 68 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 31 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 7a997db327..44d5ed4650 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -102,39 +102,42 @@ struct ClientSessionFixture : public ProxySessionFixture } }; -BOOST_FIXTURE_TEST_CASE(testQueueQuery, ClientSessionFixture) { - session =connection.newSession(ASYNC); - session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); - TypedResult result = session.queueQuery(string("my-queue")); +QPID_AUTO_TEST_CASE(testQueueQuery) { + ClientSessionFixture fix; + fix.session = fix.connection.newSession(ASYNC); + fix.session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); + TypedResult result = fix.session.queueQuery(string("my-queue")); BOOST_CHECK_EQUAL(false, result.get().getDurable()); BOOST_CHECK_EQUAL(true, result.get().getExclusive()); BOOST_CHECK_EQUAL(string("amq.fanout"), result.get().getAlternateExchange()); } -BOOST_FIXTURE_TEST_CASE(testTransfer, ClientSessionFixture) +QPID_AUTO_TEST_CASE(testTransfer) { - session=connection.newSession(ASYNC); - declareSubscribe(); - session.messageTransfer(content=TransferContent("my-message", "my-queue")); + ClientSessionFixture fix; + fix.session=fix.connection.newSession(ASYNC); + fix.declareSubscribe(); + fix.session.messageTransfer(content=TransferContent("my-message", "my-queue")); //get & test the message: - FrameSet::shared_ptr msg = session.get(); + FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK(msg->isA()); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); //confirm receipt: - session.getExecution().completed(msg->getId(), true, true); + fix.session.getExecution().completed(msg->getId(), true, true); } -BOOST_FIXTURE_TEST_CASE(testDispatcher, ClientSessionFixture) +QPID_AUTO_TEST_CASE(testDispatcher) { - session =connection.newSession(ASYNC); - declareSubscribe(); + ClientSessionFixture fix; + fix.session =fix.connection.newSession(ASYNC); + fix.declareSubscribe(); size_t count = 100; for (size_t i = 0; i < count; ++i) - session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); - DummyListener listener(session, "my-dest", count); + fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); + DummyListener listener(fix.session, "my-dest", count); listener.run(); - BOOST_REQUIRE_EQUAL(count, listener.messages.size()); + BOOST_CHECK_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } @@ -158,35 +161,38 @@ BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) } */ -BOOST_FIXTURE_TEST_CASE(_FIXTURE, ClientSessionFixture) +QPID_AUTO_TEST_CASE(_FIXTURE) { - session =connection.newSession(ASYNC, 0); - session.suspend(); // session has 0 timeout. + ClientSessionFixture fix; + fix.session =fix.connection.newSession(ASYNC, 0); + fix.session.suspend(); // session has 0 timeout. try { - connection.resume(session); + fix.connection.resume(fix.session); BOOST_FAIL("Expected InvalidArgumentException."); } catch(const InternalErrorException&) {} } -BOOST_FIXTURE_TEST_CASE(testUseSuspendedError, ClientSessionFixture) +QPID_AUTO_TEST_CASE(testUseSuspendedError) { - session =connection.newSession(ASYNC, 60); - session.suspend(); + ClientSessionFixture fix; + fix.session =fix.connection.newSession(ASYNC, 60); + fix.session.suspend(); try { - session.exchangeQuery(name="amq.fanout"); + fix.session.exchangeQuery(name="amq.fanout"); BOOST_FAIL("Expected session suspended exception"); } catch(const CommandInvalidException&) {} } -BOOST_FIXTURE_TEST_CASE(testSuspendResume, ClientSessionFixture) +QPID_AUTO_TEST_CASE(testSuspendResume) { - session =connection.newSession(ASYNC, 60); - declareSubscribe(); - session.suspend(); + ClientSessionFixture fix; + fix.session =fix.connection.newSession(ASYNC, 60); + fix.declareSubscribe(); + fix.session.suspend(); // Make sure we are still subscribed after resume. - connection.resume(session); - session.messageTransfer(content=TransferContent("my-message", "my-queue")); - FrameSet::shared_ptr msg = session.get(); + fix.connection.resume(fix.session); + fix.session.messageTransfer(content=TransferContent("my-message", "my-queue")); + FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } -- cgit v1.2.1 From 4780580874e8d6a3e3590fa5fdf8a088310b20ae Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Sun, 20 Apr 2008 12:10:37 +0000 Subject: QPID-920: converted c++ client to use final 0-10 protocol * connection handler converted to using invoker & proxy and updated to final method defs * SessionCore & ExecutionHandler replace by SessionImpl * simplified handling of completion & results, removed handling of responses git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@649915 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 44d5ed4650..9b6e0dce21 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -118,13 +118,13 @@ QPID_AUTO_TEST_CASE(testTransfer) ClientSessionFixture fix; fix.session=fix.connection.newSession(ASYNC); fix.declareSubscribe(); - fix.session.messageTransfer(content=TransferContent("my-message", "my-queue")); + fix.session.messageTransfer(acceptMode=1, content=TransferContent("my-message", "my-queue")); //get & test the message: FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK(msg->isA()); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); //confirm receipt: - fix.session.getExecution().completed(msg->getId(), true, true); + fix.session.getExecution().markCompleted(msg->getId(), true, true); } QPID_AUTO_TEST_CASE(testDispatcher) @@ -161,6 +161,8 @@ BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) } */ +/* + * GS (18-APR-2008): disabled resume tests until resumption for 0-10 final spec is implemented QPID_AUTO_TEST_CASE(_FIXTURE) { ClientSessionFixture fix; @@ -195,7 +197,7 @@ QPID_AUTO_TEST_CASE(testSuspendResume) FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } - +*/ /** * Currently broken due to a deadlock in SessionCore * -- cgit v1.2.1 From 224a70f13d371068e489625954b7034019a151bb Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 21 Apr 2008 14:37:03 +0000 Subject: QPID-920: send message-accept for acks (as well as completion) * AckPolicy now maintains a set of transfered messages for cumulative accepts git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@650159 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 9b6e0dce21..a5f7b9d803 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -20,6 +20,7 @@ */ #include "unit_test.h" #include "BrokerFixture.h" +#include "qpid/client/AckPolicy.h" #include "qpid/client/Dispatcher.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" @@ -124,7 +125,8 @@ QPID_AUTO_TEST_CASE(testTransfer) BOOST_CHECK(msg->isA()); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); //confirm receipt: - fix.session.getExecution().markCompleted(msg->getId(), true, true); + AckPolicy autoAck; + autoAck.ack(Message(*msg), fix.session); } QPID_AUTO_TEST_CASE(testDispatcher) -- cgit v1.2.1 From 31310643c3ccb6f96e53cde59772098768c80aed Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 23 Apr 2008 18:43:05 +0000 Subject: src/tests/ClientSessionTest.cpp: uncommented tests for session resume as EXPECTED_FAILURES tests. src/tests/unit_test.h: workarounds for broken EXPECTED_FAILURES tests in boost <= 1.34 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@650997 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index a5f7b9d803..f53de5688e 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -144,7 +144,8 @@ QPID_AUTO_TEST_CASE(testDispatcher) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -/* FIXME aconway 2008-01-28: hangs +// FIXME aconway 2008-04-23: hangs +#if 0 BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) { session =connection.newSession(ASYNC); @@ -161,11 +162,10 @@ BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -*/ +#endif -/* - * GS (18-APR-2008): disabled resume tests until resumption for 0-10 final spec is implemented -QPID_AUTO_TEST_CASE(_FIXTURE) + +QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) { ClientSessionFixture fix; fix.session =fix.connection.newSession(ASYNC, 0); @@ -176,7 +176,7 @@ QPID_AUTO_TEST_CASE(_FIXTURE) } catch(const InternalErrorException&) {} } -QPID_AUTO_TEST_CASE(testUseSuspendedError) +QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testUseSuspendedError, 1) { ClientSessionFixture fix; fix.session =fix.connection.newSession(ASYNC, 60); @@ -187,7 +187,7 @@ QPID_AUTO_TEST_CASE(testUseSuspendedError) } catch(const CommandInvalidException&) {} } -QPID_AUTO_TEST_CASE(testSuspendResume) +QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) { ClientSessionFixture fix; fix.session =fix.connection.newSession(ASYNC, 60); @@ -199,10 +199,9 @@ QPID_AUTO_TEST_CASE(testSuspendResume) FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } -*/ -/** - * Currently broken due to a deadlock in SessionCore - * + +// FIXME aconway 2008-04-23: broken due to a deadlock in SessionCore +#if 0 BOOST_FIXTURE_TEST_CASE(testSendToSelf, SessionFixture) { // Deadlock if SubscriptionManager run() concurrent with session ack. SimpleListener mylistener; @@ -224,7 +223,7 @@ BOOST_FIXTURE_TEST_CASE(testSendToSelf, SessionFixture) { BOOST_CHECK_EQUAL(mylistener.messages[j].getData(), data); } } -*/ +#endif QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 27ecd6f07fb30357a77cbcf8ced20d7711b0db08 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 1 May 2008 08:01:48 +0000 Subject: Cleanup: Re-enable tests that now pass; delete unused templates directory. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@652451 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 45 ++++++++++++++------------------ 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index f53de5688e..04cdee70c6 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -65,8 +65,9 @@ struct DummyListener : public sys::Runnable, public MessageListener { void received(Message& msg) { messages.push_back(msg); - if (--expected == 0) + if (--expected == 0) { dispatcher.stop(); + } } }; @@ -144,26 +145,22 @@ QPID_AUTO_TEST_CASE(testDispatcher) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -// FIXME aconway 2008-04-23: hangs -#if 0 -BOOST_FIXTURE_TEST_CASE(testDispatcherThread, ClientSessionFixture) +QPID_AUTO_TEST_CASE(testDispatcherThread) { - session =connection.newSession(ASYNC); - declareSubscribe(); - size_t count = 10000; - DummyListener listener(session, "my-dest", count); + ClientSessionFixture fix; + fix.session =fix.connection.newSession(ASYNC); + fix.declareSubscribe(); + size_t count = 1000; + DummyListener listener(fix.session, "my-dest", count); sys::Thread t(listener); for (size_t i = 0; i < count; ++i) { - session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); - if (i%100 == 0) cout << "T" << i << std::flush; + fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); } t.join(); BOOST_REQUIRE_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -#endif - QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) { @@ -200,30 +197,28 @@ QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } -// FIXME aconway 2008-04-23: broken due to a deadlock in SessionCore -#if 0 -BOOST_FIXTURE_TEST_CASE(testSendToSelf, SessionFixture) { - // Deadlock if SubscriptionManager run() concurrent with session ack. +QPID_AUTO_TEST_CASE(testSendToSelf) { + ClientSessionFixture fix; SimpleListener mylistener; - session.queueDeclare(queue="myq", exclusive=true, autoDelete=true); - subs.subscribe(mylistener, "myq", "myq"); - sys::Thread runner(subs);//start dispatcher thread + fix.session.queueDeclare(queue="myq", exclusive=true, autoDelete=true); + fix.subs.subscribe(mylistener, "myq", "myq"); + sys::Thread runner(fix.subs);//start dispatcher thread string data("msg"); Message msg(data, "myq"); - const uint count=10000; + const uint count=1000; for (uint i = 0; i < count; ++i) { - session.messageTransfer(content=msg); + fix.session.messageTransfer(content=msg); } mylistener.waitFor(count); - subs.cancel("myq"); - subs.stop(); - session.close(); + fix.subs.cancel("myq"); + fix.subs.stop(); + runner.join(); + fix.session.close(); BOOST_CHECK_EQUAL(mylistener.messages.size(), count); for (uint j = 0; j < count; ++j) { BOOST_CHECK_EQUAL(mylistener.messages[j].getData(), data); } } -#endif QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 5b929a5ec2d88b85e53c5b32906d0ed2ea135be1 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 2 May 2008 16:18:02 +0000 Subject: Use BOOST_CHECK_EQUAL in place of BOOST_REQUIRE_EQUAL (compatible with older boost) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@652799 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 04cdee70c6..dfda9ecae1 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -157,7 +157,7 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); } t.join(); - BOOST_REQUIRE_EQUAL(count, listener.messages.size()); + BOOST_CHECK_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -- cgit v1.2.1 From 5bb0604473b2367218c297927d578d19951ed775 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 20 May 2008 13:44:34 +0000 Subject: Support for AMQP 0-10 sessions in C++ broker. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@658246 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index dfda9ecae1..aeff35dbf0 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -150,7 +150,7 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) ClientSessionFixture fix; fix.session =fix.connection.newSession(ASYNC); fix.declareSubscribe(); - size_t count = 1000; + size_t count = 10; DummyListener listener(fix.session, "my-dest", count); sys::Thread t(listener); for (size_t i = 0; i < count; ++i) { @@ -205,7 +205,7 @@ QPID_AUTO_TEST_CASE(testSendToSelf) { sys::Thread runner(fix.subs);//start dispatcher thread string data("msg"); Message msg(data, "myq"); - const uint count=1000; + const uint count=10; for (uint i = 0; i < count; ++i) { fix.session.messageTransfer(content=msg); } -- cgit v1.2.1 From 558dcdd6eefd334cd81fcf0c4a3843097974f652 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 23 May 2008 13:39:07 +0000 Subject: qpid::SessionState: Added error checking for invalid frame sequences. client: Fix client crash on error during connection shutdown. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@659538 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index aeff35dbf0..801e33d412 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -157,7 +157,7 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); } t.join(); - BOOST_CHECK_EQUAL(count, listener.messages.size()); + BOOST_REQUIRE_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -- cgit v1.2.1 From 72456749101ecd33ce01f9c79f9e9082985154f6 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 26 May 2008 18:10:05 +0000 Subject: Changes to Session API: - Session is synchronous, no futures. - AsyncSession is async, returns futures. - Conversion functions sync(s) async(s) return a sync/async view of session s. - Connection::newSession - takes name, no timeout - SessionBase::getId - returns SessionId not UUID. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@660258 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 84 ++++++++++++++++---------------- 1 file changed, 43 insertions(+), 41 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 801e33d412..1dade47ee9 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -106,19 +106,19 @@ struct ClientSessionFixture : public ProxySessionFixture QPID_AUTO_TEST_CASE(testQueueQuery) { ClientSessionFixture fix; - fix.session = fix.connection.newSession(ASYNC); + fix.session = fix.connection.newSession(); fix.session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); - TypedResult result = fix.session.queueQuery(string("my-queue")); - BOOST_CHECK_EQUAL(false, result.get().getDurable()); - BOOST_CHECK_EQUAL(true, result.get().getExclusive()); + QueueQueryResult result = fix.session.queueQuery(string("my-queue")); + BOOST_CHECK_EQUAL(false, result.getDurable()); + BOOST_CHECK_EQUAL(true, result.getExclusive()); BOOST_CHECK_EQUAL(string("amq.fanout"), - result.get().getAlternateExchange()); + result.getAlternateExchange()); } QPID_AUTO_TEST_CASE(testTransfer) { ClientSessionFixture fix; - fix.session=fix.connection.newSession(ASYNC); + fix.session=fix.connection.newSession(); fix.declareSubscribe(); fix.session.messageTransfer(acceptMode=1, content=TransferContent("my-message", "my-queue")); //get & test the message: @@ -133,7 +133,7 @@ QPID_AUTO_TEST_CASE(testTransfer) QPID_AUTO_TEST_CASE(testDispatcher) { ClientSessionFixture fix; - fix.session =fix.connection.newSession(ASYNC); + fix.session =fix.connection.newSession(); fix.declareSubscribe(); size_t count = 100; for (size_t i = 0; i < count; ++i) @@ -148,7 +148,7 @@ QPID_AUTO_TEST_CASE(testDispatcher) QPID_AUTO_TEST_CASE(testDispatcherThread) { ClientSessionFixture fix; - fix.session =fix.connection.newSession(ASYNC); + fix.session =fix.connection.newSession(); fix.declareSubscribe(); size_t count = 10; DummyListener listener(fix.session, "my-dest", count); @@ -162,40 +162,42 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) -{ - ClientSessionFixture fix; - fix.session =fix.connection.newSession(ASYNC, 0); - fix.session.suspend(); // session has 0 timeout. - try { - fix.connection.resume(fix.session); - BOOST_FAIL("Expected InvalidArgumentException."); - } catch(const InternalErrorException&) {} -} - -QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testUseSuspendedError, 1) -{ - ClientSessionFixture fix; - fix.session =fix.connection.newSession(ASYNC, 60); - fix.session.suspend(); - try { - fix.session.exchangeQuery(name="amq.fanout"); - BOOST_FAIL("Expected session suspended exception"); - } catch(const CommandInvalidException&) {} -} +// FIXME aconway 2008-05-26: Re-enable with final resume implementation. +// +// QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) +// { +// ClientSessionFixture fix; +// fix.session.suspend(); // session has 0 timeout. +// try { +// fix.connection.resume(fix.session); +// BOOST_FAIL("Expected InvalidArgumentException."); +// } catch(const InternalErrorException&) {} +// } + +// QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testUseSuspendedError, 1) +// { +// ClientSessionFixture fix; +// fix.session =fix.session.timeout(60); +// fix.session.suspend(); +// try { +// fix.session.exchangeQuery(name="amq.fanout"); +// BOOST_FAIL("Expected session suspended exception"); +// } catch(const CommandInvalidException&) {} +// } + +// QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) +// { +// ClientSessionFixture fix; +// fix.session.timeout(60); +// fix.declareSubscribe(); +// fix.session.suspend(); +// // Make sure we are still subscribed after resume. +// fix.connection.resume(fix.session); +// fix.session.messageTransfer(content=TransferContent("my-message", "my-queue")); +// FrameSet::shared_ptr msg = fix.session.get(); +// BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); +// } -QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) -{ - ClientSessionFixture fix; - fix.session =fix.connection.newSession(ASYNC, 60); - fix.declareSubscribe(); - fix.session.suspend(); - // Make sure we are still subscribed after resume. - fix.connection.resume(fix.session); - fix.session.messageTransfer(content=TransferContent("my-message", "my-queue")); - FrameSet::shared_ptr msg = fix.session.get(); - BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); -} QPID_AUTO_TEST_CASE(testSendToSelf) { ClientSessionFixture fix; -- cgit v1.2.1 From 920ac8dc4eb1be2b64fda528a9ef52b047532350 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 26 May 2008 21:02:59 +0000 Subject: Removed BOOST_REQUIRE_EQUAL, not available in older boost.test. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@660304 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 1dade47ee9..83c3317094 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -157,7 +157,7 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); } t.join(); - BOOST_REQUIRE_EQUAL(count, listener.messages.size()); + BOOST_CHECK_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); } -- cgit v1.2.1 From 23b153214d057627be9d00f8cc14280cd89eb95b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 25 Jun 2008 20:51:30 +0000 Subject: Additions to the client API: - SubscriptionManager::get(queue) to get a single message from a queue. - Set FlowControl per-subscription. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@671655 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 83c3317094..0475350d6a 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -203,7 +203,7 @@ QPID_AUTO_TEST_CASE(testSendToSelf) { ClientSessionFixture fix; SimpleListener mylistener; fix.session.queueDeclare(queue="myq", exclusive=true, autoDelete=true); - fix.subs.subscribe(mylistener, "myq", "myq"); + fix.subs.subscribe(mylistener, "myq"); sys::Thread runner(fix.subs);//start dispatcher thread string data("msg"); Message msg(data, "myq"); @@ -222,5 +222,30 @@ QPID_AUTO_TEST_CASE(testSendToSelf) { } } +QPID_AUTO_TEST_CASE(testLocalQueue) { + ClientSessionFixture fix; + fix.session.queueDeclare(queue="lq", exclusive=true, autoDelete=true); + LocalQueue lq; + fix.subs.subscribe(lq, "lq", FlowControl(2, FlowControl::UNLIMITED, false)); + fix.session.messageTransfer(content=Message("foo0", "lq")); + fix.session.messageTransfer(content=Message("foo1", "lq")); + fix.session.messageTransfer(content=Message("foo2", "lq")); + BOOST_CHECK_EQUAL("foo0", lq.pop().getData()); + BOOST_CHECK_EQUAL("foo1", lq.pop().getData()); + BOOST_CHECK(lq.empty()); // Credit exhausted. + fix.subs.setFlowControl("lq", FlowControl::unlimited()); + BOOST_CHECK_EQUAL("foo2", lq.pop().getData()); +} + +QPID_AUTO_TEST_CASE(testGet) { + ClientSessionFixture fix; + fix.session.queueDeclare(queue="getq", exclusive=true, autoDelete=true); + fix.session.messageTransfer(content=Message("foo0", "getq")); + fix.session.messageTransfer(content=Message("foo1", "getq")); + BOOST_CHECK_EQUAL("foo0", fix.subs.get("getq").getData()); + BOOST_CHECK_EQUAL("foo1", fix.subs.get("getq").getData()); +} + QPID_AUTO_TEST_SUITE_END() + -- cgit v1.2.1 From 2a669d697451b965e70f562ed8b66cd1eee38446 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 26 Jun 2008 12:25:58 +0000 Subject: QPID-1137: don't treat connection as opened if the open never succeeds git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@671877 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 0475350d6a..505f3248a4 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -246,6 +246,21 @@ QPID_AUTO_TEST_CASE(testGet) { BOOST_CHECK_EQUAL("foo1", fix.subs.get("getq").getData()); } +QPID_AUTO_TEST_CASE(testOpenFailure) { + BrokerFixture b; + Connection c; + string host("unknowable-host"); + try { + c.open(host); + } catch (const Exception&) { + BOOST_CHECK(!c.isOpen()); + } + b.open(c); + BOOST_CHECK(c.isOpen()); + c.close(); + BOOST_CHECK(!c.isOpen()); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 34adcd9514de456733e88a79b2c80d0da83ef0de Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 1 Jul 2008 18:01:11 +0000 Subject: Added timeout to SubscriptionManager::get(), LocalQueue::get() and BlockingQueue::get() git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@673158 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 505f3248a4..b55e4c231e 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -41,6 +41,7 @@ using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; using qpid::sys::Monitor; +using qpid::sys::TIME_SEC; using std::string; using std::cout; using std::endl; @@ -242,8 +243,11 @@ QPID_AUTO_TEST_CASE(testGet) { fix.session.queueDeclare(queue="getq", exclusive=true, autoDelete=true); fix.session.messageTransfer(content=Message("foo0", "getq")); fix.session.messageTransfer(content=Message("foo1", "getq")); - BOOST_CHECK_EQUAL("foo0", fix.subs.get("getq").getData()); - BOOST_CHECK_EQUAL("foo1", fix.subs.get("getq").getData()); + Message got; + BOOST_CHECK(fix.subs.get(got, "getq", TIME_SEC)); + BOOST_CHECK_EQUAL("foo0", got.getData()); + BOOST_CHECK(fix.subs.get(got, "getq", TIME_SEC)); + BOOST_CHECK_EQUAL("foo1", got.getData()); } QPID_AUTO_TEST_CASE(testOpenFailure) { -- cgit v1.2.1 From 08cc9448c490c637ef4a2d696c2592844f832ab6 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 10 Jul 2008 08:39:10 +0000 Subject: Honour timeout in BlockingQueue::pop(); added test for SubscriptionManager::get() where no message exists. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@675477 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index b55e4c231e..90616cf7f3 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -248,6 +248,7 @@ QPID_AUTO_TEST_CASE(testGet) { BOOST_CHECK_EQUAL("foo0", got.getData()); BOOST_CHECK(fix.subs.get(got, "getq", TIME_SEC)); BOOST_CHECK_EQUAL("foo1", got.getData()); + BOOST_CHECK(!fix.subs.get(got, "getq")); } QPID_AUTO_TEST_CASE(testOpenFailure) { -- cgit v1.2.1 From 9a3c24de4c9f18a068be36e50fdbf44589499787 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 25 Jul 2008 10:16:22 +0000 Subject: Fixed bug in SubscriptionManager::get() where flush was issued before waiting and if message showed up after flush completed but before wait was finished there was no credit (due to flush) to deliver it to the waiting client. Added test for thise case. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@679739 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 90616cf7f3..3d9280211a 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -41,6 +41,7 @@ using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; using qpid::sys::Monitor; +using qpid::sys::Thread; using qpid::sys::TIME_SEC; using std::string; using std::cout; @@ -238,6 +239,19 @@ QPID_AUTO_TEST_CASE(testLocalQueue) { BOOST_CHECK_EQUAL("foo2", lq.pop().getData()); } +struct DelayedTransfer : sys::Runnable +{ + ClientSessionFixture& fixture; + + DelayedTransfer(ClientSessionFixture& f) : fixture(f) {} + + void run() + { + sleep(1); + fixture.session.messageTransfer(content=Message("foo2", "getq")); + } +}; + QPID_AUTO_TEST_CASE(testGet) { ClientSessionFixture fix; fix.session.queueDeclare(queue="getq", exclusive=true, autoDelete=true); @@ -249,6 +263,12 @@ QPID_AUTO_TEST_CASE(testGet) { BOOST_CHECK(fix.subs.get(got, "getq", TIME_SEC)); BOOST_CHECK_EQUAL("foo1", got.getData()); BOOST_CHECK(!fix.subs.get(got, "getq")); + DelayedTransfer sender(fix); + Thread t(sender); + //test timed get where message shows up after a short delay + BOOST_CHECK(fix.subs.get(got, "getq", 5*TIME_SEC)); + BOOST_CHECK_EQUAL("foo2", got.getData()); + t.join(); } QPID_AUTO_TEST_CASE(testOpenFailure) { -- cgit v1.2.1 From 5cede207026bb0ef3aecf79b57185103c3802be8 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 29 Jul 2008 20:26:32 +0000 Subject: QPID-1198 (Partial): Added explicit namespaces that the Sun C++ requires (that gcc doesn't) Patches from Manuel Teira. It's not clear at this point whether there is a compiler problem with gcc that it does find the symbols in the namespaces or SunCC that it doesn't! git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@680827 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 3d9280211a..0b46d39047 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -37,7 +37,6 @@ QPID_AUTO_TEST_SUITE(ClientSessionTest) using namespace qpid::client; -using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; using qpid::sys::Monitor; @@ -46,7 +45,6 @@ using qpid::sys::TIME_SEC; using std::string; using std::cout; using std::endl; -using namespace boost; struct DummyListener : public sys::Runnable, public MessageListener { @@ -99,17 +97,17 @@ struct ClientSessionFixture : public ProxySessionFixture void declareSubscribe(const string& q="my-queue", const string& dest="my-dest") { - session.queueDeclare(queue=q); - session.messageSubscribe(queue=q, destination=dest, acquireMode=1); - session.messageFlow(destination=dest, unit=0, value=0xFFFFFFFF);//messages - session.messageFlow(destination=dest, unit=1, value=0xFFFFFFFF);//bytes + session.queueDeclare(arg::queue=q); + session.messageSubscribe(arg::queue=q, arg::destination=dest, arg::acquireMode=1); + session.messageFlow(arg::destination=dest, arg::unit=0, arg::value=0xFFFFFFFF);//messages + session.messageFlow(arg::destination=dest, arg::unit=1, arg::value=0xFFFFFFFF);//bytes } }; QPID_AUTO_TEST_CASE(testQueueQuery) { ClientSessionFixture fix; fix.session = fix.connection.newSession(); - fix.session.queueDeclare(queue="my-queue", alternateExchange="amq.fanout", exclusive=true, autoDelete=true); + fix.session.queueDeclare(arg::queue="my-queue", arg::alternateExchange="amq.fanout", arg::exclusive=true, arg::autoDelete=true); QueueQueryResult result = fix.session.queueQuery(string("my-queue")); BOOST_CHECK_EQUAL(false, result.getDurable()); BOOST_CHECK_EQUAL(true, result.getExclusive()); @@ -122,7 +120,7 @@ QPID_AUTO_TEST_CASE(testTransfer) ClientSessionFixture fix; fix.session=fix.connection.newSession(); fix.declareSubscribe(); - fix.session.messageTransfer(acceptMode=1, content=TransferContent("my-message", "my-queue")); + fix.session.messageTransfer(arg::acceptMode=1, arg::content=TransferContent("my-message", "my-queue")); //get & test the message: FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK(msg->isA()); @@ -139,12 +137,12 @@ QPID_AUTO_TEST_CASE(testDispatcher) fix.declareSubscribe(); size_t count = 100; for (size_t i = 0; i < count; ++i) - fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); + fix.session.messageTransfer(arg::content=TransferContent(boost::lexical_cast(i), "my-queue")); DummyListener listener(fix.session, "my-dest", count); listener.run(); BOOST_CHECK_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) - BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); + BOOST_CHECK_EQUAL(boost::lexical_cast(i), listener.messages[i].getData()); } QPID_AUTO_TEST_CASE(testDispatcherThread) @@ -156,12 +154,12 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) DummyListener listener(fix.session, "my-dest", count); sys::Thread t(listener); for (size_t i = 0; i < count; ++i) { - fix.session.messageTransfer(content=TransferContent(lexical_cast(i), "my-queue")); + fix.session.messageTransfer(arg::content=TransferContent(boost::lexical_cast(i), "my-queue")); } t.join(); BOOST_CHECK_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) - BOOST_CHECK_EQUAL(lexical_cast(i), listener.messages[i].getData()); + BOOST_CHECK_EQUAL(boost::lexical_cast(i), listener.messages[i].getData()); } // FIXME aconway 2008-05-26: Re-enable with final resume implementation. @@ -204,14 +202,14 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) QPID_AUTO_TEST_CASE(testSendToSelf) { ClientSessionFixture fix; SimpleListener mylistener; - fix.session.queueDeclare(queue="myq", exclusive=true, autoDelete=true); + fix.session.queueDeclare(arg::queue="myq", arg::exclusive=true, arg::autoDelete=true); fix.subs.subscribe(mylistener, "myq"); sys::Thread runner(fix.subs);//start dispatcher thread string data("msg"); Message msg(data, "myq"); const uint count=10; for (uint i = 0; i < count; ++i) { - fix.session.messageTransfer(content=msg); + fix.session.messageTransfer(arg::content=msg); } mylistener.waitFor(count); fix.subs.cancel("myq"); @@ -226,12 +224,12 @@ QPID_AUTO_TEST_CASE(testSendToSelf) { QPID_AUTO_TEST_CASE(testLocalQueue) { ClientSessionFixture fix; - fix.session.queueDeclare(queue="lq", exclusive=true, autoDelete=true); + fix.session.queueDeclare(arg::queue="lq", arg::exclusive=true, arg::autoDelete=true); LocalQueue lq; fix.subs.subscribe(lq, "lq", FlowControl(2, FlowControl::UNLIMITED, false)); - fix.session.messageTransfer(content=Message("foo0", "lq")); - fix.session.messageTransfer(content=Message("foo1", "lq")); - fix.session.messageTransfer(content=Message("foo2", "lq")); + fix.session.messageTransfer(arg::content=Message("foo0", "lq")); + fix.session.messageTransfer(arg::content=Message("foo1", "lq")); + fix.session.messageTransfer(arg::content=Message("foo2", "lq")); BOOST_CHECK_EQUAL("foo0", lq.pop().getData()); BOOST_CHECK_EQUAL("foo1", lq.pop().getData()); BOOST_CHECK(lq.empty()); // Credit exhausted. @@ -248,15 +246,15 @@ struct DelayedTransfer : sys::Runnable void run() { sleep(1); - fixture.session.messageTransfer(content=Message("foo2", "getq")); + fixture.session.messageTransfer(arg::content=Message("foo2", "getq")); } }; QPID_AUTO_TEST_CASE(testGet) { ClientSessionFixture fix; - fix.session.queueDeclare(queue="getq", exclusive=true, autoDelete=true); - fix.session.messageTransfer(content=Message("foo0", "getq")); - fix.session.messageTransfer(content=Message("foo1", "getq")); + fix.session.queueDeclare(arg::queue="getq", arg::exclusive=true, arg::autoDelete=true); + fix.session.messageTransfer(arg::content=Message("foo0", "getq")); + fix.session.messageTransfer(arg::content=Message("foo1", "getq")); Message got; BOOST_CHECK(fix.subs.get(got, "getq", TIME_SEC)); BOOST_CHECK_EQUAL("foo0", got.getData()); -- cgit v1.2.1 From 83633e01c8c8df0aa23196a68eb29dcdc245fb48 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 8 Oct 2008 00:36:42 +0000 Subject: rubygen/framing.0-10/constants.rb: create functions for all 3 exception subclasses. client: added session suspend/resume functions, resume not implemented yet. ClientSessionTest: enabled compilation of suspend/resume tests with expected failures. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@702674 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 64 ++++++++++++++++---------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 0b46d39047..85497ace5d 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -162,41 +162,39 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) BOOST_CHECK_EQUAL(boost::lexical_cast(i), listener.messages[i].getData()); } -// FIXME aconway 2008-05-26: Re-enable with final resume implementation. -// -// QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) -// { -// ClientSessionFixture fix; -// fix.session.suspend(); // session has 0 timeout. -// try { -// fix.connection.resume(fix.session); -// BOOST_FAIL("Expected InvalidArgumentException."); -// } catch(const InternalErrorException&) {} -// } +QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) +{ + ClientSessionFixture fix; + fix.session.suspend(); // session has 0 timeout. + try { + fix.connection.resume(fix.session); + BOOST_FAIL("Expected InvalidArgumentException."); + } catch(const InternalErrorException&) {} +} -// QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testUseSuspendedError, 1) -// { -// ClientSessionFixture fix; -// fix.session =fix.session.timeout(60); -// fix.session.suspend(); -// try { -// fix.session.exchangeQuery(name="amq.fanout"); -// BOOST_FAIL("Expected session suspended exception"); -// } catch(const CommandInvalidException&) {} -// } +QPID_AUTO_TEST_CASE(testUseSuspendedError) +{ + ClientSessionFixture fix; + fix.session.timeout(60); + fix.session.suspend(); + try { + fix.session.exchangeQuery(arg::exchange="amq.fanout"); + BOOST_FAIL("Expected session suspended exception"); + } catch(const NotAttachedException&) {} +} -// QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) -// { -// ClientSessionFixture fix; -// fix.session.timeout(60); -// fix.declareSubscribe(); -// fix.session.suspend(); -// // Make sure we are still subscribed after resume. -// fix.connection.resume(fix.session); -// fix.session.messageTransfer(content=TransferContent("my-message", "my-queue")); -// FrameSet::shared_ptr msg = fix.session.get(); -// BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); -// } +QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) +{ + ClientSessionFixture fix; + fix.session.timeout(60); + fix.declareSubscribe(); + fix.session.suspend(); + // Make sure we are still subscribed after resume. + fix.connection.resume(fix.session); + fix.session.messageTransfer(arg::content=TransferContent("my-message", "my-queue")); + FrameSet::shared_ptr msg = fix.session.get(); + BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); +} QPID_AUTO_TEST_CASE(testSendToSelf) { -- cgit v1.2.1 From a251b4401edca8cc565550061ca9d7ce507d6ddf Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 13 Oct 2008 17:09:06 +0000 Subject: Periodically purge expired messages from queues git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@704166 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 85497ace5d..440605a2e4 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -42,6 +42,7 @@ using namespace qpid; using qpid::sys::Monitor; using qpid::sys::Thread; using qpid::sys::TIME_SEC; +using qpid::broker::Broker; using std::string; using std::cout; using std::endl; @@ -94,6 +95,8 @@ struct SimpleListener : public MessageListener struct ClientSessionFixture : public ProxySessionFixture { + ClientSessionFixture(Broker::Options opts = Broker::Options()) : ProxySessionFixture(opts) {} + void declareSubscribe(const string& q="my-queue", const string& dest="my-dest") { @@ -282,6 +285,43 @@ QPID_AUTO_TEST_CASE(testOpenFailure) { BOOST_CHECK(!c.isOpen()); } +QPID_AUTO_TEST_CASE(testPeriodicExpiration) { + Broker::Options opts; + opts.queueCleanInterval = 1; + ClientSessionFixture fix(opts); + fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); + + for (uint i = 0; i < 10; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + if (i % 2) m.getDeliveryProperties().setTtl(500); + fix.session.messageTransfer(arg::content=m); + } + + BOOST_CHECK_EQUAL(fix.session.queueQuery(string("my-queue")).getMessageCount(), 10u); + sleep(2); + BOOST_CHECK_EQUAL(fix.session.queueQuery(string("my-queue")).getMessageCount(), 5u); +} + +QPID_AUTO_TEST_CASE(testExpirationOnPop) { + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); + + for (uint i = 0; i < 10; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + if (i % 2) m.getDeliveryProperties().setTtl(200); + fix.session.messageTransfer(arg::content=m); + } + + ::usleep(300* 1000); + + for (uint i = 0; i < 10; i++) { + if (i % 2) continue; + Message m; + BOOST_CHECK(fix.subs.get(m, "my-queue", TIME_SEC)); + BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), m.getData()); + } +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 10d07002af4b211dfbbc3341a4edb6ec4c2e5cb5 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Sat, 25 Oct 2008 01:55:06 +0000 Subject: Client API change: Centralize access to subscription status, better control of acquire/accept. client/AckPolicy: removed, functionality moved to Subscription and SubscriptionSettings client/SubscriptionSettings: struct aggregates flow control & accept-acquire parameters for subscribe. client/Subscription: represents active subscription. Query settings, unacked messages, manual accept/acquire client/SubscriptionManager: use AcceptMode, AcquireMode enums rather than confusing bools. Issues addressed by the change: - old use of bool for acceptMode was inverted wrt AMQP enum values, bools are confusing. - old AckPolicy was broken - not possible to access the instance associated with an active subscription - old AckPolicy did not provide a way to do manual acquire, only accept. - setting values on SubscriptionManager to apply to subsequent subscriptions is awkward & error-prone, now can use SubscriptionSettings to control on each subscribe individually. - a subscription is a central concept in AMQP, it deserves to be a class. Subscription and SubscriptionSettings provides a single point for future expansion of interactions with a a Subscription. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@707808 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 56 +++++++++----------------------- 1 file changed, 15 insertions(+), 41 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 440605a2e4..abe317aad8 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -20,8 +20,7 @@ */ #include "unit_test.h" #include "BrokerFixture.h" -#include "qpid/client/AckPolicy.h" -#include "qpid/client/Dispatcher.h" +#include "qpid/client/SubscriptionManager.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" @@ -52,22 +51,22 @@ struct DummyListener : public sys::Runnable, public MessageListener { std::vector messages; string name; uint expected; - Dispatcher dispatcher; + SubscriptionManager submgr; DummyListener(Session& session, const string& n, uint ex) : - name(n), expected(ex), dispatcher(session) {} + name(n), expected(ex), submgr(session) {} void run() { - dispatcher.listen(name, this); - dispatcher.run(); + submgr.subscribe(*this, name); + submgr.run(); } void received(Message& msg) { messages.push_back(msg); if (--expected == 0) { - dispatcher.stop(); + submgr.stop(); } } }; @@ -95,53 +94,30 @@ struct SimpleListener : public MessageListener struct ClientSessionFixture : public ProxySessionFixture { - ClientSessionFixture(Broker::Options opts = Broker::Options()) : ProxySessionFixture(opts) {} - - void declareSubscribe(const string& q="my-queue", - const string& dest="my-dest") - { - session.queueDeclare(arg::queue=q); - session.messageSubscribe(arg::queue=q, arg::destination=dest, arg::acquireMode=1); - session.messageFlow(arg::destination=dest, arg::unit=0, arg::value=0xFFFFFFFF);//messages - session.messageFlow(arg::destination=dest, arg::unit=1, arg::value=0xFFFFFFFF);//bytes + ClientSessionFixture(Broker::Options opts = Broker::Options()) : ProxySessionFixture(opts) { + session.queueDeclare(arg::queue="my-queue"); } }; QPID_AUTO_TEST_CASE(testQueueQuery) { ClientSessionFixture fix; fix.session = fix.connection.newSession(); - fix.session.queueDeclare(arg::queue="my-queue", arg::alternateExchange="amq.fanout", arg::exclusive=true, arg::autoDelete=true); - QueueQueryResult result = fix.session.queueQuery(string("my-queue")); + fix.session.queueDeclare(arg::queue="q", arg::alternateExchange="amq.fanout", + arg::exclusive=true, arg::autoDelete=true); + QueueQueryResult result = fix.session.queueQuery("q"); BOOST_CHECK_EQUAL(false, result.getDurable()); BOOST_CHECK_EQUAL(true, result.getExclusive()); - BOOST_CHECK_EQUAL(string("amq.fanout"), - result.getAlternateExchange()); -} - -QPID_AUTO_TEST_CASE(testTransfer) -{ - ClientSessionFixture fix; - fix.session=fix.connection.newSession(); - fix.declareSubscribe(); - fix.session.messageTransfer(arg::acceptMode=1, arg::content=TransferContent("my-message", "my-queue")); - //get & test the message: - FrameSet::shared_ptr msg = fix.session.get(); - BOOST_CHECK(msg->isA()); - BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); - //confirm receipt: - AckPolicy autoAck; - autoAck.ack(Message(*msg), fix.session); + BOOST_CHECK_EQUAL("amq.fanout", result.getAlternateExchange()); } QPID_AUTO_TEST_CASE(testDispatcher) { ClientSessionFixture fix; fix.session =fix.connection.newSession(); - fix.declareSubscribe(); size_t count = 100; for (size_t i = 0; i < count; ++i) fix.session.messageTransfer(arg::content=TransferContent(boost::lexical_cast(i), "my-queue")); - DummyListener listener(fix.session, "my-dest", count); + DummyListener listener(fix.session, "my-queue", count); listener.run(); BOOST_CHECK_EQUAL(count, listener.messages.size()); for (size_t i = 0; i < count; ++i) @@ -152,9 +128,8 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) { ClientSessionFixture fix; fix.session =fix.connection.newSession(); - fix.declareSubscribe(); size_t count = 10; - DummyListener listener(fix.session, "my-dest", count); + DummyListener listener(fix.session, "my-queue", count); sys::Thread t(listener); for (size_t i = 0; i < count; ++i) { fix.session.messageTransfer(arg::content=TransferContent(boost::lexical_cast(i), "my-queue")); @@ -190,7 +165,6 @@ QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) { ClientSessionFixture fix; fix.session.timeout(60); - fix.declareSubscribe(); fix.session.suspend(); // Make sure we are still subscribed after resume. fix.connection.resume(fix.session); @@ -234,7 +208,7 @@ QPID_AUTO_TEST_CASE(testLocalQueue) { BOOST_CHECK_EQUAL("foo0", lq.pop().getData()); BOOST_CHECK_EQUAL("foo1", lq.pop().getData()); BOOST_CHECK(lq.empty()); // Credit exhausted. - fix.subs.setFlowControl("lq", FlowControl::unlimited()); + fix.subs.getSubscription("lq").setFlowControl(FlowControl::unlimited()); BOOST_CHECK_EQUAL("foo2", lq.pop().getData()); } -- cgit v1.2.1 From 075422745167501a7613411a53ddad6eaa789391 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 5 Nov 2008 21:12:54 +0000 Subject: Added ability to release messages through the Subscription class (+test) Added another mode for managing completion (+test) Fixed regression where bytes credit was not reallocated in windowing mode after an accept/release Fixed regression where subscribe request is issued before listener is registered with dispatcher git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711698 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 84 ++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index abe317aad8..cca16bd9f8 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -296,6 +296,90 @@ QPID_AUTO_TEST_CASE(testExpirationOnPop) { } } +QPID_AUTO_TEST_CASE(testRelease) { + ClientSessionFixture fix; + + const uint count=10; + for (uint i = 0; i < count; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + fix.session.messageTransfer(arg::content=m); + } + + fix.subs.setAutoStop(false); + sys::Thread runner(fix.subs);//start dispatcher thread + SubscriptionSettings settings; + settings.autoAck = 0; + + SimpleListener l1; + Subscription s1 = fix.subs.subscribe(l1, "my-queue", settings); + l1.waitFor(count); + s1.cancel(); + + for (uint i = 0; i < count; i++) { + BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), l1.messages[i].getData()); + } + s1.release(s1.getUnaccepted()); + + //check that released messages are redelivered + settings.autoAck = 1; + SimpleListener l2; + Subscription s2 = fix.subs.subscribe(l2, "my-queue", settings); + l2.waitFor(count); + for (uint i = 0; i < count; i++) { + BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), l2.messages[i].getData()); + } + + fix.subs.stop(); + runner.join(); + fix.session.close(); +} + +QPID_AUTO_TEST_CASE(testCompleteOnAccept) { + ClientSessionFixture fix; + + fix.session.queueDeclare(arg::queue="HELP_FIND_ME"); + + const uint count = 8; + const uint chunk = 4; + for (uint i = 0; i < count; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + fix.session.messageTransfer(arg::content=m); + } + + SubscriptionSettings settings; + settings.autoAck = 0; + settings.completionMode = COMPLETE_ON_ACCEPT; + settings.flowControl = FlowControl::messageWindow(chunk); + + LocalQueue q; + Subscription s = fix.subs.subscribe(q, "my-queue", settings); + fix.session.messageFlush(arg::destination=s.getName()); + SequenceSet accepted; + for (uint i = 0; i < chunk; i++) { + Message m; + BOOST_CHECK(q.get(m)); + BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), m.getData()); + accepted.add(m.getId()); + } + Message m; + BOOST_CHECK(!q.get(m)); + + s.accept(accepted); + fix.session.messageFlush(arg::destination=s.getName()); + accepted.clear(); + + for (uint i = chunk; i < count; i++) { + Message m; + BOOST_CHECK(q.get(m)); + BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), m.getData()); + accepted.add(m.getId()); + } + fix.session.messageAccept(accepted); + + fix.session.queueDelete(arg::queue="HELP_FIND_ME"); + +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 8083badb0a20b9c80797437e39cb9ed5c79f2edb Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 6 Nov 2008 10:47:57 +0000 Subject: SubscriptionManager and Dispatcher were missing wait() methods meaning that if start was called there was no way to join with the dispatch thread and shutdown cleanly. Fixed by adding that method. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711838 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index cca16bd9f8..43c12ddf5c 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -306,7 +306,7 @@ QPID_AUTO_TEST_CASE(testRelease) { } fix.subs.setAutoStop(false); - sys::Thread runner(fix.subs);//start dispatcher thread + fix.subs.start(); SubscriptionSettings settings; settings.autoAck = 0; @@ -330,7 +330,7 @@ QPID_AUTO_TEST_CASE(testRelease) { } fix.subs.stop(); - runner.join(); + fix.subs.wait(); fix.session.close(); } -- cgit v1.2.1 From 0f5373ec7f640004b4d1eeb46c1a6c9d34787358 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 24 Nov 2008 18:37:37 +0000 Subject: QPID-1478: ensure concurrent publishers work correctly (as well as reported assertion, the test uncovered a potential deadlock due to bounds being expanded before frames were added to queue). git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@720251 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 43c12ddf5c..ec040cabff 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -30,6 +30,8 @@ #include #include +#include +#include #include @@ -380,6 +382,60 @@ QPID_AUTO_TEST_CASE(testCompleteOnAccept) { } +namespace +{ +struct Publisher : qpid::sys::Runnable +{ + AsyncSession session; + Message message; + uint count; + Thread thread; + + Publisher(Connection& con, Message m, uint c) : session(con.newSession()), message(m), count(c) {} + + void start() + { + thread = Thread(*this); + } + + void join() + { + thread.join(); + } + + void run() + { + for (uint i = 0; i < count; i++) { + session.messageTransfer(arg::content=message); + } + session.sync(); + session.close(); + } +}; +} + +QPID_AUTO_TEST_CASE(testConcurrentSenders) +{ + //Ensure concurrent publishing sessions on a connection don't + //cause assertions, deadlocks or other undesirables: + BrokerFixture fix; + Connection connection; + ConnectionSettings settings; + settings.maxFrameSize = 1024; + settings.port = fix.broker->getPort(qpid::broker::Broker::TCP_TRANSPORT); + connection.open(settings); + AsyncSession session = connection.newSession(); + Message message(string(512, 'X')); + + boost::ptr_vector publishers; + for (size_t i = 0; i < 5; i++) { + publishers.push_back(new Publisher(connection, message, 100)); + } + for_each(publishers.begin(), publishers.end(), boost::bind(&Publisher::start, _1)); + for_each(publishers.begin(), publishers.end(), boost::bind(&Publisher::join, _1)); + connection.close(); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 5bf6e33743930bc8e08a91abb98c0f35513b3826 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 10 Dec 2008 23:26:18 +0000 Subject: QPID-1527: Added exclusive option to SubscriptionSettings and accompanying test. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@725484 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index ec040cabff..5d047dcd0e 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -19,6 +19,7 @@ * */ #include "unit_test.h" +#include "test_tools.h" #include "BrokerFixture.h" #include "qpid/client/SubscriptionManager.h" #include "qpid/sys/Monitor.h" @@ -338,9 +339,6 @@ QPID_AUTO_TEST_CASE(testRelease) { QPID_AUTO_TEST_CASE(testCompleteOnAccept) { ClientSessionFixture fix; - - fix.session.queueDeclare(arg::queue="HELP_FIND_ME"); - const uint count = 8; const uint chunk = 4; for (uint i = 0; i < count; i++) { @@ -377,9 +375,6 @@ QPID_AUTO_TEST_CASE(testCompleteOnAccept) { accepted.add(m.getId()); } fix.session.messageAccept(accepted); - - fix.session.queueDelete(arg::queue="HELP_FIND_ME"); - } namespace @@ -436,6 +431,22 @@ QPID_AUTO_TEST_CASE(testConcurrentSenders) connection.close(); } + +QPID_AUTO_TEST_CASE(testExclusiveSubscribe) +{ + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="myq", arg::exclusive=true, arg::autoDelete=true); + SubscriptionSettings settings; + settings.exclusive = true; + LocalQueue q; + fix.subs.subscribe(q, "myq", settings, "first"); + //attempt to create new subscriber should fail + ScopedSuppressLogging sl; + BOOST_CHECK_THROW(fix.subs.subscribe(q, "myq", "second"), ResourceLockedException); + ; + +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 5f49d66d97bc32669d4ad2a493f0afc5a57c7c27 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 7 Jan 2009 10:46:53 +0000 Subject: QPID-1560: add support for a qpid.exclusive-binding option on direct exchange that causes the binding specified to be the only one for the given key. I.e. if there is already a binding at this exchange with this key it will be atomically updated to bind the new queue. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@732297 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 5d047dcd0e..454632dd39 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -447,6 +447,28 @@ QPID_AUTO_TEST_CASE(testExclusiveSubscribe) } +QPID_AUTO_TEST_CASE(testExclusiveBinding) { + FieldTable options; + options.setString("qpid.exclusive-binding", "anything"); + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="queue-1", arg::exclusive=true, arg::autoDelete=true); + fix.session.queueDeclare(arg::queue="queue-2", arg::exclusive=true, arg::autoDelete=true); + fix.session.exchangeBind(arg::exchange="amq.direct", arg::queue="queue-1", arg::bindingKey="my-key", arg::arguments=options); + fix.session.messageTransfer(arg::destination="amq.direct", arg::content=Message("message1", "my-key")); + fix.session.exchangeBind(arg::exchange="amq.direct", arg::queue="queue-2", arg::bindingKey="my-key", arg::arguments=options); + fix.session.messageTransfer(arg::destination="amq.direct", arg::content=Message("message2", "my-key")); + + Message got; + BOOST_CHECK(fix.subs.get(got, "queue-1")); + BOOST_CHECK_EQUAL("message1", got.getData()); + BOOST_CHECK(!fix.subs.get(got, "queue-1")); + + BOOST_CHECK(fix.subs.get(got, "queue-2")); + BOOST_CHECK_EQUAL("message2", got.getData()); + BOOST_CHECK(!fix.subs.get(got, "queue-2")); +} + + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 7863ff6b35b29796185108ef263f13294756cf29 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 23 Jan 2009 14:08:42 +0000 Subject: QPID-1613: Ensure that the rule registered with the demuxer for LocalQueue subscriptions is removed when they are cancelled. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@737028 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 454632dd39..2d9239131e 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -468,6 +468,25 @@ QPID_AUTO_TEST_CASE(testExclusiveBinding) { BOOST_CHECK(!fix.subs.get(got, "queue-2")); } +QPID_AUTO_TEST_CASE(testResubscribeWithLocalQueue) { + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="some-queue", arg::exclusive=true, arg::autoDelete=true); + LocalQueue p, q; + fix.subs.subscribe(p, "some-queue"); + fix.subs.cancel("some-queue"); + fix.subs.subscribe(q, "some-queue"); + + fix.session.messageTransfer(arg::content=Message("some-data", "some-queue")); + fix.session.messageFlush(arg::destination="some-queue"); + + Message got; + BOOST_CHECK(!p.get(got)); + + BOOST_CHECK(q.get(got)); + BOOST_CHECK_EQUAL("some-data", got.getData()); + BOOST_CHECK(!q.get(got)); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 9fee311bc73f83716ada431621ec86da386c96ec Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Mon, 2 Feb 2009 22:11:20 +0000 Subject: Use qpid sleep rather than CRT sleep to build on Windows git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@740121 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 2d9239131e..f0c7c1d0c6 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -25,6 +25,7 @@ #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" +#include "qpid/sys/Time.h" #include "qpid/client/Session.h" #include "qpid/framing/TransferContent.h" #include "qpid/framing/reply_exceptions.h" @@ -223,7 +224,7 @@ struct DelayedTransfer : sys::Runnable void run() { - sleep(1); + qpid::sys::sleep(1); fixture.session.messageTransfer(arg::content=Message("foo2", "getq")); } }; @@ -275,7 +276,7 @@ QPID_AUTO_TEST_CASE(testPeriodicExpiration) { } BOOST_CHECK_EQUAL(fix.session.queueQuery(string("my-queue")).getMessageCount(), 10u); - sleep(2); + qpid::sys::sleep(2); BOOST_CHECK_EQUAL(fix.session.queueQuery(string("my-queue")).getMessageCount(), 5u); } @@ -289,7 +290,7 @@ QPID_AUTO_TEST_CASE(testExpirationOnPop) { fix.session.messageTransfer(arg::content=m); } - ::usleep(300* 1000); + qpid::sys::usleep(300* 1000); for (uint i = 0; i < 10; i++) { if (i % 2) continue; -- cgit v1.2.1 From eaed6d20d8ba86a783fb8f021c4ee55953c23b6e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 12 Feb 2009 11:43:51 +0000 Subject: QPID-1660: If selected consumer can't take a message, ensure others are notified of message availability. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@743694 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index f0c7c1d0c6..6ec73fd47c 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -488,6 +488,39 @@ QPID_AUTO_TEST_CASE(testResubscribeWithLocalQueue) { BOOST_CHECK(!q.get(got)); } +QPID_AUTO_TEST_CASE(testReliableDispatch) { + ClientSessionFixture fix; + std::string queue("a-queue"); + fix.session.queueDeclare(arg::queue=queue, arg::autoDelete=true); + + ConnectionSettings settings; + settings.port = fix.broker->getPort(qpid::broker::Broker::TCP_TRANSPORT); + + Connection c1; + c1.open(settings); + Session s1 = c1.newSession(); + SubscriptionManager subs1(s1); + LocalQueue q1; + subs1.subscribe(q1, queue, FlowControl());//first subscriber has no credit + + Connection c2; + c2.open(settings); + Session s2 = c2.newSession(); + SubscriptionManager subs2(s2); + LocalQueue q2; + subs2.subscribe(q2, queue);//second subscriber has credit + + fix.session.messageTransfer(arg::content=Message("my-message", queue)); + + //check that the second consumer gets the message + Message got; + BOOST_CHECK(q2.get(got, 1*TIME_SEC)); + BOOST_CHECK_EQUAL("my-message", got.getData()); + + c1.close(); + c2.close(); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 571225ebdad7e9777d6949596189867d4fc62d93 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 13 Feb 2009 09:30:33 +0000 Subject: Test case for previous commit. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@744052 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 6ec73fd47c..e4c311d8a0 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -521,6 +521,10 @@ QPID_AUTO_TEST_CASE(testReliableDispatch) { c2.close(); } +QPID_AUTO_TEST_CASE(testSessionCloseOnInvalidSession) { + Session session; + session.close(); +} QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 492b05e6aa1a771d86cdb29c04dfe7d0ebefdd4b Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 13 Feb 2009 19:21:21 +0000 Subject: Ensure that the queue depth in bytes remains accurate for LVQ. This also ensures that there are no underflow exceptions from the policy that keeps this count. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@744222 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index e4c311d8a0..e156000f18 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -21,6 +21,7 @@ #include "unit_test.h" #include "test_tools.h" #include "BrokerFixture.h" +#include "qpid/client/QueueOptions.h" #include "qpid/client/SubscriptionManager.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" @@ -526,6 +527,27 @@ QPID_AUTO_TEST_CASE(testSessionCloseOnInvalidSession) { session.close(); } +QPID_AUTO_TEST_CASE(testLVQVariedSize) { + ClientSessionFixture fix; + std::string queue("my-lvq"); + QueueOptions args; + args.setOrdering(LVQ_NO_BROWSE); + fix.session.queueDeclare(arg::queue=queue, arg::exclusive=true, arg::autoDelete=true, arg::arguments=args); + + std::string key; + args.getLVQKey(key); + + for (size_t i = 0; i < 10; i++) { + std::ostringstream data; + size_t size = 100 - ((i % 10) * 10); + data << std::string(size, 'x'); + + Message m(data.str(), queue); + m.getHeaders().setString(key, "abc"); + fix.session.messageTransfer(arg::content=m); + } +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 091bdea11de78b92ef2ed8232875b105b0c434f3 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 17 Feb 2009 15:44:19 +0000 Subject: QPID-1667: Test case (fix was submitted in previous rev) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@745125 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index e156000f18..1658f3d4ec 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -548,6 +548,22 @@ QPID_AUTO_TEST_CASE(testLVQVariedSize) { } } +QPID_AUTO_TEST_CASE(testSessionManagerSetFlowControl) { + ClientSessionFixture fix; + std::string name("dummy"); + LocalQueue queue; + SubscriptionSettings settings; + settings.flowControl = FlowControl(); + fix.session.queueDeclare(arg::queue=name, arg::exclusive=true, arg::autoDelete=true); + fix.subs.subscribe(queue, name, settings); + fix.session.messageTransfer(arg::content=Message("my-message", name)); + fix.subs.setFlowControl(name, 1, FlowControl::UNLIMITED, false); + fix.session.messageFlush(name); + Message got; + BOOST_CHECK(queue.get(got, 0)); + BOOST_CHECK_EQUAL("my-message", got.getData()); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 64d4fcb837518533e4f81b14ae8e509cc66edea4 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 5 Mar 2009 22:05:26 +0000 Subject: QPID-1718: Ensure that cancellation caused by e.g. SubscriptionManager::get() doesn't close dispatch queue. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@750622 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 1658f3d4ec..b164ed0166 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -564,6 +564,24 @@ QPID_AUTO_TEST_CASE(testSessionManagerSetFlowControl) { BOOST_CHECK_EQUAL("my-message", got.getData()); } +QPID_AUTO_TEST_CASE(testGetThenSubscribe) { + ClientSessionFixture fix; + std::string name("myqueue"); + fix.session.queueDeclare(arg::queue=name, arg::exclusive=true, arg::autoDelete=true); + fix.session.messageTransfer(arg::content=Message("one", name)); + fix.session.messageTransfer(arg::content=Message("two", name)); + Message got; + BOOST_CHECK(fix.subs.get(got, name)); + BOOST_CHECK_EQUAL("one", got.getData()); + + DummyListener listener(fix.session, name, 1); + listener.run(); + BOOST_CHECK_EQUAL(1u, listener.messages.size()); + if (!listener.messages.empty()) { + BOOST_CHECK_EQUAL("two", listener.messages[0].getData()); + } +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 10f2b2a6a1fe91e7b29fa74013baa0cf091bd64b Mon Sep 17 00:00:00 2001 From: Manuel Teira Paz Date: Tue, 10 Mar 2009 08:19:28 +0000 Subject: configure.ac: - Add a SOCKLIBS definition, to define needed network libraries in Solaris src/tests/failover_soak.cpp - Replace usage of timersub with direct code, since timersub appears to be non-posix. src/tests/Makefile.am - Link against $(SOCKLIBS) when needed src/tests/* - Some qualifying needed for the Sun compiler git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@752019 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index b164ed0166..589e1154e1 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -428,8 +428,8 @@ QPID_AUTO_TEST_CASE(testConcurrentSenders) for (size_t i = 0; i < 5; i++) { publishers.push_back(new Publisher(connection, message, 100)); } - for_each(publishers.begin(), publishers.end(), boost::bind(&Publisher::start, _1)); - for_each(publishers.begin(), publishers.end(), boost::bind(&Publisher::join, _1)); + std::for_each(publishers.begin(), publishers.end(), boost::bind(&Publisher::start, _1)); + std::for_each(publishers.begin(), publishers.end(), boost::bind(&Publisher::join, _1)); connection.close(); } -- cgit v1.2.1 From c11a151092de0f2c0f5cc83462637628a45cd9f6 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 20 Apr 2009 22:33:27 +0000 Subject: Apply PIMPL pattern to qpid::client::Message. Hide implementation of Message, move framing::MethodContent and framing::TransferContent out of public API. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@766899 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 589e1154e1..1c719d16dc 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -28,7 +28,7 @@ #include "qpid/sys/Runnable.h" #include "qpid/sys/Time.h" #include "qpid/client/Session.h" -#include "qpid/framing/TransferContent.h" +#include "qpid/client/Message.h" #include "qpid/framing/reply_exceptions.h" #include @@ -121,7 +121,7 @@ QPID_AUTO_TEST_CASE(testDispatcher) fix.session =fix.connection.newSession(); size_t count = 100; for (size_t i = 0; i < count; ++i) - fix.session.messageTransfer(arg::content=TransferContent(boost::lexical_cast(i), "my-queue")); + fix.session.messageTransfer(arg::content=Message(boost::lexical_cast(i), "my-queue")); DummyListener listener(fix.session, "my-queue", count); listener.run(); BOOST_CHECK_EQUAL(count, listener.messages.size()); @@ -137,7 +137,7 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) DummyListener listener(fix.session, "my-queue", count); sys::Thread t(listener); for (size_t i = 0; i < count; ++i) { - fix.session.messageTransfer(arg::content=TransferContent(boost::lexical_cast(i), "my-queue")); + fix.session.messageTransfer(arg::content=Message(boost::lexical_cast(i), "my-queue")); } t.join(); BOOST_CHECK_EQUAL(count, listener.messages.size()); @@ -173,7 +173,7 @@ QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) fix.session.suspend(); // Make sure we are still subscribed after resume. fix.connection.resume(fix.session); - fix.session.messageTransfer(arg::content=TransferContent("my-message", "my-queue")); + fix.session.messageTransfer(arg::content=Message("my-message", "my-queue")); FrameSet::shared_ptr msg = fix.session.get(); BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); } -- cgit v1.2.1 From 2f1c3e9abdedbc87fb6f281b73665fe05046b413 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 4 May 2009 17:22:33 +0000 Subject: Applied PIMPL pattern to SubscriptionManager. Cleaned up some sloppy #includes. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@771366 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 1c719d16dc..0a72facd86 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -22,7 +22,9 @@ #include "test_tools.h" #include "BrokerFixture.h" #include "qpid/client/QueueOptions.h" +#include "qpid/client/MessageListener.h" #include "qpid/client/SubscriptionManager.h" +#include "qpid/client/AsyncSession.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" -- cgit v1.2.1 From bf7b362de6f5847074fea095d3c267d79aee1854 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 6 May 2009 12:44:35 +0000 Subject: Remove client::Execution and FrameSet from the public API. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@772182 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 0a72facd86..f732d61ce1 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -176,8 +176,7 @@ QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) // Make sure we are still subscribed after resume. fix.connection.resume(fix.session); fix.session.messageTransfer(arg::content=Message("my-message", "my-queue")); - FrameSet::shared_ptr msg = fix.session.get(); - BOOST_CHECK_EQUAL(string("my-message"), msg->getContent()); + BOOST_CHECK_EQUAL("my-message", fix.subs.get("my-queue", TIME_SEC).getData()); } -- cgit v1.2.1 From 7a7c2285bfea9adeb6f09c6edb24a3f9b5138d0d Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 11 May 2009 12:21:40 +0000 Subject: Added method to test validity of session object. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@773535 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index f732d61ce1..c82cb77e95 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -583,6 +583,13 @@ QPID_AUTO_TEST_CASE(testGetThenSubscribe) { } } +QPID_AUTO_TEST_CASE(testSessionIsValid) { + ClientSessionFixture fix; + BOOST_CHECK(fix.session.isValid()); + Session session; + BOOST_CHECK(!session.isValid()); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From 0f979c0b50d1c295f0e966236dc4e5aa902f6af2 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 8 Jun 2009 17:39:24 +0000 Subject: If expiration is already set, don't alter it. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@782712 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index c82cb77e95..7a6373ac17 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -590,6 +590,20 @@ QPID_AUTO_TEST_CASE(testSessionIsValid) { BOOST_CHECK(!session.isValid()); } +QPID_AUTO_TEST_CASE(testExpirationNotAltered) { + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); + + Message m("my-message", "my-queue"); + m.getDeliveryProperties().setTtl(60000); + m.getDeliveryProperties().setExpiration(12345); + fix.session.messageTransfer(arg::content=m); + Message got; + BOOST_CHECK(fix.subs.get(got, "my-queue")); + BOOST_CHECK_EQUAL("my-message", got.getData()); + BOOST_CHECK_EQUAL(12345u, got.getDeliveryProperties().getExpiration()); +} + QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1 From e04f58117006e8f0b7edcb0bcd00a33c6f6b5755 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 17 Jun 2009 13:45:31 +0000 Subject: Drop _EXPECTED_FAILURES macro, doesn't work with all boost versions. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@785601 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 7a6373ac17..3ed7491f7d 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -147,8 +147,8 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) BOOST_CHECK_EQUAL(boost::lexical_cast(i), listener.messages[i].getData()); } -QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspend0Timeout, 1) -{ +// FIXME aconway 2009-06-17: test for unimplemented feature, enable when implemented. +void testSuspend0Timeout() { ClientSessionFixture fix; fix.session.suspend(); // session has 0 timeout. try { @@ -168,8 +168,8 @@ QPID_AUTO_TEST_CASE(testUseSuspendedError) } catch(const NotAttachedException&) {} } -QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testSuspendResume, 1) -{ +// FIXME aconway 2009-06-17: test for unimplemented feature, enable when implemented. +void testSuspendResume() { ClientSessionFixture fix; fix.session.timeout(60); fix.session.suspend(); -- cgit v1.2.1 From ffd20ee19a5fd027e0007c27a12dd402dbeca4f8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:32:39 +0000 Subject: Add directory to #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793909 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 3ed7491f7d..0adf6ccc27 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -18,9 +18,9 @@ * under the License. * */ -#include "unit_test.h" -#include "test_tools.h" -#include "BrokerFixture.h" +#include "tests/unit_test.h" +#include "tests/test_tools.h" +#include "tests/BrokerFixture.h" #include "qpid/client/QueueOptions.h" #include "qpid/client/MessageListener.h" #include "qpid/client/SubscriptionManager.h" -- cgit v1.2.1 From 795b3bb9e5c033abf33635119694e21e7143fc0a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 14 Jul 2009 14:41:22 +0000 Subject: Remove incorrect directory from #include git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@793912 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 0adf6ccc27..3ed7491f7d 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -18,9 +18,9 @@ * under the License. * */ -#include "tests/unit_test.h" -#include "tests/test_tools.h" -#include "tests/BrokerFixture.h" +#include "unit_test.h" +#include "test_tools.h" +#include "BrokerFixture.h" #include "qpid/client/QueueOptions.h" #include "qpid/client/MessageListener.h" #include "qpid/client/SubscriptionManager.h" -- cgit v1.2.1 From 9259c46ecb8c5f3e98441080a26914bdea59bffe Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 9 Sep 2009 19:46:56 +0000 Subject: Tidied up namespace usage Miscelleneous whitespace fixes git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@813094 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 67 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 3ed7491f7d..6ca0aa6d44 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -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 @@ -40,6 +40,9 @@ #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(ClientSessionTest) using namespace qpid::client; @@ -122,12 +125,12 @@ QPID_AUTO_TEST_CASE(testDispatcher) ClientSessionFixture fix; fix.session =fix.connection.newSession(); size_t count = 100; - for (size_t i = 0; i < count; ++i) + for (size_t i = 0; i < count; ++i) fix.session.messageTransfer(arg::content=Message(boost::lexical_cast(i), "my-queue")); DummyListener listener(fix.session, "my-queue", count); listener.run(); - BOOST_CHECK_EQUAL(count, listener.messages.size()); - for (size_t i = 0; i < count; ++i) + BOOST_CHECK_EQUAL(count, listener.messages.size()); + for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(boost::lexical_cast(i), listener.messages[i].getData()); } @@ -142,8 +145,8 @@ QPID_AUTO_TEST_CASE(testDispatcherThread) fix.session.messageTransfer(arg::content=Message(boost::lexical_cast(i), "my-queue")); } t.join(); - BOOST_CHECK_EQUAL(count, listener.messages.size()); - for (size_t i = 0; i < count; ++i) + BOOST_CHECK_EQUAL(count, listener.messages.size()); + for (size_t i = 0; i < count; ++i) BOOST_CHECK_EQUAL(boost::lexical_cast(i), listener.messages[i].getData()); } @@ -215,7 +218,7 @@ QPID_AUTO_TEST_CASE(testLocalQueue) { BOOST_CHECK_EQUAL("foo1", lq.pop().getData()); BOOST_CHECK(lq.empty()); // Credit exhausted. fix.subs.getSubscription("lq").setFlowControl(FlowControl::unlimited()); - BOOST_CHECK_EQUAL("foo2", lq.pop().getData()); + BOOST_CHECK_EQUAL("foo2", lq.pop().getData()); } struct DelayedTransfer : sys::Runnable @@ -246,7 +249,7 @@ QPID_AUTO_TEST_CASE(testGet) { Thread t(sender); //test timed get where message shows up after a short delay BOOST_CHECK(fix.subs.get(got, "getq", 5*TIME_SEC)); - BOOST_CHECK_EQUAL("foo2", got.getData()); + BOOST_CHECK_EQUAL("foo2", got.getData()); t.join(); } @@ -271,8 +274,8 @@ QPID_AUTO_TEST_CASE(testPeriodicExpiration) { ClientSessionFixture fix(opts); fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); - for (uint i = 0; i < 10; i++) { - Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + for (uint i = 0; i < 10; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); if (i % 2) m.getDeliveryProperties().setTtl(500); fix.session.messageTransfer(arg::content=m); } @@ -286,15 +289,15 @@ QPID_AUTO_TEST_CASE(testExpirationOnPop) { ClientSessionFixture fix; fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); - for (uint i = 0; i < 10; i++) { - Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + for (uint i = 0; i < 10; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); if (i % 2) m.getDeliveryProperties().setTtl(200); fix.session.messageTransfer(arg::content=m); } qpid::sys::usleep(300* 1000); - for (uint i = 0; i < 10; i++) { + for (uint i = 0; i < 10; i++) { if (i % 2) continue; Message m; BOOST_CHECK(fix.subs.get(m, "my-queue", TIME_SEC)); @@ -306,8 +309,8 @@ QPID_AUTO_TEST_CASE(testRelease) { ClientSessionFixture fix; const uint count=10; - for (uint i = 0; i < count; i++) { - Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + for (uint i = 0; i < count; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); fix.session.messageTransfer(arg::content=m); } @@ -334,7 +337,7 @@ QPID_AUTO_TEST_CASE(testRelease) { for (uint i = 0; i < count; i++) { BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), l2.messages[i].getData()); } - + fix.subs.stop(); fix.subs.wait(); fix.session.close(); @@ -344,8 +347,8 @@ QPID_AUTO_TEST_CASE(testCompleteOnAccept) { ClientSessionFixture fix; const uint count = 8; const uint chunk = 4; - for (uint i = 0; i < count; i++) { - Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); + for (uint i = 0; i < count; i++) { + Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); fix.session.messageTransfer(arg::content=m); } @@ -358,25 +361,25 @@ QPID_AUTO_TEST_CASE(testCompleteOnAccept) { Subscription s = fix.subs.subscribe(q, "my-queue", settings); fix.session.messageFlush(arg::destination=s.getName()); SequenceSet accepted; - for (uint i = 0; i < chunk; i++) { + for (uint i = 0; i < chunk; i++) { Message m; BOOST_CHECK(q.get(m)); BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), m.getData()); accepted.add(m.getId()); - } + } Message m; BOOST_CHECK(!q.get(m)); - + s.accept(accepted); fix.session.messageFlush(arg::destination=s.getName()); accepted.clear(); - - for (uint i = chunk; i < count; i++) { + + for (uint i = chunk; i < count; i++) { Message m; BOOST_CHECK(q.get(m)); BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i+1)).str(), m.getData()); accepted.add(m.getId()); - } + } fix.session.messageAccept(accepted); } @@ -424,7 +427,7 @@ QPID_AUTO_TEST_CASE(testConcurrentSenders) connection.open(settings); AsyncSession session = connection.newSession(); Message message(string(512, 'X')); - + boost::ptr_vector publishers; for (size_t i = 0; i < 5; i++) { publishers.push_back(new Publisher(connection, message, 100)); @@ -447,7 +450,7 @@ QPID_AUTO_TEST_CASE(testExclusiveSubscribe) ScopedSuppressLogging sl; BOOST_CHECK_THROW(fix.subs.subscribe(q, "myq", "second"), ResourceLockedException); ; - + } QPID_AUTO_TEST_CASE(testExclusiveBinding) { @@ -478,7 +481,7 @@ QPID_AUTO_TEST_CASE(testResubscribeWithLocalQueue) { fix.subs.subscribe(p, "some-queue"); fix.subs.cancel("some-queue"); fix.subs.subscribe(q, "some-queue"); - + fix.session.messageTransfer(arg::content=Message("some-data", "some-queue")); fix.session.messageFlush(arg::destination="some-queue"); @@ -542,10 +545,10 @@ QPID_AUTO_TEST_CASE(testLVQVariedSize) { std::ostringstream data; size_t size = 100 - ((i % 10) * 10); data << std::string(size, 'x'); - + Message m(data.str(), queue); m.getHeaders().setString(key, "abc"); - fix.session.messageTransfer(arg::content=m); + fix.session.messageTransfer(arg::content=m); } } @@ -594,7 +597,7 @@ QPID_AUTO_TEST_CASE(testExpirationNotAltered) { ClientSessionFixture fix; fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); - Message m("my-message", "my-queue"); + Message m("my-message", "my-queue"); m.getDeliveryProperties().setTtl(60000); m.getDeliveryProperties().setExpiration(12345); fix.session.messageTransfer(arg::content=m); @@ -606,4 +609,4 @@ QPID_AUTO_TEST_CASE(testExpirationNotAltered) { QPID_AUTO_TEST_SUITE_END() - +}} // namespace qpid::tests -- cgit v1.2.1 From 84dff8ce35a6d8bdee54b2182a1b7f03ab3ca9dd Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 20 Jan 2010 15:54:59 +0000 Subject: Provide access to a sessions connection. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@901247 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 6ca0aa6d44..8ce5d85632 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -607,6 +607,28 @@ QPID_AUTO_TEST_CASE(testExpirationNotAltered) { BOOST_CHECK_EQUAL(12345u, got.getDeliveryProperties().getExpiration()); } +QPID_AUTO_TEST_CASE(testGetConnectionFromSession) { + ClientSessionFixture fix; + FieldTable options; + options.setInt("no-local", 1); + fix.session.queueDeclare(arg::queue="a", arg::exclusive=true, arg::autoDelete=true, arg::arguments=options); + fix.session.queueDeclare(arg::queue="b", arg::exclusive=true, arg::autoDelete=true); + + Connection c = fix.session.getConnection(); + Session s = c.newSession(); + //If this new session was created as expected on the same connection as + //fix.session, then the no-local behaviour means that queue 'a' + //will not enqueue messages from this new session but queue 'b' + //will. + s.messageTransfer(arg::content=Message("a", "a")); + s.messageTransfer(arg::content=Message("b", "b")); + + Message got; + BOOST_CHECK(fix.subs.get(got, "b")); + BOOST_CHECK_EQUAL("b", got.getData()); + BOOST_CHECK(!fix.subs.get(got, "a")); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests -- cgit v1.2.1 From 94414b346e8423c7d2ced919a022867e0217fbaf Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 22 Jan 2010 10:58:20 +0000 Subject: QPID-2347: Signal deletion of queue to active subscribers via a resource-deleted exception. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@902055 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 8ce5d85632..e8cdb1f232 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -629,6 +629,19 @@ QPID_AUTO_TEST_CASE(testGetConnectionFromSession) { BOOST_CHECK(!fix.subs.get(got, "a")); } + +QPID_AUTO_TEST_CASE(testQueueDeleted) +{ + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="my-queue"); + LocalQueue queue; + fix.subs.subscribe(queue, "my-queue"); + + ScopedSuppressLogging sl; + fix.session.queueDelete(arg::queue="my-queue"); + BOOST_CHECK_THROW(queue.get(1*qpid::sys::TIME_SEC), qpid::framing::ResourceDeletedException); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests -- cgit v1.2.1 From a2469e35c26e32129d2284fac0645918e27dec30 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Mon, 15 Feb 2010 18:36:21 +0000 Subject: Added handling for adjusting TTL on outgoing message based on how long a message has been on the queue. Added a new TTL test as ClientSessionTest.testTtl. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@910289 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index e8cdb1f232..596f3282ce 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -642,6 +642,36 @@ QPID_AUTO_TEST_CASE(testQueueDeleted) BOOST_CHECK_THROW(queue.get(1*qpid::sys::TIME_SEC), qpid::framing::ResourceDeletedException); } +QPID_AUTO_TEST_CASE(testTtl) +{ + const uint64_t ms = 1000ULL; // convert sec to ms + const uint64_t us = 1000ULL * 1000ULL; // convert sec to us + + ClientSessionFixture fix; + fix.session.queueDeclare(arg::queue="ttl-test", arg::exclusive=true, arg::autoDelete=true); + Message msg1 = Message("AAA", "ttl-test"); + uint64_t ttl = 2 * ms; // 2 sec + msg1.getDeliveryProperties().setTtl(ttl); + Connection c = fix.session.getConnection(); + Session s = c.newSession(); + s.messageTransfer(arg::content=msg1); + + Message msg2 = Message("BBB", "ttl-test"); + ttl = 10 * ms; // 10 sec + msg2.getDeliveryProperties().setTtl(ttl); + s.messageTransfer(arg::content=msg2); + + ::usleep(5 * us); // 5 sec + + // Message "AAA" should be expired and never be delivered + // Check "BBB" has ttl somewhere between 1 and 5 secs + Message got; + BOOST_CHECK(fix.subs.get(got, "ttl-test")); + BOOST_CHECK_EQUAL("BBB", got.getData()); + BOOST_CHECK(got.getDeliveryProperties().getTtl() > 1 * ms); + BOOST_CHECK(got.getDeliveryProperties().getTtl() < ttl - (5 * ms)); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests -- cgit v1.2.1 From 6e0a80b089cb3e19061297b1b3b446cfa2bbb9b4 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Tue, 16 Feb 2010 15:55:57 +0000 Subject: Use qpid::sys::usleep() instead of usleep(). Resolves QPID-2408. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@910567 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 596f3282ce..939f8f2b88 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -661,7 +661,7 @@ QPID_AUTO_TEST_CASE(testTtl) msg2.getDeliveryProperties().setTtl(ttl); s.messageTransfer(arg::content=msg2); - ::usleep(5 * us); // 5 sec + qpid::sys::usleep(5 * us); // 5 sec // Message "AAA" should be expired and never be delivered // Check "BBB" has ttl somewhere between 1 and 5 secs -- cgit v1.2.1 From a125972377cb5bd9019f47bd1501d5700494585e Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 26 May 2011 13:30:41 +0000 Subject: QPID-3278: pass container for expired messages by reference git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1127901 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/ClientSessionTest.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/ClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp index 939f8f2b88..3c0cff7350 100644 --- a/qpid/cpp/src/tests/ClientSessionTest.cpp +++ b/qpid/cpp/src/tests/ClientSessionTest.cpp @@ -271,8 +271,12 @@ QPID_AUTO_TEST_CASE(testOpenFailure) { QPID_AUTO_TEST_CASE(testPeriodicExpiration) { Broker::Options opts; opts.queueCleanInterval = 1; + opts.queueFlowStopRatio = 0; + opts.queueFlowResumeRatio = 0; ClientSessionFixture fix(opts); - fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true); + FieldTable args; + args.setInt("qpid.max_count",10); + fix.session.queueDeclare(arg::queue="my-queue", arg::exclusive=true, arg::autoDelete=true, arg::arguments=args); for (uint i = 0; i < 10; i++) { Message m((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); @@ -283,6 +287,7 @@ QPID_AUTO_TEST_CASE(testPeriodicExpiration) { BOOST_CHECK_EQUAL(fix.session.queueQuery(string("my-queue")).getMessageCount(), 10u); qpid::sys::sleep(2); BOOST_CHECK_EQUAL(fix.session.queueQuery(string("my-queue")).getMessageCount(), 5u); + fix.session.messageTransfer(arg::content=Message("Message_11", "my-queue"));//ensure policy is also updated } QPID_AUTO_TEST_CASE(testExpirationOnPop) { -- cgit v1.2.1