seanohalpin-smqueue 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +15 -0
- data/README.txt +72 -0
- data/Rakefile +26 -0
- data/examples/input.rb +14 -0
- data/examples/message_queue.yml +29 -0
- data/examples/output.rb +11 -0
- data/lib/rstomp.rb +582 -0
- data/lib/smqueue.rb +227 -0
- data/lib/smqueue/adapters/spread.rb +101 -0
- data/lib/smqueue/adapters/stdio.rb +59 -0
- data/lib/smqueue/adapters/stomp.rb +291 -0
- data/smqueue.gemspec +31 -0
- data/test/helper.rb +23 -0
- data/test/test_rstomp_connection.rb +56 -0
- metadata +77 -0
    
        data/smqueue.gemspec
    ADDED
    
    | @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            Gem::Specification.new do |s|
         | 
| 2 | 
            +
              s.name     = "smqueue"
         | 
| 3 | 
            +
              s.version  = "0.1.0"
         | 
| 4 | 
            +
              s.summary  = "Simple Message Queue"
         | 
| 5 | 
            +
              s.email    = 'http://github.com/seanohalpin/smqueue'
         | 
| 6 | 
            +
              s.homepage = 'http://github.com/seanohalpin/smqueue'
         | 
| 7 | 
            +
              s.description = "Implements a simple protocol for using message queues, with adapters
         | 
| 8 | 
            +
              for ActiveMQ, Spread and stdio (for testing)."
         | 
| 9 | 
            +
              s.authors  = ["Sean O'Halpin", "Chris O'Sullivan", "Craig Webster"]
         | 
| 10 | 
            +
              s.files    =
         | 
| 11 | 
            +
                [
         | 
| 12 | 
            +
                 "History.txt",
         | 
| 13 | 
            +
                 "Manifest.txt",
         | 
| 14 | 
            +
                 "README.txt",
         | 
| 15 | 
            +
                 "Rakefile",
         | 
| 16 | 
            +
                 "examples/input.rb",
         | 
| 17 | 
            +
                 "examples/message_queue.yml",
         | 
| 18 | 
            +
                 "examples/output.rb",
         | 
| 19 | 
            +
                 "lib/rstomp.rb",
         | 
| 20 | 
            +
                 "lib/smqueue.rb",
         | 
| 21 | 
            +
                 "lib/smqueue/adapters/spread.rb",
         | 
| 22 | 
            +
                 "lib/smqueue/adapters/stdio.rb",
         | 
| 23 | 
            +
                 "lib/smqueue/adapters/stomp.rb",
         | 
| 24 | 
            +
                 "smqueue.gemspec",
         | 
| 25 | 
            +
                 "test/helper.rb",
         | 
| 26 | 
            +
                 "test/test_rstomp_connection.rb",
         | 
| 27 | 
            +
                ]
         | 
| 28 | 
            +
              s.test_files = ["test/test_rstomp_connection.rb"]
         | 
| 29 | 
            +
              s.add_dependency("doodle", [">= 0.1.9"])
         | 
| 30 | 
            +
              s.rubyforge_project = 'smqueue'
         | 
| 31 | 
            +
            end
         | 
    
        data/test/helper.rb
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            require 'test/unit'
         | 
| 3 | 
            +
            require 'mocha'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'smqueue'
         | 
| 6 | 
            +
            require 'rstomp'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module ReadableTestNames
         | 
| 9 | 
            +
              def test(name, &block)
         | 
| 10 | 
            +
                test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
         | 
| 11 | 
            +
                defined = instance_method(test_name) rescue false
         | 
| 12 | 
            +
                raise "#{test_name} is already defined in #{self}" if defined
         | 
| 13 | 
            +
                if block_given?
         | 
| 14 | 
            +
                  define_method(test_name, &block)
         | 
| 15 | 
            +
                else
         | 
| 16 | 
            +
                  define_method(test_name) do
         | 
| 17 | 
            +
                    flunk "No implementation provided for #{name}"
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Test::Unit::TestCase.send(:extend, ReadableTestNames)
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestRStompConnection < Test::Unit::TestCase
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              # Tests to see if when a primary queue falls over whether it rollsover to use the secondary.
         | 
| 6 | 
            +
              test "if primary queue fails should rollover to secondary" do
         | 
| 7 | 
            +
                TCPSocket.expects(:open).with("localhost", 61613).raises RStomp::RStompException
         | 
| 8 | 
            +
                TCPSocket.expects(:open).with("secondary", 1234).returns true
         | 
| 9 | 
            +
                
         | 
| 10 | 
            +
                stub_connection_calls_to_queue
         | 
| 11 | 
            +
                SMQueue.new(:configuration => YAML.load(configuration)).connect
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              # Tests to see if when a primary queue falls over whether it rollsover to use the secondary even for unreliable queues.
         | 
| 15 | 
            +
              test "if primary queue fails should rollover to secondary even if the queue is unreliable" do
         | 
| 16 | 
            +
                TCPSocket.expects(:open).with("localhost", 61613).raises RStomp::RStompException
         | 
| 17 | 
            +
                TCPSocket.expects(:open).with("secondary", 1234).returns true
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                stub_connection_calls_to_queue
         | 
| 20 | 
            +
                SMQueue.new(:configuration => YAML.load(configuration)).connect
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              test "multiple calls to connect should swap hosts and ports appropriately" do
         | 
| 24 | 
            +
                TCPSocket.expects(:open).with("localhost", 61613).raises(RStomp::RStompException).once
         | 
| 25 | 
            +
                TCPSocket.expects(:open).with("secondary", 1234).returns(true).at_least(2)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                stub_connection_calls_to_queue
         | 
| 28 | 
            +
                queue = SMQueue.new(:configuration => YAML.load(configuration))
         | 
| 29 | 
            +
                2.times { queue.connect }
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
            private
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              def configuration
         | 
| 35 | 
            +
                  yaml = %[
         | 
| 36 | 
            +
                :adapter: :StompAdapter
         | 
| 37 | 
            +
                :host: localhost
         | 
| 38 | 
            +
                :port: 61613
         | 
| 39 | 
            +
                :secondary_host: secondary
         | 
| 40 | 
            +
                :secondary_port: 1234
         | 
| 41 | 
            +
                :name: /topic/smput.test
         | 
| 42 | 
            +
                :reliable: true
         | 
| 43 | 
            +
                :reconnect_delay: 5
         | 
| 44 | 
            +
                :subscription_name: test_stomp
         | 
| 45 | 
            +
                :client_id: hello_from_stomp_adapter
         | 
| 46 | 
            +
                :durable: false
         | 
| 47 | 
            +
                ]
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
              
         | 
| 50 | 
            +
              def stub_connection_calls_to_queue
         | 
| 51 | 
            +
                RStomp::Connection.any_instance.stubs(:_transmit).returns true
         | 
| 52 | 
            +
                RStomp::Connection.any_instance.stubs(:_receive).returns true
         | 
| 53 | 
            +
                RStomp::Connection.any_instance.stubs(:sleep)    
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
              
         | 
| 56 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,77 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: seanohalpin-smqueue
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors: 
         | 
| 7 | 
            +
            - Sean O'Halpin
         | 
| 8 | 
            +
            - Chris O'Sullivan
         | 
| 9 | 
            +
            - Craig Webster
         | 
| 10 | 
            +
            autorequire: 
         | 
| 11 | 
            +
            bindir: bin
         | 
| 12 | 
            +
            cert_chain: []
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            date: 2009-01-11 00:00:00 -08:00
         | 
| 15 | 
            +
            default_executable: 
         | 
| 16 | 
            +
            dependencies: 
         | 
| 17 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 18 | 
            +
              name: doodle
         | 
| 19 | 
            +
              version_requirement: 
         | 
| 20 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 21 | 
            +
                requirements: 
         | 
| 22 | 
            +
                - - ">="
         | 
| 23 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 24 | 
            +
                    version: 0.1.9
         | 
| 25 | 
            +
                version: 
         | 
| 26 | 
            +
            description: Implements a simple protocol for using message queues, with adapters for ActiveMQ, Spread and stdio (for testing).
         | 
| 27 | 
            +
            email: http://github.com/seanohalpin/smqueue
         | 
| 28 | 
            +
            executables: []
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            extensions: []
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            extra_rdoc_files: []
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            files: 
         | 
| 35 | 
            +
            - History.txt
         | 
| 36 | 
            +
            - Manifest.txt
         | 
| 37 | 
            +
            - README.txt
         | 
| 38 | 
            +
            - Rakefile
         | 
| 39 | 
            +
            - examples/input.rb
         | 
| 40 | 
            +
            - examples/message_queue.yml
         | 
| 41 | 
            +
            - examples/output.rb
         | 
| 42 | 
            +
            - lib/rstomp.rb
         | 
| 43 | 
            +
            - lib/smqueue.rb
         | 
| 44 | 
            +
            - lib/smqueue/adapters/spread.rb
         | 
| 45 | 
            +
            - lib/smqueue/adapters/stdio.rb
         | 
| 46 | 
            +
            - lib/smqueue/adapters/stomp.rb
         | 
| 47 | 
            +
            - smqueue.gemspec
         | 
| 48 | 
            +
            - test/helper.rb
         | 
| 49 | 
            +
            - test/test_rstomp_connection.rb
         | 
| 50 | 
            +
            has_rdoc: false
         | 
| 51 | 
            +
            homepage: http://github.com/seanohalpin/smqueue
         | 
| 52 | 
            +
            post_install_message: 
         | 
| 53 | 
            +
            rdoc_options: []
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            require_paths: 
         | 
| 56 | 
            +
            - lib
         | 
| 57 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 58 | 
            +
              requirements: 
         | 
| 59 | 
            +
              - - ">="
         | 
| 60 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 61 | 
            +
                  version: "0"
         | 
| 62 | 
            +
              version: 
         | 
| 63 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 64 | 
            +
              requirements: 
         | 
| 65 | 
            +
              - - ">="
         | 
| 66 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 67 | 
            +
                  version: "0"
         | 
| 68 | 
            +
              version: 
         | 
| 69 | 
            +
            requirements: []
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            rubyforge_project: smqueue
         | 
| 72 | 
            +
            rubygems_version: 1.2.0
         | 
| 73 | 
            +
            signing_key: 
         | 
| 74 | 
            +
            specification_version: 2
         | 
| 75 | 
            +
            summary: Simple Message Queue
         | 
| 76 | 
            +
            test_files: 
         | 
| 77 | 
            +
            - test/test_rstomp_connection.rb
         |