You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/11/07 19:26:44 UTC
[02/10] qpid-proton git commit: PROTON-1064: [ruby] extend standard
ruby URI with amqp/amqps schemes
PROTON-1064: [ruby] extend standard ruby URI with amqp/amqps schemes
Simple URI.Generic schemes with the correct default ports, plus
a helper function amqp_uri() to default a URI with no scheme to AMQP.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8155c5af
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8155c5af
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8155c5af
Branch: refs/heads/master
Commit: 8155c5af3c6f63a585354034089a72d7dac13895
Parents: 9bb1baa
Author: Alan Conway <ac...@redhat.com>
Authored: Sat Oct 28 17:24:35 2017 +0100
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Nov 7 13:31:51 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/util/uri.rb | 27 ++++++++++++++++++
proton-c/bindings/ruby/tests/test_uri.rb | 40 +++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8155c5af/proton-c/bindings/ruby/lib/util/uri.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/uri.rb b/proton-c/bindings/ruby/lib/util/uri.rb
new file mode 100644
index 0000000..0820746
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/uri.rb
@@ -0,0 +1,27 @@
+#--
+# Licensed to the Apache 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.
+#++
+
+require 'uri'
+
+module URI
+ class AMQP < Generic; DEFAULT_PORT = 5672; end
+ @@schemes['AMQP'] = AMQP
+ class AMQPS < Generic; DEFAULT_PORT = 5671; end
+ @@schemes['AMQPS'] = AMQPS
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8155c5af/proton-c/bindings/ruby/tests/test_uri.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_uri.rb b/proton-c/bindings/ruby/tests/test_uri.rb
new file mode 100644
index 0000000..e5279d8
--- /dev/null
+++ b/proton-c/bindings/ruby/tests/test_uri.rb
@@ -0,0 +1,40 @@
+#--
+# Licensed to the Apache 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.
+#++
+
+require 'minitest/autorun'
+require 'qpid_proton'
+
+class TestURI < Minitest::Test
+
+ def amqp_uri(u) Qpid::Proton::amqp_uri(u); end
+
+ def test_amqp_uri
+ assert_equal URI("amqp:").port, 5672
+ assert_equal URI("amqps:").port, 5671
+ assert_equal URI("amqp://user:pass@host:1234/path"), amqp_uri("//user:pass@host:1234/path")
+ assert_equal URI("amqp://user:pass@host:1234/path"), amqp_uri("amqp://user:pass@host:1234/path")
+ assert_equal URI("amqps://user:pass@host:1234/path"), amqp_uri("amqps://user:pass@host:1234/path")
+ assert_equal URI("amqp://host:1234/path"), amqp_uri("//host:1234/path")
+ assert_equal URI("amqp://host:1234"), amqp_uri("//host:1234")
+ assert_equal URI("amqp://host"), amqp_uri("//host")
+ assert_equal URI("amqp://:1234"), amqp_uri("//:1234")
+ assert_raises(URI::BadURIError) { amqp_uri("http://foo") }
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org