qpid_messaging 0.20.2 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/ChangeLog +4 -0
  2. data/LICENSE +0 -4
  3. data/README.rdoc +15 -20
  4. data/TODO +10 -5
  5. data/ext/cqpid/cqpid.cpp +156 -40
  6. data/ext/cqpid/extconf.rb +10 -2
  7. data/lib/qpid_messaging.rb +56 -3
  8. data/lib/qpid_messaging/address.rb +51 -28
  9. data/lib/qpid_messaging/connection.rb +75 -46
  10. data/lib/qpid_messaging/duration.rb +49 -14
  11. data/lib/qpid_messaging/encoding.rb +5 -5
  12. data/lib/qpid_messaging/message.rb +61 -68
  13. data/lib/qpid_messaging/receiver.rb +62 -67
  14. data/lib/qpid_messaging/sender.rb +39 -56
  15. data/lib/qpid_messaging/session.rb +78 -81
  16. metadata +51 -61
  17. data/Rakefile +0 -137
  18. data/features/closing_a_connection.feature +0 -13
  19. data/features/closing_a_session.feature +0 -13
  20. data/features/connecting_to_a_broker.feature +0 -13
  21. data/features/creating_a_receiver.feature +0 -29
  22. data/features/creating_a_sender.feature +0 -25
  23. data/features/creating_a_session.feature +0 -12
  24. data/features/getting_the_connections_authenticated_username.feature +0 -8
  25. data/features/receiving_a_message.feature +0 -30
  26. data/features/sending_a_message.feature +0 -21
  27. data/features/session_returns_its_connection.feature +0 -12
  28. data/features/sessions_have_names.feature +0 -8
  29. data/features/step_definitions/address_steps.rb +0 -22
  30. data/features/step_definitions/connection_steps.rb +0 -93
  31. data/features/step_definitions/receiver_steps.rb +0 -69
  32. data/features/step_definitions/sender_steps.rb +0 -34
  33. data/features/step_definitions/session_steps.rb +0 -99
  34. data/features/support/env.rb +0 -22
  35. data/lib/qpid_messaging/errors.rb +0 -33
  36. data/lib/qpid_messaging/version.rb +0 -31
  37. data/spec/qpid_messaging/address_spec.rb +0 -87
  38. data/spec/qpid_messaging/connection_spec.rb +0 -191
  39. data/spec/qpid_messaging/duration_spec.rb +0 -56
  40. data/spec/qpid_messaging/encoding_spec.rb +0 -63
  41. data/spec/qpid_messaging/message_spec.rb +0 -305
  42. data/spec/qpid_messaging/receiver_spec.rb +0 -170
  43. data/spec/qpid_messaging/sender_spec.rb +0 -135
  44. data/spec/qpid_messaging/session_spec.rb +0 -353
  45. data/spec/spec_helper.rb +0 -20
@@ -1,56 +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 Duration do
27
-
28
- before(:each) do
29
- @duration = Qpid::Messaging::Duration::SECOND
30
- end
31
-
32
- it "returns the underlying implementation" do
33
- impl = @duration.duration_impl
34
-
35
- impl.should_not be_nil
36
- end
37
-
38
- it "can create a duration with a millisecond value" do
39
- duration = Qpid::Messaging::Duration.new 500
40
-
41
- milliseconds = duration.milliseconds
42
-
43
- milliseconds.should == 500
44
- end
45
-
46
- it "returns the time in milliseconds" do
47
- milliseconds = @duration.milliseconds
48
-
49
- milliseconds.should == 1000
50
- end
51
-
52
- end
53
-
54
- end
55
-
56
- end
@@ -1,63 +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 "encoding" do
27
- end
28
-
29
- describe "decoding" do
30
-
31
- before(:each) do
32
- @message = Qpid::Messaging::Message.new
33
- end
34
-
35
- it "can decode a message's text content" do
36
- @message.content = "This is an unencoded message."
37
-
38
- content = Qpid::Messaging.decode @message
39
-
40
- content.should == "This is an unencoded message."
41
- end
42
-
43
- it "can decode a message's list content" do
44
- @message.content = ["this", "that"]
45
-
46
- content = Qpid::Messaging.decode @message
47
-
48
- content.should == ["this", "that"]
49
- end
50
-
51
- it "can decode a message's map content" do
52
- @message.content = {"this" => "that"}
53
-
54
- content = Qpid::Messaging.decode @message
55
-
56
- content.should == {"this" => "that"}
57
- end
58
-
59
- end
60
-
61
- end
62
-
63
- end
@@ -1,305 +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 Message do
27
-
28
- before(:each) do
29
- @message = Qpid::Messaging::Message.new :content => "My content"
30
- end
31
-
32
- it "returns its implementation" do
33
- impl = @message.message_impl
34
-
35
- impl.class.should == Cqpid::Message
36
- end
37
-
38
- it "can set the reply to address" do
39
- address = Qpid::Messaging::Address.new "my-queue;{create:always}"
40
-
41
- @message.reply_to = address
42
-
43
- reply_to = @message.reply_to
44
-
45
- reply_to.name.should == address.name
46
- end
47
-
48
- it "can set the reply to from an address string" do
49
- name = "my-queue"
50
- subject = "responses"
51
- address = "#{name}/#{subject}"
52
-
53
- @message.reply_to = address
54
-
55
- reply_to = @message.reply_to
56
-
57
- reply_to.name.should == name
58
- reply_to.subject.should == subject
59
- end
60
-
61
- it "should store the content when created" do
62
- content = @message.content
63
-
64
- content.should == "My content"
65
- end
66
-
67
- it "should properly encode a map when created" do
68
- message = Qpid::Messaging::Message.new :content => {"foo" => "bar"}
69
-
70
- content = message.content
71
- content_type = message.content_type
72
-
73
- content_type.should == "amqp/map"
74
- content.class == Hash
75
- content["foo"].should == "bar"
76
- end
77
-
78
- it "should properly encode a list when created" do
79
- message = Qpid::Messaging::Message.new :content => ["foo", "bar"]
80
-
81
- content = message.content
82
- content_type = message.content_type
83
-
84
- content_type.should == "amqp/list"
85
- content.class == Array
86
- content.should include("foo")
87
- content.should include("bar")
88
- end
89
-
90
- it "should store the subject" do
91
- @message.subject = "new-subject"
92
-
93
- subject = @message.subject
94
-
95
- subject.should == "new-subject"
96
- end
97
-
98
- it "should update the content type" do
99
- @message.content_type = "amqp/audio"
100
-
101
- content_type = @message.content_type
102
-
103
- content_type.should == "amqp/audio"
104
- end
105
-
106
- it "should store the message id" do
107
- @message.message_id = "foo"
108
-
109
- id = @message.message_id
110
-
111
- id.should == "foo"
112
- end
113
-
114
- it "should store the user id" do
115
- @message.user_id = "foo"
116
-
117
- id = @message.user_id
118
-
119
- id.should == "foo"
120
- end
121
-
122
- it "should store the correlation id" do
123
- @message.correlation_id = "message1"
124
-
125
- id = @message.correlation_id
126
-
127
- id.should == "message1"
128
- end
129
-
130
- it "should store the priority" do
131
- @message.priority = 7
132
-
133
- priority = @message.priority
134
-
135
- priority.should == 7
136
- end
137
-
138
- it "should accept a Duration as the time to live" do
139
- @message.ttl = Qpid::Messaging::Duration::SECOND
140
-
141
- ttl = @message.ttl
142
-
143
- ttl.milliseconds.should == Qpid::Messaging::Duration::SECOND.milliseconds
144
- end
145
-
146
- it "should accept an integer value as the time to live" do
147
- @message.ttl = 15000
148
-
149
- ttl = @message.ttl
150
-
151
- ttl.milliseconds.should == 15000
152
- end
153
-
154
- it "should update the durable flag" do
155
- @message.durable = true
156
-
157
- durable = @message.durable
158
-
159
- durable.should == true
160
- end
161
-
162
- it "should update the redelivered flag" do
163
- @message.redelivered = true
164
-
165
- redelivered = @message.redelivered
166
-
167
- redelivered.should == true
168
- end
169
-
170
- it "should store a property" do
171
- property = @message[:test_property]
172
-
173
- property.should == nil
174
-
175
- @message[:test_property] = "test_value1"
176
-
177
- property = @message[:test_property]
178
-
179
- property.should == "test_value1"
180
- end
181
-
182
- it "should convert a symbol property value to a string" do
183
- @message[:test_property] = :test_value2
184
-
185
- property = @message[:test_property]
186
-
187
- property.should == "test_value2"
188
- end
189
-
190
- it "should convert a symbol property name to a string" do
191
- @message[:test_property] = "test_value3"
192
-
193
- property = @message["test_property"]
194
-
195
- property.should == "test_value3"
196
- end
197
-
198
- it "should store text content" do
199
- @message.content = "This is the content."
200
-
201
- content = @message.content
202
-
203
- content.should == "This is the content."
204
- end
205
-
206
- it "should store list content" do
207
- list = ["foo", "bar"]
208
-
209
- @message.content = list
210
-
211
- content = @message.content
212
- content_type = @message.content_type
213
-
214
- content.should == list
215
- content_type.should == "amqp/list"
216
- end
217
-
218
- it "should convert symbol list elements to strings" do
219
- @message.content = [:farkle]
220
-
221
- content = @message.content.first
222
-
223
- content.should == "farkle"
224
- end
225
-
226
- it "should store map content" do
227
- map = {"foo" => "bar"}
228
-
229
- @message.content = map
230
-
231
- content = @message.content
232
- content_type = @message.content_type
233
-
234
- content.should == map
235
- content_type.should == "amqp/map"
236
- end
237
-
238
- it "should convert symbol map elements to strings" do
239
- @message.content = {:first_name => :qpid}
240
-
241
- content = @message.content["first_name"]
242
-
243
- content.should == "qpid"
244
- end
245
-
246
- describe "with content from the underlying implementation" do
247
-
248
- before(:each) do
249
- @message_impl = double("Cqpid::Message")
250
- @message = Qpid::Messaging::Message.new :impl => @message_impl
251
- end
252
-
253
- it "should return simple text content" do
254
- @message_impl.should_receive(:getContent).
255
- and_return("my content")
256
- @message_impl.should_receive(:getContentType).
257
- and_return("")
258
-
259
- content = @message.content
260
-
261
- content.should == "my content"
262
- end
263
-
264
- it "should decode a list" do
265
- list = ["first", "second"]
266
-
267
- @message_impl.should_receive(:getContent).
268
- and_return(list)
269
- @message_impl.should_receive(:getContentType).
270
- twice.
271
- and_return("amqp/list")
272
- Qpid::Messaging.stub!(:decode).
273
- with(@message, "amqp/list").
274
- and_return(list)
275
-
276
- content = @message.content
277
-
278
- content.should == list
279
- end
280
-
281
- it "should decode a map" do
282
- map = {"first" => "second"}
283
-
284
- @message_impl.should_receive(:getContent).
285
- and_return(map)
286
- @message_impl.should_receive(:getContentType).
287
- twice.
288
- and_return("amqp/map")
289
- Qpid::Messaging.stub!(:decode).
290
- with(@message, "amqp/map").
291
- and_return(map)
292
-
293
- content = @message.content
294
-
295
- content.should == map
296
- end
297
-
298
-
299
- end
300
-
301
- end
302
-
303
- end
304
-
305
- end
@@ -1,170 +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 Receiver do
27
-
28
- before(:each) do
29
- @message_impl = double("Cqpid::Message")
30
- @session = double("Qpid::Messaging::Session")
31
- @receiver_impl = double("Cqpid::Receiver")
32
-
33
- @receiver = Qpid::Messaging::Receiver.new @session, @receiver_impl
34
- end
35
-
36
- it "returns the underlying implementation" do
37
- impl = @receiver.receiver_impl
38
-
39
- impl.should == @receiver_impl
40
- end
41
-
42
- it "gets a message with the default duration" do
43
- @receiver_impl.should_receive(:get).
44
- with(Qpid::Messaging::Duration::FOREVER.duration_impl).
45
- and_return(@message_impl)
46
-
47
- message = @receiver.get
48
-
49
- message.message_impl.should == @message_impl
50
- end
51
-
52
- it "gets a message with a specified duration" do
53
- @receiver_impl.should_receive(:get).
54
- with(Qpid::Messaging::Duration::SECOND.duration_impl).
55
- and_return(@message_impl)
56
-
57
- message = @receiver.get Qpid::Messaging::Duration::SECOND
58
-
59
- message.message_impl.should == @message_impl
60
- end
61
-
62
- it "returns nil when get receives no message" do
63
- @receiver_impl.should_receive(:get).
64
- with(Qpid::Messaging::Duration::MINUTE.duration_impl).
65
- and_return(nil)
66
-
67
- message = @receiver.get Qpid::Messaging::Duration::MINUTE
68
-
69
- message.should be_nil
70
- end
71
-
72
- it "fetches a message with the default duration" do
73
- @receiver_impl.should_receive(:fetch).
74
- with(Qpid::Messaging::Duration::FOREVER.duration_impl).
75
- and_return(@message_impl)
76
-
77
- message = @receiver.fetch
78
-
79
- message.message_impl.should == @message_impl
80
- end
81
-
82
- it "fetches a message with a specified duration" do
83
- @receiver_impl.should_receive(:fetch).
84
- with(Qpid::Messaging::Duration::SECOND.duration_impl).
85
- and_return(@message_impl)
86
-
87
- message = @receiver.fetch Qpid::Messaging::Duration::SECOND
88
-
89
- message.message_impl.should == @message_impl
90
- end
91
-
92
- it "returns nil when fetch recieves no message" do
93
- @receiver_impl.should_receive(:fetch).
94
- with(Qpid::Messaging::Duration::MINUTE.duration_impl).
95
- and_return(nil)
96
-
97
- message = @receiver.fetch Qpid::Messaging::Duration::MINUTE
98
-
99
- message.should be_nil
100
- end
101
-
102
- it "assigns capacity" do
103
- @receiver_impl.should_receive(:setCapacity).
104
- with(10)
105
-
106
- @receiver.capacity = 10
107
- end
108
-
109
- it "returns the capacity" do
110
- @receiver_impl.should_receive(:getCapacity).
111
- and_return(10)
112
-
113
- capacity = @receiver.capacity
114
-
115
- capacity.should == 10
116
- end
117
-
118
- it "reports the number of available messages" do
119
- @receiver_impl.should_receive(:getAvailable).
120
- and_return(20)
121
-
122
- available = @receiver.available
123
-
124
- available.should == 20
125
- end
126
-
127
- it "reports the number of unsettled messages" do
128
- @receiver_impl.should_receive(:getUnsettled).
129
- and_return(25)
130
-
131
- unsettled = @receiver.unsettled
132
-
133
- unsettled.should == 25
134
- end
135
-
136
- it "closes" do
137
- @receiver_impl.should_receive(:close)
138
-
139
- @receiver.close
140
- end
141
-
142
- it "reports its closed status" do
143
- @receiver_impl.should_receive(:isClosed).
144
- and_return(true)
145
-
146
- closed = @receiver.closed?
147
-
148
- closed.should == true
149
- end
150
-
151
- it "returns its name" do
152
- @receiver_impl.should_receive(:getName).
153
- and_return("farkle")
154
-
155
- name = @receiver.name
156
-
157
- name.should == "farkle"
158
- end
159
-
160
- it "returns its related session" do
161
- session = @receiver.session
162
-
163
- session.should == @session
164
- end
165
-
166
- end
167
-
168
- end
169
-
170
- end