From e1d873e3b4528141b9401bad9070bc205de40504 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 6 May 2008 17:52:03 +0000 Subject: From https://issues.apache.org/jira/browse/QPID-879 contributed by Jonathan Robie. XML exchange allowing messages to be routed base on XQuery expressions. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@653854 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 157 ++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 qpid/cpp/src/tests/XmlClientSessionTest.cpp (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp new file mode 100644 index 0000000000..b5c685abbf --- /dev/null +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -0,0 +1,157 @@ +/* + * + * Licensed to the Apachef 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 "unit_test.h" +#include "BrokerFixture.h" +#include "qpid/sys/Monitor.h" +#include "qpid/sys/Thread.h" +#include "qpid/sys/Runnable.h" +#include "qpid/framing/TransferContent.h" +#include "qpid/framing/reply_exceptions.h" +#include "qpid/client/Connection.h" +#include "qpid/client/Dispatcher.h" +#include "qpid/client/LocalQueue.h" +#include "qpid/client/Session.h" +#include "qpid/client/SubscriptionManager.h" + +#include +#include + +#include + +QPID_AUTO_TEST_SUITE(XmlClientSessionTest) + +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; + + +struct DummyListener : public sys::Runnable, public MessageListener { + std::vector messages; + string name; + uint expected; + Dispatcher dispatcher; + + DummyListener(Session& session, const string& n, uint ex) : + name(n), expected(ex), dispatcher(session) {} + + void run() + { + dispatcher.listen(name, this); + dispatcher.run(); + } + + void received(Message& msg) + { + messages.push_back(msg); + if (--expected == 0) + dispatcher.stop(); + } +}; + + +class SubscribedLocalQueue : public LocalQueue { + private: + SubscriptionManager& subscriptions; + public: + SubscribedLocalQueue(SubscriptionManager& subs) : subscriptions(subs) {} + Message get () { return pop(); } + virtual ~SubscribedLocalQueue() {} +}; + + +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="odd_blue", + const string& dest="xml") + { + 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 + } +}; + +// ########### START HERE #################################### + +BOOST_AUTO_TEST_CASE(testXmlBinding) { + ClientSessionFixture f; + + Session session = f.connection.newSession(ASYNC); + SubscriptionManager subscriptions(session); + SubscribedLocalQueue localQueue(subscriptions); + + session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); + session.queueDeclare(qpid::client::arg::queue="odd_blue"); + subscriptions.subscribe(localQueue, "odd_blue"); + + FieldTable binding; + binding.setString("xquery", "declare variable $color external;" + "(./message/id mod 2 = 1) and ($color = 'blue')"); + session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + + Message message; + message.getDeliveryProperties().setRoutingKey("query_name"); + + message.getHeaders().setString("color", "blue"); + string m = "1"; + message.setData(m); + + session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); + + Message m2 = localQueue.get(); + BOOST_CHECK_EQUAL(m, m2.getData()); +} + +//### Test: Bad XML does not kill the server + +//### Test: Bad XQuery does not kill the server + +//### Test: Bindings persist, surviving broker restart + +QPID_AUTO_TEST_SUITE_END() + -- cgit v1.2.1 From d4a89b159b361317d54d75dd4a2429bbd74f64d1 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 13 May 2008 09:44:43 +0000 Subject: Fix macro used in test for backwards compatability. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@655790 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index b5c685abbf..dc6cce24fc 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -118,7 +118,7 @@ struct ClientSessionFixture : public ProxySessionFixture // ########### START HERE #################################### -BOOST_AUTO_TEST_CASE(testXmlBinding) { +QPID_AUTO_TEST_CASE(testXmlBinding) { ClientSessionFixture f; Session session = f.connection.newSession(ASYNC); -- 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/XmlClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index dc6cce24fc..9b0c035f37 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -121,7 +121,7 @@ struct ClientSessionFixture : public ProxySessionFixture QPID_AUTO_TEST_CASE(testXmlBinding) { ClientSessionFixture f; - Session session = f.connection.newSession(ASYNC); + Session session = f.connection.newSession(); SubscriptionManager subscriptions(session); SubscribedLocalQueue localQueue(subscriptions); -- cgit v1.2.1 From cc0a54d8b87767b905ad690493f299df1cda8952 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 8 Jul 2008 13:54:03 +0000 Subject: Fix leak in XmlClientSessionTests - was leaking a Session. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@674825 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 9b0c035f37..d0a1520c81 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -121,18 +121,17 @@ struct ClientSessionFixture : public ProxySessionFixture QPID_AUTO_TEST_CASE(testXmlBinding) { ClientSessionFixture f; - Session session = f.connection.newSession(); - SubscriptionManager subscriptions(session); + SubscriptionManager subscriptions(f.session); SubscribedLocalQueue localQueue(subscriptions); - session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); - session.queueDeclare(qpid::client::arg::queue="odd_blue"); + f.session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); + f.session.queueDeclare(qpid::client::arg::queue="odd_blue"); subscriptions.subscribe(localQueue, "odd_blue"); FieldTable binding; binding.setString("xquery", "declare variable $color external;" "(./message/id mod 2 = 1) and ($color = 'blue')"); - session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); Message message; message.getDeliveryProperties().setRoutingKey("query_name"); @@ -141,7 +140,7 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { string m = "1"; message.setData(m); - session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); + f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); Message m2 = localQueue.get(); BOOST_CHECK_EQUAL(m, m2.getData()); -- cgit v1.2.1 From e884da88a52c44e238b05b66c60136d4e83c55fb Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 8 Sep 2008 19:23:30 +0000 Subject: Fixes to xml exchange: * changed locking for QPID-1264 * allow multiple queues to be bound with the same binding key * correct log message and management stats update on route git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@693208 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index d0a1520c81..fc92a338a8 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -146,6 +146,36 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { BOOST_CHECK_EQUAL(m, m2.getData()); } +/** + * Ensure that multiple queues can be bound using the same routing key + */ +QPID_AUTO_TEST_CASE(testBindMultipleQueues) { + ClientSessionFixture f; + + f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); + f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true); + f.session.queueDeclare(arg::queue="red", arg::exclusive=true, arg::autoDelete=true); + + FieldTable blue; + blue.setString("xquery", "./colour = 'blue'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-colour", arg::arguments=blue); + FieldTable red; + red.setString("xquery", "./colour = 'red'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-colour", arg::arguments=red); + + Message sent1("blue", "by-colour"); + f.session.messageTransfer(arg::content=sent1, arg::destination="xml"); + + Message sent2("red", "by-colour"); + f.session.messageTransfer(arg::content=sent2, arg::destination="xml"); + + Message received; + BOOST_CHECK(f.subs.get(received, "blue")); + BOOST_CHECK_EQUAL(sent1.getData(), received.getData()); + BOOST_CHECK(f.subs.get(received, "red")); + BOOST_CHECK_EQUAL(sent2.getData(), received.getData()); +} + //### Test: Bad XML does not kill the server //### Test: Bad XQuery does not kill the server -- cgit v1.2.1 From 4dcb9f24c884a3ee559b60b6d48f070c9d2287e9 Mon Sep 17 00:00:00 2001 From: "Carl C. Trieloff" Date: Wed, 15 Oct 2008 17:05:31 +0000 Subject: QPID-1341 from Jonathan - Patch applied for Jonathan - Made the following changes - added PreRoute for route() for sequencing - changed xmlexchange form struct to class - added xml.so to verify script - removed two unsed files. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@704962 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 62 +++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index fc92a338a8..df515a6adb 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -20,6 +20,7 @@ */ #include "unit_test.h" #include "BrokerFixture.h" +#include "qpid/sys/Shlib.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" @@ -43,11 +44,13 @@ using namespace qpid::client; using namespace qpid::client::arg; using namespace qpid::framing; using namespace qpid; +using qpid::sys::Shlib; using qpid::sys::Monitor; using std::string; using std::cout; using std::endl; +Shlib shlib("../.libs/xml.so"); struct DummyListener : public sys::Runnable, public MessageListener { std::vector messages; @@ -118,6 +121,8 @@ struct ClientSessionFixture : public ProxySessionFixture // ########### START HERE #################################### + + QPID_AUTO_TEST_CASE(testXmlBinding) { ClientSessionFixture f; @@ -149,9 +154,10 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { /** * Ensure that multiple queues can be bound using the same routing key */ -QPID_AUTO_TEST_CASE(testBindMultipleQueues) { +QPID_AUTO_TEST_CASE(testXMLBindMultipleQueues) { ClientSessionFixture f; + f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true); f.session.queueDeclare(arg::queue="red", arg::exclusive=true, arg::autoDelete=true); @@ -176,9 +182,59 @@ QPID_AUTO_TEST_CASE(testBindMultipleQueues) { BOOST_CHECK_EQUAL(sent2.getData(), received.getData()); } -//### Test: Bad XML does not kill the server +//### Test: Bad XML does not kill the server - and does not even +// raise an exception, the content is not required to be XML. + +QPID_AUTO_TEST_CASE(testXMLSendBadXML) { + ClientSessionFixture f; + + f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); + f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true)\ + ; + f.session.queueDeclare(arg::queue="red", arg::exclusive=true, arg::autoDelete=true); + + FieldTable blue; + blue.setString("xquery", "./colour = 'blue'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-c\ +olour", arg::arguments=blue); + FieldTable red; + red.setString("xquery", "./colour = 'red'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-co\ +lour", arg::arguments=red); + + Message sent1("<>colour>blue", "by-colour"); + f.session.messageTransfer(arg::content=sent1, arg::destination="xml"); + + BOOST_CHECK_EQUAL(1, 1); +} + + +//### Test: Bad XQuery does not kill the server, but does raise an exception + +QPID_AUTO_TEST_CASE(testXMLBadXQuery) { + ClientSessionFixture f; + + f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); + f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true)\ + ; + + try { + FieldTable blue; + blue.setString("xquery", "./colour $=! 'blue'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-c\ +olour", arg::arguments=blue); + } + catch (const InternalErrorException& e) { + return; + } + BOOST_ERROR("A bad XQuery must raise an exception when used in an XML Binding."); + +} + + +//### Test: Each session can provide its own definition for a query name + -//### Test: Bad XQuery does not kill the server //### Test: Bindings persist, surviving broker restart -- cgit v1.2.1 From 3104d778e1352e9a3a142d8c133a115c847360c2 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Fri, 17 Oct 2008 16:13:13 +0000 Subject: Suppress logging expected errors in tests. Improved log messages for connection, session errors. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@705661 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 95 +++++++++++++++-------------- 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index df515a6adb..534ecf70f2 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -18,7 +18,9 @@ * under the License. * */ + #include "unit_test.h" +#include "test_tools.h" #include "BrokerFixture.h" #include "qpid/sys/Shlib.h" #include "qpid/sys/Monitor.h" @@ -124,31 +126,31 @@ struct ClientSessionFixture : public ProxySessionFixture QPID_AUTO_TEST_CASE(testXmlBinding) { - ClientSessionFixture f; + ClientSessionFixture f; - SubscriptionManager subscriptions(f.session); - SubscribedLocalQueue localQueue(subscriptions); + SubscriptionManager subscriptions(f.session); + SubscribedLocalQueue localQueue(subscriptions); - f.session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); - f.session.queueDeclare(qpid::client::arg::queue="odd_blue"); - subscriptions.subscribe(localQueue, "odd_blue"); + f.session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); + f.session.queueDeclare(qpid::client::arg::queue="odd_blue"); + subscriptions.subscribe(localQueue, "odd_blue"); - FieldTable binding; - binding.setString("xquery", "declare variable $color external;" - "(./message/id mod 2 = 1) and ($color = 'blue')"); - f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + FieldTable binding; + binding.setString("xquery", "declare variable $color external;" + "(./message/id mod 2 = 1) and ($color = 'blue')"); + f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); - Message message; - message.getDeliveryProperties().setRoutingKey("query_name"); + Message message; + message.getDeliveryProperties().setRoutingKey("query_name"); - message.getHeaders().setString("color", "blue"); - string m = "1"; - message.setData(m); + message.getHeaders().setString("color", "blue"); + string m = "1"; + message.setData(m); - f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); + f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); - Message m2 = localQueue.get(); - BOOST_CHECK_EQUAL(m, m2.getData()); + Message m2 = localQueue.get(); + BOOST_CHECK_EQUAL(m, m2.getData()); } /** @@ -186,48 +188,49 @@ QPID_AUTO_TEST_CASE(testXMLBindMultipleQueues) { // raise an exception, the content is not required to be XML. QPID_AUTO_TEST_CASE(testXMLSendBadXML) { - ClientSessionFixture f; + ClientSessionFixture f; - f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); - f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true)\ - ; - f.session.queueDeclare(arg::queue="red", arg::exclusive=true, arg::autoDelete=true); + f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); + f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true)\ + ; + f.session.queueDeclare(arg::queue="red", arg::exclusive=true, arg::autoDelete=true); - FieldTable blue; - blue.setString("xquery", "./colour = 'blue'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-c\ + FieldTable blue; + blue.setString("xquery", "./colour = 'blue'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-c\ olour", arg::arguments=blue); - FieldTable red; - red.setString("xquery", "./colour = 'red'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-co\ + FieldTable red; + red.setString("xquery", "./colour = 'red'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-co\ lour", arg::arguments=red); - Message sent1("<>colour>blue", "by-colour"); - f.session.messageTransfer(arg::content=sent1, arg::destination="xml"); + Message sent1("<>colour>blue", "by-colour"); + f.session.messageTransfer(arg::content=sent1, arg::destination="xml"); - BOOST_CHECK_EQUAL(1, 1); + BOOST_CHECK_EQUAL(1, 1); } //### Test: Bad XQuery does not kill the server, but does raise an exception QPID_AUTO_TEST_CASE(testXMLBadXQuery) { - ClientSessionFixture f; - - f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); - f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true)\ - ; + ClientSessionFixture f; - try { - FieldTable blue; - blue.setString("xquery", "./colour $=! 'blue'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-c\ + f.session.exchangeDeclare(arg::exchange="xml", arg::type="xml"); + f.session.queueDeclare(arg::queue="blue", arg::exclusive=true, arg::autoDelete=true)\ + ; + + try { + ScopedSuppressLogging sl; // Supress logging of error messages for expected error. + FieldTable blue; + blue.setString("xquery", "./colour $=! 'blue'"); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-c\ olour", arg::arguments=blue); - } - catch (const InternalErrorException& e) { - return; - } - BOOST_ERROR("A bad XQuery must raise an exception when used in an XML Binding."); + } + catch (const InternalErrorException& e) { + return; + } + BOOST_ERROR("A bad XQuery must raise an exception when used in an XML Binding."); } -- 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/XmlClientSessionTest.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 534ecf70f2..98558f0a76 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -29,7 +29,7 @@ #include "qpid/framing/TransferContent.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/client/Connection.h" -#include "qpid/client/Dispatcher.h" +#include "qpid/client/SubscriptionManager.h" #include "qpid/client/LocalQueue.h" #include "qpid/client/Session.h" #include "qpid/client/SubscriptionManager.h" @@ -54,30 +54,6 @@ using std::endl; Shlib shlib("../.libs/xml.so"); -struct DummyListener : public sys::Runnable, public MessageListener { - std::vector messages; - string name; - uint expected; - Dispatcher dispatcher; - - DummyListener(Session& session, const string& n, uint ex) : - name(n), expected(ex), dispatcher(session) {} - - void run() - { - dispatcher.listen(name, this); - dispatcher.run(); - } - - void received(Message& msg) - { - messages.push_back(msg); - if (--expected == 0) - dispatcher.stop(); - } -}; - - class SubscribedLocalQueue : public LocalQueue { private: SubscriptionManager& subscriptions; -- 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/XmlClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 98558f0a76..aeb13c292f 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -26,7 +26,7 @@ #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" -#include "qpid/framing/TransferContent.h" +#include "qpid/client/Message.h" #include "qpid/framing/reply_exceptions.h" #include "qpid/client/Connection.h" #include "qpid/client/SubscriptionManager.h" -- cgit v1.2.1 From a05dff2847b981cda1f584398f46cbc790afec4f Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 14 May 2009 15:19:56 +0000 Subject: More work on cmake: Make tests build on Linux Fix XML tests to run Fix cmake installed locations for modules/config files git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@774814 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index aeb13c292f..b6b8520bd8 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -52,7 +52,11 @@ using std::string; using std::cout; using std::endl; -Shlib shlib("../.libs/xml.so"); +#if defined (QPID_MODULE_SUFFIX) + Shlib shlib("../xml" QPID_MODULE_SUFFIX); +#else + Shlib shlib("../.libs/xml.so"); +#endif class SubscribedLocalQueue : public LocalQueue { private: -- 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/XmlClientSessionTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index b6b8520bd8..368b539f23 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -19,9 +19,9 @@ * */ -#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/sys/Shlib.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.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/XmlClientSessionTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 368b539f23..b6b8520bd8 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -19,9 +19,9 @@ * */ -#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/sys/Shlib.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Thread.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/XmlClientSessionTest.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index b6b8520bd8..8d6e29f6e0 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.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 @@ -52,6 +52,9 @@ using std::string; using std::cout; using std::endl; +namespace qpid { +namespace tests { + #if defined (QPID_MODULE_SUFFIX) Shlib shlib("../xml" QPID_MODULE_SUFFIX); #else @@ -118,10 +121,10 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { FieldTable binding; binding.setString("xquery", "declare variable $color external;" "(./message/id mod 2 = 1) and ($color = 'blue')"); - f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); Message message; - message.getDeliveryProperties().setRoutingKey("query_name"); + message.getDeliveryProperties().setRoutingKey("query_name"); message.getHeaders().setString("color", "blue"); string m = "1"; @@ -130,7 +133,7 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); Message m2 = localQueue.get(); - BOOST_CHECK_EQUAL(m, m2.getData()); + BOOST_CHECK_EQUAL(m, m2.getData()); } /** @@ -146,10 +149,10 @@ QPID_AUTO_TEST_CASE(testXMLBindMultipleQueues) { FieldTable blue; blue.setString("xquery", "./colour = 'blue'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-colour", arg::arguments=blue); + f.session.exchangeBind(arg::exchange="xml", arg::queue="blue", arg::bindingKey="by-colour", arg::arguments=blue); FieldTable red; red.setString("xquery", "./colour = 'red'"); - f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-colour", arg::arguments=red); + f.session.exchangeBind(arg::exchange="xml", arg::queue="red", arg::bindingKey="by-colour", arg::arguments=red); Message sent1("blue", "by-colour"); f.session.messageTransfer(arg::content=sent1, arg::destination="xml"); @@ -223,3 +226,4 @@ olour", arg::arguments=blue); QPID_AUTO_TEST_SUITE_END() +}} // namespace qpid::tests -- cgit v1.2.1 From 296bef932c2685da2c6258776ada08f99f726ad0 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Wed, 9 Sep 2009 21:17:25 +0000 Subject: Fixed wrong namespace placement in previous check in git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@813123 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 8d6e29f6e0..46a4c826a3 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -39,6 +39,9 @@ #include +namespace qpid { +namespace tests { + QPID_AUTO_TEST_SUITE(XmlClientSessionTest) using namespace qpid::client; @@ -52,9 +55,6 @@ using std::string; using std::cout; using std::endl; -namespace qpid { -namespace tests { - #if defined (QPID_MODULE_SUFFIX) Shlib shlib("../xml" QPID_MODULE_SUFFIX); #else -- cgit v1.2.1 From 6bb0134ca322b6e50e6ec76a242f89259cd12274 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 30 Nov 2009 19:34:36 +0000 Subject: Clean up test environment variables, prepare for running more tests in cmake. - consolidate test env vars in test_env.sh, also useful from command line. - generate test_env.sh with autoconf/cmake to cover library location differences. - Remove explicit mention of .libs, use $QPID_MODULE_DIR to load modules. - Fix run_test to run valgrind under cmake git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@885557 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 46a4c826a3..b59abbf2cc 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -55,11 +55,8 @@ using std::string; using std::cout; using std::endl; -#if defined (QPID_MODULE_SUFFIX) - Shlib shlib("../xml" QPID_MODULE_SUFFIX); -#else - Shlib shlib("../.libs/xml.so"); -#endif + +Shlib shlib(getLibPath("XML_LIB")); class SubscribedLocalQueue : public LocalQueue { private: -- cgit v1.2.1 From a48812f5cd045775a70d9e3ccf2b0bd04b43f103 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Mon, 18 Jan 2010 18:07:04 +0000 Subject: Commiting John Dunning's revisions to the XML client session test. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@900488 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index b59abbf2cc..d64c5e47f0 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -64,6 +64,7 @@ class SubscribedLocalQueue : public LocalQueue { public: SubscribedLocalQueue(SubscriptionManager& subs) : subscriptions(subs) {} Message get () { return pop(); } + Message get (sys::Duration timeout) { return pop(timeout); } virtual ~SubscribedLocalQueue() {} }; @@ -129,7 +130,7 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); - Message m2 = localQueue.get(); + Message m2 = localQueue.get(1); BOOST_CHECK_EQUAL(m, m2.getData()); } -- cgit v1.2.1 From 29745628ade582e3ae244f2cbf1c58b92b163755 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 19 Jan 2010 08:29:24 +0000 Subject: QPID-2335: Set the timeout used when waiting for a message to be 1 second which I assume was the original intention. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@900697 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index d64c5e47f0..95a40bb777 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -130,7 +130,7 @@ QPID_AUTO_TEST_CASE(testXmlBinding) { f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); - Message m2 = localQueue.get(1); + Message m2 = localQueue.get(1*qpid::sys::TIME_SEC); BOOST_CHECK_EQUAL(m, m2.getData()); } -- cgit v1.2.1 From a997c67454feae8a213c884caf62573cde6ebf4e Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Fri, 26 Nov 2010 17:42:53 +0000 Subject: Binds integer, floating point, or string-typed headers using appropriate datatypes. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1039478 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/XmlClientSessionTest.cpp | 74 ++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/tests/XmlClientSessionTest.cpp') diff --git a/qpid/cpp/src/tests/XmlClientSessionTest.cpp b/qpid/cpp/src/tests/XmlClientSessionTest.cpp index 95a40bb777..b3b7f12b53 100644 --- a/qpid/cpp/src/tests/XmlClientSessionTest.cpp +++ b/qpid/cpp/src/tests/XmlClientSessionTest.cpp @@ -104,8 +104,6 @@ struct ClientSessionFixture : public ProxySessionFixture // ########### START HERE #################################### - - QPID_AUTO_TEST_CASE(testXmlBinding) { ClientSessionFixture f; @@ -216,6 +214,78 @@ olour", arg::arguments=blue); } +//### Test: double, string, and integer field values can all be bound to queries + +QPID_AUTO_TEST_CASE(testXmlBindingUntyped) { + ClientSessionFixture f; + + SubscriptionManager subscriptions(f.session); + SubscribedLocalQueue localQueue(subscriptions); + + f.session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); + f.session.queueDeclare(qpid::client::arg::queue="odd_blue"); + subscriptions.subscribe(localQueue, "odd_blue"); + + FieldTable binding; + binding.setString("xquery", + "declare variable $s external;" + "declare variable $i external;" + "declare variable $d external;" + "$s = 'string' and $i = 1 and $d < 1"); + f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + + Message message; + message.getDeliveryProperties().setRoutingKey("query_name"); + + message.getHeaders().setString("s", "string"); + message.getHeaders().setInt("i", 1); + message.getHeaders().setDouble("d", 0.5); + string m = "Hi, Mom!"; + message.setData(m); + + f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); + + Message m2 = localQueue.get(1*qpid::sys::TIME_SEC); + BOOST_CHECK_EQUAL(m, m2.getData()); +} + + +//### Test: double, string, and integer field values can all be bound to queries + +QPID_AUTO_TEST_CASE(testXmlBindingTyped) { + ClientSessionFixture f; + + SubscriptionManager subscriptions(f.session); + SubscribedLocalQueue localQueue(subscriptions); + + f.session.exchangeDeclare(qpid::client::arg::exchange="xml", qpid::client::arg::type="xml"); + f.session.queueDeclare(qpid::client::arg::queue="odd_blue"); + subscriptions.subscribe(localQueue, "odd_blue"); + + FieldTable binding; + binding.setString("xquery", + "declare variable $s as xs:string external;" + "declare variable $i as xs:integer external;" + "declare variable $d external;" // XQilla bug when declaring xs:float, xs:double types? Fine if untyped, acts as float. + "$s = 'string' and $i = 1 and $d < 1"); + f.session.exchangeBind(qpid::client::arg::exchange="xml", qpid::client::arg::queue="odd_blue", qpid::client::arg::bindingKey="query_name", qpid::client::arg::arguments=binding); + + Message message; + message.getDeliveryProperties().setRoutingKey("query_name"); + + message.getHeaders().setString("s", "string"); + message.getHeaders().setInt("i", 1); + message.getHeaders().setDouble("d", 0.5); + string m = "Hi, Mom!"; + message.setData(m); + + f.session.messageTransfer(qpid::client::arg::content=message, qpid::client::arg::destination="xml"); + + Message m2 = localQueue.get(1*qpid::sys::TIME_SEC); + BOOST_CHECK_EQUAL(m, m2.getData()); +} + + //### Test: Each session can provide its own definition for a query name -- cgit v1.2.1