stomp 1.2.7 → 1.2.8

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.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.2.8 20121228
2
+
3
+ * Fix inverted encode / decode logic (fairly major 1.1+ bug)
4
+ * Enhance codec tests
5
+ * Enhance Stomp 1.1+ tests
6
+
1
7
  == 1.2.7 20121102
2
8
 
3
9
  * Stomp 1.2 support (see http://stomp.github.com)
data/README.rdoc CHANGED
@@ -10,6 +10,7 @@ An implementation of the Stomp protocol for Ruby. See:
10
10
 
11
11
  ===New
12
12
 
13
+ * Gem version 1.2.8. Stomp 1.1+ header codec inversion fix, test refactoring. See _CHANGELOG.rdoc_ for details.
13
14
  * Gem version 1.2.7. Stomp 1.2 support and miscellaneous fixes. See _CHANGELOG.rdoc_ for details.
14
15
  * Gem version 1.2.6. Miscellaneous fixes and changes. See _CHANGELOG.rdoc_ for details.
15
16
  * Gem version 1.2.5. Restructure. Forks with modifcations will be affected. See _CHANGELOG.rdoc_ for details.
@@ -110,7 +110,7 @@ module Stomp
110
110
  # The transmit may fail so we may need to retry.
111
111
  while TRUE
112
112
  begin
113
- used_socket = socket
113
+ used_socket = socket()
114
114
  _transmit(used_socket, command, headers, body)
115
115
  return
116
116
  rescue Stomp::Error::MaxReconnectAttempts => e
@@ -120,7 +120,7 @@ module Stomp
120
120
  raise unless @reliable
121
121
  errstr = "transmit to #{@host} failed: #{$!}\n"
122
122
  if @logger && @logger.respond_to?(:on_miscerr)
123
- @logger.on_miscerr(log_params, errstr)
123
+ @logger.on_miscerr(log_params, "es_trans: " + errstr)
124
124
  else
125
125
  $stderr.print errstr
126
126
  end
@@ -83,8 +83,11 @@ module Stomp
83
83
 
84
84
  # _post_connect handles low level logic just after a physical connect.
85
85
  def _post_connect()
86
- return unless (@connect_headers[:"accept-version"] && @connect_headers[:host])
87
- return if @connection_frame.command == Stomp::CMD_ERROR
86
+ return unless (@connect_headers[:"accept-version"] && @connect_headers[:host]) # 1.0
87
+ if @connection_frame.command == Stomp::CMD_ERROR
88
+ @connection_frame.headers = _decodeHeaders(@connection_frame.headers)
89
+ return
90
+ end
88
91
  # We are CONNECTed
89
92
  cfh = @connection_frame.headers.symbolize_keys
90
93
  @protocol = cfh[:version]
@@ -109,7 +112,7 @@ module Stomp
109
112
  while used_socket.nil? || !@failure.nil?
110
113
  @failure = nil
111
114
  begin
112
- used_socket = open_socket()
115
+ used_socket = open_socket() # sets @closed = false if OK
113
116
  # Open is complete
114
117
  connect(used_socket)
115
118
  if @logger && @logger.respond_to?(:on_connected)
@@ -215,14 +218,14 @@ module Stomp
215
218
  # The receive may fail so we may need to retry.
216
219
  while TRUE
217
220
  begin
218
- used_socket = socket
221
+ used_socket = socket()
219
222
  return _receive(used_socket)
220
223
  rescue
221
224
  @failure = $!
222
225
  raise unless @reliable
223
226
  errstr = "receive failed: #{$!}"
224
227
  if @logger && @logger.respond_to?(:on_miscerr)
225
- @logger.on_miscerr(log_params, errstr)
228
+ @logger.on_miscerr(log_params, "es_oldrecv: " + errstr)
226
229
  else
227
230
  $stderr.print errstr
228
231
  end
data/lib/stomp/codec.rb CHANGED
@@ -21,8 +21,8 @@ module Stomp
21
21
  return in_string unless in_string
22
22
  ev = Stomp::ENCODE_VALUES # avoid typing below
23
23
  os = in_string + ""
24
- 0.step(ev.length-2,2) do |i|
25
- os.gsub!(ev[i], ev[i+1])
24
+ 0.step(ev.length-2,2) do |i| # [encoded, decoded]
25
+ os.gsub!(ev[i+1], ev[i])
26
26
  end
27
27
  os
28
28
  end
@@ -32,8 +32,8 @@ module Stomp
32
32
  return in_string unless in_string
33
33
  ev = Stomp::DECODE_VALUES # avoid typing below
34
34
  os = in_string + ""
35
- 0.step(ev.length-2,2) do |i|
36
- os.gsub!(ev[i+1], ev[i])
35
+ 0.step(ev.length-2,2) do |i| # [encoded, decoded]
36
+ os.gsub!(ev[i], ev[i+1])
37
37
  end
38
38
  os
39
39
  end
@@ -373,7 +373,7 @@ module Stomp
373
373
  if super_result.nil? && @reliable && !closed?
374
374
  errstr = "connection.receive returning EOF as nil - resetting connection.\n"
375
375
  if @logger && @logger.respond_to?(:on_miscerr)
376
- @logger.on_miscerr(log_params, errstr)
376
+ @logger.on_miscerr(log_params, "es_recv: " + errstr)
377
377
  else
378
378
  $stderr.print errstr
379
379
  end
@@ -74,7 +74,7 @@ module Stomp
74
74
  # Codec from/to values.
75
75
  #
76
76
  ENCODE_VALUES = [
77
- "\\\\", "\\", # encoded, decoded
77
+ "\\\\\\\\", "\\", # encoded, decoded
78
78
  "\\" + "n", "\n",
79
79
  "\\" + "r", "\r",
80
80
  "\\c", ":",
@@ -82,7 +82,7 @@ module Stomp
82
82
 
83
83
  #
84
84
  DECODE_VALUES = [
85
- "\\\\\\\\", "\\", # encoded, decoded
85
+ "\\\\", "\\", # encoded, decoded
86
86
  "\\" + "n", "\n",
87
87
  "\\" + "r", "\r",
88
88
  "\\c", ":",
data/lib/stomp/message.rb CHANGED
@@ -56,11 +56,11 @@ module Stomp
56
56
  end
57
57
  self.command = work_command
58
58
  work_headers.split("\n").map do |value|
59
- parsed_value = value.match /^([\r|\w|-]*):(.*)$/
60
- raise Stomp::Error::InvalidFormat, 'parsed header value' unless parsed_value
59
+ fc = value.index(":")
60
+ raise Stomp::Error::InvalidFormat, 'parsed header value' unless fc
61
61
  #
62
- pk = parsed_value[1]
63
- pv = parsed_value[2]
62
+ pk = value[0...fc]
63
+ pv = value[fc+1..-1]
64
64
  #
65
65
  if protocol11p
66
66
  pk.force_encoding(Stomp::UTF8) if pk.respond_to?(:force_encoding)
data/lib/stomp/version.rb CHANGED
@@ -6,7 +6,7 @@ module Stomp
6
6
  module Version #:nodoc: all
7
7
  MAJOR = 1
8
8
  MINOR = 2
9
- PATCH = 7
9
+ PATCH = 8
10
10
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
11
11
  end
12
12
  end
data/stomp.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stomp}
8
- s.version = "1.2.7"
8
+ s.version = "1.2.8"
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-11-02}
12
+ s.date = %q{2012-12-28}
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"]
data/test/test_client.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'test_helper'
3
+ if Kernel.respond_to?(:require_relative)
4
+ require_relative("test_helper")
5
+ else
6
+ $:.unshift(File.dirname(__FILE__))
7
+ require 'test_helper'
8
+ end
6
9
 
7
10
  =begin
8
11
 
data/test/test_codec.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'test_helper'
3
+ if Kernel.respond_to?(:require_relative)
4
+ require_relative("test_helper")
5
+ else
6
+ $:.unshift(File.dirname(__FILE__))
7
+ require 'test_helper'
8
+ end
6
9
 
7
10
  =begin
8
11
 
@@ -37,10 +40,10 @@ class TestCodec < Test::Unit::TestCase
37
40
  #
38
41
  test_data.each do |s|
39
42
  #
40
- s_decoded = Stomp::HeaderCodec::decode(s)
41
- assert_equal s, s_decoded, "Sanity check decode: #{s} | #{s_decoded}"
42
- s_reencoded = Stomp::HeaderCodec::encode(s_decoded)
43
- assert_equal s_decoded, s_reencoded, "Sanity check reencode: #{s_decoded} | #{s_reencoded}"
43
+ s_decoded_a = Stomp::HeaderCodec::decode(s)
44
+ assert_equal s, s_decoded_a, "Sanity check decode: #{s} | #{s_decoded_a}"
45
+ s_reencoded = Stomp::HeaderCodec::encode(s_decoded_a)
46
+ assert_equal s_decoded_a, s_reencoded, "Sanity check reencode: #{s_decoded_a} | #{s_reencoded}"
44
47
  #
45
48
  end
46
49
  end
@@ -48,7 +51,8 @@ class TestCodec < Test::Unit::TestCase
48
51
  # Test the basic encoding / decoding requirements.
49
52
  def test_1010_basic_encode_decode
50
53
  test_data = [
51
- [ "\\\\", "\\" ],
54
+ [ "\\\\\\\\", "\\\\" ], # [encoded, decoded]
55
+ [ "\\\\", "\\" ], # [encoded, decoded]
52
56
  ["\\n", "\n"],
53
57
  ["\\r", "\r"],
54
58
  ["\\c", ":"],
@@ -63,31 +67,51 @@ class TestCodec < Test::Unit::TestCase
63
67
  ]
64
68
  #
65
69
  test_data.each do |s|
70
+ encoded_orig = s[0]
71
+ decoded_orig = s[1]
72
+
73
+ # Part 1
74
+ s_decoded_a = Stomp::HeaderCodec::decode(encoded_orig)
75
+ assert_equal decoded_orig, s_decoded_a, "Sanity check decode: #{decoded_orig} | #{s_decoded_a}"
66
76
  #
67
- s_decoded = Stomp::HeaderCodec::encode(s[0])
68
- assert_equal s[1], s_decoded, "Sanity check encode: #{s[1]} | #{s_decoded}"
77
+ s_encoded_a = Stomp::HeaderCodec::encode(decoded_orig)
78
+ assert_equal encoded_orig, s_encoded_a, "Sanity check encode: #{encoded_orig} | #{s_encoded_a}"
79
+
80
+ # Part 2
81
+ s_decoded_b = Stomp::HeaderCodec::decode(s_encoded_a)
82
+ assert_equal decoded_orig, s_decoded_b, "Sanity check 2 decode: #{decoded_orig} | #{s_decoded_b}"
69
83
  #
70
- s_encoded = Stomp::HeaderCodec::decode(s[1])
71
- assert_equal s[0], s_encoded, "Sanity check decode: #{s[0]} | #{s_encoded}"
84
+ s_encoded_b = Stomp::HeaderCodec::encode(s_decoded_a)
85
+ assert_equal encoded_orig, s_encoded_b, "Sanity check 2 encode: #{encoded_orig} | #{s_encoded_b}"
72
86
  end
73
87
  end
74
88
 
75
89
  # Test more complex strings with the codec.
76
90
  def test_1020_fancier
77
91
  test_data = [
78
- [ "a\\\\b", "a\\b" ],
92
+ [ "a\\\\b", "a\\b" ], # [encoded, decoded]
79
93
  [ "\\\\\\n\\c", "\\\n:" ],
80
94
  [ "\\\\\\r\\c", "\\\r:" ],
81
95
  [ "\\rr\\\\\\n\\c", "\rr\\\n:" ],
82
96
  ]
83
97
  #
84
98
  test_data.each do |s|
99
+ encoded_orig = s[0]
100
+ decoded_orig = s[1]
101
+
102
+ # Part 1
103
+ s_decoded_a = Stomp::HeaderCodec::decode(encoded_orig)
104
+ assert_equal decoded_orig, s_decoded_a, "Sanity check decode: #{decoded_orig} | #{s_decoded_a}"
85
105
  #
86
- s_decoded = Stomp::HeaderCodec::encode(s[0])
87
- assert_equal s[1], s_decoded, "Sanity check encode: #{s[1]} | #{s_decoded}"
106
+ s_encoded_a = Stomp::HeaderCodec::encode(decoded_orig)
107
+ assert_equal encoded_orig, s_encoded_a, "Sanity check encode: #{encoded_orig} | #{s_encoded_a}"
108
+
109
+ # Part 2
110
+ s_decoded_b = Stomp::HeaderCodec::decode(s_encoded_a)
111
+ assert_equal decoded_orig, s_decoded_b, "Sanity check 2 decode: #{decoded_orig} | #{s_decoded_b}"
88
112
  #
89
- s_encoded = Stomp::HeaderCodec::decode(s[1])
90
- assert_equal s[0], s_encoded, "Sanity check decode: #{s[0]} | #{s_encoded}"
113
+ s_encoded_b = Stomp::HeaderCodec::encode(s_decoded_a)
114
+ assert_equal encoded_orig, s_encoded_b, "Sanity check 2 encode: #{encoded_orig} | #{s_encoded_b}"
91
115
  end
92
116
  end
93
117
 
@@ -1,8 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'test_helper'
3
+ if Kernel.respond_to?(:require_relative)
4
+ require_relative("test_helper")
5
+ else
6
+ $:.unshift(File.dirname(__FILE__))
7
+ require 'test_helper'
8
+ end
6
9
 
7
10
  =begin
8
11
 
@@ -1,12 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'test_helper'
3
+ if Kernel.respond_to?(:require_relative)
4
+ require_relative("test_helper")
5
+ else
6
+ $:.unshift(File.dirname(__FILE__))
7
+ require 'test_helper'
8
+ end
6
9
 
7
10
  =begin
8
11
 
9
- Main class for testing Stomp::Connection instances, protocol level 1.1+.
12
+ Main class for testing Stomp::Connection instances, protocol levels 1.1+.
10
13
 
11
14
  =end
12
15
  class TestConnection1P < Test::Unit::TestCase
@@ -27,6 +30,7 @@ class TestConnection1P < Test::Unit::TestCase
27
30
 
28
31
  # Test missing connect headers.
29
32
  def test_conn_1p_0010
33
+ @conn.disconnect
30
34
  #
31
35
  cha = {:host => "localhost"}
32
36
  assert_raise Stomp::Error::ProtocolErrorConnect do
@@ -41,6 +45,7 @@ class TestConnection1P < Test::Unit::TestCase
41
45
 
42
46
  # Test requesting only a 1.0 connection.
43
47
  def test_conn_1p_0020
48
+ @conn.disconnect
44
49
  #
45
50
  cha = {:host => "localhost", "accept-version" => "1.0"}
46
51
  cha[:host] = "/" if ENV['STOMP_RABBIT']
@@ -52,38 +57,38 @@ class TestConnection1P < Test::Unit::TestCase
52
57
  assert_equal conn.protocol, Stomp::SPL_10
53
58
  end
54
59
 
55
- # Test requesting only a 1.1 connection.
60
+ # Test requesting only a 1.1+ connection.
56
61
  def test_conn_1p_0030
62
+ @conn.disconnect
57
63
  #
58
- cha = {:host => "localhost", "accept-version" => "1.1"}
59
- cha[:host] = "/" if ENV['STOMP_RABBIT']
64
+ cha = get_conn_headers()
60
65
  conn = nil
61
66
  assert_nothing_raised do
62
67
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
63
68
  conn.disconnect
64
69
  end
65
- assert_equal conn.protocol, Stomp::SPL_11
70
+ assert conn.protocol >= Stomp::SPL_11
66
71
  end
67
72
 
68
73
  # Test basic request for no heartbeats.
69
74
  def test_conn_1p_0040
75
+ @conn.disconnect
70
76
  #
71
- cha = {:host => "localhost", "accept-version" => "1.1"}
72
- cha[:host] = "/" if ENV['STOMP_RABBIT']
77
+ cha = get_conn_headers()
73
78
  cha["heart-beat"] = "0,0" # No heartbeats
74
79
  conn = nil
75
80
  assert_nothing_raised do
76
81
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
77
82
  conn.disconnect
78
83
  end
79
- assert_equal conn.protocol, Stomp::SPL_11
84
+ assert conn.protocol >= Stomp::SPL_11
80
85
  end
81
86
 
82
87
  # Test malformed heartbeat header.
83
88
  def test_conn_1p_0050
89
+ @conn.disconnect
84
90
  #
85
- cha = {:host => "localhost", "accept-version" => "1.1"}
86
- cha[:host] = "/" if ENV['STOMP_RABBIT']
91
+ cha = get_conn_headers()
87
92
  cha["heart-beat"] = "10,10,20" # Bad header Heartbeats
88
93
  conn = nil
89
94
  assert_raise Stomp::Error::InvalidHeartBeatHeaderError do
@@ -93,9 +98,9 @@ class TestConnection1P < Test::Unit::TestCase
93
98
 
94
99
  # Test malformed heartbeat header.
95
100
  def test_conn_11h_0060
101
+ @conn.disconnect
96
102
  #
97
- cha = {:host => "localhost", "accept-version" => "1.1"}
98
- cha[:host] = "/" if ENV['STOMP_RABBIT']
103
+ cha = get_conn_headers()
99
104
  cha["heart-beat"] = "a,10" # Bad header Heartbeats
100
105
  conn = nil
101
106
  assert_raise Stomp::Error::InvalidHeartBeatHeaderError do
@@ -105,9 +110,9 @@ class TestConnection1P < Test::Unit::TestCase
105
110
 
106
111
  # Test a valid heartbeat header.
107
112
  def test_conn_1p_0070
113
+ @conn.disconnect
108
114
  #
109
- cha = {:host => "localhost", "accept-version" => "1.1"}
110
- cha[:host] = "/" if ENV['STOMP_RABBIT']
115
+ cha = get_conn_headers()
111
116
  cha["heart-beat"] = "500,1000" # Valid heart beat headers
112
117
  conn = nil
113
118
  assert_nothing_raised do
@@ -120,9 +125,9 @@ class TestConnection1P < Test::Unit::TestCase
120
125
 
121
126
  # Test only sending heartbeats.
122
127
  def test_conn_1p_0080
128
+ @conn.disconnect
123
129
  #
124
- cha = {:host => "localhost", "accept-version" => "1.1"}
125
- cha[:host] = "/" if ENV['STOMP_RABBIT']
130
+ cha = get_conn_headers()
126
131
  cha["heart-beat"] = "10000,0" # Valid heart beat headers, send only
127
132
  conn = nil
128
133
  logger = Tlogger.new
@@ -138,9 +143,9 @@ class TestConnection1P < Test::Unit::TestCase
138
143
 
139
144
  # Test only receiving heartbeats.
140
145
  def test_conn_1p_0090
146
+ @conn.disconnect
141
147
  #
142
- cha = {:host => "localhost", "accept-version" => "1.1"}
143
- cha[:host] = "/" if ENV['STOMP_RABBIT']
148
+ cha = get_conn_headers()
144
149
  cha["heart-beat"] = "0,6000" # Valid heart beat headers, receive only
145
150
  conn = nil
146
151
  logger = Tlogger.new
@@ -157,9 +162,9 @@ class TestConnection1P < Test::Unit::TestCase
157
162
 
158
163
  # Test sending and receiving heartbeats.
159
164
  def test_conn_1p_0100
165
+ @conn.disconnect
160
166
  #
161
- cha = {:host => "localhost", "accept-version" => "1.1"}
162
- cha[:host] = "/" if ENV['STOMP_RABBIT']
167
+ cha = get_conn_headers()
163
168
  cha["heart-beat"] = "5000,10000" # Valid heart beat headers, send and receive
164
169
  conn = nil
165
170
  logger = Tlogger.new
@@ -176,9 +181,9 @@ class TestConnection1P < Test::Unit::TestCase
176
181
 
177
182
  # Test valid UTF8 data.
178
183
  def test_conn_1p_0110
184
+ @conn.disconnect
179
185
  #
180
- cha = {:host => "localhost", "accept-version" => "1.1"}
181
- cha[:host] = "/" if ENV['STOMP_RABBIT']
186
+ cha = get_conn_headers()
182
187
  cha["heart-beat"] = "0,0" # No heartbeats
183
188
  conn = nil
184
189
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
@@ -207,9 +212,9 @@ class TestConnection1P < Test::Unit::TestCase
207
212
 
208
213
  # Test invalid UTF8 data.
209
214
  def test_conn_1p_0120
215
+ @conn.disconnect
210
216
  #
211
- cha = {:host => "localhost", "accept-version" => "1.1"}
212
- cha[:host] = "/" if ENV['STOMP_RABBIT']
217
+ cha = get_conn_headers()
213
218
  cha["heart-beat"] = "0,0" # No heartbeats
214
219
  conn = nil
215
220
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
@@ -279,9 +284,9 @@ class TestConnection1P < Test::Unit::TestCase
279
284
 
280
285
  # Test heartbeats with send and receive.
281
286
  def test_conn_1p_0130
287
+ @conn.disconnect
282
288
  #
283
- cha = {:host => "localhost", "accept-version" => "1.1"}
284
- cha[:host] = "/" if ENV['STOMP_RABBIT']
289
+ cha = get_conn_headers()
285
290
  cha["heart-beat"] = "10000,6000" # Valid heart beat headers, send and receive
286
291
  conn = nil
287
292
  logger = Tlogger.new
@@ -298,9 +303,9 @@ class TestConnection1P < Test::Unit::TestCase
298
303
 
299
304
  # Test heartbeats with send and receive.
300
305
  def test_conn_1p_0135
306
+ @conn.disconnect
301
307
  #
302
- cha = {:host => "localhost", "accept-version" => "1.1"}
303
- cha[:host] = "/" if ENV['STOMP_RABBIT']
308
+ cha = get_conn_headers()
304
309
  cha["heart-beat"] = "10000,1000" # Valid heart beat headers, send and receive
305
310
  conn = nil
306
311
  logger = Tlogger.new
@@ -317,9 +322,9 @@ class TestConnection1P < Test::Unit::TestCase
317
322
 
318
323
  # Test heartbeats with send and receive.
319
324
  def test_conn_1p_0140
325
+ @conn.disconnect
320
326
  #
321
- cha = {:host => "localhost", "accept-version" => "1.1"}
322
- cha[:host] = "/" if ENV['STOMP_RABBIT']
327
+ cha = get_conn_headers()
323
328
  cha["heart-beat"] = "1000,10000" # Valid heart beat headers, send and receive
324
329
  conn = nil
325
330
  logger = Tlogger.new
@@ -334,6 +339,36 @@ class TestConnection1P < Test::Unit::TestCase
334
339
  hb_asserts_both(conn)
335
340
  end if ENV['STOMP_HB11LONG']
336
341
 
342
+ # Test very encoding / decoding of headers
343
+ def test_conn_1p_0200
344
+ @conn.disconnect
345
+ #
346
+ cha = get_conn_headers()
347
+ conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
348
+ msg = "payload: #{Time.now.to_f}"
349
+ dest = make_destination
350
+ shdrs = { "ab:cd" => "ef:gh", "a\nb" => "c\nd", "x\\y" => "z\\s" }
351
+ if conn.protocol >= Stomp::SPL_12
352
+ shdrs["bb\rcc"] = "dd\ree"
353
+ end
354
+ assert_nothing_raised {
355
+ conn.publish dest, msg, shdrs
356
+ }
357
+ #
358
+ sid = conn.uuid()
359
+ conn.subscribe dest, :id => sid
360
+ #
361
+ received = conn.receive
362
+ assert_equal msg, received.body
363
+ #
364
+ shdrs.each_pair {|k,v|
365
+ assert received.headers.has_key?(k), "Key not found: #{k}"
366
+ assert received.headers.has_value?(v), "Value not found: #{v}"
367
+ assert received.headers[k] == v, "Mismatch: #{k},#{v}"
368
+ }
369
+ conn.disconnect
370
+ end unless ENV['STOMP_RABBIT']
371
+
337
372
  private
338
373
 
339
374
  def hb_asserts_both(conn)
data/test/test_helper.rb CHANGED
@@ -1,11 +1,16 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
4
-
5
3
  require 'test/unit'
6
4
  require 'timeout'
7
- require 'stomp'
8
- require 'tlogger'
5
+
6
+ if Kernel.respond_to?(:require_relative)
7
+ require_relative("../lib/stomp")
8
+ require_relative("tlogger")
9
+ else
10
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
11
+ require 'stomp'
12
+ require 'tlogger'
13
+ end
9
14
 
10
15
  begin
11
16
  dummy = RUBY_ENGINE
data/test/test_message.rb CHANGED
@@ -6,11 +6,16 @@
6
6
  # as UTF-8 encoded.
7
7
  #
8
8
 
9
- $:.unshift(File.dirname(__FILE__))
9
+ if Kernel.respond_to?(:require_relative)
10
+ require_relative("test_helper")
11
+ else
12
+ $:.unshift(File.dirname(__FILE__))
13
+ require 'test_helper'
14
+ end
15
+
10
16
  #
11
17
  # Test Ruby 1.8 with $KCODE='U'
12
18
  #
13
- require 'test_helper'
14
19
 
15
20
  =begin
16
21
 
data/test/test_ssl.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'test_helper'
3
+ if Kernel.respond_to?(:require_relative)
4
+ require_relative("test_helper")
5
+ else
6
+ $:.unshift(File.dirname(__FILE__))
7
+ require 'test_helper'
8
+ end
6
9
 
7
10
  =begin
8
11
 
data/test/tlogger.rb CHANGED
@@ -4,54 +4,19 @@ require 'logger' # use the standard Ruby logger .....
4
4
 
5
5
  =begin
6
6
 
7
- Callback logger for Stomp 1.1 heartbeat tests.
7
+ Callback logger for Stomp 1.1+ heartbeat tests.
8
8
 
9
9
  =end
10
10
  class Tlogger
11
11
 
12
12
  # Initialize a callback logger class.
13
13
  def initialize(init_parms = nil)
14
+ puts
14
15
  @log = Logger::new(STDOUT) # User preference
15
16
  @log.level = Logger::DEBUG # User preference
16
17
  @log.info("Logger initialization complete.")
17
18
  end
18
19
 
19
- # Log connecting events.
20
- def on_connecting(parms)
21
- begin
22
- @log.debug "Connecting: #{info(parms)}"
23
- rescue
24
- @log.debug "Connecting oops"
25
- end
26
- end
27
-
28
- # Log connected events.
29
- def on_connected(parms)
30
- begin
31
- @log.debug "Connected: #{info(parms)}"
32
- rescue
33
- @log.debug "Connected oops"
34
- end
35
- end
36
-
37
- # Log connectfail events.
38
- def on_connectfail(parms)
39
- begin
40
- @log.debug "Connect Fail #{info(parms)}"
41
- rescue
42
- @log.debug "Connect Fail oops"
43
- end
44
- end
45
-
46
- # Log disconnect events.
47
- def on_disconnect(parms)
48
- begin
49
- @log.debug "Disconnected #{info(parms)}"
50
- rescue
51
- @log.debug "Disconnected oops"
52
- end
53
- end
54
-
55
20
  # Log miscellaneous errors.
56
21
  def on_miscerr(parms, errstr)
57
22
  begin
@@ -62,37 +27,6 @@ class Tlogger
62
27
  end
63
28
  end
64
29
 
65
- # Log subscribes.
66
- def on_subscribe(parms, headers)
67
- begin
68
- @log.debug "Subscribe Parms #{info(parms)}"
69
- @log.debug "Subscribe Headers #{headers}"
70
- rescue
71
- @log.debug "Subscribe oops"
72
- end
73
- end
74
-
75
- # Log publishes.
76
- def on_publish(parms, message, headers)
77
- begin
78
- @log.debug "Publish Parms #{info(parms)}"
79
- @log.debug "Publish Message #{message}"
80
- @log.debug "Publish Headers #{headers}"
81
- rescue
82
- @log.debug "Publish oops"
83
- end
84
- end
85
-
86
- # Log receives.
87
- def on_receive(parms, result)
88
- begin
89
- @log.debug "Receive Parms #{info(parms)}"
90
- @log.debug "Receive Result #{result}"
91
- rescue
92
- @log.debug "Receive oops"
93
- end
94
- end
95
-
96
30
  # Stomp 1.1+ - heart beat send (transmit) failed
97
31
  def on_hbwrite_fail(parms, ticker_data)
98
32
  begin
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stomp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 7
10
- version: 1.2.7
9
+ - 8
10
+ version: 1.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian McCallister
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2012-11-02 00:00:00 -04:00
21
+ date: 2012-12-28 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency