[DRE-commits] [ruby-stomp] 02/05: Imported Upstream Version 1.2.16

Jonas Genannt jonas at brachium-system.net
Fri Sep 20 20:01:53 UTC 2013


This is an automated email from the git hooks/post-receive script.

hggh-guest pushed a commit to branch master
in repository ruby-stomp.

commit 7793e5e5adf362a6bca20f3944855d23ee743a0b
Author: Jonas Genannt <jonas at brachium-system.net>
Date:   Fri Sep 20 21:52:05 2013 +0200

    Imported Upstream Version 1.2.16
---
 CHANGELOG.rdoc          |   10 +++++
 README.rdoc             |    3 ++
 Rakefile                |    1 +
 checksums.yaml.gz       |  Bin 0 -> 427 bytes
 lib/client/utils.rb     |   59 +++++++++++--------------
 lib/connection/netio.rb |   65 ++++++++++++++++++---------
 lib/connection/utils.rb |    4 +-
 lib/stomp/client.rb     |   31 ++++---------
 lib/stomp/connection.rb |    8 +++-
 lib/stomp/errors.rb     |    8 ++++
 lib/stomp/version.rb    |    2 +-
 metadata.yml            |   13 +++---
 spec/client_spec.rb     |  113 ++++++++++++++++++++++++++++++-----------------
 spec/connection_spec.rb |    7 ++-
 stomp.gemspec           |    3 +-
 15 files changed, 196 insertions(+), 131 deletions(-)

diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index b445b97..b9711c6 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,3 +1,13 @@
+== 1.2.16 20130812
+
+* Stomp::Client's should expose connection's host params
+
+== 1.2.15 20130809
+
+* Add user-specified timeout for initial CONNECTED/ERROR frame read.
+* Eliminate dup Timeout::timeout in ssl connect
+* Add license information to gemspec (#69)
+
 == 1.2.14 20130819
 
 * Version bump (1.2.13 release had Stomp::Version of 1.1.12.)
diff --git a/README.rdoc b/README.rdoc
index 4270a60..34615a3 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -12,6 +12,8 @@ An implementation of the Stomp protocol for Ruby. See:
 
 See _CHANGELOG.rdoc_ for details.
 
+* Gem version 1.2.16. Fixed Stomp::Client to expose its connection's host parameters.
+* Gem version 1.2.15. Timeout cleanup, added license info to gemspec.
 * Gem version 1.2.14. Cleanup.
 * Gem version 1.2.13. Stomp::Client#unreceive max_redeliveries fix.
 * Gem version 1.2.12. Miscellaneous issue fixes and cleanup.
@@ -60,6 +62,7 @@ See _CHANGELOG.rdoc_ for details.
       :fast_hbs_adjust => 0.0,            # Fast heartbeat senders sleep adjustment, seconds, needed ...
                                           # For fast heartbeat senders.  'fast' == YMMV.  If not
                                           # correct for your environment, expect unnecessary fail overs
+      :connread_timeout => 0,             # Timeout during CONNECT for read of CONNECTED/ERROR, secs
     }
 
     # for client
diff --git a/Rakefile b/Rakefile
index 2644257..03826b6 100644
--- a/Rakefile
+++ b/Rakefile
@@ -30,6 +30,7 @@ begin
     gem.name = "stomp"
     gem.version = Stomp::Version::STRING
     gem.summary = %Q{Ruby client for the Stomp messaging protocol}
+    gem.license = "Apache 2.0"
     gem.description = %Q{Ruby client for the Stomp messaging protocol.  Note that this gem is no longer supported on rubyforge.}
     gem.email = ["brianm at apache.org", 'marius at stones.com', 'morellon at gmail.com',
        'allard.guy.m at gmail.com' ]
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
new file mode 100644
index 0000000..88fb18b
Binary files /dev/null and b/checksums.yaml.gz differ
diff --git a/lib/client/utils.rb b/lib/client/utils.rb
index 9170344..925a092 100644
--- a/lib/client/utils.rb
+++ b/lib/client/utils.rb
@@ -13,25 +13,20 @@ module Stomp
       return false unless params.is_a?(Hash)
 
       @parameters = params
-      first_host = @parameters[:hosts][0]
-      @login = first_host[:login]
-      @passcode = first_host[:passcode]
-      @host = first_host[:host]
-      @port = first_host[:port] || Connection::default_port(first_host[:ssl])
-      @reliable = true
+      @parameters[:reliable] = true
+
       true
     end
 
     def parse_stomp_url(login)
       regexp = /^stomp:\/\/#{URL_REPAT}/
-      return false unless login =~ regexp
-
-      @login = $3 || ""
-      @passcode = $4 || ""
-      @host = $5
-      @port = $6.to_i
+      return false unless url = regexp.match(login)
 
-      @reliable = false
+      @parameters = { :reliable => false,
+                      :hosts => [ { :login => url[3] || "",
+                                    :passcode => url[4] || "",
+                                    :host => url[5],
+                                    :port => url[6].to_i} ] }
       true
     end
 
@@ -40,31 +35,28 @@ module Stomp
       rval = nil
       if md = FAILOVER_REGEX.match(login)
         finhosts = parse_hosts(login)
-        #
-        @login = finhosts[0][:login] || ""
-        @passcode = finhosts[0][:passcode] || ""
-        @host = finhosts[0][:host] || ""
-        @port = finhosts[0][:port] || ""
-        #
+
         options = {}
-        if md_last = md[md.size-1]
+        if md_last = md[-1]
           parts = md_last.split(/&|=/)
-          raise Stomp::Error::MalformedFailoverOptionsError unless (parts.size % 2 ) == 0
+          raise Stomp::Error::MalformedFailoverOptionsError unless ( parts.size % 2 ) == 0
           options = Hash[*parts]
         end
-        @parameters = {:hosts => finhosts}.merge! filter_options(options)
-        @reliable = true
+
+        @parameters = {:hosts => finhosts}.merge!(filter_options(options))
+
+        @parameters[:reliable] = true
         rval = true
       end
       rval
     end
 
     def parse_positional_params(login, passcode, host, port, reliable)
-      @login = login
-      @passcode = passcode
-      @host = host
-      @port = port.to_i
-      @reliable = reliable
+      @parameters = { :reliable => reliable,
+                      :hosts => [ { :login => login,
+                                    :passcode => passcode,
+                                    :host => host,
+                                    :port => port.to_i } ] }
       true
     end
 
@@ -108,9 +100,12 @@ end
 
     # A very basic check of required arguments.
     def check_arguments!()
-      raise ArgumentError if @host.nil? || @host.empty?
-      raise ArgumentError if @port.nil? || @port == '' || @port < 1 || @port > 65535
-      raise ArgumentError unless @reliable.is_a?(TrueClass) || @reliable.is_a?(FalseClass)
+      first_host = @parameters && @parameters[:hosts] && @parameters[:hosts].first
+
+      raise ArgumentError if first_host.nil?
+      raise ArgumentError if first_host[:host].nil? || first_host[:host].empty?
+      raise ArgumentError if first_host[:port].nil? || first_host[:port] == '' || first_host[:port] < 1 || first_host[:port] > 65535
+      raise ArgumentError unless @parameters[:reliable].is_a?(TrueClass) || @parameters[:reliable].is_a?(FalseClass)
     end
 
     # filter_options returns a new Hash of filtered options.
@@ -149,7 +144,7 @@ end
         while true
           message = @connection.receive
           # AMQ specific behavior
-          if message.nil? && (!@reliable)
+          if message.nil? && (!@parameters[:reliable])
             raise Stomp::Error::NilMessageError
           end
           if message # message can be nil on rapid AMQ stop / start sequences
diff --git a/lib/connection/netio.rb b/lib/connection/netio.rb
index dd08213..9a4c99c 100644
--- a/lib/connection/netio.rb
+++ b/lib/connection/netio.rb
@@ -12,28 +12,24 @@ module Stomp
     private
 
     # Really read from the wire.
-    def _receive(read_socket)
+    def _receive(read_socket, connread = false)
       @read_semaphore.synchronize do
-        line = ''
-        if @protocol == Stomp::SPL_10 || (@protocol >= Stomp::SPL_11 && !@hbr)
-          if @jruby
-            # Handle JRuby specific behavior.
-            while true
-              line = read_socket.gets # Data from wire
-              break unless line == "\n"
-              line = ''
+        line = nil
+        if connread
+          begin
+            Timeout::timeout(@connread_timeout, Stomp::Error::ConnectReadTimeout) do
+              line = _init_line_read(read_socket)
             end
-          else
-            line = read_socket.gets # The old way
-          end
-        else # We are >= 1.1 *AND* receiving heartbeats.
-          while true
-            line = read_socket.gets # Data from wire
-            break unless line == "\n"
-            line = ''
-            @lr = Time.now.to_f
+          rescue Stomp::Error::ConnectReadTimeout => ex
+            if @reliable
+              _reconn_prep()
+            end
+            raise ex
           end
+        else
+          line = _init_line_read(read_socket)
         end
+        #
         return nil if line.nil?
         # p [ "wiredatain_01", line ]
         line = _normalize_line_end(line) if @protocol >= Stomp::SPL_12
@@ -290,7 +286,8 @@ module Stomp
         end
 
         Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do
-          ssl = OpenSSL::SSL::SSLSocket.new(open_tcp_socket, ctx)
+          tcp_socket = TCPSocket.open(@host, @port)
+          ssl = OpenSSL::SSL::SSLSocket.new(tcp_socket, ctx)
           ssl.hostname = @host if ssl.respond_to? :hostname=
           ssl.sync_close = true # Sync ssl close with underlying TCP socket
           ssl.connect
@@ -345,7 +342,9 @@ module Stomp
 
       @closed = false
       if @parameters # nil in some rspec tests
-        @reconnect_delay = @parameters[:initial_reconnect_delay] ? @parameters[:initial_reconnect_delay] : 0.01
+        unless @reconnect_delay
+          @reconnect_delay = @parameters[:initial_reconnect_delay] ? @parameters[:initial_reconnect_delay] : 0.01
+        end
       end
       # Use keepalive
       used_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
@@ -364,7 +363,7 @@ module Stomp
       else
         _transmit(used_socket, Stomp::CMD_CONNECT, headers)
       end
-      @connection_frame = _receive(used_socket)
+      @connection_frame = _receive(used_socket, true)
       _post_connect
       @disconnect_receipt = nil
       @session = @connection_frame.headers["session"] if @connection_frame
@@ -374,6 +373,30 @@ module Stomp
       }
     end
 
+    def _init_line_read(read_socket)
+        line = ''
+        if @protocol == Stomp::SPL_10 || (@protocol >= Stomp::SPL_11 && !@hbr)
+          if @jruby
+            # Handle JRuby specific behavior.
+            while true
+              line = read_socket.gets # Data from wire
+              break unless line == "\n"
+              line = ''
+            end
+          else
+            line = read_socket.gets # The old way
+          end
+        else # We are >= 1.1 *AND* receiving heartbeats.
+          while true
+            line = read_socket.gets # Data from wire
+            break unless line == "\n"
+            line = ''
+            @lr = Time.now.to_f
+          end
+        end
+        line
+    end
+
   end # class Connection
 
 end # module Stomp
diff --git a/lib/connection/utils.rb b/lib/connection/utils.rb
index 548bf0b..624b114 100644
--- a/lib/connection/utils.rb
+++ b/lib/connection/utils.rb
@@ -182,6 +182,7 @@ module Stomp
         :max_hbread_fails => 0,
         :max_hbrlck_fails => 0,
         :fast_hbs_adjust => 0.0,
+        :connread_timeout => 0,
       }
 
       res_params = default_params.merge(params)
@@ -191,7 +192,7 @@ module Stomp
       return res_params
     end
 
-    # change_host selects the next host for retires.
+    # change_host selects the next host for retries.
     def change_host
       @parameters[:hosts] = @parameters[:hosts].sort_by { rand } if @parameters[:randomize]
 
@@ -204,7 +205,6 @@ module Stomp
       @port = current_host[:port] || Connection::default_port(@ssl)
       @login = current_host[:login] || ""
       @passcode = current_host[:passcode] || ""
-
     end
 
     # max_reconnect_attempts? returns nil or the number of maximum reconnect
diff --git a/lib/stomp/client.rb b/lib/stomp/client.rb
index 28625c2..223c5a6 100644
--- a/lib/stomp/client.rb
+++ b/lib/stomp/client.rb
@@ -2,6 +2,7 @@
 
 require 'thread'
 require 'digest/sha1'
+require 'forwardable'
 
 module Stomp
 
@@ -11,25 +12,14 @@ module Stomp
   # Receives all happen in one thread, so consider not doing much processing
   # in that thread if you have much message volume.
   class Client
+    extend Forwardable
 
-    # The login ID used by the client.
-    attr_reader :login
-
-    # The login credentials used by the client.
-    attr_reader :passcode
-
-    # The Stomp host specified by the client.
-    attr_reader :host
-
-    # The Stomp host's listening port.
-    attr_reader :port
-
-    # Is this connection reliable?
-    attr_reader :reliable
-
-    # Parameters Hash, possibly nil for a non-hashed connect.
+    # Parameters hash
     attr_reader :parameters
 
+    def_delegators :@connection, :login, :passcode, :port, :host, :ssl
+    def_delegator :@parameters, :reliable
+
     # A new Client object can be initialized using three forms:
     #
     # Hash (this is the recommended Client initialization method):
@@ -58,6 +48,7 @@ module Stomp
     #     :max_hbread_fails => 0,
     #     :max_hbrlck_fails => 0,
     #     :fast_hbs_adjust => 0.0,
+    #     :connread_timeout => 0,
     #   }
     #
     #   e.g. c = Stomp::Client.new(hash)
@@ -99,12 +90,8 @@ module Stomp
     end
 
     def create_connection(autoflush)
-      if @parameters
-        @connection = Connection.new(@parameters)
-      else
-        @connection = Connection.new(@login, @passcode, @host, @port, @reliable)
-        @connection.autoflush = autoflush
-      end
+      @connection = Connection.new(@parameters)
+      @connection.autoflush = autoflush
     end
     private :create_connection
 
diff --git a/lib/stomp/connection.rb b/lib/stomp/connection.rb
index e20344f..181d2b8 100644
--- a/lib/stomp/connection.rb
+++ b/lib/stomp/connection.rb
@@ -38,6 +38,9 @@ module Stomp
     # dynamically by calling code.
     attr_accessor :autoflush
 
+    # Currently-connected host and port
+    attr_reader :host, :port
+
     # default_port returns the default port used by the gem for TCP or SSL.
     def self.default_port(ssl)
       ssl ? 61612 : 61613
@@ -71,6 +74,7 @@ module Stomp
     #     :max_hbread_fails => 0,
     #     :max_hbrlck_fails => 0,
     #     :fast_hbs_adjust => 0.0,
+    #     :connread_timeout => 0,
     #   }
     #
     #   e.g. c = Stomp::Connection.new(hash)
@@ -117,7 +121,8 @@ module Stomp
         @usecrlf = false      # If true, use \r\n as line ends (1.2 only)
         @max_hbread_fails = 0 # 0 means never retry for HB read failures
         @max_hbrlck_fails = 0 # 0 means never retry for HB read lock failures
-        @fast_hbs_adjust = 0.0 # Fast heartbeat senders sleep adjustment 
+        @fast_hbs_adjust = 0.0 # Fast heartbeat senders sleep adjustment
+        @connread_timeout = 0 # Connect read CONNECTED/ERROR timeout
         warn "login looks like a URL, do you have the correct parameters?" if @login =~ /:\/\//
       end
 
@@ -153,6 +158,7 @@ module Stomp
       @max_hbread_fails = @parameters[:max_hbread_fails]
       @max_hbrlck_fails = @parameters[:max_hbrlck_fails]
       @fast_hbs_adjust = @parameters[:fast_hbs_adjust]
+      @connread_timeout = @parameters[:connread_timeout]
       #sets the first host to connect
       change_host
     end
diff --git a/lib/stomp/errors.rb b/lib/stomp/errors.rb
index 4ed7bb2..bf1e526 100644
--- a/lib/stomp/errors.rb
+++ b/lib/stomp/errors.rb
@@ -213,6 +213,14 @@ module Stomp
       end
     end
 
+    # ConnectReadTimeout is raised if:
+    # * A read for CONNECTED/ERROR is untimely
+    class ConnectReadTimeout < RuntimeError
+      def message
+        "Connect read for CONNECTED/ERROR timeout"
+      end
+    end
+
   end # module Error
 
 end # module Stomp
diff --git a/lib/stomp/version.rb b/lib/stomp/version.rb
index 11b5a77..7070208 100644
--- a/lib/stomp/version.rb
+++ b/lib/stomp/version.rb
@@ -6,7 +6,7 @@ module Stomp
   module Version  #:nodoc: all
     MAJOR = 1
     MINOR = 2
-    PATCH = 14
+    PATCH = 16
     STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
   end
 end
diff --git a/metadata.yml b/metadata.yml
index 1a50f48..88f9646 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,8 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: stomp
 version: !ruby/object:Gem::Version
-  version: 1.2.14
-  prerelease: 
+  version: 1.2.16
 platform: ruby
 authors:
 - Brian McCallister
@@ -17,7 +16,6 @@ dependencies:
 - !ruby/object:Gem::Dependency
   name: rspec
   requirement: !ruby/object:Gem::Requirement
-    none: false
     requirements:
     - - ! '>='
       - !ruby/object:Gem::Version
@@ -25,7 +23,6 @@ dependencies:
   type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
-    none: false
     requirements:
     - - ! '>='
       - !ruby/object:Gem::Version
@@ -160,26 +157,26 @@ files:
 - test/test_urlogin.rb
 - test/tlogger.rb
 homepage: https://github.com/stompgem/stomp
-licenses: []
+licenses:
+- Apache 2.0
+metadata: {}
 post_install_message: 
 rdoc_options: []
 require_paths:
 - lib
 required_ruby_version: !ruby/object:Gem::Requirement
-  none: false
   requirements:
   - - ! '>='
     - !ruby/object:Gem::Version
       version: '0'
 required_rubygems_version: !ruby/object:Gem::Requirement
-  none: false
   requirements:
   - - ! '>='
     - !ruby/object:Gem::Version
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 1.8.25
+rubygems_version: 2.0.5
 signing_key: 
 specification_version: 3
 summary: Ruby client for the Stomp messaging protocol
diff --git a/spec/client_spec.rb b/spec/client_spec.rb
index 35c5c5b..5e305e4 100644
--- a/spec/client_spec.rb
+++ b/spec/client_spec.rb
@@ -7,8 +7,8 @@ require 'client_shared_examples'
 describe Stomp::Client do
 
   before(:each) do
