stomp 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
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/test/test_helper.rb CHANGED
@@ -13,30 +13,43 @@ rescue NameError => ne
13
13
  RUBY_ENGINE = "unknown"
14
14
  end
15
15
 
16
- # Helper routines
16
+ =begin
17
+
18
+ Test helper methods.
19
+
20
+ =end
17
21
  module TestBase
22
+
23
+ # Get user
18
24
  def user
19
25
  ENV['STOMP_USER'] || "guest"
20
26
  end
27
+
28
+ # Gete passcode
21
29
  def passcode
22
30
  ENV['STOMP_PASSCODE'] || "guest"
23
31
  end
32
+
24
33
  # Get host
25
34
  def host
26
35
  ENV['STOMP_HOST'] || "localhost"
27
36
  end
37
+
28
38
  # Get port
29
39
  def port
30
40
  (ENV['STOMP_PORT'] || 61613).to_i
31
41
  end
42
+
32
43
  # Get SSL port
33
44
  def ssl_port
34
45
  (ENV['STOMP_SSLPORT'] || 61612).to_i
35
46
  end
47
+
36
48
  # Helper for minitest on 1.9
37
49
  def caller_method_name
38
50
  parse_caller(caller(2).first).last
39
51
  end
52
+
40
53
  # Helper for minitest on 1.9
41
54
  def parse_caller(at)
42
55
  if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
@@ -48,12 +61,14 @@ module TestBase
48
61
  end
49
62
  end
50
63
 
64
+ # Get a Stomp Connection.
51
65
  def get_connection()
52
66
  ch = get_conn_headers()
53
67
  conn = Stomp::Connection.open(user, passcode, host, port, false, 5, ch)
54
68
  conn
55
69
  end
56
70
 
71
+ # Get a Stomp SSL Connection.
57
72
  def get_ssl_connection()
58
73
  ch = get_conn_headers()
59
74
  ssl_params = Stomp::SSLParams.new # S/B safe for all Ruby versions tested
@@ -66,6 +81,7 @@ module TestBase
66
81
  conn
67
82
  end
68
83
 
84
+ # Get a Stomp Client.
69
85
  def get_client()
70
86
  hash = { :hosts => [
71
87
  {:login => user, :passcode => passcode, :host => host, :port => port},
@@ -77,6 +93,7 @@ module TestBase
77
93
  client
78
94
  end
79
95
 
96
+ # Get a connection headers hash.
80
97
  def get_conn_headers()
81
98
  ch = {}
82
99
  if ENV['STOMP_TEST11']
@@ -92,6 +109,7 @@ module TestBase
92
109
  ch
93
110
  end
94
111
 
112
+ # Subscribe to a destination.
95
113
  def conn_subscribe(dest, headers = {})
96
114
  if @conn.protocol >= Stomp::SPL_11
97
115
  headers[:id] = @conn.uuid() unless headers[:id]
@@ -99,8 +117,7 @@ module TestBase
99
117
  @conn.subscribe dest, headers
100
118
  end
101
119
 
102
- # Test helper methods
103
-
120
+ # Get a dynamic destination name.
104
121
  def make_destination
105
122
  name = caller_method_name unless name
106
123
  qname = ENV['STOMP_DOTQUEUE'] ? "/queue/test.ruby.stomp." + name : "/queue/test/ruby/stomp/" + name
data/test/test_message.rb CHANGED
@@ -11,7 +11,12 @@ $:.unshift(File.dirname(__FILE__))
11
11
  # Test Ruby 1.8 with $KCODE='U'
12
12
  #
13
13
  require 'test_helper'
14
- #
14
+
15
+ =begin
16
+
17
+ Main class for testing Stomp::Message.
18
+
19
+ =end
15
20
  class TestMessage < Test::Unit::TestCase
16
21
  include TestBase
17
22
  #
@@ -87,7 +92,7 @@ class TestMessage < Test::Unit::TestCase
87
92
  end
88
93
  end
89
94
 
90
- #
95
+ # Test various valid and invalid frames.
91
96
  def test_0040_msg_create
92
97
  #
93
98
  assert_raise(Stomp::Error::InvalidFormat) {
@@ -132,7 +137,7 @@ class TestMessage < Test::Unit::TestCase
132
137
 
133
138
  end
134
139
 
135
- # Multiple headers with the same key
140
+ # Test multiple headers with the same key
136
141
  def test_0050_mh_msg_create
137
142
  aframe = bframe = nil
138
143
  assert_nothing_raised {
data/test/test_ssl.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::SSLParams.
10
+
11
+ =end
7
12
  class TestSSL < Test::Unit::TestCase
8
13
  include TestBase
9
14
 
@@ -19,7 +24,7 @@ class TestSSL < Test::Unit::TestCase
19
24
  assert @conn.open?
20
25
  end
21
26
 
22
- #
27
+ # Test SSLParams basic.
23
28
  def test_ssl_0010_parms
24
29
  ssl_params = Stomp::SSLParams.new
25
30
  assert ssl_params.ts_files.nil?
@@ -28,7 +33,7 @@ class TestSSL < Test::Unit::TestCase
28
33
  assert ssl_params.fsck.nil?
29
34
  end
30
35
 
31
- #
36
+ # Test using correct parameters.
32
37
  def test_ssl_0020_noraise
33
38
  assert_nothing_raised {
34
39
  ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1", :key_file => "dummy2")
@@ -41,7 +46,8 @@ class TestSSL < Test::Unit::TestCase
41
46
  :cert_file => "dummy1", :key_file => "dummy2")
42
47
  }
43
48
  end
44
- #
49
+
50
+ # Test using incorrect / incomplete parameters.
45
51
  def test_ssl_0030_raise
46
52
  assert_raise(Stomp::Error::SSLClientParamsError) {
47
53
  ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1")
@@ -51,7 +57,7 @@ class TestSSL < Test::Unit::TestCase
51
57
  }
52
58
  end
53
59
 
54
- #
60
+ # Test that :fsck works.
55
61
  def test_ssl_0040_fsck
56
62
  assert_raise(Stomp::Error::SSLNoCertFileError) {
57
63
  ssl_parms = Stomp::SSLParams.new(:cert_file => "dummy1",
data/test/tlogger.rb CHANGED
@@ -1,22 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
+ require 'logger' # use the standard Ruby logger .....
4
+
3
5
  =begin
4
6
 
5
- Callback logger for tests.
7
+ Callback logger for Stomp 1.1 heartbeat tests.
6
8
 
7
9
  =end
8
-
9
- require 'logger' # use the standard Ruby logger .....
10
-
11
10
  class Tlogger
12
- #
11
+
12
+ # Initialize a callback logger class.
13
13
  def initialize(init_parms = nil)
14
14
  @log = Logger::new(STDOUT) # User preference
15
15
  @log.level = Logger::DEBUG # User preference
16
16
  @log.info("Logger initialization complete.")
17
17
  end
18
18
 
19
- # Log connecting events
19
+ # Log connecting events.
20
20
  def on_connecting(parms)
21
21
  begin
22
22
  @log.debug "Connecting: #{info(parms)}"
@@ -25,7 +25,7 @@ class Tlogger
25
25
  end
26
26
  end
27
27
 
28
- # Log connected events
28
+ # Log connected events.
29
29
  def on_connected(parms)
30
30
  begin
31
31
  @log.debug "Connected: #{info(parms)}"
@@ -34,7 +34,7 @@ class Tlogger
34
34
  end
35
35
  end
36
36
 
37
- # Log connectfail events
37
+ # Log connectfail events.
38
38
  def on_connectfail(parms)
39
39
  begin
40
40
  @log.debug "Connect Fail #{info(parms)}"
@@ -43,7 +43,7 @@ class Tlogger
43
43
  end
44
44
  end
45
45
 
46
- # Log disconnect events
46
+ # Log disconnect events.
47
47
  def on_disconnect(parms)
48
48
  begin
49
49
  @log.debug "Disconnected #{info(parms)}"
@@ -52,7 +52,7 @@ class Tlogger
52
52
  end
53
53
  end
54
54
 
55
- # Log miscellaneous errors
55
+ # Log miscellaneous errors.
56
56
  def on_miscerr(parms, errstr)
57
57
  begin
58
58
  @log.debug "Miscellaneous Error #{info(parms)}"
@@ -62,7 +62,7 @@ class Tlogger
62
62
  end
63
63
  end
64
64
 
65
- # Subscribe
65
+ # Log subscribes.
66
66
  def on_subscribe(parms, headers)
67
67
  begin
68
68
  @log.debug "Subscribe Parms #{info(parms)}"
@@ -72,7 +72,7 @@ class Tlogger
72
72
  end
73
73
  end
74
74
 
75
- # Publish
75
+ # Log publishes.
76
76
  def on_publish(parms, message, headers)
77
77
  begin
78
78
  @log.debug "Publish Parms #{info(parms)}"
@@ -83,7 +83,7 @@ class Tlogger
83
83
  end
84
84
  end
85
85
 
86
- # Receive
86
+ # Log receives.
87
87
  def on_receive(parms, result)
88
88
  begin
89
89
  @log.debug "Receive Parms #{info(parms)}"
@@ -139,7 +139,7 @@ class Tlogger
139
139
 
140
140
  def info(parms)
141
141
  #
142
- # Available in the Hash:
142
+ # Available in the parms Hash:
143
143
  # parms[:cur_host]
144
144
  # parms[:cur_port]
145
145
  # parms[:cur_login]
@@ -148,8 +148,9 @@ class Tlogger
148
148
  # parms[:cur_recondelay]
149
149
  # parms[:cur_parseto]
150
150
  # parms[:cur_conattempts]
151
+ # parms[:openstat]
151
152
  #
152
- "Host: #{parms[:cur_host]}, Port: #{parms[:cur_port]}, Login: Port: #{parms[:cur_login]}, Passcode: #{parms[:cur_passcode]}"
153
+ "Host: #{parms[:cur_host]}, Port: #{parms[:cur_port]}, Login: #{parms[:cur_login]}, Passcode: #{parms[:cur_passcode]}"
153
154
  end
154
155
  end # of class
155
156
 
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 4
10
- version: 1.2.4
9
+ - 5
10
+ version: 1.2.5
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-06-25 00:00:00 -04:00
21
+ date: 2012-08-04 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -48,8 +48,58 @@ executables:
48
48
  extensions: []
49
49
 
50
50
  extra_rdoc_files:
51
+ - CHANGELOG.rdoc
51
52
  - LICENSE
52
53
  - README.rdoc
54
+ - examples/client11_ex1.rb
55
+ - examples/client11_putget1.rb
56
+ - examples/conn11_ex1.rb
57
+ - examples/conn11_ex2.rb
58
+ - examples/conn11_hb1.rb
59
+ - examples/consumer.rb
60
+ - examples/get11conn_ex1.rb
61
+ - examples/get11conn_ex2.rb
62
+ - examples/logexamp.rb
63
+ - examples/logexamp_ssl.rb
64
+ - examples/publisher.rb
65
+ - examples/put11conn_ex1.rb
66
+ - examples/putget11_rh1.rb
67
+ - examples/slogger.rb
68
+ - examples/ssl_uc1.rb
69
+ - examples/ssl_uc1_ciphers.rb
70
+ - examples/ssl_uc2.rb
71
+ - examples/ssl_uc2_ciphers.rb
72
+ - examples/ssl_uc3.rb
73
+ - examples/ssl_uc3_ciphers.rb
74
+ - examples/ssl_uc4.rb
75
+ - examples/ssl_uc4_ciphers.rb
76
+ - examples/ssl_ucx_default_ciphers.rb
77
+ - examples/stomp11_common.rb
78
+ - examples/topic_consumer.rb
79
+ - examples/topic_publisher.rb
80
+ - lib/client/utils.rb
81
+ - lib/connection/heartbeats.rb
82
+ - lib/connection/netio.rb
83
+ - lib/connection/utf8.rb
84
+ - lib/connection/utils.rb
85
+ - lib/stomp.rb
86
+ - lib/stomp/client.rb
87
+ - lib/stomp/codec.rb
88
+ - lib/stomp/connection.rb
89
+ - lib/stomp/constants.rb
90
+ - lib/stomp/errors.rb
91
+ - lib/stomp/ext/hash.rb
92
+ - lib/stomp/message.rb
93
+ - lib/stomp/sslparams.rb
94
+ - lib/stomp/version.rb
95
+ - test/test_client.rb
96
+ - test/test_codec.rb
97
+ - test/test_connection.rb
98
+ - test/test_connection1p.rb
99
+ - test/test_helper.rb
100
+ - test/test_message.rb
101
+ - test/test_ssl.rb
102
+ - test/tlogger.rb
53
103
  files:
54
104
  - CHANGELOG.rdoc
55
105
  - LICENSE
@@ -83,6 +133,11 @@ files:
83
133
  - examples/stomp11_common.rb
84
134
  - examples/topic_consumer.rb
85
135
  - examples/topic_publisher.rb
136
+ - lib/client/utils.rb
137
+ - lib/connection/heartbeats.rb
138
+ - lib/connection/netio.rb
139
+ - lib/connection/utf8.rb
140
+ - lib/connection/utils.rb
86
141
  - lib/stomp.rb
87
142
  - lib/stomp/client.rb
88
143
  - lib/stomp/codec.rb