onstomp 1.0.8 → 1.0.9

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.
@@ -54,7 +54,7 @@ module OnStomp::Connections::Stomp_1
54
54
 
55
55
  def create_frame command, layered_headers, body=nil
56
56
  headers = layered_headers.inject({}) do |final, h|
57
- h = OnStomp.keys_to_sym(h).delete_if { |k,v| final.key?(k) && (v.nil? || v.empty?) }
57
+ h = OnStomp.keys_to_sym(h).delete_if { |k,v| v.nil? || v.empty? }
58
58
  final.merge!(h)
59
59
  final
60
60
  end
@@ -45,7 +45,7 @@ class OnStomp::Failover::Client
45
45
  end
46
46
  @client_mutex = Mutex.new
47
47
  configure_configurable options
48
- create_client_pool hosts
48
+ create_client_pool hosts, options
49
49
  @active_client = nil
50
50
  @connection = nil
51
51
  @frame_buffer = buffer.new self
@@ -129,8 +129,12 @@ class OnStomp::Failover::Client
129
129
  sleep(retry_delay) if retry_delay > 0 && attempt > 1
130
130
  end
131
131
 
132
- def create_client_pool hosts
133
- @client_pool = pool.new hosts
132
+ def create_client_pool hosts, options
133
+ client_options = options.dup
134
+ client_options.delete_if { |k,_|
135
+ self.class.config_attributes.keys.include?(k)
136
+ }
137
+ @client_pool = pool.new hosts, client_options
134
138
  on_connection_closed do |client, *_|
135
139
  if client == active_client
136
140
  unless @disconnecting
@@ -8,9 +8,9 @@ class OnStomp::Failover::Pools::Base
8
8
 
9
9
  # Creates a new client pool by mapping an array of URIs into an array of
10
10
  # {OnStomp::Client clients}.
11
- def initialize hosts
11
+ def initialize hosts, options = {}
12
12
  @clients = hosts.map do |h|
13
- h.is_a?(OnStomp::Client) ? h : OnStomp::Client.new(h)
13
+ h.is_a?(OnStomp::Client) ? h : OnStomp::Client.new(h, options)
14
14
  end
15
15
  end
16
16
 
@@ -3,7 +3,7 @@
3
3
  # A round-robin client pool. Clients are processed sequentially, and once
4
4
  # all clients have been processed, the pool cycles back to the beginning.
5
5
  class OnStomp::Failover::Pools::RoundRobin < OnStomp::Failover::Pools::Base
6
- def initialize uris
6
+ def initialize uris, options = {}
7
7
  super
8
8
  @index = -1
9
9
  end
@@ -7,7 +7,7 @@ module OnStomp
7
7
  # Minor / feature version
8
8
  MINOR = 0
9
9
  # Patch version
10
- PATCH = 8
10
+ PATCH = 9
11
11
  # Complete version
12
12
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
13
13
  end
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  module OnStomp::Failover
5
5
  describe Client, :failover => true do
6
+ let(:client_options) { Hash.new }
6
7
  let(:active_client) {
7
8
  mock('active client').tap do |m|
8
9
  m.extend OnStomp::Interfaces::ClientEvents
@@ -13,20 +14,48 @@ module OnStomp::Failover
13
14
  c.stub(:active_client => active_client)
14
15
  end
15
16
  }
17
+
18
+ class DummyBuffer
19
+ def initialize *args
20
+ end
21
+ end
22
+
16
23
  describe "initialize" do
17
24
  it "should be initialized by string" do
18
25
  c = Client.new('failover:(stomp:///,stomp+ssl:///)')
19
26
  c.uri.to_s.should == 'failover:(stomp:///,stomp+ssl:///)'
20
27
  c.hosts.should == ['stomp:///', 'stomp+ssl:///']
21
28
  end
29
+
22
30
  it "should be initialized by array" do
23
31
  real_client = OnStomp::Client.new('stomp+ssl:///')
24
32
  c = Client.new(['stomp:///', real_client])
25
33
  c.uri.to_s.should == 'failover:()'
26
34
  c.hosts.should == ['stomp:///', real_client]
27
35
  end
36
+
37
+ it 'passes other options on to the client pool' do
38
+ # We really only need to verify that the failover client is passing
39
+ # the appropriate hash to the pool, because we have a spec that ensures
40
+ # the pool is passing the options hash on to the underlying clients.
41
+ # However, even performing this simple test requires an impressive
42
+ # amount of legwork. This design is far too muddy.
43
+
44
+ m_client = mock('client', on_connection_closed: "ignore me!")
45
+ Pools::Base.should_receive(:new).with([ 'stomp:///', 'stomp+ssl:///' ], {
46
+ ssl: { ca_file: 'ca.crt' },
47
+ login: 'user_name'
48
+ }).and_return([ m_client ])
49
+
50
+ c = Client.new('failover:(stomp:///,stomp+ssl:///)', {
51
+ buffer: 'OnStomp::Failover::DummyBuffer',
52
+ retry_attempts: 2,
53
+ ssl: { ca_file: 'ca.crt' },
54
+ login: 'user_name'
55
+ })
56
+ end
28
57
  end
29
-
58
+
30
59
  describe ".connected?" do
31
60
  it "should be connected if it has an active client that's connected" do
32
61
  active_client.stub(:connected? => true)
@@ -81,7 +110,7 @@ module OnStomp::Failover
81
110
  # Get the hooks installed on our mocks
82
111
  active_client.stub(:connection => connection)
83
112
  client.stub(:client_pool => client_pool)
84
- client.__send__ :create_client_pool, []
113
+ client.__send__ :create_client_pool, [], {}
85
114
  end
86
115
  it "should do nothing special if there is no active client" do
87
116
  client.stub(:active_client => nil)
@@ -12,10 +12,10 @@ module OnStomp::Failover::Pools
12
12
 
13
13
  describe ".initialize" do
14
14
  it "should create a new Client for each URI" do
15
- OnStomp::Client.should_receive(:new).with('1').and_return('c 1')
16
- OnStomp::Client.should_receive(:new).with('2').and_return('c 2')
17
- OnStomp::Client.should_receive(:new).with('3').and_return('c 3')
18
- new_pool = Base.new ['1', '2', '3']
15
+ OnStomp::Client.should_receive(:new).with('1', { option: true }).and_return('c 1')
16
+ OnStomp::Client.should_receive(:new).with('2', { option: true }).and_return('c 2')
17
+ OnStomp::Client.should_receive(:new).with('3', { option: true }).and_return('c 3')
18
+ new_pool = Base.new ['1', '2', '3'], { option: true }
19
19
  new_pool.clients.should =~ ['c 1', 'c 2', 'c 3']
20
20
  end
21
21
  end
@@ -95,6 +95,26 @@ describe OnStomp::Client, "full stack test (stomp+ssl:)", :fullstack => true do
95
95
  broker.join
96
96
  blocked_up.should be_false
97
97
  end
98
+
99
+ it 'should include login/passcode headers that are not empty' do
100
+ client = OnStomp::Client.new('stomp://localhost:10101', login: 'user', passcode: 'secr3t')
101
+ client.connect
102
+ client.disconnect
103
+ broker.join
104
+ broker.frames_received.first.command.should == 'CONNECT'
105
+ broker.frames_received.first.headers['login'].should == 'user'
106
+ broker.frames_received.first.headers['passcode'].should == 'secr3t'
107
+ end
108
+
109
+ it 'should not include login/passcode headers that are empty' do
110
+ client = OnStomp::Client.new('stomp://localhost:10101')
111
+ client.connect
112
+ client.disconnect
113
+ broker.join
114
+ broker.frames_received.first.command.should == 'CONNECT'
115
+ broker.frames_received.first.headers.set?('login').should == false
116
+ broker.frames_received.first.headers.set?('passcode').should == false
117
+ end
98
118
 
99
119
  it "should block on write" do
100
120
  blocked_up = false
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onstomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ian D. Eccles
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
12
+ date: 2015-07-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,43 +30,49 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: simplecov
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 0.3.0
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 0.3.0
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: yard
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.6.0
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.6.0
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  description: Client library for message passing with brokers that support the Stomp
@@ -205,26 +214,30 @@ files:
205
214
  - yard_extensions.rb
206
215
  homepage: http://github.com/meadvillerb/onstomp
207
216
  licenses: []
208
- metadata: {}
209
217
  post_install_message:
210
218
  rdoc_options: []
211
219
  require_paths:
212
220
  - lib
213
221
  required_ruby_version: !ruby/object:Gem::Requirement
222
+ none: false
214
223
  requirements:
215
- - - '>='
224
+ - - ! '>='
216
225
  - !ruby/object:Gem::Version
217
226
  version: 1.8.7
218
227
  required_rubygems_version: !ruby/object:Gem::Requirement
228
+ none: false
219
229
  requirements:
220
- - - '>='
230
+ - - ! '>='
221
231
  - !ruby/object:Gem::Version
222
232
  version: '0'
233
+ segments:
234
+ - 0
235
+ hash: -2397510086146937216
223
236
  requirements: []
224
237
  rubyforge_project: onstomp-core
225
- rubygems_version: 2.0.6
238
+ rubygems_version: 1.8.23.2
226
239
  signing_key:
227
- specification_version: 4
240
+ specification_version: 3
228
241
  summary: Client for message queues implementing the Stomp protocol interface.
229
242
  test_files:
230
243
  - spec/onstomp/client_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 5f0fcfaa300e31031e10003e4c2b4ba86bffe72d
4
- data.tar.gz: 2358bc943063271535dee0bfbfa4a5c88fd0603b
5
- SHA512:
6
- metadata.gz: bb71c53a00f2cf4e8ed8916035d2f51f81baf1d50da0e13fc94c4f2c9e6cf6db085a9b6198b2cb35121258a39c7ef99d71f2a9d4dd26b9c005e62c34ee1fd749
7
- data.tar.gz: 154804957105f06e82adc9db3f4c95897b9b2a233d9937e8c46711f0d9326b7cb3920a397564b858fe809837757b5aa5125c18c2e123c99cf730a954d90f7ddb