-    @mock_connection = mock('connection', :autoflush= => true)
-    Stomp::Connection.stub!(:new).and_return(@mock_connection)
+    @mock_connection = double('connection', :autoflush= => true)
+    Stomp::Connection.stub(:new).and_return(@mock_connection)
   end
 
   describe "(created with no params)" do
@@ -33,6 +33,29 @@ describe Stomp::Client do
 
   end
 
+  describe 'delegated params' do
+    before :each do
+      @mock_connection = double('connection', :autoflush= => true,
+                                              :login => 'dummy login',
+                                              :passcode => 'dummy passcode',
+                                              :port => 12345,
+                                              :host => 'dummy host',
+                                              :ssl => 'dummy ssl')
+      Stomp::Connection.stub(:new).and_return(@mock_connection)
+      @client = Stomp::Client.new
+    end
+
+    describe 'it should delegate parameters to its connection' do
+      subject { @client }
+
+      its(:login) { should eql 'dummy login' }
+      its(:passcode) { should eql 'dummy passcode' }
+      its(:port) { should eql 12345 }
+      its(:host) { should eql 'dummy host' }
+      its(:ssl) { should eql 'dummy ssl' }
+    end
+  end
+
   describe "(autoflush)" do
     it "should delegate to the connection for accessing the autoflush property" do
       @mock_connection.should_receive(:autoflush)
@@ -98,17 +121,17 @@ describe Stomp::Client do
 
 
   describe "(created with positional params)" do
-
     before(:each) do
       @client = Stomp::Client.new('testlogin', 'testpassword', 'localhost', '12345', false)
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('testlogin')
-      @client.passcode.should eql('testpassword')
-      @client.host.should eql('localhost')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => 'testlogin',
+                                                              :passcode => 'testpassword',
+                                                              :host => 'localhost',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('testlogin', 'testpassword', 'localhost', '12345', false)
     end
 
     it_should_behave_like "standard Client"
@@ -122,11 +145,12 @@ describe Stomp::Client do
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('')
-      @client.passcode.should eql('')
-      @client.host.should eql('foobar')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => '',
+                                                              :passcode => '',
+                                                              :host => 'foobar',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('stomp://foobar:12345')
     end
 
     it_should_behave_like "standard Client"
@@ -140,11 +164,12 @@ describe Stomp::Client do
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('')
-      @client.passcode.should eql('')
-      @client.host.should eql('foo-bar')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => '',
+                                                              :passcode => '',
+                                                              :host => 'foo-bar',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('stomp://foo-bar:12345')
     end
 
     it_should_behave_like "standard Client"
@@ -158,11 +183,12 @@ describe Stomp::Client do
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('test-login')
-      @client.passcode.should eql('testpasscode')
-      @client.host.should eql('foobar')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => 'test-login',
+                                                              :passcode => 'testpasscode',
+                                                              :host => 'foobar',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('stomp://test-login:testpasscode@foobar:12345')
     end
 
     it_should_behave_like "standard Client"
@@ -176,11 +202,12 @@ describe Stomp::Client do
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('test-login')
-      @client.passcode.should eql('testpasscode')
-      @client.host.should eql('foo-bar')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => 'test-login',
+                                                              :passcode => 'testpasscode',
+                                                              :host => 'foo-bar',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('stomp://test-login:testpasscode@foo-bar:12345')
     end
 
     it_should_behave_like "standard Client"
@@ -197,11 +224,12 @@ describe Stomp::Client do
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('')
-      @client.passcode.should eql('')
-      @client.host.should eql('host.foobar.com')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => '',
+                                                              :passcode => '',
+                                                              :host => 'host.foobar.com',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('stomp://host.foobar.com:12345')
     end
 
     it_should_behave_like "standard Client"
@@ -215,11 +243,12 @@ describe Stomp::Client do
     end
 
     it "should properly parse the URL provided" do
-      @client.login.should eql('testlogin')
-      @client.passcode.should eql('testpasscode')
-      @client.host.should eql('host.foobar.com')
-      @client.port.should eql(12345)
-      @client.reliable.should be_false
+      Stomp::Connection.should_receive(:new).with(:hosts => [{:login => 'testlogin',
+                                                              :passcode => 'testpasscode',
+                                                              :host => 'host.foobar.com',
+                                                              :port => 12345}],
+                                                  :reliable => false)
+      Stomp::Client.new('stomp://testlogin:testpasscode@host.foobar.com:12345')
     end
 
     it_should_behave_like "standard Client"
@@ -236,7 +265,8 @@ describe Stomp::Client do
         :back_off_multiplier => 2,
         :max_reconnect_attempts => 0,
         :randomize => false,
-        :connect_timeout => 0
+        :connect_timeout => 0,
+        :reliable => true
       }
     end
     it "should properly parse a URL with failover://" do
@@ -303,14 +333,15 @@ describe Stomp::Client do
       url = "failover:(stomp://login1:passcode1@localhost:61616,stomp://login2:passcode2@remotehost:61617)?#{query}"
       
       #
-      @parameters = {  
+      @parameters = {
         :initial_reconnect_delay => 5.0,
         :max_reconnect_delay => 60.0,
         :use_exponential_back_off => false,
         :back_off_multiplier => 3,
         :max_reconnect_attempts => 4,
         :randomize => true,
-        :connect_timeout => 0
+        :connect_timeout => 0,
+        :reliable => true
       }
       
       @parameters[:hosts] = [
diff --git a/spec/connection_spec.rb b/spec/connection_spec.rb
index 1289764..81cf532 100644
--- a/spec/connection_spec.rb
+++ b/spec/connection_spec.rb
@@ -28,11 +28,12 @@ describe Stomp::Connection do
       :max_hbread_fails => 0,
       :max_hbrlck_fails => 0,
       :fast_hbs_adjust => 0.0,
+      :connread_timeout => 0,
    }
         
     #POG:
     class Stomp::Connection
-      def _receive( s )
+      def _receive( s, connread = false )
       end
     end
     
@@ -96,6 +97,7 @@ describe Stomp::Connection do
         :maxHbreadFails => 0,
         :maxHbrlckFails => 0,
         :fastHbsAdjust => 0.0,
+        :connreadTimeout => 0,
       }
       
       @connection = Stomp::Connection.new(used_hash)
@@ -350,6 +352,7 @@ describe Stomp::Connection do
           :max_hbread_fails => 0,
           :max_hbrlck_fails => 0,
           :fast_hbs_adjust => 0.0,
+          :connread_timeout => 0,
         }
         
         used_hash =  {
@@ -389,6 +392,7 @@ describe Stomp::Connection do
           :max_hbread_fails => 123,
           :max_hbrlck_fails => 456,
           :fast_hbs_adjust => 0.2,
+          :connread_timeout => 42,
         }
         
         @connection = Stomp::Connection.new(used_hash)
@@ -438,7 +442,6 @@ describe Stomp::Connection do
       @connection.instance_variable_set(:@connection_attempts, limit)
       @connection.send(:max_reconnect_attempts?).should be_true
     end
-
     # These should be raised for the user to deal with
     it "should not rescue MaxReconnectAttempts" do
       @connection = Stomp::Connection.new(@parameters)
diff --git a/stomp.gemspec b/stomp.gemspec
index 17111fd..7a866eb 100644
--- a/stomp.gemspec
+++ b/stomp.gemspec
@@ -5,7 +5,8 @@
 
 Gem::Specification.new do |s|
   s.name = %q{stomp}
-  s.version = "1.2.14"
+  s.version = "1.2.16"
+  s.license = "Apache 2.0"
 
   s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
   s.authors = ["Brian McCallister", "Marius Mathiesen", "Thiago Morello", "Guy M. Allard"]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-stomp.git



More information about the Pkg-ruby-extras-commits mailing list