amqp 0.7.1 → 0.7.2

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.
@@ -8,7 +8,7 @@ describe AMQP do
8
8
  # Environment
9
9
  #
10
10
 
11
- include AMQP::Spec
11
+ include EventedSpec::AMQPSpec
12
12
 
13
13
  default_timeout 5
14
14
 
@@ -28,15 +28,15 @@ describe AMQP do
28
28
  it "declares a new queue with that name" do
29
29
  queue = @channel.queue(name)
30
30
  queue.name.should == name
31
-
32
- done
31
+ queue.delete
32
+ done(0.2)
33
33
  end
34
34
 
35
35
  it "caches that queue" do
36
36
  queue = @channel.queue(name)
37
37
  @channel.queue(name).object_id.should == queue.object_id
38
-
39
- done
38
+ queue.delete
39
+ done(0.2)
40
40
  end
41
41
  end # context
42
42
 
@@ -44,7 +44,8 @@ describe AMQP do
44
44
  it "uses server-assigned queue name" do
45
45
  @channel.queue("") do |queue, *args|
46
46
  queue.name.should_not be_empty
47
- done
47
+ queue.delete
48
+ done(0.2)
48
49
  end
49
50
  end
50
51
  end # context
@@ -53,25 +54,26 @@ describe AMQP do
53
54
 
54
55
 
55
56
  context "when passive option is used" do
56
- context "and exchange with given name already exists" do
57
+ context "and queue with given name already exists" do
57
58
  it "silently returns" do
58
59
  name = "a_new_queue declared at #{Time.now.to_i}"
59
60
 
60
- original_exchange = @channel.queue(name)
61
- exchange = @channel.queue(name, :passive => true)
61
+ original_queue = @channel.queue(name)
62
+ queue = @channel.queue(name, :passive => true)
62
63
 
63
- exchange.should == original_exchange
64
+ queue.should == original_queue
64
65
 
65
- done
66
+ queue.delete
67
+ done(0.3)
66
68
  end # it
67
69
  end
68
70
 
69
- context "and exchange with given name DOES NOT exist" do
71
+ context "and queue with given name DOES NOT exist" do
70
72
  it "raises an exception" do
71
73
  pending "Not yet supported"
72
74
 
73
75
  expect {
74
- exchange = @channel.queue("queue declared at #{Time.now.to_i}", :passive => true)
76
+ queue = @channel.queue("queue declared at #{Time.now.to_i}", :passive => true)
75
77
  }.to raise_error
76
78
 
77
79
  done
@@ -84,13 +86,14 @@ describe AMQP do
84
86
 
85
87
  context "when queue is re-declared with parameters different from original declaration" do
86
88
  it "raises an exception" do
87
- @channel.queue("previously.declared.durable.queue", :durable => true)
89
+ queue = @channel.queue("previously.declared.durable.queue", :durable => true)
88
90
 
89
91
  expect {
90
92
  @channel.queue("previously.declared.durable.queue", :durable => false)
91
93
  }.to raise_error(AMQP::IncompatibleOptionsError)
92
94
 
93
- done
95
+ queue.delete
96
+ done(0.2)
94
97
  end # it
95
98
  end # context
96
99
  end # describe
@@ -8,7 +8,7 @@ describe "Non-exclusive queue" do
8
8
  # Environment
9
9
  #
10
10
 
11
- include AMQP::Spec
11
+ include EventedSpec::AMQPSpec
12
12
 
13
13
  default_timeout 5
14
14
 
@@ -60,9 +60,9 @@ describe "Exclusive queue" do
60
60
  # Environment
61
61
  #
62
62
 
63
- include AMQP::Spec
63
+ include EventedSpec::AMQPSpec
64
64
 
65
- default_timeout 1
65
+ default_timeout 3
66
66
 
67
67
  amqp_before do
68
68
  @connection1 = AMQP.connect
@@ -80,16 +80,18 @@ describe "Exclusive queue" do
80
80
  channel1 = AMQP::Channel.new(@connection1)
81
81
  channel2 = AMQP::Channel.new(@connection2)
