summaryrefslogtreecommitdiff
path: root/cpp/src
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
commit4d6c362d7b026dc894c11772b9ffe5f538c27923 (patch)
tree0ff61ea3f0e82d05a6d9e75488e84f243e280ccb /cpp/src
parent02bbab932f5f845bfa8eac6069bc4159bbe53d07 (diff)
downloadqpid-python-4d6c362d7b026dc894c11772b9ffe5f538c27923.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/qpid@1226931 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/messaging/AddressParser.cpp15
-rw-r--r--cpp/src/tests/MessagingSessionTests.cpp21
2 files changed, 29 insertions, 7 deletions
diff --git a/cpp/src/qpid/messaging/AddressParser.cpp b/cpp/src/qpid/messaging/AddressParser.cpp
index d76210ee5d..67249e188e 100644
--- a/cpp/src/qpid/messaging/AddressParser.cpp
+++ b/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/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp
index 9d5db84bb4..313e8b3132 100644
--- a/cpp/src/tests/MessagingSessionTests.cpp
+++ b/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