amq-client 0.7.0.alpha35 → 0.8.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.
Files changed (69) hide show
  1. data/.rspec +0 -1
  2. data/.travis.yml +9 -3
  3. data/Gemfile +22 -12
  4. data/amq-client.gemspec +1 -1
  5. data/examples/coolio_adapter/example_helper.rb +2 -0
  6. data/examples/eventmachine_adapter/basic_consume_with_acknowledgements.rb +3 -3
  7. data/examples/eventmachine_adapter/{connection_failure_callback.rb → error_handling/connection_failure_callback.rb} +4 -8
  8. data/examples/eventmachine_adapter/{connection_failure_exception.rb → error_handling/connection_failure_exception.rb} +5 -9
  9. data/examples/eventmachine_adapter/{connection_loss_handler.rb → error_handling/connection_loss_handler_that_fails_over.rb} +12 -12
  10. data/examples/eventmachine_adapter/error_handling/connection_loss_handler_with_automatic_recovery.rb +85 -0
  11. data/examples/eventmachine_adapter/error_handling/connection_loss_handler_with_manual_recovery.rb +85 -0
  12. data/examples/eventmachine_adapter/error_handling/handling_a_channel_level_exception.rb +2 -5
  13. data/examples/eventmachine_adapter/example_helper.rb +2 -0
  14. data/examples/eventmachine_adapter/server_capabilities.rb +12 -0
  15. data/examples/eventmachine_adapter/tls/tls_without_peer_verification.rb +2 -2
  16. data/lib/amq/client/async/adapter.rb +170 -31
  17. data/lib/amq/client/async/adapters/coolio.rb +18 -1
  18. data/lib/amq/client/async/adapters/event_machine.rb +48 -32
  19. data/lib/amq/client/async/adapters/eventmachine.rb +3 -1
  20. data/lib/amq/client/async/callbacks.rb +9 -7
  21. data/lib/amq/client/async/channel.rb +113 -20
  22. data/lib/amq/client/async/consumer.rb +270 -0
  23. data/lib/amq/client/async/exchange.rb +137 -16
  24. data/lib/amq/client/async/extensions/rabbitmq/confirm.rb +4 -4
  25. data/lib/amq/client/async/queue.rb +217 -113
  26. data/lib/amq/client/callbacks.rb +2 -0
  27. data/lib/amq/client/consumer_tag_generator.rb +24 -0
  28. data/lib/amq/client/exceptions.rb +10 -6
  29. data/lib/amq/client/handlers_registry.rb +2 -0
  30. data/lib/amq/client/queue.rb +2 -0
  31. data/lib/amq/client/server_named_entity.rb +1 -8
  32. data/lib/amq/client/settings.rb +64 -2
  33. data/lib/amq/client/version.rb +3 -1
  34. data/spec/benchmarks/adapters.rb +2 -0
  35. data/spec/client/framing/io_frame_spec.rb +9 -6
  36. data/spec/integration/coolio/basic_ack_spec.rb +2 -0
  37. data/spec/integration/coolio/basic_cancel_spec.rb +2 -0
  38. data/spec/integration/coolio/basic_consume_spec.rb +58 -0
  39. data/spec/integration/coolio/basic_get_spec.rb +2 -0
  40. data/spec/integration/coolio/basic_return_spec.rb +2 -0
  41. data/spec/integration/coolio/channel_close_spec.rb +2 -0
  42. data/spec/integration/coolio/channel_flow_spec.rb +2 -0
  43. data/spec/integration/coolio/connection_close_spec.rb +2 -0
  44. data/spec/integration/coolio/connection_start_spec.rb +2 -0
  45. data/spec/integration/coolio/exchange_declare_spec.rb +8 -6
  46. data/spec/integration/coolio/spec_helper.rb +2 -0
  47. data/spec/integration/coolio/tx_commit_spec.rb +2 -1
  48. data/spec/integration/coolio/tx_rollback_spec.rb +1 -1
  49. data/spec/integration/eventmachine/basic_ack_spec.rb +3 -1
  50. data/spec/integration/eventmachine/basic_cancel_spec.rb +2 -0
  51. data/spec/integration/eventmachine/basic_consume_spec.rb +90 -6
  52. data/spec/integration/eventmachine/basic_get_spec.rb +2 -0
  53. data/spec/integration/eventmachine/basic_return_spec.rb +2 -0
  54. data/spec/integration/eventmachine/channel_close_spec.rb +2 -0
  55. data/spec/integration/eventmachine/channel_flow_spec.rb +4 -2
  56. data/spec/integration/eventmachine/concurrent_basic_publish_spec.rb +79 -0
  57. data/spec/integration/eventmachine/connection_close_spec.rb +2 -0
  58. data/spec/integration/eventmachine/connection_start_spec.rb +2 -0
  59. data/spec/integration/eventmachine/exchange_declare_spec.rb +4 -2
  60. data/spec/integration/eventmachine/queue_declare_spec.rb +2 -0
  61. data/spec/integration/eventmachine/regressions/amqp_gem_issue66_spec.rb +2 -0
  62. data/spec/integration/eventmachine/spec_helper.rb +2 -0
  63. data/spec/integration/eventmachine/tx_commit_spec.rb +2 -1
  64. data/spec/integration/eventmachine/tx_rollback_spec.rb +1 -1
  65. data/spec/regression/bad_frame_slicing_in_adapters_spec.rb +2 -0
  66. data/spec/spec_helper.rb +10 -0
  67. data/spec/unit/client/settings_spec.rb +92 -3
  68. metadata +24 -23
  69. data/CONTRIBUTORS +0 -3
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -6,9 +8,9 @@ require 'integration/eventmachine/spec_helper'
6
8
  # See basic_ack_spec for example with acks
7
9
  #
8
10
 
9
- describe AMQ::Client::EventMachineClient, "Basic.Consume" do
11
+ describe AMQ::Client::EventMachineClient, "AMQP consumer" do
10
12
  include EventedSpec::SpecHelper
11
- default_timeout 4
13
+ default_timeout 5
12
14
 
13
15
  context "sending 100 messages" do
14
16
  let(:messages) { (0..99).map {|i| "Message #{i}" } }
@@ -32,7 +34,7 @@ describe AMQ::Client::EventMachineClient, "Basic.Consume" do
32
34
  end
33
35
  end
34
36
 
35
- done(1.5) {
37
+ done(3.5) {
36
38
  @received_messages.should =~ messages
37
39
  }
38
40
  end
@@ -62,8 +64,8 @@ describe AMQ::Client::EventMachineClient, "Basic.Consume" do
62
64
  end
63
65
 
64
66
  # We're opening another channel and starting consuming the same queue,
65
- # assuming 1.5 secs was enough to receive all the messages
66
- delayed(1.5) do
67
+ # assuming 2.0 secs was enough to receive all the messages
68
+ delayed(2.0) do
67
69
  other_channel = AMQ::Client::Channel.new(client, 2)
68
70
  other_channel.open do
69
71
  other_channel.qos(0, 1) # Maximum prefetch size = 1
@@ -79,7 +81,7 @@ describe AMQ::Client::EventMachineClient, "Basic.Consume" do
79
81
  end
80
82
 
81
83
 
82
- done(2.5) {
84
+ done(4.5) {
83
85
  @rereceived_messages.should == []
84
86
  @received_messages.should =~ messages
85
87
  }
@@ -87,3 +89,85 @@ describe AMQ::Client::EventMachineClient, "Basic.Consume" do
87
89
  end # it "should not leave messages in the queues with noack=true"
88
90
  end # context "sending 100 messages"
89
91
  end # describe AMQ::Client::EventMachineClient, "Basic.Consume"
92
+
93
+
94
+
95
+
96
+ describe "Multiple", AMQ::Client::Async::Consumer do
97
+ include EventedSpec::SpecHelper
98
+ default_timeout 4
99
+
100
+ context "sharing the same queue with equal prefetch levels" do
101
+ let(:messages) { (0..99).map {|i| "Message #{i}" } }
102
+
103
+ it "have messages distributed to them in the round-robin manner" do
104
+ @consumer1_mailbox = []
105
+ @consumer2_mailbox = []
106
+ @consumer3_mailbox = []
107
+
108
+ em_amqp_connect do |client|
109
+ channel = AMQ::Client::Channel.new(client, 1)
110
+ channel.open do
111
+ queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true)
112
+ queue.bind("amq.fanout")
113
+
114
+ consumer1 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{Time.now}")
115
+ consumer2 = AMQ::Client::Async::Consumer.new(channel, queue)
116
+ consumer3 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{rand}-#{Time.now}", false, true)
117
+
118
+
119
+ consumer1.consume.on_delivery do |method, header, payload|
120
+ @consumer1_mailbox << payload
121
+ end
122
+
123
+ consumer2.consume(true).on_delivery do |method, header, payload|
124
+ @consumer2_mailbox << payload
125
+ end
126
+
127
+ consumer3.consume(false) do
128
+ puts "Consumer 3 is ready"
129
+ end
130
+ consumer3.on_delivery do |method, header, payload|
131
+ @consumer3_mailbox << payload
132
+ end
133
+
134
+
135
+ exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout)
136
+ messages.each do |message|
137
+ exchange.publish(message)
138
+ end
139
+ end
140
+
141
+ done(1.5) {
142
+ @consumer1_mailbox.size.should == 34
143
+ @consumer2_mailbox.size.should == 33
144
+ @consumer3_mailbox.size.should == 33
145
+ }
146
+ end
147
+ end # it
148
+ end # context
149
+ end # describe
150
+
151
+
152
+
153
+ describe AMQ::Client::Async::Consumer do
154
+ include EventedSpec::SpecHelper
155
+ default_timeout 4
156
+
157
+ context "registered with a callback" do
158
+ it "runs that callback when basic.consume-ok arrives" do
159
+ em_amqp_connect do |client|
160
+ channel = AMQ::Client::Channel.new(client, 1)
161
+ channel.open do
162
+ queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true)
163
+ queue.bind("amq.fanout")
164
+
165
+ consumer1 = AMQ::Client::Async::Consumer.new(channel, queue, "#{queue.name}-consumer-#{Time.now}")
166
+ consumer1.consume do
167
+ done
168
+ end # consume do
169
+ end # open do
170
+ end # em_amqp_connect
171
+ end # it
172
+ end # context
173
+ end # describe
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,9 +1,11 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
4
6
  describe AMQ::Client::EventMachineClient, "Channel#flow" do
5
7
  include EventedSpec::SpecHelper
6
- default_timeout 1
8
+ default_timeout 2
7
9
 
8
10
  it "controls channel flow state" do
9
11
  em_amqp_connect do |client|
@@ -24,7 +26,7 @@ describe AMQ::Client::EventMachineClient, "Channel#flow" do
24
26
  end # channel.flow
25
27
  end # channel.open
26
28
 
27
- done(0.5) { flow_states.should == [false, true] }
29
+ done(1.0) { flow_states.should == [false, true] }
28
30
  end # em_amqp_connect
29
31
  end # it
30
32
  end # describe
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'integration/eventmachine/spec_helper'
5
+
6
+
7
+ include PlatformDetection
8
+
9
+ if mri?
10
+ require "multi_json"
11
+
12
+ describe AMQ::Client::EventMachineClient, "Basic.Publish" do
13
+ include EventedSpec::SpecHelper
14
+ default_timeout 21.0
15
+
16
+ context "when messages are published across threads" do
17
+ let(:inputs) do
18
+ [
19
+ { :index=>{:_routing=>530,:_index=>"optimizer",:_type=>"earnings",:_id=>530}},
20
+ { :total_conversions=>0,:banked_clicks=>0,:total_earnings=>0,:pending_conversions=>0,:paid_net_earnings=>0,:banked_conversions=>0,:pending_earnings=>0,:optimizer_id=>530,:total_impressions=>0,:banked_earnings=>0,:bounce_count=>0,:time_on_page=>0,:total_clicks=>0,:entrances=>0,:pending_clicks=>0,:paid_earnings=>0},
21
+
22
+ { :index=>{:_routing=>430,:_index=>"optimizer",:_type=>"earnings",:_id=>430}},
23
+ { :total_conversions=>1443,:banked_clicks=>882,:total_earnings=>5796.3315841537,:pending_conversions=>22,:paid_net_earnings=>4116.90224486802,:banked_conversions=>1086,:pending_earnings=>257.502767857143,:optimizer_id=>430,:total_impressions=>6370497,:banked_earnings=>122.139339285714,:bounce_count=>6825,:time_on_page=>0,:total_clicks=>38143,:entrances=>12336,:pending_clicks=>1528,:paid_earnings=>5670.78224486798},
24
+
25
+ { :index=>{:_routing=>506,:_index=>"optimizer",:_type=>"earnings",:_id=>506}},
26
+ { :total_conversions=>237,:banked_clicks=>232,:total_earnings=>550.6212071428588277,:pending_conversions=>9,:paid_net_earnings=>388.021207142857,:banked_conversions=>225,:pending_earnings=>150.91,:optimizer_id=>506,:total_impressions=>348319,:banked_earnings=>12.92,:bounce_count=>905,:time_on_page=>0,:total_clicks=>4854,:entrances=>1614,:pending_clicks=>1034,:paid_earnings=>537.501207142858},
27
+
28
+ {:index=>{:_routing=>345,:_index=>"optimizer",:_type=>"earnings",:_id=>345}},
29
+ {:total_conversions=>0,:banked_clicks=>0,:total_earnings=>0,:pending_conversions=>0,:paid_net_earnings=>0,:banked_conversions=>0,:pending_earnings=>0,:optimizer_id=>345,:total_impressions=>0,:banked_earnings=>0,:bounce_count=>0,:time_on_page=>0,:total_clicks=>0,:entrances=>0,:pending_clicks=>0,:paid_earnings=>0}
30
+ ]
31
+ end
32
+ let(:messages) { inputs.map {|i| MultiJson.encode(i) } * 3 }
33
+
34
+ # the purpose of this is to make sure UNEXPECTED_FRAME issues are gone
35
+ it "synchronizes on channel" do
36
+ @received_messages = []
37
+
38
+ @received_messages = []
39
+ em_amqp_connect do |client|
40
+ client.on_error do |conn, connection_close|
41
+ fail "Handling a connection-level exception: #{connection_close.reply_text}"
42
+ end
43
+
44
+ channel = AMQ::Client::Channel.new(client, 1)
45
+ channel.open do
46
+ queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true)
47
+ queue.bind("amq.fanout")
48
+
49
+ queue.consume(true) do |amq_method|
50
+ queue.on_delivery do |method, header, payload|
51
+ @received_messages << payload
52
+ end
53
+
54
+ exchange = AMQ::Client::Exchange.new(client, channel, "amq.fanout", :fanout)
55
+ EventMachine.add_timer(2.0) do
56
+ # ZOMG THREADS!
57
+ 30.times do
58
+ Thread.new do
59
+ messages.each do |message|
60
+ exchange.publish(message, queue.name, {}, false, true)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ # let it run for several seconds because you know, concurrency issues do not always manifest themselves
68
+ # immediately. MK.
69
+ done(14.0) {
70
+ # we don't care about the exact number, just the fact that there are
71
+ # no UNEXPECTED_FRAME connection-level exceptions. MK.
72
+ @received_messages.size.should > 120
73
+ }
74
+ end
75
+ end # em_amqp_connect
76
+ end # it
77
+ end # context
78
+ end # describe
79
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -8,7 +10,7 @@ describe AMQ::Client::EventMachineClient, "Exchange.Declare" do
8
10
  #
9
11
 
10
12
  include EventedSpec::SpecHelper
11
- default_timeout 1
13
+ default_timeout 2
12
14
  let(:exchange_name) { "amq-client.testexchange.#{Time.now.to_i}" }
13
15
 
14
16
 
@@ -25,7 +27,7 @@ describe AMQ::Client::EventMachineClient, "Exchange.Declare" do
25
27
  channel.open do
26
28
  begin
27
29
  AMQ::Client::Exchange.new(client, channel, exchange_name, "my_shiny_metal_exchange_type")
28
- rescue AMQ::Client::Exchange::IncompatibleExchangeTypeError => e
30
+ rescue AMQ::Client::UnknownExchangeTypeError => e
29
31
  done
30
32
  end
31
33
  end # channel.open
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/eventmachine/spec_helper'
3
5
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require "amq/client/adapters/event_machine"
2
4
  require "amq/client/queue"
3
5
  require "amq/client/exchange"
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'spec_helper'
3
4
  require 'integration/eventmachine/spec_helper'
4
5
 
@@ -9,7 +10,7 @@ describe AMQ::Client::EventMachineClient, "Tx.Commit" do
9
10
  #
10
11
 
11
12
  include EventedSpec::SpecHelper
12
- default_timeout 2
13
+ default_timeout 4
13
14
 
14
15
  let(:message) { "Hello, world!" }
15
16
 
@@ -4,7 +4,7 @@ require 'integration/eventmachine/spec_helper'
4
4
 
5
5
  describe AMQ::Client::EventMachineClient, "Tx.Rollback" do
6
6
  include EventedSpec::SpecHelper
7
- default_timeout 2
7
+ default_timeout 4
8
8
  let(:message) { "Hello, world!" }
9
9
  it "should cancel all the changes done during transaction" do
10
10
  pending("Need to figure out details with AMQP protocol on that matter")
@@ -1,3 +1,5 @@
1
+ # encoding: binary
2
+
1
3
  require 'spec_helper'
2
4
  require 'integration/coolio/spec_helper'
3
5
  require 'integration/eventmachine/spec_helper'
data/spec/spec_helper.rb CHANGED
@@ -6,10 +6,13 @@ Bundler.setup
6
6
  Bundler.require(:default, :test)
7
7
 
8
8
  require 'amq/client'
9
+
9
10
  #
10
11
  # Ruby version-specific
11
12
  #
12
13
 
14
+ require "effin_utf8"
15
+
13
16
  case RUBY_VERSION
14
17
  when "1.8.7" then
15
18
  class Array
@@ -22,4 +25,11 @@ end
22
25
 
23
26
  RSpec.configure do |c|
24
27
  c.filter_run_excluding :nojruby => true if RUBY_PLATFORM =~ /java/
28
+ end
29
+
30
+
31
+ module PlatformDetection
32
+ def mri?
33
+ !defined?(RUBY_ENGINE) || (defined?(RUBY_ENGINE) && ("ruby" == RUBY_ENGINE))
34
+ end
25
35
  end
@@ -18,9 +18,98 @@ describe AMQ::Client::Settings do
18
18
  end
19
19
 
20
20
  it "should merge custom settings from AMQP URL with default settings" do
21
- pending "AMQP URL parsing" do
22
- settings = AMQ::Client::Settings.configure("amqp://tagadab")
23
- settings[:host].should eql("tagadab")
21
+ settings = AMQ::Client::Settings.configure("amqp://tagadab")
22
+ settings[:host].should eql("tagadab")
23
+ end
24
+ end
25
+
26
+ describe ".parse_amqp_url(connection_string)" do
27
+ context "when schema is not one of [amqp, amqps]" do
28
+ it "raises ArgumentError" do
29
+ expect {
30
+ described_class.parse_amqp_url("http://dev.rabbitmq.com")
31
+ }.to raise_error(ArgumentError, /amqp or amqps schema/)
32
+ end
33
+ end
34
+
35
+
36
+ it "handles amqp:// URIs w/o path part" do
37
+ val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com")
38
+
39
+ val[:vhost].should be_nil # in this case, default / will be used
40
+ val[:host].should == "dev.rabbitmq.com"
41
+ val[:port].should == 5672
42
+ val[:scheme].should == "amqp"
43
+ val[:ssl].should be_false
44
+ end
45
+
46
+ it "handles amqps:// URIs w/o path part" do
47
+ val = described_class.parse_amqp_url("amqps://dev.rabbitmq.com")
48
+
49
+ val[:vhost].should be_nil
50
+ val[:host].should == "dev.rabbitmq.com"
51
+ val[:port].should == 5671
52
+ val[:scheme].should == "amqps"
53
+ val[:ssl].should be_true
54
+ end
55
+
56
+
57
+ context "when URI ends in a slash" do
58
+ it "parses vhost as an empty string" do
59
+ val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com/")
60
+
61
+ val[:host].should == "dev.rabbitmq.com"
62
+ val[:port].should == 5672
63
+ val[:scheme].should == "amqp"
64
+ val[:ssl].should be_false
65
+ val[:vhost].should == ""
66
+ end
67
+ end
68
+
69
+
70
+ context "when URI ends in /%2Fvault" do
71
+ it "parses vhost as /vault" do
72
+ val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com/%2Fvault")
73
+
74
+ val[:host].should == "dev.rabbitmq.com"
75
+ val[:port].should == 5672
76
+ val[:scheme].should == "amqp"
77
+ val[:ssl].should be_false
78
+ val[:vhost].should == "/vault"
79
+ end
80
+ end
81
+
82
+
83
+ context "when URI is amqp://dev.rabbitmq.com/a.path.without.slashes" do
84
+ it "parses vhost as a.path.without.slashes" do
85
+ val = described_class.parse_amqp_url("amqp://dev.rabbitmq.com/a.path.without.slashes")
86
+
87
+ val[:host].should == "dev.rabbitmq.com"
88
+ val[:port].should == 5672
89
+ val[:scheme].should == "amqp"
90
+ val[:ssl].should be_false
91
+ val[:vhost].should == "a.path.without.slashes"
92
+ end
93
+ end
94
+
95
+ context "when URI is amqp://dev.rabbitmq.com/a/path/with/slashes" do
96
+ it "raises an ArgumentError" do
97
+ lambda { described_class.parse_amqp_url("amqp://dev.rabbitmq.com/a/path/with/slashes") }.should raise_error(ArgumentError)
98
+ end
99
+ end
100
+
101
+
102
+ context "when URI has username:password, for instance, amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal" do
103
+ it "parses them out" do
104
+ val = described_class.parse_amqp_url("amqp://hedgehog:t0ps3kr3t@hub.megacorp.internal")
105
+
106
+ val[:host].should == "hub.megacorp.internal"
107
+ val[:port].should == 5672
108
+ val[:scheme].should == "amqp"
109
+ val[:ssl].should be_false
110
+ val[:user].should == "hedgehog"
111
+ val[:pass].should == "t0ps3kr3t"
112
+ val[:vhost].should be_nil # in this case, default / will be used
24
113
  end
25
114
  end
26
115
  end