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/12/15 22:01:45 UTC
[1/2] qpid-proton git commit: PROTON-1721 [ruby] resovler errors are
not handled correctly [Forced Update!]
Repository: qpid-proton
Updated Branches:
refs/heads/ruby-api 3c6537606 -> 091676959 (forced update)
PROTON-1721 [ruby] resovler errors are not handled correctly
Catch exceptions raised by TCPServer.new/TCPSocket.new and convert into error events.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c4d5fde7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c4d5fde7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c4d5fde7
Branch: refs/heads/ruby-api
Commit: c4d5fde71d925f3f44b0e29d672de7b039ee709f
Parents: f252b2f
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 15 11:34:44 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 16:59:23 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/container.rb | 26 +++++++++++++++++++--
proton-c/bindings/ruby/tests/test_container.rb | 14 +++++++++--
2 files changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c4d5fde7/proton-c/bindings/ruby/lib/core/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/container.rb b/proton-c/bindings/ruby/lib/core/container.rb
index 242356f..5dc9d60 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -41,6 +41,18 @@ module Qpid::Proton
end
end
+ # Used as the @io when a socket cannot be created due to an erro (e.g resolver fails)
+ # Saves the error and raises it in on_readable so it can be reported via normal channels.
+ class BrokenSocket
+ def initialize(msg) @error = IOError.new(msg); end
+ [:read_nonblock, :write_nonblock, :accept].each do |m|
+ define_method(m) { |*args| raise @error }
+ end
+ [:close_read, :close_write, :close].each do |m|
+ define_method(m) {}
+ end
+ end
+
class ListenTask < Listener
def initialize(io, handler, container)
@@ -177,7 +189,12 @@ module Qpid::Proton
opts[:password] ||= url.password
end
# TODO aconway 2017-10-26: Use SSL for amqps URLs
- connect_io(TCPSocket.new(url.host, url.port), opts)
+ socket = begin
+ TCPSocket.new(url.host, url.port)
+ rescue => e
+ BrokenSocket.new("connect(#{url}): #{e}")
+ end
+ connect_io(socket, opts)
end
# Open an AMQP protocol connection on an existing {IO} object
@@ -202,7 +219,12 @@ module Qpid::Proton
not_stopped
url = Qpid::Proton::uri url
# TODO aconway 2017-11-01: amqps, SSL
- listen_io(TCPServer.new(url.host, url.port), handler)
+ server = begin
+ TCPServer.new(url.host, url.port)
+ rescue => e
+ BrokenSocket.new("listen(#{url}): #{e}")
+ end
+ listen_io(server, handler)
end
# Listen for incoming AMQP connections on an existing server socket.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c4d5fde7/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index 044ebf4..d8bd52c 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -149,6 +149,16 @@ class ContainerTest < Minitest::Test
assert_nil l.condition
assert_nil conn.condition
end
+
+ def test_bad_host
+ cont = Container.new(__method__)
+ l = cont.listen("badlisten.example.com:999")
+ c = cont.connect("badconnect.example.com:999")
+ cont.run
+ assert_match(/badlisten.example.com:999/, l.condition.description)
+ assert_match(/badconnect.example.com:999/, c.transport.condition.description)
+ end
+
end
@@ -201,8 +211,8 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
")
end
# Tell proton library to use the new configuration
- SASL.config_path(conf_dir)
- SASL.config_name(conf_name)
+ SASL.config_path = conf_dir
+ SASL.config_name = conf_name
end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-proton git commit: WIP: [ruby] Add missing connection
options, update Connection API.
Posted by ac...@apache.org.
WIP: [ruby] Add missing connection options, update Connection API.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/09167695
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/09167695
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/09167695
Branch: refs/heads/ruby-api
Commit: 091676959afe21f185066593c6c5f6f97e337adf
Parents: c4d5fde
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Dec 15 16:53:30 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Dec 15 16:59:48 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/connection.rb | 121 +++++++++++--------
.../bindings/ruby/lib/core/connection_driver.rb | 1 -
proton-c/bindings/ruby/lib/core/container.rb | 3 +-
proton-c/bindings/ruby/lib/core/message.rb | 6 +-
proton-c/bindings/ruby/lib/core/transport.rb | 54 ++-------
proton-c/bindings/ruby/lib/reactor/container.rb | 3 +
proton-c/bindings/ruby/lib/types/array.rb | 6 +-
proton-c/bindings/ruby/lib/types/hash.rb | 13 +-
proton-c/bindings/ruby/lib/util/deprecation.rb | 7 +-
proton-c/bindings/ruby/tests/test_container.rb | 63 +++++++++-
10 files changed, 169 insertions(+), 108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/core/connection.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb
index b9b5746..f5fcc09 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -20,32 +20,17 @@ module Qpid::Proton
# An AMQP connection.
class Connection < Endpoint
- include Util::Deprecation
-
- # @private
PROTON_METHOD_PREFIX = "pn_connection"
- # @private
include Util::Wrapper
+ include Util::Deprecation
- # @!attribute hostname
- # @return [String] The AMQP hostname for the connection.
- proton_set_get :hostname
-
- # @!attribute user
- # @return [String] User name used for authentication (outgoing connection) or the authenticated user name (incoming connection)
- proton_set_get :user
-
- private
-
- proton_set :password
- attr_accessor :overrides
- attr_accessor :session_policy
-
+ # @private
def self.wrap(impl)
return nil if impl.nil?
self.fetch_instance(impl, :pn_connection_attachments) || Connection.new(impl)
end
+ # @private
def initialize(impl = Cproton.pn_connection)
super()
@impl = impl
@@ -56,7 +41,19 @@ module Qpid::Proton
self.class.store_instance(self, :pn_connection_attachments)
end
- public
+ # @return [String] The AMQP hostname for the connection.
+ def virtual_host() Cproton.pn_connection_remote_hostname(@impl); end
+ deprecated_alias :remote_hostname, :virtual_host
+
+ # @!attribute hostname
+ # @deprecated use {#virtual_host}
+ proton_set_get :hostname
+
+ # @return [String] User name used for authentication (outgoing connection)
+ # or the authenticated user name (incoming connection)
+ def user()
+ Cproton.pn_connection_get_user(impl) or (connection.transport && connection.transport.user)
+ end
# @deprecated no replacement
def overrides?() deprecated __method__; false; end
@@ -68,49 +65,54 @@ module Qpid::Proton
def connection() self; end
# @return [Transport, nil] transport bound to this connection, or nil if unbound.
- #
def transport() Transport.wrap(Cproton.pn_connection_transport(@impl)); end
- # @return AMQP container ID advertised by the remote peer
- def remote_container_id() Cproton.pn_connection_remote_container(@impl); end
-
- alias remote_container remote_container_id
+ # @return AMQP container ID advertised by the remote peer.
+ # To get the local container ID use {#container} and {Container#id}
+ def container_id() Cproton.pn_connection_remote_container(@impl); end
+ deprecated_alias :remote_container, :container_id
# @return [Container] the container managing this connection
attr_reader :container
- # @return AMQP container ID for the local end of the connection
- def container_id() Cproton.pn_connection_get_container(@impl); end
-
- # @return [String] hostname used by the remote end of the connection
- def remote_hostname() Cproton.pn_connection_remote_hostname(@impl); end
-
# @return [Array<Symbol>] offered capabilities provided by the remote peer
- def remote_offered_capabilities
+ def offered_capabilities
Codec::Data.to_object(Cproton.pn_connection_remote_offered_capabilities(@impl))
end
+ deprecated_alias :remote_offered_capabilities, :desired_offered_capabilities
# @return [Array<Symbol>] desired capabilities provided by the remote peer
- def remote_desired_capabilities
+ def desired_capabilities
Codec::Data.to_object(Cproton.pn_connection_remote_desired_capabilities(@impl))
end
+ deprecated_alias :remote_desired_capabilities, :desired_capabilities
# @return [Hash] connection-properties provided by the remote peer
- def remote_properties
- Codec::Data.to_object(Cproton.pn_connection_remote_properites(@impl))
+ def properties
+ Codec::Data.to_object(Cproton.pn_connection_remote_properties(@impl))
end
+ deprecated_alias :remote_properties, :properties
# Open the local end of the connection.
#
# @option opts [MessagingHandler] :handler handler for events related to this connection.
- # @option opts [String] :user user-name for authentication.
- # @option opts [String] :password password for authentication.
- # @option opts [Numeric] :idle_timeout seconds before closing an idle connection
- # @option opts [Boolean] :sasl_enabled Enable or disable SASL.
- # @option opts [Boolean] :sasl_allow_insecure_mechs Allow mechanisms that disclose clear text
- # passwords, even over an insecure connection.
- # @option opts [String] :sasl_allowed_mechs the allowed SASL mechanisms for use on the connection.
- # @option opts [String] :container_id AMQP container ID, normally provided by {Container}
+ #
+ # @option opts [String] :user User name for authentication
+ # @option opts [String] :password Authentication secret
+ # @option opts [String] :virtual_host Virtual host name
+ # @option opts [String] :container_id (provided by {Container}) override advertised container-id
+ #
+ # @option opts [Hash<Symbol=>Object>] :properties Application-defined properties
+ # @option opts [Array<Symbol>] :offered_capabilities Extensions the endpoint supports
+ # @option opts [Array<Symbol>] :desired_capabilities Extensions the endpoint can use
+ #
+ # @option opts [Numeric] :idle_timeout Seconds before closing an idle connection
+ # @option opts [Integer] :max_sessions Limit the number of active sessions
+ # @option opts [Integer] :max_frame_size Limit the size of AMQP frames
+ #
+ # @option opts [Boolean] :sasl_enabled (false) Enable or disable SASL.
+ # @option opts [Boolean] :sasl_allow_insecure_mechs (false) Allow mechanisms send secrets in clear text
+ # @option opts [String] :sasl_allowed_mechs SASL mechanisms allowed by this end of the connection
#
def open(opts=nil)
return if local_active?
@@ -129,23 +131,44 @@ module Qpid::Proton
Cproton.pn_connection_set_container(@impl, cid)
Cproton.pn_connection_set_user(@impl, opts[:user]) if opts[:user]
Cproton.pn_connection_set_password(@impl, opts[:password]) if opts[:password]
- @link_prefix = opts[:link_prefix] || container_id
- Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl), opts[:offered_capabilities])
- Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl), opts[:desired_capabilities])
- Codec::Data.from_object(Cproton.pn_connection_properties(@impl), opts[:properties])
+ Cproton.pn_connection_set_hostname(@impl, opts[:virtual_host]) if opts[:virtual_host]
+ @link_prefix = opts[:link_prefix] || cid
+ Codec::Data.from_object(Cproton.pn_connection_offered_capabilities(@impl),
+ Types.symbol_array(opts[:offered_capabilities]))
+ Codec::Data.from_object(Cproton.pn_connection_desired_capabilities(@impl),
+ Types.symbol_array(opts[:desired_capabilities]))
+ Codec::Data.from_object(Cproton.pn_connection_properties(@impl),
+ Types.symbol_keys(opts[:properties]))
end
# Idle-timeout advertised by the remote peer, in seconds.
- # Set by {Connection#open} with the +:idle_timeout+ option.
# @return [Numeric] Idle-timeout advertised by the remote peer, in seconds.
- # @return [nil] if The peer does not advertise an idle time-out
- # @option :idle_timeout (see {#open})
+ # @return [nil] if the peer does not advertise an idle time-out
def idle_timeout()
if transport && (t = transport.remote_idle_timeout)
Rational(t, 1000) # More precise than Float
end
end
+ # Session limit advertised by the remote peer. See {Connection#open :max_sessions}
+ # @return [Integer] maximum number of sessions per connection allowed by remote peer.
+ # @return [nil] no specific limit is set.
+ def max_sessions()
+ raise StateError, "connection not bound to transport" unless transport
+ max = transport.remote_channel_max
+ return max.zero? ? nil : max
+ end
+
+ # Maximum frame size, in bytes, advertised by the remote peer.
+ # See {Connection#open :max_frame_size}
+ # @return [Integer] maximum frame size
+ # @return [nil] no limit
+ def max_frame_size()
+ raise StateError, "connection not bound to transport" unless transport
+ max = transport.remote_max_frame
+ return max.zero? ? nil : max
+ end
+
# Closes the local end of the connection. The remote end may or may not be closed.
# @param error [Condition] Optional error condition to send with the close.
def close(error=nil)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/core/connection_driver.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection_driver.rb b/proton-c/bindings/ruby/lib/core/connection_driver.rb
index 2ce132e..12dcb68 100644
--- a/proton-c/bindings/ruby/lib/core/connection_driver.rb
+++ b/proton-c/bindings/ruby/lib/core/connection_driver.rb
@@ -181,7 +181,6 @@ module Qpid::Proton
case e.method # Events that affect the driver
when :on_transport_tail_closed then close_read
when :on_transport_head_closed then close_write
- when :on_transport_authenticated then connection.user = transport.user
end
e.dispatch @adapter
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/core/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/container.rb b/proton-c/bindings/ruby/lib/core/container.rb
index 5dc9d60..9d9463e 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -125,7 +125,8 @@ module Qpid::Proton
@handler = args[0] unless @id
else raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..2"
end
- @adapter = Handler::Adapter.adapt(@handler)
+ # Use an empty messaging adapter to give default behaviour if there's no global handler.
+ @adapter = Handler::Adapter.adapt(@handler) || Handler::MessagingAdapter.new(nil)
@id = (@id || SecureRandom.uuid).freeze
# Implementation note:
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/core/message.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/message.rb b/proton-c/bindings/ruby/lib/core/message.rb
index 8b13de2..9afaa0a 100644
--- a/proton-c/bindings/ruby/lib/core/message.rb
+++ b/proton-c/bindings/ruby/lib/core/message.rb
@@ -73,8 +73,10 @@ module Qpid::Proton
# @private
def pre_encode
# encode elements from the message
- Codec::Data.from_object(Cproton::pn_message_properties(@impl), !@properties.empty? && @properties)
- Codec::Data.from_object(Cproton::pn_message_instructions(@impl), !@instructions.empty? && @instructions)
+ Codec::Data.from_object(Cproton::pn_message_properties(@impl),
+ !@properties.empty? && Types.symbol_keys!(@properties))
+ Codec::Data.from_object(Cproton::pn_message_instructions(@impl),
+ !@instructions.empty? && Types.symbol_keys!(@instructions))
if @annotations # Make sure keys are symbols
@annotations.keys.each do |k|
@annotations[k.to_sym] = @annotations.delete(k) unless k.is_a? Symbol
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/core/transport.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transport.rb b/proton-c/bindings/ruby/lib/core/transport.rb
index 9b36335..eb5fb01 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -18,49 +18,7 @@
module Qpid::Proton
- # A transport is used by a connection to interface with the network.
- #
- # A transport is associated with, at most, one Connection.
- #
- # == Client And Server Mode
- #
- # Initially, a transport is configured to be a client tranpsort. It can be
- # configured to act as a server when it is created.
- #
- # A client transport initiates outgoing connections.
- #
- # A client transport must be configured with the protocol layers to use and
- # cannot configure itself automatically.
- #
- # A server transport accepts incoming connections. It can automatically
- # configure itself to include the various protocol layers depending on the
- # incoming protocol headers.
- #
- # == Tracing Data
- #
- # Data can be traced into and out of the transport programmatically by setting
- # the #trace level to one of the defined trace values (TRACE_RAW, TRACE_FRM or
- # TRACE_DRV). Tracing can also be turned off programmatically by setting the
- # #trace level to TRACE_OFF.
- #
- # @example
- #
- # # turns on frame tracing
- # @transport.trace = Qpid::Proton::Transport::TRACE_FRM
- #
- # # ... do something where the frames are of interest, such as debugging
- #
- # # turn tracing off again
- # @transport.trace = Qpid::Proton::Transport::TRACE_NONE
- #
- # Tracing can also be enabled from the command line by defining the similarly
- # named environment variable before starting a Proton application:
- #
- # @example
- #
- # # enable tracing from the command line
- # PN_TRACE_FRM=1 ruby my_proton_app.rb
- #
+ # @deprecated all important features are available from {#Connection}
class Transport
include Util::Deprecation
@@ -78,6 +36,7 @@ module Qpid::Proton
# Log driver related events; i.e., initialization, end of stream, etc.
TRACE_DRV = Cproton::PN_TRACE_DRV
+ proton_get :user
# @!attribute channel_max
#
@@ -94,8 +53,8 @@ module Qpid::Proton
# @!attribute max_frame_size
#
# @return [Integer] The maximum frame size.
- #
- proton_set_get :max_frame_size
+ proton_set_get :max_frame
+ proton_get :remote_max_frame
# @!attribute [r] remote_max_frame_size
#
@@ -394,14 +353,15 @@ module Qpid::Proton
end
# @private
+ # Options are documented {Connection#open}, keep that consistent with this
def apply opts
sasl if opts[:sasl_enabled] # Explicitly enabled
unless opts.include?(:sasl_enabled) && !opts[:sasl_enabled] # Not explicitly disabled
sasl.allowed_mechs = opts[:sasl_allowed_mechs] if opts.include? :sasl_allowed_mechs
sasl.allow_insecure_mechs = opts[:sasl_allow_insecure_mechs] if opts.include? :sasl_allow_insecure_mechs
end
- self.channel_max= opts[:channel_max] if opts.include? :channel_max
- self.max_frame_size= opts[:max_frame_size] if opts.include? :max_frame_size
+ self.channel_max= opts[:max_sessions] if opts.include? :max_sessions
+ self.max_frame = opts[:max_frame_size] if opts.include? :max_frame_size
# NOTE: The idle_timeout option is in Numeric *seconds*, can be Integer, Float or Rational.
# This is consistent with idiomatic ruby.
# The transport #idle_timeout property is in *milliseconds* passed direct to C.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/reactor/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/reactor/container.rb b/proton-c/bindings/ruby/lib/reactor/container.rb
index 22cb0e8..0576647 100644
--- a/proton-c/bindings/ruby/lib/reactor/container.rb
+++ b/proton-c/bindings/ruby/lib/reactor/container.rb
@@ -42,6 +42,9 @@ module Qpid::Proton
def connect(opts=nil)
url = opts && (opts[:url] || opts[:address])
raise ::ArgumentError.new, "no :url or :address option provided" unless url
+ # Default to ReactorMessagingAdapter default behavior
+ opts ||= {}
+ opts[:handler] ||= Handler::ReactorMessagingAdapter.new
super(url, opts)
end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/types/array.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/array.rb b/proton-c/bindings/ruby/lib/types/array.rb
index 7a20adb..d7e15e6 100644
--- a/proton-c/bindings/ruby/lib/types/array.rb
+++ b/proton-c/bindings/ruby/lib/types/array.rb
@@ -51,7 +51,11 @@ module Qpid::Proton
@type, @descriptor = type, descriptor
raise ArgumentError, "no type specified for array" if @type.nil?
super elements if elements
- @proton_array_header = ArrayHeader.new(@type, @descriptor) # Deprecated
+ end
+
+ # @deprecated backwards compatibility {UniformArray}
+ def proton_array_header
+ @proton_array_header ||= ArrayHeader.new(@type, @descriptor) # Deprecated
end
# @return [Type] Array elements must be convertible to this AMQP type
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/types/hash.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb
index 2d78f74..2702ab2 100644
--- a/proton-c/bindings/ruby/lib/types/hash.rb
+++ b/proton-c/bindings/ruby/lib/types/hash.rb
@@ -23,7 +23,6 @@
# @private
class Hash # :nodoc:
-
# @deprecated
def proton_data_put(data)
@@ -37,3 +36,15 @@ class Hash # :nodoc:
data.map
end
end
+
+module Qpid::Proton::Types
+ # @private
+ def self.symbol_keys(h)
+ h && h.reduce({}) { |x, (k, v)| x[k.to_sym] = v; x }
+ end
+
+ # @private
+ def self.symbol_array(a)
+ a && UniformArray.new(SYMBOL, a.collect { |v| v.to_sym })
+ end
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb b/proton-c/bindings/ruby/lib/util/deprecation.rb
index d9d0563..4980a9e 100644
--- a/proton-c/bindings/ruby/lib/util/deprecation.rb
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -20,10 +20,13 @@ module Qpid::Proton::Util
module Deprecation
MATCH_DIR = /#{File.dirname(File.dirname(__FILE__))}/
+ DEPRECATE_FULL_TRACE = false
+
def self.deprecated(old, new=nil)
replace = new ? "use `#{new}`" : "internal use only"
- line = caller.find { |l| not MATCH_DIR.match(l) }
- warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from #{line}"
+
+ from = DEPRECATE_FULL_TRACE ? caller(2).join("\n") : caller.find { |l| not MATCH_DIR.match(l) }
+ warn "[DEPRECATION] `#{old}` is deprecated, #{replace}. Called from #{from}"
end
def deprecated(*arg) Deprecation.deprecated(*arg); end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/09167695/proton-c/bindings/ruby/tests/test_container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container.rb b/proton-c/bindings/ruby/tests/test_container.rb
index d8bd52c..82c34e2 100644
--- a/proton-c/bindings/ruby/tests/test_container.rb
+++ b/proton-c/bindings/ruby/tests/test_container.rb
@@ -75,7 +75,7 @@ class ContainerTest < Minitest::Test
end
class CloseOnOpenHandler < TestHandler
- def on_connection_open(c) c.close; end
+ def on_connection_open(c) super; c.close; end
end
def test_auto_stop_one
@@ -159,6 +159,61 @@ class ContainerTest < Minitest::Test
assert_match(/badconnect.example.com:999/, c.transport.condition.description)
end
+ # Verify that connection options are sent to the peer and available as Connection methods
+ def test_connection_options
+ # Note: user, password and sasl_xxx options are tested by ContainerSASLTest below
+ server_handler = Class.new(MessagingHandler) do
+ def on_error(e) raise e.inspect; end
+ def on_connection_open(c) @connection = c
+ c.open({
+ :virtual_host => "server.to.client",
+ :properties => { :server => :client },
+ :offered_capabilities => [ :s1 ],
+ :desired_capabilities => [ :s2 ],
+ :container_id => "box",
+ })
+ c.close
+ end
+ attr_reader :connection
+ end.new
+ # Transport options must be provided to the listener, by Connection#open it is too late
+ cont = TestContainer.new(nil, {
+ :handler => server_handler,
+ :idle_timeout => 88,
+ :max_sessions =>1000,
+ :max_frame_size => 8888,
+ })
+ client = cont.connect(cont.url,
+ {:virtual_host => "client.to.server",
+ :properties => { :foo => :bar, "str" => "str" },
+ :offered_capabilities => [:c1 ],
+ :desired_capabilities => ["c2" ],
+ :idle_timeout => 42,
+ :max_sessions =>100,
+ :max_frame_size => 4096,
+ :container_id => "bowl"
+ })
+ cont.run
+ c = server_handler.connection
+ assert_equal "client.to.server", c.virtual_host
+ assert_equal({ :foo => :bar, :str => "str" }, c.properties)
+ assert_equal([:c1], c.offered_capabilities)
+ assert_equal([:c2], c.desired_capabilities)
+ assert_equal 21, c.idle_timeout # Proton divides by 2
+ assert_equal 100, c.max_sessions
+ assert_equal 4096, c.max_frame_size
+ assert_equal "bowl", c.container_id
+
+ c = client
+ assert_equal "server.to.client", c.virtual_host
+ assert_equal({ :server => :client }, c.properties)
+ assert_equal([:s1], c.offered_capabilities)
+ assert_equal([:s2], c.desired_capabilities)
+ assert_equal "box", c.container_id
+ assert_equal 8888, c.max_frame_size
+ assert_equal 44, c.idle_timeout # Proton divides by 2
+ assert_equal 100, c.max_sessions
+ end
end
@@ -184,7 +239,7 @@ class ContainerSASLTest < Minitest::Test
if connection == @client
connection.close
else
- @auth_user = connection.transport.sasl.user
+ @auth_user = connection.user
end
end
end
@@ -231,7 +286,7 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
def test_sasl_anonymous()
s = SASLHandler.new("amqp://", {:sasl_allowed_mechs => "ANONYMOUS"})
TestContainer.new(s, {:sasl_allowed_mechs => "ANONYMOUS"}, __method__).run
- assert_nil(s.connections[0].user)
+ assert_equal "anonymous", s.connections[0].user
end
def test_sasl_plain_url()
@@ -239,7 +294,7 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
# Use default realm with URL, should authenticate with "default_password"
opts = {:sasl_allowed_mechs => "PLAIN", :sasl_allow_insecure_mechs => true}
s = SASLHandler.new("amqp://user:default_password@", opts)
- TestContainer.new(s, opts).run
+ TestContainer.new(s, opts, __method__).run
assert_equal(2, s.connections.size)
assert_equal("user", s.auth_user)
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org