82
82
 
83
- AMQP::Queue.new(channel1, "amqpgem.integration.queues.exclusive", :exclusive => true)
84
- sleep 0.1
83
+ AMQP::Queue.new(channel1, "amqpgem.integration.queues.exclusive", :exclusive => true, :auto_delete => true)
85
84
 
86
- AMQP::Queue.new(channel2, "amqpgem.integration.queues.exclusive", :exclusive => true)
87
-
85
+ EventMachine.add_timer(1.0) do
86
+ AMQP::Queue.new(channel2, "amqpgem.integration.queues.exclusive", :exclusive => true, :auto_delete => true)
87
+ end
88
88
 
89
- done(0.2) {
90
- channel1.should_not be_closed
91
- # because it is a channel-level exception
92
- channel2.should be_closed
93
- }
89
+ EventMachine.add_timer(1.3) do
90
+ done(0.5) {
91
+ channel1.should_not be_closed
92
+ # because it is a channel-level exception
93
+ channel2.should be_closed
94
+ }
95
+ end
94
96
  end
95
97
  end
@@ -7,7 +7,7 @@ describe "Exclusive server-named queue" do
7
7
  # Environment
8
8
  #
9
9
 
10
- include AMQP::Spec
10
+ include EventedSpec::AMQPSpec
11
11
 
12
12
  default_timeout 1
13
13
 
@@ -57,7 +57,7 @@ describe "Exclusive server-named queue" do
57
57
  queue1.unsubscribe
58
58
  queue2.unsubscribe
59
59
  }
60
- end # do
60
+ end # do
61
61
  end # do
62
62
  end # it
63
63
  end # describe
@@ -7,8 +7,7 @@ describe "Store-and-forward routing" do
7
7
  # Environment
8
8
  #
9
9
 
10
- include AMQP::Spec
11
- include AMQP::SpecHelper
10
+ include EventedSpec::AMQPSpec
12
11
 
13
12
  em_before { AMQP.cleanup_state }
14
13
  em_after { AMQP.cleanup_state }
@@ -112,7 +111,8 @@ describe "Store-and-forward routing" do
112
111
  end # pop
113
112
  end # do
114
113
 
115
- done(0.5) {
114
+ delayed(0.9) { @queue.delete }
115
+ done(0.8) {
116
116
  number_of_received_messages.should == expected_number_of_messages
117
117
  }
118
118
  end # it
@@ -7,8 +7,7 @@ describe "Topic-based subscription" do
7
7
  # Environment
8
8
  #
9
9
 
10
- include AMQP::Spec
11
- include AMQP::SpecHelper
10
+ include EventedSpec::AMQPSpec
12
11
 
13
12
  em_before { AMQP.cleanup_state }
14
13
  em_after { AMQP.cleanup_state }
@@ -7,8 +7,7 @@ describe "Workload distribution" do
7
7
  # Environment
8
8
  #
9
9
 
10
- include AMQP::Spec
11
- include AMQP::SpecHelper
10
+ include EventedSpec::AMQPSpec
12
11
 
13
12
  em_before { AMQP.cleanup_state }
14
13
  em_after { AMQP.cleanup_state }
@@ -6,8 +6,8 @@ require 'bundler'
6
6
  Bundler.setup
7
7
  Bundler.require :default, :test
8
8
 
9
- require "amqp-spec"
10
9
  require "amqp"
10
+ require "evented-spec"
11
11
 
12
12
  amqp_config = File.dirname(__FILE__) + '/amqp.yml'
13
13
 
@@ -24,7 +24,7 @@ if File.exists? amqp_config
24
24
  end
25
25
  AMQP_OPTS = YAML::load_file(amqp_config).symbolize_keys[:test]
26
26
  else
27
- AMQP_OPTS = {:host => 'localhost', :port => 5672}
27
+ AMQP_OPTS = {:host => 'localhost', :port => 5672, :username => "guest", :password => "guest", :vhost => "/"}
28
28
  end
29
29
 
30
30
  #
@@ -78,3 +78,8 @@ def test_method_deliver opts = {}
78
78
  AMQP::Protocol::Basic::Deliver.new(
79
79
  :consumer_tag => opts[:consumer_tag] || 'test_consumer'))
80
80
  end
81
+
82
+ def delayed(timeout, &block)
83
+ instance = self
84
+ EM.add_timer(timeout) { instance.instance_eval(&block) }
85
+ end # delayed
@@ -8,7 +8,7 @@ describe AMQP do
8
8
  # Environment
9
9
  #
10
10
 
11
- include AMQP::Spec
11
+ include EventedSpec::AMQPSpec
12
12
 
13
13
  default_timeout 5
14
14
 
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe AMQP::Client do
6
+
7
+ #
8
+ # Examples
9
+ #
10
+
11
+
12
+ describe ".parse_connection_uri(connection_string)" do
13
+ context "when schema is not one of [amqp, amqps]" do
14
+ it "raises ArgumentError" do
15
+ expect {
16
+ described_class.parse_connection_uri("http://dev.rabbitmq.com")
17
+ }.to raise_error(ArgumentError, /amqp or amqps schema/)
18
+ end
19
+ end
20
+
21
+
22
+ it "handles amqp:// URIs w/o path part" do
23
+ val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com")
24
+
25
+ val[:vhost].should be_nil # in this case, default / will be used
26
+ val[:host].should == "dev.rabbitmq.com"
27
+ val[:port].should == 5672
28
+ val[:scheme].should == "amqp"
29
+ val[:ssl].should be_false
30
+ end
31
+
32
+ it "handles amqps:// URIs w/o path part" do
33
+ val = described_class.parse_connection_uri("amqps://dev.rabbitmq.com")
34
+
35
+ val[:vhost].should be_nil
36
+ val[:host].should == "dev.rabbitmq.com"
37
+ val[:port].should == 5671
38
+ val[:scheme].should == "amqps"
39
+ val[:ssl].should be_true
40
+ end
41
+
42
+
43
+ context "when URI ends in a slash" do
44
+ it "parses vhost as an empty string" do
45
+ val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com/")
46
+
47
+ val[:host].should == "dev.rabbitmq.com"
48
+ val[:port].should == 5672
49
+ val[:scheme].should == "amqp"
50
+ val[:ssl].should be_false
51
+ val[:vhost].should == ""
52
+ end
53
+ end
54
+
55
+
56
+ context "when URI ends in /%2Fvault" do
57
+ it "parses vhost as /vault" do
58
+ val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com/%2Fvault")
59
+
60
+ val[:host].should == "dev.rabbitmq.com"
61
+ val[:port].should == 5672
62
+ val[:scheme].should == "amqp"
63
+ val[:ssl].should be_false
64
+ val[:vhost].should == "/vault"
65
+ end
66
+ end
67
+
68
+
69
+ context "when URI is amqp://dev.rabbitmq.com/a.path.without.slashes" do
70
+ it "parses vhost as a.path.without.slashes" do
71
+ val = described_class.parse_connection_uri("amqp://dev.rabbitmq.com/a.path.without.slashes")
72
+
73
+ val[:host].should == "dev.rabbitmq.com"
74
+ val[:port].should == 5672
75
+ val[:scheme].should == "amqp"
76
+ val[:ssl].should be_false
77
+ val[:vhost].should == "a.path.without.slashes"
78
+ end
79
+ end
80
+
81
+ context "when URI is amqp://dev.rabbitmq.com/a/path/with/slashes" do
82
+ it "raises an ArgumentError" do
83
+ lambda { described_class.parse_connection_uri("amqp://dev.rabbitmq.com/a/path/with/slashes") }.should raise_error(ArgumentError)
84
+ end
85
+ end
86
+
87
+
88
+ context "when URI has username:password, for instance, amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal" do
89
+ it "parses them out" do
90
+ val = described_class.parse_connection_uri("amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal")
91
+
92
+ val[:host].should == "hub.megacorp.internal"
93
+ val[:port].should == 5672
94
+ val[:scheme].should == "amqp"
95
+ val[:ssl].should be_false
96
+ val[:user].should == "hedgehog"
97
+ val[:pass].should == "t0ps3kr3t"
98
+ val[:vhost].should be_nil # in this case, default / will be used
99
+ end
100
+ end
101
+ end
102
+ end
@@ -50,7 +50,7 @@ describe AMQP, 'class object' do
50
50
  # Environment
51
51
  #
52
52
 
53
- include AMQP::SpecHelper
53
+ include EventedSpec::SpecHelper
54
54
 
55
55
  em_before { AMQP.cleanup_state }
56
56
  em_after { AMQP.cleanup_state }
@@ -65,6 +65,8 @@ describe AMQP, 'class object' do
65
65
  @block_fired = true
66
66
 
67
67
  AMQP.connection.should be_connected
68
+ AMQP.channel.should_not be_nil
69
+ AMQP.channel.connection.should == AMQP.connection
68
70
  end
69
71
  done(0.1) { @block_fired.should be_true }
70
72
  end
@@ -89,7 +91,7 @@ describe AMQP, 'class object' do
89
91
  #
90
92
  #
91
93
 
92
- include AMQP::Spec
94
+ include EventedSpec::AMQPSpec
93
95
  after { AMQP.cleanup_state; done }
94
96
  default_options AMQP_OPTS
95
97
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amqp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
- prerelease: false
4
+ hash: 7
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aman Gupta
@@ -15,8 +15,9 @@ authors:
15
15
  - Michael S. Klishin
16
16
  autorequire:
17
17
  bindir: bin
18
- cert_chain:
19
- date: 2011-03-18 00:00:00 +03:00
18
+ cert_chain: []
19
+
20
+ date: 2011-07-18 00:00:00 +04:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
@@ -27,15 +28,13 @@ dependencies:
27
28
  requirements:
28
29
  - - ">="
29
30
  - !ruby/object:Gem::Version
30
- hash: 39
31
+ hash: 3
31
32
  segments:
32
33
  - 0
33
- - 12
34
- - 4
35
- version: 0.12.4
34
+ version: "0"
36
35
  type: :runtime
37
36
  version_requirements: *id001
38
- description: An implementation of the AMQP protocol in Ruby/EventMachine for writing clients to the RabbitMQ message broker.
37
+ description: Asynchronous AMQP 0.9.1 client for Ruby. Built on top of Eventmachine.
39
38
  email:
40
39
  - michael@novemberain.com
41
40
  - stastny@101ideas.cz
@@ -45,6 +44,9 @@ extensions: []
45
44
 
46
45
  extra_rdoc_files:
47
46
  - README.md
47
+ - doc/_index.html
48
+ - doc/AMQP.html
49
+ - doc/class_list.html
48
50
  - doc/EXAMPLE_01_PINGPONG
49
51
  - doc/EXAMPLE_02_CLOCK
50
52
  - doc/EXAMPLE_03_STOCKS
@@ -52,9 +54,35 @@ extra_rdoc_files:
52
54
  - doc/EXAMPLE_05_ACK
53
55
  - doc/EXAMPLE_05_POP
54
56
  - doc/EXAMPLE_06_HASHTABLE
57
+ - doc/file.08Migration.html
58
+ - doc/file.Bindings.html
59
+ - doc/file.CHANGELOG.html
60
+ - doc/file.Clustering.html
61
+ - doc/file.ConnectingToTheBroker.html
62
+ - doc/file.ConnectionEncryptionWithTLS.html
63
+ - doc/file.DocumentationGuidesIndex.html
64
+ - doc/file.Durability.html
65
+ - doc/file.ErrorHandling.html
66
+ - doc/file.Exchanges.html
67
+ - doc/file.GettingStarted.html
68
+ - doc/file.Queues.html
69
+ - doc/file.RabbitMQVersions.html
70
+ - doc/file.README.html
71
+ - doc/file.Routing.html
72
+ - doc/file.RunningTests.html
73
+ - doc/file.TestingWithEventedSpec.html
74
+ - doc/file.Troubleshooting.html
75
+ - doc/file.VendorSpecificExtensions.html
76
+ - doc/file_list.html
77
+ - doc/frames.html
78
+ - doc/index.html
79
+ - doc/method_list.html
80
+ - doc/MQ.html
81
+ - doc/top-level-namespace.html
55
82
  files:
56
83
  - .gitignore
57
84
  - .rspec
85
+ - .travis.yml
58
86
  - CHANGELOG
59
87
  - CONTRIBUTORS
60
88
  - Gemfile
@@ -65,7 +93,6 @@ files:
65
93
  - amqp.pre.gemspec
66
94
  - bin/cleanify.rb
67
95
  - bin/irb
68
- - bin/jenkins.sh
69
96
  - bin/set_test_suite_realms_up.sh
70
97
  - doc/EXAMPLE_01_PINGPONG
71
98
  - doc/EXAMPLE_02_CLOCK
@@ -78,8 +105,11 @@ files:
78
105
  - examples/automatic_binding_for_default_direct_exchange.rb
79
106
  - examples/callbacks.rb
80
107
  - examples/clock.rb
108
+ - examples/default_channel.rb
81
109
  - examples/hashtable.rb
110
+ - examples/immediately_bind_a_server_named_queue.rb
82
111
  - examples/internal.rb
112
+ - examples/issues/issue_75.rb
83
113
  - examples/logger.rb
84
114
  - examples/multiclock.rb
85
115
  - examples/pingpong.rb
@@ -88,6 +118,7 @@ files:
88
118
  - examples/primes.rb
89
119
  - examples/simple.rb
90
120
  - examples/stocks.rb
121
+ - gemfiles/eventmachine-pre
91
122
  - lib/amqp.rb
92
123
  - lib/amqp/basic_client.rb
93
124
  - lib/amqp/buffer.rb
@@ -130,10 +161,39 @@ files:
130
161
  - spec/spec_helper.rb
131
162
  - spec/unit/amqp/basic_spec.rb
132
163
  - spec/unit/amqp/buffer_spec.rb
164
+ - spec/unit/amqp/client_spec.rb
133
165
  - spec/unit/amqp/collection_spec.rb
134
166
  - spec/unit/amqp/connection_spec.rb
135
167
  - spec/unit/amqp/frame_spec.rb
136
168
  - spec/unit/amqp/protocol_spec.rb
169
+ - doc/_index.html
170
+ - doc/AMQP.html
171
+ - doc/class_list.html
172
+ - doc/file.08Migration.html
173
+ - doc/file.Bindings.html
174
+ - doc/file.CHANGELOG.html
175
+ - doc/file.Clustering.html
176
+ - doc/file.ConnectingToTheBroker.html
177
+ - doc/file.ConnectionEncryptionWithTLS.html
178
+ - doc/file.DocumentationGuidesIndex.html
179
+ - doc/file.Durability.html
180
+ - doc/file.ErrorHandling.html
181
+ - doc/file.Exchanges.html
182
+ - doc/file.GettingStarted.html
183
+ - doc/file.Queues.html
184
+ - doc/file.RabbitMQVersions.html
185
+ - doc/file.README.html
186
+ - doc/file.Routing.html
187
+ - doc/file.RunningTests.html
188
+ - doc/file.TestingWithEventedSpec.html
189
+ - doc/file.Troubleshooting.html
190
+ - doc/file.VendorSpecificExtensions.html
191
+ - doc/file_list.html
192
+ - doc/frames.html
193
+ - doc/index.html
194
+ - doc/method_list.html
195
+ - doc/MQ.html
196
+ - doc/top-level-namespace.html
137
197
  has_rdoc: true
138
198
  homepage: http://github.com/ruby-amqp/amqp
139
199
  licenses: []
@@ -164,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
224
  requirements: []
165
225
 
166
226
  rubyforge_project: amqp
167
- rubygems_version: 1.3.7
227
+ rubygems_version: 1.6.2
168
228
  signing_key:
169
229
  specification_version: 3
170
230
  summary: AMQP client implementation in Ruby/EventMachine.