thechrisoshow-smqueue 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/smqueue.gemspec ADDED
@@ -0,0 +1,24 @@
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"]
10
+ s.files = ["History.txt",
11
+ "Manifest.txt",
12
+ "README.txt",
13
+ "Rakefile",
14
+ "smqueue.gemspec",
15
+ "lib/rstomp.rb",
16
+ "lib/smqueue.rb",
17
+ "lib/smqueue/adapters/spread.rb",
18
+ "lib/smqueue/adapters/stdio.rb",
19
+ "lib/smqueue/adapters/stomp.rb"
20
+ ]
21
+ s.test_files = ["test/test_rstomp_connection.rb"]
22
+ s.add_dependency("doodle", [">= 0.1.9"])
23
+ s.rubyforge_project = 'smqueue'
24
+ end
@@ -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,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thechrisoshow-smqueue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean O'Halpin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-15 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: doodle
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.1.9
23
+ version:
24
+ description: Implements a simple protocol for using message queues, with adapters for ActiveMQ, Spread and stdio (for testing).
25
+ email: http://github.com/seanohalpin/smqueue
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - README.txt
36
+ - Rakefile
37
+ - smqueue.gemspec
38
+ - lib/rstomp.rb
39
+ - lib/smqueue.rb
40
+ - lib/smqueue/adapters/spread.rb
41
+ - lib/smqueue/adapters/stdio.rb
42
+ - lib/smqueue/adapters/stomp.rb
43
+ has_rdoc: false
44
+ homepage: http://github.com/seanohalpin/smqueue
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ requirements: []
63
+
64
+ rubyforge_project: smqueue
65
+ rubygems_version: 1.2.0
66
+ signing_key:
67
+ specification_version: 2
68
+ summary: Simple Message Queue
69
+ test_files:
70
+ - test/test_rstomp_connection.rb