stomp 1.2.4 → 1.2.5

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 (56) hide show
  1. data/CHANGELOG.rdoc +11 -0
  2. data/README.rdoc +38 -26
  3. data/Rakefile +3 -0
  4. data/bin/catstomp +34 -34
  5. data/bin/stompcat +36 -36
  6. data/examples/client11_ex1.rb +64 -55
  7. data/examples/client11_putget1.rb +47 -35
  8. data/examples/conn11_ex1.rb +59 -51
  9. data/examples/conn11_ex2.rb +59 -50
  10. data/examples/conn11_hb1.rb +35 -26
  11. data/examples/consumer.rb +25 -12
  12. data/examples/get11conn_ex1.rb +97 -89
  13. data/examples/get11conn_ex2.rb +55 -47
  14. data/examples/logexamp.rb +66 -52
  15. data/examples/logexamp_ssl.rb +66 -52
  16. data/examples/publisher.rb +21 -10
  17. data/examples/put11conn_ex1.rb +35 -24
  18. data/examples/putget11_rh1.rb +66 -56
  19. data/examples/slogger.rb +65 -52
  20. data/examples/ssl_uc1.rb +24 -13
  21. data/examples/ssl_uc1_ciphers.rb +28 -15
  22. data/examples/ssl_uc2.rb +26 -16
  23. data/examples/ssl_uc2_ciphers.rb +31 -18
  24. data/examples/ssl_uc3.rb +25 -14
  25. data/examples/ssl_uc3_ciphers.rb +31 -18
  26. data/examples/ssl_uc4.rb +26 -15
  27. data/examples/ssl_uc4_ciphers.rb +32 -19
  28. data/examples/ssl_ucx_default_ciphers.rb +25 -12
  29. data/examples/stomp11_common.rb +16 -15
  30. data/examples/topic_consumer.rb +23 -10
  31. data/examples/topic_publisher.rb +22 -8
  32. data/lib/client/utils.rb +116 -0
  33. data/lib/connection/heartbeats.rb +173 -0
  34. data/lib/connection/netio.rb +322 -0
  35. data/lib/connection/utf8.rb +294 -0
  36. data/lib/connection/utils.rb +104 -0
  37. data/lib/stomp/client.rb +127 -179
  38. data/lib/stomp/codec.rb +5 -2
  39. data/lib/stomp/connection.rb +109 -865
  40. data/lib/stomp/constants.rb +52 -33
  41. data/lib/stomp/errors.rb +56 -5
  42. data/lib/stomp/ext/hash.rb +4 -0
  43. data/lib/stomp/message.rb +49 -29
  44. data/lib/stomp/sslparams.rb +83 -71
  45. data/lib/stomp/version.rb +3 -1
  46. data/lib/stomp.rb +18 -9
  47. data/stomp.gemspec +58 -3
  48. data/test/test_client.rb +28 -1
  49. data/test/test_codec.rb +8 -2
  50. data/test/test_connection.rb +29 -0
  51. data/test/test_connection1p.rb +31 -16
  52. data/test/test_helper.rb +20 -3
  53. data/test/test_message.rb +8 -3
  54. data/test/test_ssl.rb +10 -4
  55. data/test/tlogger.rb +16 -15
  56. metadata +59 -4
data/stomp.gemspec CHANGED
@@ -5,17 +5,67 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stomp}
8
- s.version = "1.2.4"
8
+ s.version = "1.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian McCallister", "Marius Mathiesen", "Thiago Morello", "Guy M. Allard"]
12
- s.date = %q{2012-06-25}
12
+ s.date = %q{2012-08-04}
13
13
  s.description = %q{Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.}
14
14
  s.email = ["brianm@apache.org", "marius@stones.com", "morellon@gmail.com", "allard.guy.m@gmail.com"]
15
15
  s.executables = ["catstomp", "stompcat"]
16
16
  s.extra_rdoc_files = [
17
+ "CHANGELOG.rdoc",
17
18
  "LICENSE",
18
- "README.rdoc"
19
+ "README.rdoc",
20
+ "examples/client11_ex1.rb",
21
+ "examples/client11_putget1.rb",
22
+ "examples/conn11_ex1.rb",
23
+ "examples/conn11_ex2.rb",
24
+ "examples/conn11_hb1.rb",
25
+ "examples/consumer.rb",
26
+ "examples/get11conn_ex1.rb",
27
+ "examples/get11conn_ex2.rb",
28
+ "examples/logexamp.rb",
29
+ "examples/logexamp_ssl.rb",
30
+ "examples/publisher.rb",
31
+ "examples/put11conn_ex1.rb",
32
+ "examples/putget11_rh1.rb",
33
+ "examples/slogger.rb",
34
+ "examples/ssl_uc1.rb",
35
+ "examples/ssl_uc1_ciphers.rb",
36
+ "examples/ssl_uc2.rb",
37
+ "examples/ssl_uc2_ciphers.rb",
38
+ "examples/ssl_uc3.rb",
39
+ "examples/ssl_uc3_ciphers.rb",
40
+ "examples/ssl_uc4.rb",
41
+ "examples/ssl_uc4_ciphers.rb",
42
+ "examples/ssl_ucx_default_ciphers.rb",
43
+ "examples/stomp11_common.rb",
44
+ "examples/topic_consumer.rb",
45
+ "examples/topic_publisher.rb",
46
+ "lib/client/utils.rb",
47
+ "lib/connection/heartbeats.rb",
48
+ "lib/connection/netio.rb",
49
+ "lib/connection/utf8.rb",
50
+ "lib/connection/utils.rb",
51
+ "lib/stomp.rb",
52
+ "lib/stomp/client.rb",
53
+ "lib/stomp/codec.rb",
54
+ "lib/stomp/connection.rb",
55
+ "lib/stomp/constants.rb",
56
+ "lib/stomp/errors.rb",
57
+ "lib/stomp/ext/hash.rb",
58
+ "lib/stomp/message.rb",
59
+ "lib/stomp/sslparams.rb",
60
+ "lib/stomp/version.rb",
61
+ "test/test_client.rb",
62
+ "test/test_codec.rb",
63
+ "test/test_connection.rb",
64
+ "test/test_connection1p.rb",
65
+ "test/test_helper.rb",
66
+ "test/test_message.rb",
67
+ "test/test_ssl.rb",
68
+ "test/tlogger.rb"
19
69
  ]
20
70
  s.files = [
21
71
  "CHANGELOG.rdoc",
@@ -50,6 +100,11 @@ Gem::Specification.new do |s|
50
100
  "examples/stomp11_common.rb",
51
101
  "examples/topic_consumer.rb",
52
102
  "examples/topic_publisher.rb",
103
+ "lib/client/utils.rb",
104
+ "lib/connection/heartbeats.rb",
105
+ "lib/connection/netio.rb",
106
+ "lib/connection/utf8.rb",
107
+ "lib/connection/utils.rb",
53
108
  "lib/stomp.rb",
54
109
  "lib/stomp/client.rb",
55
110
  "lib/stomp/codec.rb",
data/test/test_client.rb CHANGED
@@ -4,6 +4,11 @@ $:.unshift(File.dirname(__FILE__))
4
4
 
5
5
  require 'test_helper'
6
6
 
7
+ =begin
8
+
9
+ Main class for testing Stomp::Client instances.
10
+
11
+ =end
7
12
  class TestClient < Test::Unit::TestCase
8
13
  include TestBase
9
14
 
@@ -18,12 +23,14 @@ class TestClient < Test::Unit::TestCase
18
23
  @client.close if @client.open? # allow tests to close
19
24
  end
20
25
 
26
+ # Test poll works.
21
27
  def test_poll_async
22
28
  # If the test 'hangs' here, Connection#poll is broken.
23
29
  m = @client.poll
24
30
  assert m.nil?
25
31
  end
26
32
 
33
+ # Test ACKs.
27
34
  def test_ack_api_works
28
35
  @client.publish make_destination, message_text, {:suppress_content_length => true}
29
36
 
@@ -41,6 +48,7 @@ class TestClient < Test::Unit::TestCase
41
48
  assert_not_nil receipt.headers['receipt-id']
42
49
  end unless ENV['STOMP_RABBIT']
43
50
 
51
+ # Test Client subscribe
44
52
  def test_asynch_subscribe
45
53
  received = false
46
54
  @client.subscribe(make_destination) {|msg| received = msg}
@@ -50,6 +58,7 @@ class TestClient < Test::Unit::TestCase
50
58
  assert_equal message_text, received.body
51
59
  end
52
60
 
61
+ # Test not ACKing messages.
53
62
  def test_noack
54
63
  @client.publish make_destination, message_text
55
64
 
@@ -71,17 +80,19 @@ class TestClient < Test::Unit::TestCase
71
80
  assert_equal received.headers['message-id'], received2.headers['message-id'] unless ENV['STOMP_RABBIT']
72
81
  end unless RUBY_ENGINE =~ /jruby/
73
82
 
83
+ # Test obtaining a RECEIPT via a listener.
74
84
  def test_receipts
75
85
  receipt = false
76
86
  @client.publish(make_destination, message_text) {|r| receipt = r}
77
87
  sleep 0.1 until receipt
78
-
88
+ assert_equal receipt.command, Stomp::CMD_RECEIPT
79
89
  message = nil
80
90
  @client.subscribe(make_destination) {|m| message = m}
81
91
  sleep 0.1 until message
82
92
  assert_equal message_text, message.body
83
93
  end
84
94
 
95
+ # Test requesting a receipt on disconnect.
85
96
  def test_disconnect_receipt
86
97
  @client.close :receipt => "xyz789"
87
98
  assert_nothing_raised {
@@ -91,6 +102,7 @@ class TestClient < Test::Unit::TestCase
91
102
  }
92
103
  end
93
104
 
105
+ # Test publish and immediate subscribe.
94
106
  def test_publish_then_sub
95
107
  @client.publish make_destination, message_text
96
108
  message = nil
@@ -100,12 +112,14 @@ class TestClient < Test::Unit::TestCase
100
112
  assert_equal message_text, message.body
101
113
  end
102
114
 
115
+ # Test that Client subscribe requires a block.
103
116
  def test_subscribe_requires_block
104
117
  assert_raise(RuntimeError) do
105
118
  @client.subscribe make_destination
106
119
  end
107
120
  end unless RUBY_ENGINE =~ /jruby/
108
121
 
122
+ # Test transaction publish.
109
123
  def test_transactional_publish
110
124
  @client.begin 'tx1'
111
125
  @client.publish make_destination, message_text, :transaction => 'tx1'
@@ -118,6 +132,7 @@ class TestClient < Test::Unit::TestCase
118
132
  assert_equal message_text, message.body
119
133
  end
120
134
 
135
+ # Test transaction publish and abort.
121
136
  def test_transaction_publish_then_rollback
122
137
  @client.begin 'tx1'
123
138
  @client.publish make_destination, "first_message", :transaction => 'tx1'
@@ -133,6 +148,7 @@ class TestClient < Test::Unit::TestCase
133
148
  assert_equal "second_message", message.body
134
149
  end unless RUBY_ENGINE =~ /jruby/
135
150
 
151
+ # Test transaction publish and abort, receive with new client.
136
152
  def test_transaction_ack_rollback_with_new_client
137
153
  @client.publish make_destination, message_text
138
154
 
@@ -185,6 +201,7 @@ class TestClient < Test::Unit::TestCase
185
201
  }
186
202
  end
187
203
 
204
+ # Test that subscription destinations must be unique for a Client.
188
205
  def test_raise_on_multiple_subscriptions_to_same_make_destination
189
206
  subscribe_dest = make_destination
190
207
  @client.subscribe(subscribe_dest) {|m| nil }
@@ -193,6 +210,7 @@ class TestClient < Test::Unit::TestCase
193
210
  end
194
211
  end
195
212
 
213
+ # Test that subscription IDs must be unique for a Client.
196
214
  def test_raise_on_multiple_subscriptions_to_same_id
197
215
  subscribe_dest = make_destination
198
216
  @client.subscribe(subscribe_dest, {'id' => 'myid'}) {|m| nil }
@@ -201,6 +219,7 @@ class TestClient < Test::Unit::TestCase
201
219
  end
202
220
  end
203
221
 
222
+ # Test that subscription IDs must be unique for a Client, mixed id specification.
204
223
  def test_raise_on_multiple_subscriptions_to_same_id_mixed
205
224
  subscribe_dest = make_destination
206
225
  @client.subscribe(subscribe_dest, {'id' => 'myid'}) {|m| nil }
@@ -209,6 +228,7 @@ class TestClient < Test::Unit::TestCase
209
228
  end
210
229
  end
211
230
 
231
+ # Test wildcard subscribe. Primarily for AMQ.
212
232
  def test_asterisk_wildcard_subscribe
213
233
  queue_base_name = make_destination
214
234
  queue1 = queue_base_name + ".a"
@@ -239,6 +259,7 @@ class TestClient < Test::Unit::TestCase
239
259
 
240
260
  end unless ENV['STOMP_NOWILD']
241
261
 
262
+ # Test wildcard subscribe with >. Primarily for AMQ.
242
263
  def test_greater_than_wildcard_subscribe
243
264
  queue_base_name = make_destination + "."
244
265
  queue1 = queue_base_name + "foo.a"
@@ -272,6 +293,7 @@ class TestClient < Test::Unit::TestCase
272
293
  assert results.all?{|a| a == true }
273
294
  end unless ENV['STOMP_NOWILD'] || ENV['STOMP_DOTQUEUE']
274
295
 
296
+ # Test transaction with client side redilivery.
275
297
  def test_transaction_with_client_side_redelivery
276
298
  @client.publish make_destination, message_text
277
299
 
@@ -310,10 +332,12 @@ class TestClient < Test::Unit::TestCase
310
332
  @client.commit 'tx2'
311
333
  end
312
334
 
335
+ # Test that a connection frame is received.
313
336
  def test_connection_frame
314
337
  assert_not_nil @client.connection_frame
315
338
  end unless RUBY_ENGINE =~ /jruby/
316
339
 
340
+ # Test basic unsubscribe.
317
341
  def test_unsubscribe
318
342
  message = nil
319
343
  dest = make_destination
@@ -353,6 +377,7 @@ class TestClient < Test::Unit::TestCase
353
377
  assert_equal message.headers['message-id'], message_copy.headers['message-id'], "header check" unless ENV['STOMP_RABBIT']
354
378
  end
355
379
 
380
+ # Test subscribe from a worker thread.
356
381
  def test_thread_one_subscribe
357
382
  msg = nil
358
383
  dest = make_destination
@@ -374,6 +399,7 @@ class TestClient < Test::Unit::TestCase
374
399
  assert_not_nil msg
375
400
  end unless RUBY_ENGINE =~ /jruby/
376
401
 
402
+ # Test subscribe from multiple worker threads.
377
403
  def test_thread_multi_subscribe
378
404
  #
379
405
  lock = Mutex.new
@@ -424,6 +450,7 @@ class TestClient < Test::Unit::TestCase
424
450
  assert_equal @max_msgs, msg_ctr
425
451
  end
426
452
 
453
+ # Test that methods detect no client connection is present.
427
454
  def test_closed_checks_client
428
455
  @client.close
429
456
  #
data/test/test_codec.rb CHANGED
@@ -4,6 +4,11 @@ $:.unshift(File.dirname(__FILE__))
4
4
 
5
5
  require 'test_helper'
6
6
 
7
+ =begin
8
+
9
+ Main class for testing Stomp::HeadreCodec methods.
10
+
11
+ =end
7
12
  class TestCodec < Test::Unit::TestCase
8
13
  include TestBase
9
14
 
@@ -18,6 +23,7 @@ class TestCodec < Test::Unit::TestCase
18
23
  @conn.disconnect if @conn.open? # allow tests to disconnect
19
24
  end
20
25
 
26
+ # Test that the codec does nothing to strings that do not need encoding.
21
27
  def test_1000_check_notneeded
22
28
  test_data = [
23
29
  "a",
@@ -39,7 +45,7 @@ class TestCodec < Test::Unit::TestCase
39
45
  end
40
46
  end
41
47
 
42
- #
48
+ # Test the basic encoding / decoding requirements.
43
49
  def test_1010_basic_encode_decode
44
50
  test_data = [
45
51
  [ "\\\\", "\\" ],
@@ -62,7 +68,7 @@ class TestCodec < Test::Unit::TestCase
62
68
  end
63
69
  end
64
70
 
65
- #
71
+ # Test more complex strings with the codec.
66
72
  def test_1020_fancier
67
73
  test_data = [
68
74
  [ "a\\\\b", "a\\b" ],
@@ -4,6 +4,11 @@ $:.unshift(File.dirname(__FILE__))
4
4
 
5
5
  require 'test_helper'
6
6
 
7
+ =begin
8
+
9
+ Main class for testing Stomp::Connection instances.
10
+
11
+ =end
7
12
  class TestConnection < Test::Unit::TestCase
8
13
  include TestBase
9
14
 
@@ -18,10 +23,12 @@ class TestConnection < Test::Unit::TestCase
18
23
  @conn.disconnect if @conn.open? # allow tests to disconnect
19
24
  end
20
25
 
26
+ # Test basic connection creation.
21
27
  def test_connection_exists
22
28
  assert_not_nil @conn
23
29
  end
24
30
 
31
+ # Test asynchronous polling.
25
32
  def test_poll_async
26
33
  @conn.subscribe("/queue/do.not.put.messages.on.this.queue", :id => "a.no.messages.queue")
27
34
  # If the test 'hangs' here, Connection#poll is broken.
@@ -29,6 +36,7 @@ class TestConnection < Test::Unit::TestCase
29
36
  assert m.nil?
30
37
  end
31
38
 
39
+ # Test suppression of content length header.
32
40
  def test_no_length
33
41
  conn_subscribe make_destination
34
42
  #
@@ -47,6 +55,7 @@ class TestConnection < Test::Unit::TestCase
47
55
  end
48
56
  end unless ENV['STOMP_RABBIT']
49
57
 
58
+ # Test direct / explicit receive.
50
59
  def test_explicit_receive
51
60
  conn_subscribe make_destination
52
61
  @conn.publish make_destination, "test_stomp#test_explicit_receive"
@@ -54,12 +63,14 @@ class TestConnection < Test::Unit::TestCase
54
63
  assert_equal "test_stomp#test_explicit_receive", msg.body
55
64
  end
56
65
 
66
+ # Test asking for a receipt.
57
67
  def test_receipt
58
68
  conn_subscribe make_destination, :receipt => "abc"
59
69
  msg = @conn.receive
60
70
  assert_equal "abc", msg.headers['receipt-id']
61
71
  end
62
72
 
73
+ # Test asking for a receipt on disconnect.
63
74
  def test_disconnect_receipt
64
75
  @conn.disconnect :receipt => "abc123"
65
76
  assert_nothing_raised {
@@ -69,6 +80,7 @@ class TestConnection < Test::Unit::TestCase
69
80
  }
70
81
  end
71
82
 
83
+ # Test ACKs using symbols for header keys.
72
84
  def test_client_ack_with_symbol
73
85
  if @conn.protocol == Stomp::SPL_10
74
86
  @conn.subscribe make_destination, :ack => :client
@@ -87,6 +99,7 @@ class TestConnection < Test::Unit::TestCase
87
99
  }
88
100
  end
89
101
 
102
+ # Test a message with 0x00 embedded in the body.
90
103
  def test_embedded_null
91
104
  conn_subscribe make_destination
92
105
  @conn.publish make_destination, "a\0"
@@ -94,18 +107,21 @@ class TestConnection < Test::Unit::TestCase
94
107
  assert_equal "a\0" , msg.body
95
108
  end
96
109
 
110
+ # Test connection open checking.
97
111
  def test_connection_open?
98
112
  assert_equal true , @conn.open?
99
113
  @conn.disconnect
100
114
  assert_equal false, @conn.open?
101
115
  end
102
116
 
117
+ # Test connection closed checking.
103
118
  def test_connection_closed?
104
119
  assert_equal false, @conn.closed?
105
120
  @conn.disconnect
106
121
  assert_equal true, @conn.closed?
107
122
  end
108
123
 
124
+ # Test that methods detect a closed connection.
109
125
  def test_closed_checks_conn
110
126
  @conn.disconnect
111
127
  #
@@ -154,6 +170,7 @@ class TestConnection < Test::Unit::TestCase
154
170
  end
155
171
  end
156
172
 
173
+ # Test that we receive a Stomp::Message.
157
174
  def test_response_is_instance_of_message_class
158
175
  conn_subscribe make_destination
159
176
  @conn.publish make_destination, "a\0"
@@ -161,6 +178,7 @@ class TestConnection < Test::Unit::TestCase
161
178
  assert_instance_of Stomp::Message , msg
162
179
  end
163
180
 
181
+ # Test converting a Message to a string.
164
182
  def test_message_to_s
165
183
  conn_subscribe make_destination
166
184
  @conn.publish make_destination, "a\0"
@@ -168,10 +186,12 @@ class TestConnection < Test::Unit::TestCase
168
186
  assert_match /^<Stomp::Message headers=/ , msg.to_s
169
187
  end
170
188
 
189
+ # Test that a connection frame is present.
171
190
  def test_connection_frame
172
191
  assert_not_nil @conn.connection_frame
173
192
  end
174
193
 
194
+ # Test messages with multiple line ends.
175
195
  def test_messages_with_multipleLine_ends
176
196
  conn_subscribe make_destination
177
197
  @conn.publish make_destination, "a\n\n"
@@ -184,6 +204,7 @@ class TestConnection < Test::Unit::TestCase
184
204
  assert_equal "b\n\na\n\n", msg_b.body
185
205
  end
186
206
 
207
+ # Test publishing multiple messages.
187
208
  def test_publish_two_messages
188
209
  conn_subscribe make_destination
189
210
  @conn.publish make_destination, "a\0"
@@ -211,6 +232,7 @@ class TestConnection < Test::Unit::TestCase
211
232
  assert_equal message, received.body
212
233
  end
213
234
 
235
+ # Test polling with a single thread.
214
236
  def test_thread_poll_one
215
237
  received = nil
216
238
  max_sleep = (RUBY_VERSION =~ /1\.8/) ? 10 : 1
@@ -231,6 +253,7 @@ class TestConnection < Test::Unit::TestCase
231
253
  assert_equal message, received.body
232
254
  end
233
255
 
256
+ # Test receiving with multiple threads.
234
257
  def test_multi_thread_receive
235
258
  lock = Mutex.new
236
259
  msg_ctr = 0
@@ -268,6 +291,7 @@ class TestConnection < Test::Unit::TestCase
268
291
  assert_equal @max_msgs, msg_ctr
269
292
  end unless RUBY_ENGINE =~ /jruby/
270
293
 
294
+ # Test polling with multiple threads.
271
295
  def test_multi_thread_poll
272
296
  #
273
297
  lock = Mutex.new
@@ -311,6 +335,7 @@ class TestConnection < Test::Unit::TestCase
311
335
  assert_equal @max_msgs, msg_ctr
312
336
  end unless RUBY_ENGINE =~ /jruby/
313
337
 
338
+ # Test using a nil body.
314
339
  def test_nil_body
315
340
  dest = make_destination
316
341
  assert_nothing_raised {
@@ -321,6 +346,7 @@ class TestConnection < Test::Unit::TestCase
321
346
  assert_equal "", msg.body
322
347
  end
323
348
 
349
+ # Test transaction message sequencing.
324
350
  def test_transaction
325
351
  conn_subscribe make_destination
326
352
 
@@ -337,6 +363,7 @@ class TestConnection < Test::Unit::TestCase
337
363
  assert_equal "txn message", msg.body
338
364
  end
339
365
 
366
+ # Test duplicate subscriptions.
340
367
  def test_duplicate_subscription
341
368
  @conn.disconnect # not reliable
342
369
  @conn = Stomp::Connection.open(user, passcode, host, port, true) # reliable
@@ -348,6 +375,7 @@ class TestConnection < Test::Unit::TestCase
348
375
  end
349
376
  end
350
377
 
378
+ # Test nil 1.1 connection parameters.
351
379
  def test_nil_connparms
352
380
  @conn.disconnect
353
381
  #
@@ -356,6 +384,7 @@ class TestConnection < Test::Unit::TestCase
356
384
  end
357
385
  end
358
386
 
387
+ # Basic NAK test.
359
388
  def test_nack11p_0010
360
389
  if @conn.protocol == Stomp::SPL_10
361
390
  assert_raise Stomp::Error::UnsupportedProtocolError do
@@ -4,6 +4,11 @@ $:.unshift(File.dirname(__FILE__))
4
4
 
5
5
  require 'test_helper'
6
6
 
7
+ =begin
8
+
9
+ Main class for testing Stomp::Connection instances, protocol level 1.1+.
10
+
11
+ =end
7
12
  class TestConnection1P < Test::Unit::TestCase
8
13
  include TestBase
9
14
 
@@ -14,11 +19,13 @@ class TestConnection1P < Test::Unit::TestCase
14
19
  def teardown
15
20
  @conn.disconnect if @conn.open? # allow tests to disconnect
16
21
  end
17
- #
22
+
23
+ # Test basic connection open.
18
24
  def test_conn_1p_0000
19
25
  assert @conn.open?
20
26
  end
21
- #
27
+
28
+ # Test missing connect headers.
22
29
  def test_conn_1p_0010
23
30
  #
24
31
  cha = {:host => "localhost"}
@@ -31,7 +38,8 @@ class TestConnection1P < Test::Unit::TestCase
31
38
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, chb)
32
39
  end
33
40
  end
34
- #
41
+
42
+ # Test requesting only a 1.0 connection.
35
43
  def test_conn_1p_0020
36
44
  #
37
45
  cha = {:host => "localhost", "accept-version" => "1.0"}
@@ -43,7 +51,8 @@ class TestConnection1P < Test::Unit::TestCase
43
51
  end
44
52
  assert_equal conn.protocol, Stomp::SPL_10
45
53
  end
46
- #
54
+
55
+ # Test requesting only a 1.1 connection.
47
56
  def test_conn_1p_0030
48
57
  #
49
58
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -55,7 +64,8 @@ class TestConnection1P < Test::Unit::TestCase
55
64
  end
56
65
  assert_equal conn.protocol, Stomp::SPL_11
57
66
  end
58
- #
67
+
68
+ # Test basic request for no heartbeats.
59
69
  def test_conn_1p_0040
60
70
  #
61
71
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -68,8 +78,8 @@ class TestConnection1P < Test::Unit::TestCase
68
78
  end
69
79
  assert_equal conn.protocol, Stomp::SPL_11
70
80
  end
71
- #
72
81
 
82
+ # Test malformed heartbeat header.
73
83
  def test_conn_1p_0050
74
84
  #
75
85
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -80,7 +90,8 @@ class TestConnection1P < Test::Unit::TestCase
80
90
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
81
91
  end
82
92
  end
83
- #
93
+
94
+ # Test malformed heartbeat header.
84
95
  def test_conn_11h_0060
85
96
  #
86
97
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -91,7 +102,8 @@ class TestConnection1P < Test::Unit::TestCase
91
102
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
92
103
  end
93
104
  end
94
- #
105
+
106
+ # Test a valid heartbeat header.
95
107
  def test_conn_1p_0070
96
108
  #
97
109
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -106,7 +118,7 @@ class TestConnection1P < Test::Unit::TestCase
106
118
  assert conn.hbrecv_interval > 0
107
119
  end
108
120
 
109
- #
121
+ # Test only sending heartbeats.
110
122
  def test_conn_1p_0080
111
123
  #
112
124
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -124,7 +136,7 @@ class TestConnection1P < Test::Unit::TestCase
124
136
  hb_asserts_send(conn)
125
137
  end if ENV['STOMP_HB11LONG']
126
138
 
127
- #
139
+ # Test only receiving heartbeats.
128
140
  def test_conn_1p_0090
129
141
  #
130
142
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -143,7 +155,7 @@ class TestConnection1P < Test::Unit::TestCase
143
155
  hb_asserts_recv(conn)
144
156
  end if ENV['STOMP_HB11LONG']
145
157
 
146
- #
158
+ # Test sending and receiving heartbeats.
147
159
  def test_conn_1p_0100
148
160
  #
149
161
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -162,7 +174,7 @@ class TestConnection1P < Test::Unit::TestCase
162
174
  hb_asserts_both(conn)
163
175
  end if ENV['STOMP_HB11LONG']
164
176
 
165
- #
177
+ # Test valid UTF8 data.
166
178
  def test_conn_1p_0110
167
179
  #
168
180
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -193,7 +205,7 @@ class TestConnection1P < Test::Unit::TestCase
193
205
  conn.disconnect
194
206
  end
195
207
 
196
- #
208
+ # Test invalid UTF8 data.
197
209
  def test_conn_1p_0120
198
210
  #
199
211
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -230,6 +242,8 @@ class TestConnection1P < Test::Unit::TestCase
230
242
  # Repeated headers test. Currently:
231
243
  # - Apollo emits repeated headers for a 1.1 connection only
232
244
  # - RabbitMQ does not emit repeated headers under any circumstances
245
+ # - AMQ 5.6 does not emit repeated headers under any circumstances
246
+ # Pure luck that this runs against AMQ at present.
233
247
  def test_conn_1p_0120
234
248
  dest = make_destination
235
249
  msg = "payload: #{Time.now.to_f}"
@@ -253,6 +267,7 @@ class TestConnection1P < Test::Unit::TestCase
253
267
  @conn.unsubscribe dest, :id => sid
254
268
  end
255
269
 
270
+ # Test frozen headers.
256
271
  def test_conn_1p_0120
257
272
  dest = make_destination
258
273
  sid = @conn.uuid()
@@ -262,7 +277,7 @@ class TestConnection1P < Test::Unit::TestCase
262
277
  }
263
278
  end
264
279
 
265
- #
280
+ # Test heartbeats with send and receive.
266
281
  def test_conn_1p_0130
267
282
  #
268
283
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -281,7 +296,7 @@ class TestConnection1P < Test::Unit::TestCase
281
296
  hb_asserts_both(conn)
282
297
  end if ENV['STOMP_HB11LONG']
283
298
 
284
- #
299
+ # Test heartbeats with send and receive.
285
300
  def test_conn_1p_0130
286
301
  #
287
302
  cha = {:host => "localhost", "accept-version" => "1.1"}
@@ -300,7 +315,7 @@ class TestConnection1P < Test::Unit::TestCase
300
315
  hb_asserts_both(conn)
301
316
  end if ENV['STOMP_HB11LONG']
302
317
 
303
- #
318
+ # Test heartbeats with send and receive.
304
319
  def test_conn_1p_0140
305
320
  #
306
321
  cha = {:host => "localhost", "accept-version" => "1.1"}