diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2008-10-15 17:05:31 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2008-10-15 17:05:31 +0000 |
commit | ca2c15b9121db502807221936bc146a4b5520234 (patch) | |
tree | aa1be37782166521f8a772f18d2047927506aaa5 /cpp/src/tests/XmlClientSessionTest.cpp | |
parent | 207dbcb73d225bdd21e797706a6ea2f235790f98 (diff) | |
download | qpid-python-ca2c15b9121db502807221936bc146a4b5520234.tar.gz |
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/qpid@704962 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/XmlClientSessionTest.cpp')
-rw-r--r-- | cpp/src/tests/XmlClientSessionTest.cpp | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/cpp/src/tests/XmlClientSessionTest.cpp b/cpp/src/tests/XmlClientSessionTest.cpp index fc92a338a8..df515a6adb 100644 --- a/cpp/src/tests/XmlClientSessionTest.cpp +++ b/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<Message> 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</colour>", "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 |