[DRE-commits] [SCM] ruby-stomp.git branch, master, updated. debian/1.2.1-1-2-gdd52598

Jonas Genannt jonas at brachium-system.net
Tue Mar 27 20:45:04 UTC 2012


The following commit has been merged in the master branch:
commit df96d4fc67c7f12e7ee0f87ddbd064453a539a77
Author: Jonas Genannt <jonas at brachium-system.net>
Date:   Tue Mar 27 22:35:51 2012 +0200

    Adding upstream version 1.2.2.

diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index dd97fe9..2ee6ff2 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,3 +1,13 @@
+== 1.2.2 2012-24-03
+
+* Major performance improvement for read of messages without content-length header
+* Correct Stomp 1.1 failing test
+* Update sample code to reflect removal of 'send'
+* Add on_ssl_connectfail callback and allow clients to signal quit from the callback
+* Ensure that SSL certificates and SSL related files exist and are readable
+* Allow SSL file checks before connect using SSLParams.new(:fsck => true, ...)
+* Correct a test for Windows compatibility
+
 == 1.2.1 2012-13-03
 
 * Robust SSL certificate support.  See examples and: https://github.com/morellon/stomp/wiki/extended-ssl-overview
diff --git a/README.rdoc b/README.rdoc
index b6bf12b..87b3f9c 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -1,8 +1,7 @@
 ==README
 
-* (http://gitorious.org/projects/stomp/)
 * (https://github.com/morellon/stomp/)
-* (http://stomp.rubyforge.org/)
+* (http://gitorious.org/projects/stomp/)
 
 ===Overview
 
@@ -12,13 +11,17 @@ An implementation of the Stomp protocol for Ruby. See:
 
 ===New
 
-Support of Stomp protocol level 1.1 is announced as of gem version 1.2.0.
+* Gem version 1.2.2.  Performance and more SSL enhancements.
+* Full support of SSL certificates is announced as of gem version 1.2.1.
+* Support of Stomp protocol level 1.1 is announced as of gem version 1.2.0.
+
+See the change log for details.
 
 ===Example Usage
 
     client = Stomp::Client.new("test", "user", "localhost", 61613)
-    client.send("/my/queue", "hello world!")
-    client.subscribe("/my/queue") do |msg|
+    client.send("/queue/mine", "hello world!")
+    client.subscribe("/queue/mine") do |msg|
       p msg
     end
 
@@ -26,11 +29,11 @@ Support of Stomp protocol level 1.1 is announced as of gem version 1.2.0.
 
     options = "initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false"
     
-    #remotehost1 uses SSL, remotehost2 doesn't
+    # remotehost1 uses SSL, remotehost2 doesn't
     client = Stomp::Client.new("failover:(stomp+ssl://login1:passcode1@remotehost1:61612,stomp://login2:passcode2@remotehost2:61613)?#{options}")
     
-    client.send("/my/queue", "hello world!")
-    client.subscribe("/my/queue") do |msg|
+    client.publish("/queue/mine", "hello world!")
+    client.subscribe("/queue/mine") do |msg|
       p msg
     end
 
@@ -63,26 +66,16 @@ Support of Stomp protocol level 1.1 is announced as of gem version 1.2.0.
     connection = Stomp::Connection.new(hash)
     
 
-===Contact info 
+===Hstorical Information
 
 Up until March 2009 the project was maintained and primarily developed by Brian McCallister. 
 
-The project is now maintained by Johan Sørensen <johan at johansorensen.com> and others.
-
-===Source Code
+===Source Code and Project URLs
 
   https://github.com/morellon/stomp/
   http://gitorious.org/projects/stomp/
-  http://github.com/js/stomp/
-
-===Project urls
-
-Project Home :
-
-  http://gitorious.org/projects/stomp/
-  http://rubyforge.org/projects/stomp/
 
-Stomp Protocol Info :
+===Stomp Protocol Information :
 
   http://stomp.github.com/index.html
 
@@ -110,6 +103,16 @@ The following people have contributed to Stomp:
 * Chris Needham
 * R.I. Pienaar
 * tworker
+* James Pearson
+
+= Announcements
+
+In the next version of the gem, the dates in CHANGELOG.rdoc will be changed from:
+
+* yyyy-dd-mm
+
+to:
 
+* ISO8601 format (yyyymmdd)
 
 
diff --git a/Rakefile b/Rakefile
index cbbc87c..59d8027 100644
--- a/Rakefile
+++ b/Rakefile
@@ -61,8 +61,8 @@ Rake::RDocTask.new do |rdoc|
   rdoc.rdoc_dir = "doc"
   rdoc.title = "Stomp"
   rdoc.options += %w[ --line-numbers --inline-source --charset utf-8 ]
-  rdoc.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc")
-  rdoc.rdoc_files.include("lib/**/*.rb")
+  rdoc.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb", "examples/**/*.rb",
+    "test/**/*.rb")
 end
 
 Rake::TestTask.new do |t|
diff --git a/examples/slogger.rb b/examples/slogger.rb
index 1e8ae9a..dff0050 100644
--- a/examples/slogger.rb
+++ b/examples/slogger.rb
@@ -17,12 +17,27 @@ Optional callback methods:
     on_subscribe: subscribe called
     on_receive: receive called and successful
 
+    on_ssl_connecting: SSL connection starting
+    on_ssl_connected: successful SSL connect
+    on_ssl_connectfail: unsuccessful SSL connect (will usually be retried)
+
+    on_hbread_fail: unsuccessful Heartbeat read
+    on_hbwrite_fail: unsuccessful Heartbeat write
+
 All methods are optional, at the user's requirements.
 
 If a method is not provided, it is not called (of course.)
 
-IMPORTANT NOTE:  call back logging methods *MUST* not raise exceptions, 
-otherwise the underlying STOMP connection will fail in mysterious ways.
+IMPORTANT NOTE:  in general, call back logging methods *SHOULD* not raise exceptions, 
+otherwise the underlying STOMP connection may fail in mysterious ways.
+
+There are two useful exceptions to this rule for:
+
+    on_connectfail
+    on_ssl_connectfail
+
+These two methods can raise a Stomp::Errors::LoggerConnectionError.  If this
+exception is raised, it is passed up the chain to the caller.
 
 Callback parameters: are a copy of the @parameters instance variable for
 the Stomp::Connection.
@@ -64,6 +79,11 @@ class Slogger
     rescue
       @log.debug "Connect Fail oops"
     end
+=begin
+    # An example LoggerConnectionError raise
+    @log.debug "Connect Fail, will raise"
+    raise Stomp::Error::LoggerConnectionError.new("quit from connect")
+=end
   end
 
   # Log disconnect events
@@ -136,28 +156,6 @@ class Slogger
     end
   end
 
-
-  # Stomp 1.1+ - heart beat read (receive) failed
-  def on_hbread_fail(parms, ticker_data)
-    begin
-      @log.debug "Hbreadf Parms #{info(parms)}"
-      @log.debug "Hbreadf Result #{ticker_data}"
-    rescue
-      @log.debug "Hbreadf oops"
-    end
-  end
-
-  # Stomp 1.1+ - heart beat thread fires
-  def on_hbfire(parms, type, time)
-    begin
-      @log.debug "HBfire #{type} " + "=" * 30
-      @log.debug "HBfire #{type} Parms #{info(parms)}"
-      @log.debug "HBfire #{type} Time #{time}"
-    rescue
-      @log.debug "HBfire #{type} oops"
-    end
-  end
-
   def on_ssl_connecting(parms)
     begin
       @log.debug "SSL Connecting Parms #{info(parms)}"
@@ -174,6 +172,20 @@ class Slogger
     end
   end
 
+  def on_ssl_connectfail(parms)
+    begin
+      @log.debug "SSL Connect Fail Parms #{info(parms)}"
+      @log.debug "SSL Connect Fail Excception #{parms[:ssl_exception]}, #{parms[:ssl_exception].message}"
+    rescue
+      @log.debug "SSL Connect Fail oops"
+    end
+=begin
+    # An example LoggerConnectionError raise
+    @log.debug "SSL Connect Fail, will raise"
+    raise Stomp::Error::LoggerConnectionError.new("quit from SSL connect")
+=end
+  end
+
   private
 
   def info(parms)
@@ -188,6 +200,9 @@ class Slogger
     # parms[:cur_parseto]
     # parms[:cur_conattempts]
     #
+    # For the on_ssl_connectfail callback these are also available:
+    # parms[:ssl_exception]
+    #
     "Host: #{parms[:cur_host]}, Port: #{parms[:cur_port]}, Login: Port: #{parms[:cur_login]}, Passcode: #{parms[:cur_passcode]}, ssl: #{parms[:cur_ssl]}"
   end
 end # of class
diff --git a/lib/stomp/connection.rb b/lib/stomp/connection.rb
index d8839d5..adf59b2 100644
--- a/lib/stomp/connection.rb
+++ b/lib/stomp/connection.rb
@@ -141,8 +141,14 @@ module Stomp
             @failure = $!
             used_socket = nil
             raise unless @reliable
+            raise if @failure.is_a?(Stomp::Error::LoggerConnectionError)
             if @logger && @logger.respond_to?(:on_connectfail)
-              @logger.on_connectfail(log_params)
+              # on_connectfail may raise
+              begin
+                @logger.on_connectfail(log_params)
+              rescue Exception => aex
+                raise if aex.is_a?(Stomp::Error::LoggerConnectionError)
+              end
             else
               $stderr.print "connect to #{@host} failed: #{$!} will retry(##{@connection_attempts}) in #{@reconnect_delay}\n"
             end
@@ -500,14 +506,14 @@ module Stomp
             content_length = message_header.match /content-length\s?:\s?(\d+)\s?\n/
             message_body = ''
 
-            # If it does, reads the specified amount of bytes
-            char = ''
+            # If content_length is present, read the specified amount of bytes
             if content_length
               message_body = read_socket.read content_length[1].to_i
               raise Stomp::Error::InvalidMessageLength unless parse_char(read_socket.getc) == "\0"
-            # Else reads, the rest of the message until the first \0
+            # Else read the rest of the message until the first \0
             else
-              message_body += char while (char = parse_char(read_socket.getc)) != "\0"
+              message_body = read_socket.readline("\0")
+              message_body.chop!
             end
 
             # If the buffer isn't empty, reads trailing new lines.
@@ -629,93 +635,106 @@ module Stomp
 
       def open_ssl_socket
         require 'openssl' unless defined?(OpenSSL)
-        ctx = OpenSSL::SSL::SSLContext.new
-        ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now
-        #
-        # Note: if a client uses :ssl => true this results in the gem using
-        # the _default_ Ruby ciphers list.  This is _known_ to fail in later
-        # Ruby releases.  The gem provides a default cipher list that may
-        # function in these cases.  To use this connect with:
-        # * :ssl => Stomp::SSLParams.new
-        # * :ssl => Stomp::SSLParams.new(..., :ciphers => Stomp::DEFAULT_CIPHERS)
-        #
-        # If connecting with an SSLParams instance, and the _default_ Ruby
-        # ciphers list is required, use:
-        # * :ssl => Stomp::SSLParams.new(..., :use_ruby_ciphers => true)
-        #
-        # If a custom ciphers list is required, connect with:
-        # * :ssl => Stomp::SSLParams.new(..., :ciphers => custom_ciphers_list)
-        #
-        if @ssl != true
+        begin # Any raised SSL exceptions
+          ctx = OpenSSL::SSL::SSLContext.new
+          ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now
+          #
+          # Note: if a client uses :ssl => true this results in the gem using
+          # the _default_ Ruby ciphers list.  This is _known_ to fail in later
+          # Ruby releases.  The gem provides a default cipher list that may
+          # function in these cases.  To use this connect with:
+          # * :ssl => Stomp::SSLParams.new
+          # * :ssl => Stomp::SSLParams.new(..., :ciphers => Stomp::DEFAULT_CIPHERS)
           #
-          # Here @ssl is:
-          # * an instance of Stomp::SSLParams
-          # Control would not be here if @ssl == false or @ssl.nil?.
+          # If connecting with an SSLParams instance, and the _default_ Ruby
+          # ciphers list is required, use:
+          # * :ssl => Stomp::SSLParams.new(..., :use_ruby_ciphers => true)
           #
+          # If a custom ciphers list is required, connect with:
+          # * :ssl => Stomp::SSLParams.new(..., :ciphers => custom_ciphers_list)
+          #
+          if @ssl != true
+            #
+            # Here @ssl is:
+            # * an instance of Stomp::SSLParams
+            # Control would not be here if @ssl == false or @ssl.nil?.
+            #
+
+            # Back reference the SSLContext
+            @ssl.ctx = ctx
+
+            # Server authentication parameters if required
+            if @ssl.ts_files
+              ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
+              truststores = OpenSSL::X509::Store.new
+              fl = @ssl.ts_files.split(",")
+              fl.each do |fn|
+                # Add next cert file listed
+                raise Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)
+                raise Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)
+                truststores.add_file(fn)
+              end
+              ctx.cert_store = truststores
+            end
 
-          # Back reference the SSLContext
-          @ssl.ctx = ctx
-
-          # Server authentication parameters if required
-          if @ssl.ts_files
-            ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
-            truststores = OpenSSL::X509::Store.new
-            fl = @ssl.ts_files.split(",")
-            fl.each do |fn|
-              # Add next cert file listed
-              raise Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)
-              truststores.add_file(fn)
+            # Client authentication parameters
+            # Both cert file and key file must be present or not, it can not be a mix
+            raise Stomp::Error::SSLClientParamsError if @ssl.cert_file.nil? && !@ssl.key_file.nil?
+            raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? && @ssl.key_file.nil?
+            if @ssl.cert_file # Any check will do here
+              raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)
+              raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@ssl.cert_file)
+              ctx.cert = OpenSSL::X509::Certificate.new(File.open(@ssl.cert_file))
+              raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)
+              raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@ssl.key_file)
+              ctx.key  = OpenSSL::PKey::RSA.new(File.open(@ssl.key_file))
+            end
+
+            # Cipher list
+            if !@ssl.use_ruby_ciphers # No Ruby ciphers (the default)
+              if @ssl.ciphers # User ciphers list?
+                ctx.ciphers = @ssl.ciphers # Accept user supplied ciphers
+              else
+                ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults
+              end
             end
-            ctx.cert_store = truststores
           end
 
-          # Client authentication parameters
-          # Both cert file and key file must be present or not, it can not be a mix
-          raise Stomp::Error::SSLClientParamsError if @ssl.cert_file.nil? && !@ssl.key_file.nil?
-          raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? && @ssl.key_file.nil?
-          if @ssl.cert_file # Any check will do here
-            raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)
-            ctx.cert = OpenSSL::X509::Certificate.new(File.open(@ssl.cert_file))
-            raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)
-            ctx.key  = OpenSSL::PKey::RSA.new(File.open(@ssl.key_file))
+          #
+          ssl = nil
+          if @logger && @logger.respond_to?(:on_ssl_connecting)
+            @logger.on_ssl_connecting(log_params)
           end
 
-          # Cipher list
-          if !@ssl.use_ruby_ciphers # No Ruby ciphers (the default)
-            if @ssl.ciphers # User ciphers list?
-              ctx.ciphers = @ssl.ciphers # Accept user supplied ciphers
+        	Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do
+          	ssl = OpenSSL::SSL::SSLSocket.new(open_tcp_socket, ctx)
+        	end
+          def ssl.ready?
+            ! @rbuffer.empty? || @io.ready?
+          end
+          ssl.connect
+          if @ssl != true
+            # Pass back results if possible
+            if RUBY_VERSION =~ /1\.8\.[56]/
+              @ssl.verify_result = "N/A for Ruby #{RUBY_VERSION}"
             else
-              ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults
+              @ssl.verify_result = ssl.verify_result
             end
+            @ssl.peer_cert = ssl.peer_cert
           end
-        end
-
-        #
-        ssl = nil
-        if @logger && @logger.respond_to?(:on_ssl_connecting)
-          @logger.on_ssl_connecting(log_params)
-        end
-
-      	Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do
-        	ssl = OpenSSL::SSL::SSLSocket.new(open_tcp_socket, ctx)
-      	end
-        def ssl.ready?
-          ! @rbuffer.empty? || @io.ready?
-        end
-        ssl.connect
-        if @ssl != true
-          # Pass back results if possible
-          if RUBY_VERSION =~ /1\.8\.[56]/
-            @ssl.verify_result = "N/A for Ruby #{RUBY_VERSION}"
-          else
-            @ssl.verify_result = ssl.verify_result
+          if @logger && @logger.respond_to?(:on_ssl_connected)
+            @logger.on_ssl_connected(log_params)
           end
-          @ssl.peer_cert = ssl.peer_cert
-        end
-        if @logger && @logger.respond_to?(:on_ssl_connected)
-          @logger.on_ssl_connected(log_params)
+          ssl
+        rescue Exception => ex
+          if @logger && @logger.respond_to?(:on_ssl_connectfail)
+            lp = log_params.clone
+            lp[:ssl_exception] = ex
+            @logger.on_ssl_connectfail(lp)
+          end
+          #
+          raise # Reraise
         end
-        ssl
       end
 
       def close_socket
diff --git a/lib/stomp/constants.rb b/lib/stomp/constants.rb
index 5feaedf..5183565 100644
--- a/lib/stomp/constants.rb
+++ b/lib/stomp/constants.rb
@@ -25,7 +25,7 @@ module Stomp
 	SPL_10 = "1.0"
 	SPL_11 = "1.1"
 
-  # To be: No 1.1 yet
+  # Stomp 1.0 and 1.1
   SUPPORTED = [SPL_10, SPL_11]
 
   # 1.9 Encoding Name
diff --git a/lib/stomp/errors.rb b/lib/stomp/errors.rb
index 1f80655..e9157f5 100644
--- a/lib/stomp/errors.rb
+++ b/lib/stomp/errors.rb
@@ -104,18 +104,39 @@ module Stomp
       end
     end
 
+    class SSLUnreadableKeyFileError < RuntimeError
+      def message
+        "client key file can not be read"
+      end
+    end
+
     class SSLNoCertFileError < RuntimeError
       def message
         "client cert file does not exist"
       end
     end
 
+    class SSLUnreadableCertFileError < RuntimeError
+      def message
+        "client cert file can not be read"
+      end
+    end
+
     class SSLNoTruststoreFileError < RuntimeError
       def message
         "a client truststore file does not exist"
       end
     end
 
+    class SSLUnreadableTruststoreFileError < RuntimeError
+      def message
+        "a client truststore file can not be read"
+      end
+    end
+
+    class LoggerConnectionError < RuntimeError
+    end
+
   end # module Error
 end # module Stomp
 
diff --git a/lib/stomp/sslparams.rb b/lib/stomp/sslparams.rb
index baec954..40cded9 100644
--- a/lib/stomp/sslparams.rb
+++ b/lib/stomp/sslparams.rb
@@ -1,50 +1,69 @@
-# -*- encoding: utf-8 -*-
+#  -*-  encoding:  utf-8  -*-
 
-module Stomp
-  #
-  # == Purpose
-  #
-  # Parameters for STOMP ssl connections.
-  #
-  class SSLParams
-    # The trust store files.  Normally the certificate of the CA that signed
-    # the server's certificate.  One file name, or a CSV list of file names.
-    attr_accessor :ts_files
-    # The client certificate file.
-    attr_accessor :cert_file
-    # The client private key file.
-    attr_accessor :key_file
-    # SSL Connect Verify Result.  The result of the handshake.
-    attr_accessor :verify_result
-    # The certificate of the connection peer (the server), received during
-    # the handshake.
-    attr_accessor :peer_cert
-    # Optional list of SSL ciphers to be used.  In the format documented for
-    # Ruby's OpenSSL.
-    attr_accessor :ciphers
-    # Abcolute command to use Ruby default ciphers
-    attr_reader :use_ruby_ciphers
-    # Back reference to the OpenSSL::SSL::SSLContext instance, gem sets before connect
-    attr_accessor :ctx # Set by the gem during connect, before the callbacks
+module  Stomp
     #
-    def initialize(opts={})
+    #  ==  Purpose
+    #
+    #  Parameters  for  STOMP  ssl  connections.
+    #
+    class  SSLParams
+        #  The  trust  store  files.    Normally  the  certificate  of  the  CA  that  signed
+        #  the  server's  certificate.    One  file  name,  or  a  CSV  list  of  file  names.
+        attr_accessor  :ts_files
+        #  The  client  certificate  file.
+        attr_accessor  :cert_file
+        #  The  client  private  key  file.
+        attr_accessor  :key_file
+        #  SSL  Connect  Verify  Result.    The  result  of  the  handshake.
+        attr_accessor  :verify_result
+        #  The  certificate  of  the  connection  peer  (the  server),  received  during
+        #  the  handshake.
+        attr_accessor  :peer_cert
+        #  Optional  list  of  SSL  ciphers  to  be  used.    In  the  format  documented  for
+        #  Ruby's  OpenSSL.
+        attr_accessor  :ciphers
+        #  Abcolute  command  to  use  Ruby  default  ciphers
+        attr_reader  :use_ruby_ciphers
+        #  Back  reference  to  the  OpenSSL::SSL::SSLContext  instance,  gem  sets  before  connect
+        attr_accessor  :ctx  #  Set  by  the  gem  during  connect,  before  the  callbacks
+        # Client  wants  file  existance  check  now. true/value or false/nil
+        attr_reader  :fsck  #
+        #
+        def  initialize(opts={})
 
-      # Server authentication parameters
-      @ts_files = opts[:ts_files]   # A trust store file, normally a CA's cert
-      # or a CSV list of cert file names
+          #  Server  authentication  parameters
+          @ts_files  =  opts[:ts_files]      #  A  trust  store  file,  normally  a  CA's  cert
+          #  or  a  CSV  list  of  cert  file  names
 
-      # Client authentication parameters
-      @cert_file = opts[:cert_file]         # Client cert
-      @key_file = opts[:key_file]           # Client key
-      #
-      raise Stomp::Error::SSLClientParamsError if @cert_file.nil? && !@key_file.nil?
-      raise Stomp::Error::SSLClientParamsError if !@cert_file.nil? && @key_file.nil?
-      #
-      @ciphers = opts[:ciphers]
-      @use_ruby_ciphers = opts[:use_ruby_ciphers] ? opts[:use_ruby_ciphers] : false
-      #
-    end
-  end # of class SSLParams
+          #  Client  authentication  parameters
+          @cert_file  =  opts[:cert_file]                  #  Client  cert
+          @key_file  =  opts[:key_file]                      #  Client  key
+          #
+          raise  Stomp::Error::SSLClientParamsError if @cert_file.nil?  &&  !@key_file.nil?
+          raise  Stomp::Error::SSLClientParamsError if !@cert_file.nil?  &&  @key_file.nil?
+          #
+          @ciphers  =  opts[:ciphers]
+          @use_ruby_ciphers  =  opts[:use_ruby_ciphers]  ?  opts[:use_ruby_ciphers]  :  false
+          #
+          if  opts[:fsck]
+            if  @cert_file
+              raise  Stomp::Error::SSLNoCertFileError if !File::exists?(@cert_file)
+              raise  Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@cert_file)
+            end
+            if  @key_file
+              raise  Stomp::Error::SSLNoKeyFileError if !File::exists?(@key_file)
+              raise  Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@key_file)
+            end
+            if  @ts_files
+              tsa  =  @ts_files.split(",")
+              tsa.each  do  |fn|
+                raise  Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)
+                raise  Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)
+              end
+            end
+          end
+        end
+    end  #  of  class  SSLParams
 
-end # of module Stomp
+end  #  of  module  Stomp
 
diff --git a/lib/stomp/version.rb b/lib/stomp/version.rb
index afdaf71..ce3b2ff 100644
--- a/lib/stomp/version.rb
+++ b/lib/stomp/version.rb
@@ -4,7 +4,7 @@ module Stomp
   module Version  #:nodoc: all
     MAJOR = 1
     MINOR = 2
-    PATCH = 1
+    PATCH = 2
     STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
   end
 end
diff --git a/metadata.yml b/metadata.yml
index 91319b9..7f1d4c6 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,13 +1,13 @@
 --- !ruby/object:Gem::Specification 
 name: stomp
 version: !ruby/object:Gem::Version 
-  hash: 29
+  hash: 27
   prerelease: false
   segments: 
   - 1
   - 2
-  - 1
-  version: 1.2.1
+  - 2
+  version: 1.2.2
 platform: ruby
 authors: 
 - Brian McCallister
@@ -18,7 +18,7 @@ autorequire:
 bindir: bin
 cert_chain: []
 
-date: 2012-03-13 00:00:00 -04:00
+date: 2012-03-24 00:00:00 -04:00
 default_executable: 
 dependencies: 
 - !ruby/object:Gem::Dependency 
diff --git a/stomp.gemspec b/stomp.gemspec
index 6cf7f85..0834d2f 100644
--- a/stomp.gemspec
+++ b/stomp.gemspec
@@ -5,11 +5,11 @@
 
 Gem::Specification.new do |s|
   s.name = %q{stomp}
-  s.version = "1.2.1"
+  s.version = "1.2.2"
 
   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"]
-  s.date = %q{2012-03-13}
+  s.date = %q{2012-03-24}
   s.description = %q{Ruby client for the Stomp messaging protocol.  Note that this gem is no longer supported on rubyforge.}
   s.email = ["brianm at apache.org", "marius at stones.com", "morellon at gmail.com", "allard.guy.m at gmail.com"]
   s.executables = ["catstomp", "stompcat"]
diff --git a/test/test_connection.rb b/test/test_connection.rb
index b16f86f..e5c4b0d 100644
--- a/test/test_connection.rb
+++ b/test/test_connection.rb
@@ -23,7 +23,7 @@ class TestConnection < Test::Unit::TestCase
   end
 
   def test_poll_async
-    @conn.subscribe("/queue/do.not.put.messages.on.this.queue")
+    @conn.subscribe("/queue/do.not.put.messages.on.this.queue", :id => "a.no.messages.queue")
     # If the test 'hangs' here, Connection#poll is broken.
     m = @conn.poll
     assert m.nil?
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8d52d81..407f66a 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -56,8 +56,9 @@ module TestBase
 
   def get_ssl_connection()
     ch = get_conn_headers()
+    ssl_params = Stomp::SSLParams.new # S/B safe for all Ruby versions tested
     hash = { :hosts => [ 
-      {:login => user, :passcode => passcode, :host => host, :port => ssl_port, :ssl => true},
+      {:login => user, :passcode => passcode, :host => host, :port => ssl_port, :ssl => ssl_params},
       ],
       :connect_headers => ch
     }
diff --git a/test/test_ssl.rb b/test/test_ssl.rb
index 4e03703..6992f52 100644
--- a/test/test_ssl.rb
+++ b/test/test_ssl.rb
@@ -12,7 +12,7 @@ class TestSSL < Test::Unit::TestCase
   end
 
   def teardown
-    @conn.disconnect if @conn.open? # allow tests to disconnect
+    @conn.disconnect if @conn && @conn.open? # allow tests to disconnect
   end
   #
   def test_ssl_0000
@@ -20,29 +20,50 @@ class TestSSL < Test::Unit::TestCase
   end
 
   #
-  def test_ssl_0010
+  def test_ssl_0010_parms
     ssl_params = Stomp::SSLParams.new
     assert ssl_params.ts_files.nil?
     assert ssl_params.cert_file.nil?
     assert ssl_params.key_file.nil?
+    assert ssl_params.fsck.nil?
   end
 
   #
-  def test_ssl_0020
+  def test_ssl_0020_noraise
+    assert_nothing_raised {
+      ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1", :key_file => "dummy2")
+    }
+    assert_nothing_raised {
+      ssl_parms = Stomp::SSLParams.new(:ts_files => "dummyts1")
+    }
+    assert_nothing_raised {
+      ssl_parms = Stomp::SSLParams.new(:ts_files => "dummyts1", 
+        :cert_file => "dummy1", :key_file => "dummy2")
+    }
+  end
+  #
+  def test_ssl_0030_raise
     assert_raise(Stomp::Error::SSLClientParamsError) {
       ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1")
     }
     assert_raise(Stomp::Error::SSLClientParamsError) {
       ssl_parms = Stomp::SSLParams.new(:key_file => "dummy2")
     }
-    assert_nothing_raised {
-      ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1", :key_file => "dummy2")
+  end
+
+  #
+  def test_ssl_0040_fsck
+    assert_raise(Stomp::Error::SSLNoCertFileError) {
+      ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1", 
+        :key_file => "dummy2", :fsck => true)
     }
-    assert_nothing_raised {
-      ssl_parms = Stomp::SSLParams.new(:ts_files => "dummyts1")
+    assert_raise(Stomp::Error::SSLNoKeyFileError) {
+      ssl_parms = Stomp::SSLParams.new(:cert_file => __FILE__,
+        :key_file => "dummy2", :fsck => true)
     }
-    assert_nothing_raised {
-      ssl_parms = Stomp::SSLParams.new(:ts_files => "dummyts1", :cert_file => "dummy1", :key_file => "dummy2")
+    assert_raise(Stomp::Error::SSLNoTruststoreFileError) {
+      ssl_parms = Stomp::SSLParams.new(:ts_files => "/tmp/not-likely-here.txt", 
+        :fsck => true)
     }
   end
 

-- 
ruby-stomp.git



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