qpid_management 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.
@@ -0,0 +1,43 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'spec_helper'
21
+
22
+ describe Qpid::Management::BrokerAgent do
23
+ before(:each) do
24
+ @broker_port = `qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
25
+ @connection = Qpid::Messaging::Connection.new(url:"localhost:#{@broker_port}")
26
+ @connection.open()
27
+ @agent = Qpid::Management::BrokerAgent.new(@connection)
28
+ end
29
+
30
+ after(:each) do
31
+ @agent.close()
32
+ @connection.close()
33
+ `qpidd -q --port #{@broker_port}`
34
+ end
35
+
36
+ describe '#broker' do
37
+ let(:broker) { @agent.broker }
38
+
39
+ it 'returns the broker' do
40
+ broker.class.should == Qpid::Management::Broker
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,373 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'spec_helper'
21
+
22
+ describe Qpid::Management::Broker do
23
+ before(:each) do
24
+ @broker_port = `qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
25
+ @connection = Qpid::Messaging::Connection.new(url:"localhost:#{@broker_port}")
26
+ @connection.open()
27
+ @agent = Qpid::Management::BrokerAgent.new(@connection)
28
+ @broker = @agent.broker
29
+ end
30
+
31
+ after(:each) do
32
+ @agent.close()
33
+ @connection.close()
34
+ `qpidd --quit --port #{@broker_port}`
35
+ end
36
+
37
+ def setup_queue_route
38
+ @other_port = `qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
39
+ @broker.add_link('link1', 'localhost', @other_port)
40
+ @broker.add_queue('queue')
41
+ @broker.add_queue_route('qr1',
42
+ link: 'link1',
43
+ queue: 'queue',
44
+ exchange: 'amq.direct',
45
+ sync: 2)
46
+ end
47
+
48
+ %w(connection session subscription exchange queue binding link bridge).each do |type|
49
+ describe "##{type}s" do
50
+ before(:each) do
51
+ setup_queue_route if %w(link bridge).include?(type)
52
+ end
53
+
54
+ after(:each) do
55
+ if %w(link bridge).include?(type)
56
+ `qpidd --quit --port #{@other_port}`
57
+ end
58
+ end
59
+
60
+ let(:collection) { @broker.send("#{type}s") }
61
+
62
+ it "returns at least 1 #{type}" do
63
+ if type == 'subscription'
64
+ session = @connection.create_session
65
+ receiver = session.create_receiver("amq.direct/temp")
66
+ end
67
+ collection.count.should be > 0
68
+ end
69
+ end
70
+
71
+ describe "##{type}" do
72
+ before(:each) do
73
+ setup_queue_route if %w(link bridge).include?(type)
74
+ end
75
+
76
+ after(:each) do
77
+ if %w(link bridge).include?(type)
78
+ `qpidd --quit --port #{@other_port}`
79
+ end
80
+ end
81
+
82
+ let(:object) { @broker.send("#{type}s")[0] }
83
+
84
+ it "returns a #{type} by oid" do
85
+ if type == 'subscription'
86
+ session = @connection.create_session
87
+ receiver = session.create_receiver("amq.direct/temp")
88
+ end
89
+ @broker.send(type, object.short_id).id.should == object.id
90
+ end
91
+ end
92
+ end
93
+
94
+ describe '#add_exchange' do
95
+ %w(fanout direct topic headers).each do |type|
96
+ context "when adding a #{type} exchange" do
97
+ let(:exchange_name) { "#{type}1" }
98
+ before(:each) do
99
+ @before_creation = Time.now
100
+ @broker.add_exchange(type, exchange_name, {'qpid.replicate' => 'none'})
101
+ end
102
+
103
+ subject { @broker.exchange(exchange_name) }
104
+ its(:short_id) { should == exchange_name }
105
+ its(:type) { should == type }
106
+ its(:created_at) { should be > @before_creation }
107
+ it 'has the correct arguments' do
108
+ subject.arguments.should == {'qpid.replicate' => 'none'}
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ describe "#delete_exchange" do
115
+ before(:each) do
116
+ @before_creation = Time.now
117
+ @broker.add_exchange('fanout', 'fanout_to_delete')
118
+ end
119
+
120
+ let(:exchange) { @broker.exchange('fanout_to_delete') }
121
+
122
+ context "with a valid exchange name" do
123
+ it "deletes the exchange" do
124
+ @broker.delete_exchange(exchange.short_id)
125
+ expect { exchange.refresh! }.to raise_error
126
+ end
127
+ end
128
+
129
+ context "with an invalid exchange name" do
130
+ it "raises a not-found exception" do
131
+ expect { @broker.delete_exchange("badname") }.to raise_error(/not-found.*badname/)
132
+ end
133
+ end
134
+ end
135
+
136
+ describe "#add_queue" do
137
+ before(:each) do
138
+ @before_creation = Time.now
139
+ @queue_name = 'myqueue'
140
+ @broker.add_queue(@queue_name, {'qpid.replicate' => 'none'})
141
+ end
142
+
143
+ subject { @broker.queue(@queue_name) }
144
+ its(:short_id) { should == @queue_name }
145
+ its(:created_at) { should be > @before_creation }
146
+ it 'has the correct arguments' do
147
+ subject.arguments.should == {'qpid.replicate' => 'none'}
148
+ end
149
+ end
150
+
151
+ describe "#delete_queue" do
152
+ before(:each) do
153
+ @before_creation = Time.now
154
+ @broker.add_queue('queue_to_delete')
155
+ end
156
+
157
+ let(:queue) { @broker.queue('queue_to_delete') }
158
+
159
+ context "with a valid queue name" do
160
+ it "deletes the queue" do
161
+ @broker.delete_queue(queue.short_id)
162
+ expect { queue.refresh! }.to raise_error
163
+ end
164
+ end
165
+
166
+ context "with an invalid name" do
167
+ it "raises a not-found exception" do
168
+ expect { @broker.delete_queue("badname") }.to raise_error(/not-found.*badname/)
169
+ end
170
+ end
171
+ end
172
+
173
+ describe "#add_binding" do
174
+ before(:each) do
175
+ @broker.add_queue('queue')
176
+ end
177
+
178
+ it "creates a binding for a fanout exchange" do
179
+ @broker.add_exchange('fanout', 'fanout')
180
+ @broker.add_binding('fanout', 'queue')
181
+ expect { @broker.binding('org.apache.qpid.broker:exchange:fanout,org.apache.qpid.broker:queue:queue,') }.to_not raise_error
182
+ end
183
+
184
+ it "creates a binding for a direct exchange" do
185
+ @broker.add_exchange('direct', 'direct')
186
+ @broker.add_binding('direct', 'queue', 'mykey')
187
+ expect { @broker.binding('org.apache.qpid.broker:exchange:direct,org.apache.qpid.broker:queue:queue,mykey') }.to_not raise_error
188
+ end
189
+
190
+ it "creates a binding for a topic exchange" do
191
+ @broker.add_exchange('topic', 'topic')
192
+ @broker.add_binding('topic', 'queue', 'us.#')
193
+ expect { @broker.binding('org.apache.qpid.broker:exchange:topic,org.apache.qpid.broker:queue:queue,us.#') }.to_not raise_error
194
+ end
195
+ end
196
+
197
+ describe "#delete_binding" do
198
+ it "deletes an existing binding" do
199
+ @broker.add_queue('queue')
200
+ @broker.add_exchange('fanout', 'fanout')
201
+ @broker.add_binding('fanout', 'queue')
202
+ expect { @broker.delete_binding('fanout', 'queue') }.to_not raise_error
203
+ end
204
+ end
205
+
206
+ describe "#add_link" do
207
+ before(:each) do
208
+ @other_port = `/usr/sbin/qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
209
+ end
210
+
211
+ after(:each) do
212
+ `/usr/sbin/qpidd -q --port #{@other_port}`
213
+ end
214
+
215
+ it "adds a link" do
216
+ @broker.add_link('link1', 'localhost', @other_port)
217
+ @broker.links.count.should == 1
218
+ end
219
+ end
220
+
221
+ describe "#delete_link" do
222
+ before(:each) do
223
+ @other_port = `/usr/sbin/qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
224
+ @broker.add_link('link1', 'localhost', @other_port)
225
+ end
226
+
227
+ after(:each) do
228
+ `/usr/sbin/qpidd -q --port #{@other_port}`
229
+ end
230
+
231
+ it "deletes a link" do
232
+ @broker.delete_link('link1')
233
+ @broker.links.count.should == 0
234
+ end
235
+ end
236
+
237
+ describe "#add_queue_route" do
238
+ context "with missing options" do
239
+ [:link, :queue, :exchange, :sync].each do |opt|
240
+ opts = {link: 'l', queue: 'q', exchange: 'e', sync:2}
241
+ opts.delete(opt)
242
+ it "raises an error when :#{opt} is missing" do
243
+ expect { @broker.add_queue_route('name', opts) }.to raise_error(/Option :#{opt} is required/)
244
+ end
245
+ end
246
+ end
247
+
248
+ context "with all required options" do
249
+ before(:each) do
250
+ @other_port = `/usr/sbin/qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
251
+ @broker.add_link('link1', 'localhost', @other_port)
252
+ @broker.add_queue('queue')
253
+ @broker.add_queue_route('qr1',
254
+ link: 'link1',
255
+ queue: 'queue',
256
+ exchange: 'amq.direct',
257
+ sync: 2)
258
+ end
259
+
260
+ after(:each) do
261
+ `/usr/sbin/qpidd -q --port #{@other_port}`
262
+ end
263
+
264
+ it "adds a queue route" do
265
+ @broker.bridges.count.should == 1
266
+ end
267
+
268
+ subject { @broker.bridges[0] }
269
+ its(:dest) { should == 'amq.direct' }
270
+ its(:durable) { should == false }
271
+ its(:dynamic) { should == false }
272
+ its(:excludes) { should == "" }
273
+ its(:key) { should == "" }
274
+ its(:name) { should == "qr1" }
275
+ its(:src) { should == "queue" }
276
+ its(:srcIsLocal) { should == false }
277
+ its(:srcIsQueue) { should == true }
278
+ its(:sync) { should == 2 }
279
+ its(:tag) { should == "" }
280
+ end
281
+ end
282
+
283
+ describe "#add_exchange_route" do
284
+ context "with missing options" do
285
+ [:link, :exchange, :key, :sync].each do |opt|
286
+ opts = {link: 'l', exchange: 'e', key:'rk', sync:2}
287
+ opts.delete(opt)
288
+ it "raises an error when :#{opt} is missing" do
289
+ expect { @broker.add_exchange_route('name', opts) }.to raise_error(/Option :#{opt} is required/)
290
+ end
291
+ end
292
+ end
293
+
294
+ context "with all required options" do
295
+ before(:each) do
296
+ @other_port = `/usr/sbin/qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
297
+ @broker.add_link('link1', 'localhost', @other_port)
298
+ @broker.add_queue('queue')
299
+ @broker.add_exchange_route('er1',
300
+ link: 'link1',
301
+ exchange: 'amq.direct',
302
+ key: 'foo',
303
+ sync: 2)
304
+ end
305
+
306
+ after(:each) do
307
+ `/usr/sbin/qpidd -q --port #{@other_port}`
308
+ end
309
+
310
+ it "adds an exchange route" do
311
+ @broker.bridges.count.should == 1
312
+ end
313
+
314
+ subject { @broker.bridges[0] }
315
+ its(:dest) { should == 'amq.direct' }
316
+ its(:durable) { should == false }
317
+ its(:dynamic) { should == false }
318
+ its(:excludes) { should == "" }
319
+ its(:key) { should == "foo" }
320
+ its(:name) { should == "er1" }
321
+ its(:src) { should == "amq.direct" }
322
+ its(:srcIsLocal) { should == false }
323
+ its(:srcIsQueue) { should == false }
324
+ its(:sync) { should == 2 }
325
+ its(:tag) { should == "" }
326
+ end
327
+ end
328
+
329
+ describe "#add_dynamic_route" do
330
+ context "with missing options" do
331
+ [:link, :exchange, :sync].each do |opt|
332
+ opts = {link: 'l', exchange: 'e', sync:2}
333
+ opts.delete(opt)
334
+ it "raises an error when :#{opt} is missing" do
335
+ expect { @broker.add_dynamic_route('name', opts) }.to raise_error(/Option :#{opt} is required/)
336
+ end
337
+ end
338
+ end
339
+
340
+ context "with all required options" do
341
+ before(:each) do
342
+ @other_port = `/usr/sbin/qpidd --no-data-dir --auth=no --no-module-dir --daemon --port 0`.chop
343
+ @broker.add_link('link1', 'localhost', @other_port)
344
+ @broker.add_queue('queue')
345
+ @broker.add_dynamic_route('dr1',
346
+ link: 'link1',
347
+ exchange: 'amq.direct',
348
+ sync: 2)
349
+ end
350
+
351
+ after(:each) do
352
+ `/usr/sbin/qpidd -q --port #{@other_port}`
353
+ end
354
+
355
+ it "adds an exchange route" do
356
+ @broker.bridges.count.should == 1
357
+ end
358
+
359
+ subject { @broker.bridges[0] }
360
+ its(:dest) { should == 'amq.direct' }
361
+ its(:durable) { should == false }
362
+ its(:dynamic) { should == true }
363
+ its(:excludes) { should == "" }
364
+ its(:key) { should == "" }
365
+ its(:name) { should == "dr1" }
366
+ its(:src) { should == "amq.direct" }
367
+ its(:srcIsLocal) { should == false }
368
+ its(:srcIsQueue) { should == false }
369
+ its(:sync) { should == 2 }
370
+ its(:tag) { should == "" }
371
+ end
372
+ end
373
+ end
@@ -0,0 +1,21 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'qpid_messaging'
21
+ require 'qpid_management'
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qpid_management
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Apache Qpid Project
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: qpid_messaging
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Qpid management library
28
+ email:
29
+ - dev@qpid.apache.org
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - .rspec
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - Rakefile
39
+ - lib/qpid_management.rb
40
+ - lib/qpid_management/acl.rb
41
+ - lib/qpid_management/binding.rb
42
+ - lib/qpid_management/bridge.rb
43
+ - lib/qpid_management/broker.rb
44
+ - lib/qpid_management/broker_agent.rb
45
+ - lib/qpid_management/broker_object.rb
46
+ - lib/qpid_management/cluster.rb
47
+ - lib/qpid_management/connection.rb
48
+ - lib/qpid_management/errors.rb
49
+ - lib/qpid_management/exchange.rb
50
+ - lib/qpid_management/ha_broker.rb
51
+ - lib/qpid_management/link.rb
52
+ - lib/qpid_management/memory.rb
53
+ - lib/qpid_management/queue.rb
54
+ - lib/qpid_management/session.rb
55
+ - lib/qpid_management/subscription.rb
56
+ - qpid_management.gemspec
57
+ - spec/broker_agent_spec.rb
58
+ - spec/broker_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: http://qpid.apache.org
61
+ licenses: []
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Qpid management library
83
+ test_files:
84
+ - spec/broker_agent_spec.rb
85
+ - spec/broker_spec.rb
86
+ - spec/spec_helper.rb
87
+ has_rdoc: