qpid_messaging 0.20.2 → 0.22.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.
- data/ChangeLog +4 -0
- data/LICENSE +0 -4
- data/README.rdoc +15 -20
- data/TODO +10 -5
- data/ext/cqpid/cqpid.cpp +156 -40
- data/ext/cqpid/extconf.rb +10 -2
- data/lib/qpid_messaging.rb +56 -3
- data/lib/qpid_messaging/address.rb +51 -28
- data/lib/qpid_messaging/connection.rb +75 -46
- data/lib/qpid_messaging/duration.rb +49 -14
- data/lib/qpid_messaging/encoding.rb +5 -5
- data/lib/qpid_messaging/message.rb +61 -68
- data/lib/qpid_messaging/receiver.rb +62 -67
- data/lib/qpid_messaging/sender.rb +39 -56
- data/lib/qpid_messaging/session.rb +78 -81
- metadata +51 -61
- data/Rakefile +0 -137
- data/features/closing_a_connection.feature +0 -13
- data/features/closing_a_session.feature +0 -13
- data/features/connecting_to_a_broker.feature +0 -13
- data/features/creating_a_receiver.feature +0 -29
- data/features/creating_a_sender.feature +0 -25
- data/features/creating_a_session.feature +0 -12
- data/features/getting_the_connections_authenticated_username.feature +0 -8
- data/features/receiving_a_message.feature +0 -30
- data/features/sending_a_message.feature +0 -21
- data/features/session_returns_its_connection.feature +0 -12
- data/features/sessions_have_names.feature +0 -8
- data/features/step_definitions/address_steps.rb +0 -22
- data/features/step_definitions/connection_steps.rb +0 -93
- data/features/step_definitions/receiver_steps.rb +0 -69
- data/features/step_definitions/sender_steps.rb +0 -34
- data/features/step_definitions/session_steps.rb +0 -99
- data/features/support/env.rb +0 -22
- data/lib/qpid_messaging/errors.rb +0 -33
- data/lib/qpid_messaging/version.rb +0 -31
- data/spec/qpid_messaging/address_spec.rb +0 -87
- data/spec/qpid_messaging/connection_spec.rb +0 -191
- data/spec/qpid_messaging/duration_spec.rb +0 -56
- data/spec/qpid_messaging/encoding_spec.rb +0 -63
- data/spec/qpid_messaging/message_spec.rb +0 -305
- data/spec/qpid_messaging/receiver_spec.rb +0 -170
- data/spec/qpid_messaging/sender_spec.rb +0 -135
- data/spec/qpid_messaging/session_spec.rb +0 -353
- data/spec/spec_helper.rb +0 -20
@@ -1,135 +0,0 @@
|
|
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
|
-
module Qpid
|
23
|
-
|
24
|
-
module Messaging
|
25
|
-
|
26
|
-
describe Sender do
|
27
|
-
|
28
|
-
before(:each) do
|
29
|
-
@message = double("Qpid::Messaging::Message")
|
30
|
-
@message_impl = double("Cqpid::Message")
|
31
|
-
@sender_impl = double("Cqpid::Sender")
|
32
|
-
@session = double("Qpid::Messaging::Session")
|
33
|
-
|
34
|
-
@sender = Qpid::Messaging::Sender.new @session, @sender_impl
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns its implementation" do
|
38
|
-
impl = @sender.sender_impl
|
39
|
-
|
40
|
-
impl.should == @sender_impl
|
41
|
-
end
|
42
|
-
|
43
|
-
it "sends a message" do
|
44
|
-
@message.should_receive(:message_impl).
|
45
|
-
and_return(@message_impl)
|
46
|
-
@sender_impl.should_receive(:send).
|
47
|
-
with(@message_impl, false)
|
48
|
-
|
49
|
-
@sender.send @message
|
50
|
-
end
|
51
|
-
|
52
|
-
it "sends a message with optional synch" do
|
53
|
-
@message.should_receive(:message_impl).
|
54
|
-
and_return(@message_impl)
|
55
|
-
@sender_impl.should_receive(:send).
|
56
|
-
with(@message_impl, true)
|
57
|
-
|
58
|
-
@sender.send @message, :sync => true
|
59
|
-
end
|
60
|
-
|
61
|
-
it "sends a message with an optional block" do
|
62
|
-
block_called = false
|
63
|
-
|
64
|
-
@message.should_receive(:message_impl).
|
65
|
-
and_return(@message_impl)
|
66
|
-
@sender_impl.should_receive(:send).
|
67
|
-
with(@message_impl, false)
|
68
|
-
|
69
|
-
@sender.send @message do |message|
|
70
|
-
block_called = true if message == @message
|
71
|
-
end
|
72
|
-
|
73
|
-
block_called.should be_true
|
74
|
-
end
|
75
|
-
|
76
|
-
it "closes" do
|
77
|
-
@sender_impl.should_receive(:close)
|
78
|
-
|
79
|
-
@sender.close
|
80
|
-
end
|
81
|
-
|
82
|
-
it "returns its name" do
|
83
|
-
@sender_impl.should_receive(:getName).
|
84
|
-
and_return("farkle")
|
85
|
-
|
86
|
-
name = @sender.name
|
87
|
-
|
88
|
-
name.should == "farkle"
|
89
|
-
end
|
90
|
-
|
91
|
-
it "sets its capacity" do
|
92
|
-
@sender_impl.should_receive(:setCapacity).
|
93
|
-
with(100)
|
94
|
-
|
95
|
-
@sender.capacity = 100
|
96
|
-
end
|
97
|
-
|
98
|
-
it "returns its capacity" do
|
99
|
-
@sender_impl.should_receive(:getCapacity).
|
100
|
-
and_return(25)
|
101
|
-
|
102
|
-
capacity = @sender.capacity
|
103
|
-
|
104
|
-
capacity.should == 25
|
105
|
-
end
|
106
|
-
|
107
|
-
it "returns the number of unsettled messages" do
|
108
|
-
@sender_impl.should_receive(:getUnsettled).
|
109
|
-
and_return(15)
|
110
|
-
|
111
|
-
unsettled = @sender.unsettled
|
112
|
-
|
113
|
-
unsettled.should == 15
|
114
|
-
end
|
115
|
-
|
116
|
-
it "returns the number of available message slots" do
|
117
|
-
@sender_impl.should_receive(:getAvailable).
|
118
|
-
and_return(50)
|
119
|
-
|
120
|
-
available = @sender.available
|
121
|
-
|
122
|
-
available.should == 50
|
123
|
-
end
|
124
|
-
|
125
|
-
it "returns a reference to its session" do
|
126
|
-
session = @sender.session
|
127
|
-
|
128
|
-
session.should == @session
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
@@ -1,353 +0,0 @@
|
|
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
|
-
module Qpid
|
23
|
-
|
24
|
-
module Messaging
|
25
|
-
|
26
|
-
describe Session do
|
27
|
-
|
28
|
-
before(:each) do
|
29
|
-
@connection = double("Qpid::Messaging::Connection")
|
30
|
-
@session_impl = double("Cqpid::Session")
|
31
|
-
@session = Qpid::Messaging::Session.new @connection, @session_impl
|
32
|
-
@sender_impl = double("Cqpid::Sender")
|
33
|
-
@receiver_impl = double("Cqpid::Receiver")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "returns its implementation" do
|
37
|
-
impl = @session.session_impl
|
38
|
-
|
39
|
-
impl.should == @session_impl
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns its connection" do
|
43
|
-
connection = @session.connection
|
44
|
-
|
45
|
-
connection.should == @connection
|
46
|
-
end
|
47
|
-
|
48
|
-
it "creates a Sender from an Address" do
|
49
|
-
address = Qpid::Messaging::Address.new "my-queue;{create:always}"
|
50
|
-
|
51
|
-
@session_impl.should_receive(:createSender).
|
52
|
-
with(address.address_impl).
|
53
|
-
and_return(@sender_impl)
|
54
|
-
@sender_impl.should_receive(:getName).
|
55
|
-
and_return("my-queue")
|
56
|
-
|
57
|
-
sender = @session.create_sender address
|
58
|
-
|
59
|
-
sender.sender_impl.should == @sender_impl
|
60
|
-
end
|
61
|
-
|
62
|
-
it "creates a Sender from an address string" do
|
63
|
-
address = "my-queue;{create:true}"
|
64
|
-
|
65
|
-
@session_impl.should_receive(:createSender).
|
66
|
-
with(address).
|
67
|
-
and_return(@sender_impl)
|
68
|
-
@sender_impl.should_receive(:getName).
|
69
|
-
and_return("my-queue")
|
70
|
-
|
71
|
-
sender = @session.create_sender address
|
72
|
-
|
73
|
-
sender.sender_impl.should == @sender_impl
|
74
|
-
end
|
75
|
-
|
76
|
-
#######################################
|
77
|
-
# scenarios involing an existing Sender
|
78
|
-
#######################################
|
79
|
-
describe "when retrieving a Sender by name" do
|
80
|
-
|
81
|
-
before(:each) do
|
82
|
-
address = "my-queue;{create:always}"
|
83
|
-
@name = "my-queue"
|
84
|
-
|
85
|
-
@session_impl.should_receive(:createSender).
|
86
|
-
with(address).
|
87
|
-
and_return(@sender_impl)
|
88
|
-
@sender_impl.should_receive(:getName).
|
89
|
-
and_return(@name)
|
90
|
-
|
91
|
-
@sender = @session.create_sender address
|
92
|
-
end
|
93
|
-
|
94
|
-
it "works when the name is valid" do
|
95
|
-
sender = @session.sender @name
|
96
|
-
|
97
|
-
sender.should == @sender
|
98
|
-
end
|
99
|
-
|
100
|
-
it "raises an error when the name is invalid" do
|
101
|
-
expect {
|
102
|
-
@session.sender @name.reverse
|
103
|
-
}.to raise_error(Qpid::Messaging::KeyError)
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
it "creates a Receiver from an Address" do
|
109
|
-
address = Qpid::Messaging::Address.new "my-queue", ""
|
110
|
-
|
111
|
-
@session_impl.should_receive(:createReceiver).
|
112
|
-
with(address.address_impl).
|
113
|
-
and_return(@receiver_impl)
|
114
|
-
@receiver_impl.should_receive(:getName).
|
115
|
-
and_return("my-queue")
|
116
|
-
|
117
|
-
receiver = @session.create_receiver address
|
118
|
-
|
119
|
-
receiver.receiver_impl.should == @receiver_impl
|
120
|
-
end
|
121
|
-
|
122
|
-
it "creates a Receiver from an address string" do
|
123
|
-
address = "my-queue"
|
124
|
-
|
125
|
-
@session_impl.should_receive(:createReceiver).
|
126
|
-
with(address).
|
127
|
-
and_return(@receiver_impl)
|
128
|
-
@receiver_impl.should_receive(:getName).
|
129
|
-
and_return("my-queue")
|
130
|
-
|
131
|
-
receiver = @session.create_receiver address
|
132
|
-
|
133
|
-
receiver.receiver_impl.should == @receiver_impl
|
134
|
-
end
|
135
|
-
|
136
|
-
#########################################
|
137
|
-
# scenarios involving an existing Receiver
|
138
|
-
##########################################
|
139
|
-
describe "when retrieving a Receiver by name" do
|
140
|
-
|
141
|
-
before(:each) do
|
142
|
-
address = "my-queue"
|
143
|
-
@name = "my-queue"
|
144
|
-
|
145
|
-
@session_impl.should_receive(:createReceiver).
|
146
|
-
with(address).
|
147
|
-
and_return(@receiver_impl)
|
148
|
-
@receiver_impl.should_receive(:getName).
|
149
|
-
and_return(@name)
|
150
|
-
|
151
|
-
@receiver = @session.create_receiver address
|
152
|
-
end
|
153
|
-
|
154
|
-
it "works with a valid name" do
|
155
|
-
receiver = @session.receiver @name
|
156
|
-
|
157
|
-
receiver.should == @receiver
|
158
|
-
end
|
159
|
-
|
160
|
-
it "raises an error when the name is invalid" do
|
161
|
-
expect {
|
162
|
-
@session.receiver @name.reverse
|
163
|
-
}.to raise_error(Qpid::Messaging::KeyError)
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
it "closes the session" do
|
169
|
-
@session_impl.should_receive(:close)
|
170
|
-
|
171
|
-
@session.close
|
172
|
-
end
|
173
|
-
|
174
|
-
it "commits a pending transaction" do
|
175
|
-
@session_impl.should_receive(:commit)
|
176
|
-
|
177
|
-
@session.commit
|
178
|
-
end
|
179
|
-
|
180
|
-
it "rolls back an uncommitted transaction" do
|
181
|
-
@session_impl.should_receive(:rollback)
|
182
|
-
|
183
|
-
@session.rollback
|
184
|
-
end
|
185
|
-
|
186
|
-
it "acknowledges all received messages" do
|
187
|
-
@session_impl.should_receive(:acknowledge).
|
188
|
-
with(false)
|
189
|
-
|
190
|
-
@session.acknowledge
|
191
|
-
end
|
192
|
-
|
193
|
-
it "acknowledges all messages synchronously" do
|
194
|
-
@session_impl.should_receive(:acknowledge).
|
195
|
-
with(true)
|
196
|
-
|
197
|
-
@session.acknowledge :sync => true
|
198
|
-
end
|
199
|
-
|
200
|
-
it "acknowledges all messages asynchronously" do
|
201
|
-
@session_impl.should_receive(:acknowledge).
|
202
|
-
with(false)
|
203
|
-
|
204
|
-
@session.acknowledge :sync => false
|
205
|
-
end
|
206
|
-
|
207
|
-
######################################
|
208
|
-
# Scenarios involving a single message
|
209
|
-
######################################
|
210
|
-
describe "with a single message" do
|
211
|
-
|
212
|
-
before(:each) do
|
213
|
-
@message = Qpid::Messaging::Message.new :content => "Testing"
|
214
|
-
end
|
215
|
-
|
216
|
-
it "can acknowledge asynchronously by default" do
|
217
|
-
@session_impl.should_receive(:acknowledge).
|
218
|
-
with(@message.message_impl, false)
|
219
|
-
|
220
|
-
@session.acknowledge :message => @message
|
221
|
-
end
|
222
|
-
|
223
|
-
it "can acknowledge synchronously" do
|
224
|
-
@session_impl.should_receive(:acknowledge).
|
225
|
-
with(@message.message_impl, true)
|
226
|
-
|
227
|
-
@session.acknowledge :message => @message, :sync => true
|
228
|
-
end
|
229
|
-
|
230
|
-
it "can acknowledge asynchronously" do
|
231
|
-
@session_impl.should_receive(:acknowledge).
|
232
|
-
with(@message.message_impl, false)
|
233
|
-
|
234
|
-
@session.acknowledge :message => @message, :sync => false
|
235
|
-
end
|
236
|
-
|
237
|
-
it "can reject it" do
|
238
|
-
@session_impl.should_receive(:reject).
|
239
|
-
with(@message.message_impl)
|
240
|
-
|
241
|
-
@session.reject @message
|
242
|
-
end
|
243
|
-
|
244
|
-
it "can release it" do
|
245
|
-
@session_impl.should_receive(:release).
|
246
|
-
with(@message.message_impl)
|
247
|
-
|
248
|
-
@session.release @message
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
|
253
|
-
it "does not block by default when synchronizating with the broker" do
|
254
|
-
@session_impl.should_receive(:sync).
|
255
|
-
with(false)
|
256
|
-
|
257
|
-
@session.sync
|
258
|
-
end
|
259
|
-
|
260
|
-
it "can block while synchronizing with the broker" do
|
261
|
-
@session_impl.should_receive(:sync).
|
262
|
-
with(true)
|
263
|
-
|
264
|
-
@session.sync :block => true
|
265
|
-
end
|
266
|
-
|
267
|
-
it "can not block while synchronizing with the broker" do
|
268
|
-
@session_impl.should_receive(:sync).
|
269
|
-
with(false)
|
270
|
-
|
271
|
-
@session.sync :block => false
|
272
|
-
end
|
273
|
-
|
274
|
-
it "returns the number of messages that are receivable" do
|
275
|
-
@session_impl.should_receive(:getReceivable).
|
276
|
-
and_return(15)
|
277
|
-
|
278
|
-
receivable = @session.receivable
|
279
|
-
|
280
|
-
receivable.should == 15
|
281
|
-
end
|
282
|
-
|
283
|
-
it "returns the number of unsettled messages" do
|
284
|
-
@session_impl.should_receive(:getUnsettledAcks).
|
285
|
-
and_return(25)
|
286
|
-
|
287
|
-
unsettled = @session.unsettled_acks
|
288
|
-
|
289
|
-
unsettled.should == 25
|
290
|
-
end
|
291
|
-
|
292
|
-
it "waits forever by default for the next Receiver with messages" do
|
293
|
-
@session_impl.should_receive(:nextReceiver).
|
294
|
-
with(Qpid::Messaging::Duration::FOREVER.duration_impl).
|
295
|
-
and_return(@receiver_impl)
|
296
|
-
|
297
|
-
receiver = @session.next_receiver
|
298
|
-
|
299
|
-
receiver.receiver_impl.should == @receiver_impl
|
300
|
-
end
|
301
|
-
|
302
|
-
it "uses the specified time when waiting for the next Receiver with messages" do
|
303
|
-
@session_impl.should_receive(:nextReceiver).
|
304
|
-
with(Qpid::Messaging::Duration::SECOND.duration_impl).
|
305
|
-
and_return(@receiver_impl)
|
306
|
-
|
307
|
-
receiver = @session.next_receiver Qpid::Messaging::Duration::SECOND
|
308
|
-
|
309
|
-
receiver.receiver_impl.should == @receiver_impl
|
310
|
-
end
|
311
|
-
|
312
|
-
it "returns nil when no Receiver has messages within the timeout period" do
|
313
|
-
@session_impl.should_receive(:nextReceiver).
|
314
|
-
with(Qpid::Messaging::Duration::MINUTE.duration_impl).
|
315
|
-
and_return(nil)
|
316
|
-
|
317
|
-
receiver = @session.next_receiver Qpid::Messaging::Duration::MINUTE
|
318
|
-
|
319
|
-
receiver.should be_nil
|
320
|
-
end
|
321
|
-
|
322
|
-
it "returns true when there are errors on the session" do
|
323
|
-
@session_impl.should_receive(:hasError).
|
324
|
-
and_return(true)
|
325
|
-
|
326
|
-
errors = @session.errors?
|
327
|
-
|
328
|
-
errors.should be_true
|
329
|
-
end
|
330
|
-
|
331
|
-
it "returns false when there are no errors on the session" do
|
332
|
-
@session_impl.should_receive(:hasError).
|
333
|
-
and_return(false)
|
334
|
-
|
335
|
-
errors = @session.errors?
|
336
|
-
|
337
|
-
errors.should be_false
|
338
|
-
end
|
339
|
-
|
340
|
-
it "causes exceptions to be raised when there are errors" do
|
341
|
-
@session_impl.should_receive(:checkError).
|
342
|
-
and_raise(RuntimeError)
|
343
|
-
|
344
|
-
expect {
|
345
|
-
@session.errors
|
346
|
-
}.to raise_error(RuntimeError)
|
347
|
-
end
|
348
|
-
|
349
|
-
end
|
350
|
-
|
351
|
-
end
|
352
|
-
|
353
|
-
end
|