summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-06-15 21:27:22 +0000
committerAlan Conway <aconway@apache.org>2007-06-15 21:27:22 +0000
commitdcb9a4336fb53925e9ae0e48aae5d44ac967f69e (patch)
tree3bf5ba0d52a03c53fdb0e2985e7b23486641f148 /qpid/cpp/src/tests
parentb912b22ade11cba27111bf42427f57d2c74a61e2 (diff)
downloadqpid-python-dcb9a4336fb53925e9ae0e48aae5d44ac967f69e.tar.gz
Parser for AMQP-95 URLs
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@547789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests')
-rw-r--r--qpid/cpp/src/tests/Makefile.am4
-rw-r--r--qpid/cpp/src/tests/unit/Url.cpp55
2 files changed, 59 insertions, 0 deletions
diff --git a/qpid/cpp/src/tests/Makefile.am b/qpid/cpp/src/tests/Makefile.am
index cd14bd57ab..76d675ee12 100644
--- a/qpid/cpp/src/tests/Makefile.am
+++ b/qpid/cpp/src/tests/Makefile.am
@@ -10,6 +10,10 @@ UNIT_TESTS+=logging
logging_SOURCES=unit/logging.cpp unit/test_tools.h
logging_LDADD=-lboost_unit_test_framework -lboost_regex $(lib_common)
+UNIT_TESTS+=Url
+Url_SOURCES=unit/Url.cpp unit/test_tools.h
+Url_LDADD=-lboost_unit_test_framework $(lib_common)
+
if CLUSTER
include cluster.mk
endif
diff --git a/qpid/cpp/src/tests/unit/Url.cpp b/qpid/cpp/src/tests/unit/Url.cpp
new file mode 100644
index 0000000000..a8b415e641
--- /dev/null
+++ b/qpid/cpp/src/tests/unit/Url.cpp
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+#define BOOST_AUTO_TEST_MAIN // Must come before #include<boost/test/*>
+#include "test_tools.h"
+#include "qpid/Url.h"
+#include <boost/assign.hpp>
+
+using namespace std;
+using namespace qpid;
+using namespace boost::assign;
+
+BOOST_AUTO_TEST_CASE(testUrl_str) {
+ Url url;
+ url.push_back(TcpAddress("foo.com"));
+ url.push_back(TcpAddress("bar.com", 6789));
+
+ BOOST_CHECK_EQUAL(
+ url.str(), "amqp:tcp:foo.com:5672,tcp:bar.com:6789");
+ BOOST_CHECK_EQUAL(Url().str(), "amqp:");
+}
+
+
+BOOST_AUTO_TEST_CASE(testUrl_ctor) {
+ BOOST_CHECK_EQUAL(
+ Url("amqp:foo.com,tcp:bar.com:1234").str(),
+ "amqp:tcp:foo.com:5672,tcp:bar.com:1234");
+ BOOST_CHECK_EQUAL(
+ Url("amqp:foo/ignorethis").str(),
+ "amqp:tcp:foo:5672");
+ BOOST_CHECK_EQUAL("amqp:tcp::5672", Url("amqp:").str());
+ BOOST_CHECK_EQUAL(0u, Url("xxx", nothrow).size());
+ try {
+ Url invalid("xxx");
+ BOOST_FAIL("Expected InvalidUrl exception");
+ }
+ catch (const Url::InvalidUrl&) {}
+}
+
+