summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2012-01-03 19:50:37 +0000
committerGordon Sim <gsim@apache.org>2012-01-03 19:50:37 +0000
commit632098a71beded1a01ce7e1677ec87c3dd79f4ef (patch)
tree76625802c90f804ae89036a8031ce41ae13d9a07 /qpid/cpp
parent7d49f72405d84c64023f40a1981393cb1c490da7 (diff)
downloadqpid-python-632098a71beded1a01ce7e1677ec87c3dd79f4ef.tar.gz
QPID-3492: Fix quoted values as well as unquoted values; added a test case
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1226931 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/messaging/AddressParser.cpp15
-rw-r--r--qpid/cpp/src/tests/MessagingSessionTests.cpp21
2 files changed, 29 insertions, 7 deletions
diff --git a/qpid/cpp/src/qpid/messaging/AddressParser.cpp b/qpid/cpp/src/qpid/messaging/AddressParser.cpp
index d76210ee5d..67249e188e 100644
--- a/qpid/cpp/src/qpid/messaging/AddressParser.cpp
+++ b/qpid/cpp/src/qpid/messaging/AddressParser.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
@@ -191,13 +191,14 @@ bool AddressParser::readQuotedValue(Variant& value)
std::string s;
if (readQuotedString(s)) {
value = s;
+ value.setEncoding("utf8");
return true;
} else {
return false;
}
}
-
-bool AddressParser::readSimpleValue(Variant& value)
+
+bool AddressParser::readSimpleValue(Variant& value)
{
std::string s;
if (readWord(s)) {
@@ -217,7 +218,7 @@ bool AddressParser::readWord(std::string& value, const std::string& delims)
//read any number of non-whitespace, non-reserved chars into value
std::string::size_type start = current;
while (!eos() && !iswhitespace() && !in(delims)) ++current;
-
+
if (current > start) {
value = input.substr(start, current - start);
return true;
@@ -229,8 +230,8 @@ bool AddressParser::readWord(std::string& value, const std::string& delims)
bool AddressParser::readChar(char c)
{
while (!eos()) {
- if (iswhitespace()) {
- ++current;
+ if (iswhitespace()) {
+ ++current;
} else if (input.at(current) == c) {
++current;
return true;
diff --git a/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp
index 9d5db84bb4..313e8b3132 100644
--- a/qpid/cpp/src/tests/MessagingSessionTests.cpp
+++ b/qpid/cpp/src/tests/MessagingSessionTests.cpp
@@ -1118,6 +1118,27 @@ QPID_AUTO_TEST_CASE(testUnsubscribeOnClose)
fix.session.acknowledge();
}
+QPID_AUTO_TEST_CASE(testHeadersExchange)
+{
+ MessagingFixture fix;
+ //use both quoted and unquoted values
+ Receiver receiver = fix.session.createReceiver("amq.match; {link:{x-bindings:[{arguments:{x-match:all,qpid.subject:'abc',my-property:abc}}]}}");
+ Sender sender = fix.session.createSender("amq.match");
+ Message out("test-message");
+ out.setSubject("abc");
+ Variant& property = out.getProperties()["my-property"];
+ property = "abc";
+ property.setEncoding("utf8");
+ sender.send(out, true);
+ Message in;
+ if (receiver.fetch(in, Duration::SECOND)) {
+ fix.session.acknowledge();
+ BOOST_CHECK_EQUAL(in.getContent(), out.getContent());
+ } else {
+ BOOST_FAIL("Message did not match as expected!");
+ }
+}
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests