stomp 1.3.4 → 1.3.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.
- data/CHANGELOG.rdoc +11 -0
- data/README.rdoc +32 -27
- data/Rakefile +1 -1
- data/examples/amqdurasub.rb +81 -0
- data/lib/connection/netio.rb +2 -0
- data/lib/connection/utils.rb +8 -3
- data/lib/stomp/client.rb +1 -1
- data/lib/stomp/connection.rb +3 -2
- data/lib/stomp/message.rb +0 -2
- data/lib/stomp/null_logger.rb +4 -1
- data/lib/stomp/version.rb +1 -1
- data/spec/client_shared_examples.rb +17 -17
- data/spec/client_spec.rb +61 -42
- data/spec/connection_spec.rb +59 -59
- data/spec/message_spec.rb +9 -8
- data/spec/spec_helper.rb +3 -0
- data/stomp.gemspec +7 -5
- metadata +10 -7
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 1.3.5 20160302
|
2
|
+
|
3
|
+
* Add AMQ specific durable topic example.
|
4
|
+
* Output error to stderr only in logger is undefined.
|
5
|
+
* Move README changelog lower.
|
6
|
+
* Handle newline at start of receive buffer.
|
7
|
+
* Use Timeout::timeout instead of deprecated kernel version.
|
8
|
+
* If socket open on reconnect, close it before new open.
|
9
|
+
* On misc_err, make error messages more readable.
|
10
|
+
* Attempt to support both Rspec 2.14.1+ and 3.x.
|
11
|
+
|
1
12
|
== 1.3.4 20141202
|
2
13
|
|
3
14
|
* Change :start_timeout default to 0 (might break some clients) (#98).
|
data/README.rdoc
CHANGED
@@ -8,33 +8,6 @@ An implementation of the Stomp protocol for Ruby. See:
|
|
8
8
|
|
9
9
|
* [STOMP 1.0, 1.1, and 1.2] (http://stomp.github.com/index.html)
|
10
10
|
|
11
|
-
===New
|
12
|
-
|
13
|
-
See _CHANGELOG.rdoc_ for details.
|
14
|
-
|
15
|
-
* Gem version 1.3.4. Miscellaneous fixes, see CHANGELOG.rdoc for details.
|
16
|
-
* Gem version 1.3.3. Miscellaneous fixes, see CHANGELOG.rdoc for details.
|
17
|
-
* Gem version 1.3.2. Miscellaneous fixes, see changelog for details.
|
18
|
-
* Gem version 1.3.1. Bugfix for logging.
|
19
|
-
* Gem version 1.3.0. Added ERROR frame raising as exception, added anonymous connections, miscellaneous other fixes.
|
20
|
-
* Gem version 1.2.16. Fixed Stomp::Client to expose its connection's host parameters.
|
21
|
-
* Gem version 1.2.15. Timeout cleanup, added license info to gemspec.
|
22
|
-
* Gem version 1.2.14. Cleanup.
|
23
|
-
* Gem version 1.2.13. Stomp::Client#unreceive max_redeliveries fix.
|
24
|
-
* Gem version 1.2.12. Miscellaneous issue fixes and cleanup.
|
25
|
-
* Gem version 1.2.11. JRuby and AMQ support fixes.
|
26
|
-
* Gem version 1.2.10. Support failover from heartbeat threads.
|
27
|
-
* Gem version 1.2.9. Miscellaneous fixes and changes.
|
28
|
-
* Gem version 1.2.8. Stomp 1.1+ header codec inversion fix, test refactoring.
|
29
|
-
* Gem version 1.2.7. Stomp 1.2 support and miscellaneous fixes.
|
30
|
-
* Gem version 1.2.6. Miscellaneous fixes and changes.
|
31
|
-
* Gem version 1.2.5. Restructure. Forks with modifcations will be affected.
|
32
|
-
* Gem version 1.2.4. Stomp 1.1 heartbeat fix, autoflush capability, miscellaneous fixes.
|
33
|
-
* Gem version 1.2.3. Miscellaneous fixes, see changelog for details.
|
34
|
-
* Gem version 1.2.2. Performance and more SSL enhancements.
|
35
|
-
* Gem version 1.2.1. Full support of SSL certificates.
|
36
|
-
* Gem version 1.2.0. Support of Stomp protocol level 1.1.
|
37
|
-
|
38
11
|
===Hash Login Example Usage (this is the recommended login technique)
|
39
12
|
|
40
13
|
hash = {
|
@@ -111,6 +84,34 @@ See _CHANGELOG.rdoc_ for details.
|
|
111
84
|
p msg
|
112
85
|
end
|
113
86
|
|
87
|
+
===New
|
88
|
+
|
89
|
+
See _CHANGELOG.rdoc_ for details.
|
90
|
+
|
91
|
+
* Gem version 1.3.5. Miscellaneous fixes, see CHANGELOG.rdoc for details.
|
92
|
+
* Gem version 1.3.4. Miscellaneous fixes, see CHANGELOG.rdoc for details.
|
93
|
+
* Gem version 1.3.3. Miscellaneous fixes, see CHANGELOG.rdoc for details.
|
94
|
+
* Gem version 1.3.2. Miscellaneous fixes, see changelog for details.
|
95
|
+
* Gem version 1.3.1. Bugfix for logging.
|
96
|
+
* Gem version 1.3.0. Added ERROR frame raising as exception, added anonymous connections, miscellaneous other fixes.
|
97
|
+
* Gem version 1.2.16. Fixed Stomp::Client to expose its connection's host parameters.
|
98
|
+
* Gem version 1.2.15. Timeout cleanup, added license info to gemspec.
|
99
|
+
* Gem version 1.2.14. Cleanup.
|
100
|
+
* Gem version 1.2.13. Stomp::Client#unreceive max_redeliveries fix.
|
101
|
+
* Gem version 1.2.12. Miscellaneous issue fixes and cleanup.
|
102
|
+
* Gem version 1.2.11. JRuby and AMQ support fixes.
|
103
|
+
* Gem version 1.2.10. Support failover from heartbeat threads.
|
104
|
+
* Gem version 1.2.9. Miscellaneous fixes and changes.
|
105
|
+
* Gem version 1.2.8. Stomp 1.1+ header codec inversion fix, test refactoring.
|
106
|
+
* Gem version 1.2.7. Stomp 1.2 support and miscellaneous fixes.
|
107
|
+
* Gem version 1.2.6. Miscellaneous fixes and changes.
|
108
|
+
* Gem version 1.2.5. Restructure. Forks with modifcations will be affected.
|
109
|
+
* Gem version 1.2.4. Stomp 1.1 heartbeat fix, autoflush capability, miscellaneous fixes.
|
110
|
+
* Gem version 1.2.3. Miscellaneous fixes, see changelog for details.
|
111
|
+
* Gem version 1.2.2. Performance and more SSL enhancements.
|
112
|
+
* Gem version 1.2.1. Full support of SSL certificates.
|
113
|
+
* Gem version 1.2.0. Support of Stomp protocol level 1.1.
|
114
|
+
|
114
115
|
===Historical Information
|
115
116
|
|
116
117
|
Up until March 2009 the project was maintained and primarily developed by Brian McCallister.
|
@@ -155,4 +156,8 @@ The following people have contributed to Stomp:
|
|
155
156
|
* Glenn Roberts
|
156
157
|
* Ian Smith
|
157
158
|
* Orazio Cotroneo
|
159
|
+
* m4rCsi
|
160
|
+
* Michael Klishin
|
161
|
+
* Patrick Sharp
|
162
|
+
* Wayne Robinson
|
158
163
|
|
data/Rakefile
CHANGED
@@ -37,7 +37,7 @@ begin
|
|
37
37
|
gem.homepage = "https://github.com/stompgem/stomp"
|
38
38
|
gem.authors = ["Brian McCallister", 'Marius Mathiesen', 'Thiago Morello',
|
39
39
|
'Guy M. Allard']
|
40
|
-
gem.add_development_dependency "rspec", '>= 2.
|
40
|
+
gem.add_development_dependency "rspec", '>= 2.14.1'
|
41
41
|
gem.extra_rdoc_files = [ "README.rdoc", "CHANGELOG.rdoc", "LICENSE",
|
42
42
|
"lib/**/*.rb", "examples/**/*.rb",
|
43
43
|
"test/**/*.rb" ]
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
#
|
4
|
+
# The current require dance for different Ruby versions.
|
5
|
+
# Change this to suit your requirements.
|
6
|
+
#
|
7
|
+
if Kernel.respond_to?(:require_relative)
|
8
|
+
require_relative("./stomp11_common")
|
9
|
+
else
|
10
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
+
require "stomp11_common"
|
12
|
+
end
|
13
|
+
|
14
|
+
=begin
|
15
|
+
|
16
|
+
A recent experience suggested that we might provide an example of how
|
17
|
+
to establish a "durable" topic subscription using ActiveMQ.
|
18
|
+
|
19
|
+
This code attempts to do that.
|
20
|
+
|
21
|
+
References:
|
22
|
+
|
23
|
+
http://activemq.apache.org/stomp.html
|
24
|
+
|
25
|
+
http://activemq.apache.org/how-does-a-queue-compare-to-a-topic.html
|
26
|
+
|
27
|
+
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
|
28
|
+
|
29
|
+
Specifically, locate the section titled: ActiveMQ extensions to Stomp.
|
30
|
+
|
31
|
+
There are two programmatic requirements:
|
32
|
+
|
33
|
+
1) On CONNECT, indicate to AMQ the code will be using durable topic
|
34
|
+
subscription(s).
|
35
|
+
Done by providing a "cilent-id" CONNECT header.
|
36
|
+
|
37
|
+
2) On SUBSCRIBE, indicate an AMQ specific (uniqie) subscription ID. Done
|
38
|
+
by providing a "activemq.subscriptionName" header to SUBSCRIBE.
|
39
|
+
|
40
|
+
=end
|
41
|
+
|
42
|
+
# login hash
|
43
|
+
hash = { :hosts => [
|
44
|
+
{:login => 'guest', :passcode => 'guest', :host => 'localhost', :port => 61613, :ssl => false}, # AMQ
|
45
|
+
],
|
46
|
+
:reliable => true,
|
47
|
+
:closed_check => false,
|
48
|
+
:connect_headers => {:host => "localhost", :"accept-version" => "1.0",
|
49
|
+
# Requirement 1, name should be unique.
|
50
|
+
:"client-id" => "dursubcli01", # REF the 1st AMQ link above
|
51
|
+
}
|
52
|
+
}
|
53
|
+
# The topic
|
54
|
+
topic = "/topic/topicName"
|
55
|
+
|
56
|
+
# Establish the client connection
|
57
|
+
cli = Stomp::Client.open(hash)
|
58
|
+
# SUBSCRIBE Headers
|
59
|
+
sh = { "activemq.subscriptionName" => "subname01" } # REF the 1st AMQ link above
|
60
|
+
# And the client subscribe
|
61
|
+
cli.subscribe(topic, sh) do |msg|
|
62
|
+
puts "msg: #{msg}"
|
63
|
+
end
|
64
|
+
# Wait for a very long time, usually exit via ^C
|
65
|
+
puts "Press ^C to exit"
|
66
|
+
sleep 1000000
|
67
|
+
puts "Done yet?"
|
68
|
+
|
69
|
+
=begin
|
70
|
+
At this point open your AMQ admin console (port 8161 usually), and examine
|
71
|
+
the 'subscribers' section. You should see an instance of this client
|
72
|
+
displayed in the "Active Durable Topic Subscribers" section.
|
73
|
+
|
74
|
+
When you press ^C to exit this program, return to the AMQ console and
|
75
|
+
refresh the display. (Do not restart AMQ). You should see this client in the
|
76
|
+
"Offline Durable Topic Subscribers" section.
|
77
|
+
=end
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
data/lib/connection/netio.rb
CHANGED
@@ -31,6 +31,8 @@ module Stomp
|
|
31
31
|
end
|
32
32
|
#
|
33
33
|
return nil if line.nil?
|
34
|
+
#An extra \n at the beginning of the frame, possibly not caught by is_ready?
|
35
|
+
line = '' if line == "\n"
|
34
36
|
# p [ "wiredatain_01", line ]
|
35
37
|
line = _normalize_line_end(line) if @protocol >= Stomp::SPL_12
|
36
38
|
# If the reading hangs for more than X seconds, abort the parsing process.
|
data/lib/connection/utils.rb
CHANGED
@@ -245,9 +245,13 @@ module Stomp
|
|
245
245
|
@failure = $!
|
246
246
|
raise unless @reliable
|
247
247
|
errstr = "receive failed: #{$!}"
|
248
|
-
unless slog(:on_miscerr, log_params, "
|
249
|
-
$stderr.print
|
250
|
-
|
248
|
+
unless slog(:on_miscerr, log_params, "es1_oldrecv: " + errstr)
|
249
|
+
$stderr.print "\non_miscerr\n"
|
250
|
+
$stderr.print log_params.inspect
|
251
|
+
$stderr.print "\n"
|
252
|
+
$stderr.print "es2_oldrecv: " + errstr
|
253
|
+
$stderr.print "\n"
|
254
|
+
end
|
251
255
|
|
252
256
|
# !!! This initiates a re-connect !!!
|
253
257
|
_reconn_prep()
|
@@ -257,6 +261,7 @@ module Stomp
|
|
257
261
|
|
258
262
|
# _reconn_prep prepares for a reconnect retry
|
259
263
|
def _reconn_prep()
|
264
|
+
close_socket()
|
260
265
|
if @parameters
|
261
266
|
change_host()
|
262
267
|
end
|
data/lib/stomp/client.rb
CHANGED
data/lib/stomp/connection.rb
CHANGED
@@ -442,8 +442,9 @@ module Stomp
|
|
442
442
|
super_result = __old_receive()
|
443
443
|
if super_result.nil? && @reliable && !closed?
|
444
444
|
errstr = "connection.receive returning EOF as nil - resetting connection.\n"
|
445
|
-
slog(:on_miscerr, log_params, "es_recv: " + errstr)
|
446
|
-
|
445
|
+
unless slog(:on_miscerr, log_params, "es_recv: " + errstr)
|
446
|
+
$stderr.print errstr
|
447
|
+
end
|
447
448
|
|
448
449
|
# !!! This initiates a re-connect !!!
|
449
450
|
# The call to __old_receive() will in turn call socket(). Before
|
data/lib/stomp/message.rb
CHANGED
@@ -102,8 +102,6 @@ module Stomp
|
|
102
102
|
"<Stomp::Message headers=#{headers.inspect} body='#{body}' command='#{command}' >"
|
103
103
|
end
|
104
104
|
|
105
|
-
private
|
106
|
-
|
107
105
|
# is_blank? tests if a data value is nil or empty.
|
108
106
|
def is_blank?(value)
|
109
107
|
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
data/lib/stomp/null_logger.rb
CHANGED
@@ -3,8 +3,11 @@
|
|
3
3
|
module Stomp
|
4
4
|
class NullLogger
|
5
5
|
def on_miscerr(parms, error_msg)
|
6
|
-
$stderr.print
|
6
|
+
$stderr.print "\non_miscerr\n"
|
7
|
+
$stderr.print parms.inspect
|
8
|
+
$stderr.print "\n"
|
7
9
|
$stderr.print error_msg
|
10
|
+
$stderr.print "\n"
|
8
11
|
end
|
9
12
|
|
10
13
|
def on_connecting(parms); end
|
data/lib/stomp/version.rb
CHANGED
@@ -11,58 +11,58 @@ shared_examples_for "standard Client" do
|
|
11
11
|
|
12
12
|
describe "the closed? method" do
|
13
13
|
it "should be false when the connection is open" do
|
14
|
-
@mock_connection.
|
15
|
-
@client.closed
|
14
|
+
allow(@mock_connection).to receive(:closed?).and_return(false)
|
15
|
+
expect(@client.closed?).to eq(false)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should be true when the connection is closed" do
|
19
|
-
@mock_connection.
|
20
|
-
@client.closed
|
19
|
+
allow(@mock_connection).to receive(:closed?).and_return(true)
|
20
|
+
expect(@client.closed?).to eq(true)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "the open? method" do
|
25
25
|
it "should be true when the connection is open" do
|
26
|
-
@mock_connection.
|
27
|
-
@client.open
|
26
|
+
allow(@mock_connection).to receive(:open?).and_return(true)
|
27
|
+
expect(@client.open?).to eq(true)
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should be false when the connection is closed" do
|
31
|
-
@mock_connection.
|
32
|
-
@client.open
|
31
|
+
allow(@mock_connection).to receive(:open?).and_return(false)
|
32
|
+
expect(@client.open?).to eq(false)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "the subscribe method" do
|
37
37
|
|
38
38
|
before(:each) do
|
39
|
-
@mock_connection.
|
39
|
+
allow(@mock_connection).to receive(:subscribe).and_return(true)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should raise RuntimeError if not passed a block" do
|
43
|
-
|
43
|
+
expect {
|
44
44
|
@client.subscribe(@destination)
|
45
|
-
}.
|
45
|
+
}.to raise_error(RuntimeError)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should not raise an error when passed a block" do
|
49
|
-
|
49
|
+
expect {
|
50
50
|
@client.subscribe(@destination) {|msg| received = msg}
|
51
|
-
}.
|
51
|
+
}.not_to raise_error
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should raise RuntimeError on duplicate subscriptions" do
|
55
|
-
|
55
|
+
expect {
|
56
56
|
@client.subscribe(@destination)
|
57
57
|
@client.subscribe(@destination)
|
58
|
-
}.
|
58
|
+
}.to raise_error(RuntimeError)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should raise RuntimeError with duplicate id headers" do
|
62
|
-
|
62
|
+
expect {
|
63
63
|
@client.subscribe(@destination, {'id' => 'abcdef'})
|
64
64
|
@client.subscribe(@destination, {'id' => 'abcdef'})
|
65
|
-
}.
|
65
|
+
}.to raise_error(RuntimeError)
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -8,9 +8,9 @@ describe Stomp::Client do
|
|
8
8
|
let(:null_logger) { double("mock Stomp::NullLogger") }
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
Stomp::NullLogger.
|
11
|
+
allow(Stomp::NullLogger).to receive(:new).and_return(null_logger)
|
12
12
|
@mock_connection = double('connection', :autoflush= => true)
|
13
|
-
Stomp::Connection.
|
13
|
+
allow(Stomp::Connection).to receive(:new).and_return(@mock_connection)
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "(created with no params)" do
|
@@ -20,15 +20,15 @@ describe Stomp::Client do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should not return any errors" do
|
23
|
-
|
23
|
+
expect {
|
24
24
|
@client = Stomp::Client.new
|
25
|
-
}.
|
25
|
+
}.not_to raise_error
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should not return any errors when created with the open constructor" do
|
29
|
-
|
29
|
+
expect {
|
30
30
|
@client = Stomp::Client.open
|
31
|
-
}.
|
31
|
+
}.not_to raise_error
|
32
32
|
end
|
33
33
|
|
34
34
|
it_should_behave_like "standard Client"
|
@@ -43,34 +43,53 @@ describe Stomp::Client do
|
|
43
43
|
:port => 12345,
|
44
44
|
:host => 'dummy host',
|
45
45
|
:ssl => 'dummy ssl')
|
46
|
-
Stomp::Connection.
|
46
|
+
allow(Stomp::Connection).to receive(:new).and_return(@mock_connection)
|
47
47
|
@client = Stomp::Client.new
|
48
48
|
end
|
49
49
|
|
50
50
|
describe 'it should delegate parameters to its connection' do
|
51
51
|
subject { @client }
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
describe '#login' do
|
54
|
+
subject { super().login }
|
55
|
+
it { should eql 'dummy login' }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#passcode' do
|
59
|
+
subject { super().passcode }
|
60
|
+
it { should eql 'dummy passcode' }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#port' do
|
64
|
+
subject { super().port }
|
65
|
+
it { should eql 12345 }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#host' do
|
69
|
+
subject { super().host }
|
70
|
+
it { should eql 'dummy host' }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#ssl' do
|
74
|
+
subject { super().ssl }
|
75
|
+
it { should eql 'dummy ssl' }
|
76
|
+
end
|
58
77
|
end
|
59
78
|
end
|
60
79
|
|
61
80
|
describe "(autoflush)" do
|
62
81
|
it "should delegate to the connection for accessing the autoflush property" do
|
63
|
-
@mock_connection.
|
82
|
+
expect(@mock_connection).to receive(:autoflush)
|
64
83
|
Stomp::Client.new.autoflush
|
65
84
|
end
|
66
85
|
|
67
86
|
it "should delegate to the connection for setting the autoflush property" do
|
68
|
-
@mock_connection.
|
87
|
+
expect(@mock_connection).to receive(:autoflush=).with(true)
|
69
88
|
Stomp::Client.new.autoflush = true
|
70
89
|
end
|
71
90
|
|
72
91
|
it "should set the autoflush property on the connection when passing in autoflush as a parameter to the Stomp::Client" do
|
73
|
-
@mock_connection.
|
92
|
+
expect(@mock_connection).to receive(:autoflush=).with(true)
|
74
93
|
Stomp::Client.new("login", "password", 'localhost', 61613, false, true)
|
75
94
|
end
|
76
95
|
end
|
@@ -78,33 +97,33 @@ describe Stomp::Client do
|
|
78
97
|
describe "(created with invalid params)" do
|
79
98
|
|
80
99
|
it "should return ArgumentError if port is nil" do
|
81
|
-
|
100
|
+
expect {
|
82
101
|
@client = Stomp::Client.new('login', 'passcode', 'localhost', nil)
|
83
|
-
}.
|
102
|
+
}.to raise_error(ArgumentError)
|
84
103
|
end
|
85
104
|
|
86
105
|
it "should return ArgumentError if port is < 1" do
|
87
|
-
|
106
|
+
expect {
|
88
107
|
@client = Stomp::Client.new('login', 'passcode', 'localhost', 0)
|
89
|
-
}.
|
108
|
+
}.to raise_error(ArgumentError)
|
90
109
|
end
|
91
110
|
|
92
111
|
it "should return ArgumentError if port is > 65535" do
|
93
|
-
|
112
|
+
expect {
|
94
113
|
@client = Stomp::Client.new('login', 'passcode', 'localhost', 65536)
|
95
|
-
}.
|
114
|
+
}.to raise_error(ArgumentError)
|
96
115
|
end
|
97
116
|
|
98
117
|
it "should return ArgumentError if port is empty" do
|
99
|
-
|
118
|
+
expect {
|
100
119
|
@client = Stomp::Client.new('login', 'passcode', 'localhost', '')
|
101
|
-
}.
|
120
|
+
}.to raise_error(ArgumentError)
|
102
121
|
end
|
103
122
|
|
104
123
|
it "should return ArgumentError if reliable is something other than true or false" do
|
105
|
-
|
124
|
+
expect {
|
106
125
|
@client = Stomp::Client.new('login', 'passcode', 'localhost', '12345', 'foo')
|
107
|
-
}.
|
126
|
+
}.to raise_error(ArgumentError)
|
108
127
|
end
|
109
128
|
|
110
129
|
end
|
@@ -116,7 +135,7 @@ describe Stomp::Client do
|
|
116
135
|
end
|
117
136
|
|
118
137
|
it "should properly parse the URL provided" do
|
119
|
-
Stomp::Connection.
|
138
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => 'testlogin',
|
120
139
|
:passcode => 'testpassword',
|
121
140
|
:host => 'localhost',
|
122
141
|
:port => 12345}],
|
@@ -135,7 +154,7 @@ describe Stomp::Client do
|
|
135
154
|
end
|
136
155
|
|
137
156
|
it "should properly parse the URL provided" do
|
138
|
-
Stomp::Connection.
|
157
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => '',
|
139
158
|
:passcode => '',
|
140
159
|
:host => 'foobar',
|
141
160
|
:port => 12345}],
|
@@ -155,7 +174,7 @@ describe Stomp::Client do
|
|
155
174
|
end
|
156
175
|
|
157
176
|
it "should properly parse the URL provided" do
|
158
|
-
Stomp::Connection.
|
177
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => '',
|
159
178
|
:passcode => '',
|
160
179
|
:host => 'foo-bar',
|
161
180
|
:port => 12345}],
|
@@ -175,7 +194,7 @@ describe Stomp::Client do
|
|
175
194
|
end
|
176
195
|
|
177
196
|
it "should properly parse the URL provided" do
|
178
|
-
Stomp::Connection.
|
197
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => 'test-login',
|
179
198
|
:passcode => 'testpasscode',
|
180
199
|
:host => 'foobar',
|
181
200
|
:port => 12345}],
|
@@ -195,7 +214,7 @@ describe Stomp::Client do
|
|
195
214
|
end
|
196
215
|
|
197
216
|
it "should properly parse the URL provided" do
|
198
|
-
Stomp::Connection.
|
217
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => 'test-login',
|
199
218
|
:passcode => 'testpasscode',
|
200
219
|
:host => 'foo-bar',
|
201
220
|
:port => 12345}],
|
@@ -218,7 +237,7 @@ describe Stomp::Client do
|
|
218
237
|
end
|
219
238
|
|
220
239
|
it "should properly parse the URL provided" do
|
221
|
-
Stomp::Connection.
|
240
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => '',
|
222
241
|
:passcode => '',
|
223
242
|
:host => 'host.foobar.com',
|
224
243
|
:port => 12345}],
|
@@ -238,7 +257,7 @@ describe Stomp::Client do
|
|
238
257
|
end
|
239
258
|
|
240
259
|
it "should properly parse the URL provided" do
|
241
|
-
Stomp::Connection.
|
260
|
+
expect(Stomp::Connection).to receive(:new).with(:hosts => [{:login => 'testlogin',
|
242
261
|
:passcode => 'testpasscode',
|
243
262
|
:host => 'host.foobar.com',
|
244
263
|
:port => 12345}],
|
@@ -275,10 +294,10 @@ describe Stomp::Client do
|
|
275
294
|
|
276
295
|
@parameters.merge!({:logger => null_logger})
|
277
296
|
|
278
|
-
Stomp::Connection.
|
297
|
+
expect(Stomp::Connection).to receive(:new).with(@parameters)
|
279
298
|
|
280
299
|
client = Stomp::Client.new(url)
|
281
|
-
client.parameters.
|
300
|
+
expect(client.parameters).to eq(@parameters)
|
282
301
|
end
|
283
302
|
|
284
303
|
it "should properly parse a URL with failover:" do
|
@@ -292,10 +311,10 @@ describe Stomp::Client do
|
|
292
311
|
|
293
312
|
@parameters.merge!({:logger => null_logger})
|
294
313
|
|
295
|
-
Stomp::Connection.
|
314
|
+
expect(Stomp::Connection).to receive(:new).with(@parameters)
|
296
315
|
|
297
316
|
client = Stomp::Client.new(url)
|
298
|
-
client.parameters.
|
317
|
+
expect(client.parameters).to eq(@parameters)
|
299
318
|
end
|
300
319
|
|
301
320
|
it "should properly parse a URL without user and password" do
|
@@ -308,10 +327,10 @@ describe Stomp::Client do
|
|
308
327
|
|
309
328
|
@parameters.merge!({:logger => null_logger})
|
310
329
|
|
311
|
-
Stomp::Connection.
|
330
|
+
expect(Stomp::Connection).to receive(:new).with(@parameters)
|
312
331
|
|
313
332
|
client = Stomp::Client.new(url)
|
314
|
-
client.parameters.
|
333
|
+
expect(client.parameters).to eq(@parameters)
|
315
334
|
end
|
316
335
|
|
317
336
|
it "should properly parse a URL with user and/or password blank" do
|
@@ -324,10 +343,10 @@ describe Stomp::Client do
|
|
324
343
|
|
325
344
|
@parameters.merge!({:logger => null_logger})
|
326
345
|
|
327
|
-
Stomp::Connection.
|
346
|
+
expect(Stomp::Connection).to receive(:new).with(@parameters)
|
328
347
|
|
329
348
|
client = Stomp::Client.new(url)
|
330
|
-
client.parameters.
|
349
|
+
expect(client.parameters).to eq(@parameters)
|
331
350
|
end
|
332
351
|
|
333
352
|
it "should properly parse a URL with the options query" do
|
@@ -355,10 +374,10 @@ describe Stomp::Client do
|
|
355
374
|
|
356
375
|
@parameters.merge!({:logger => null_logger})
|
357
376
|
|
358
|
-
Stomp::Connection.
|
377
|
+
expect(Stomp::Connection).to receive(:new).with(@parameters)
|
359
378
|
|
360
379
|
client = Stomp::Client.new(url)
|
361
|
-
client.parameters.
|
380
|
+
expect(client.parameters).to eq(@parameters)
|
362
381
|
end
|
363
382
|
|
364
383
|
end
|
data/spec/connection_spec.rb
CHANGED
@@ -43,8 +43,8 @@ describe Stomp::Connection do
|
|
43
43
|
# clone() does a shallow copy, we want a deep one so we can garantee the hosts order
|
44
44
|
normal_parameters = Marshal::load(Marshal::dump(@parameters))
|
45
45
|
|
46
|
-
@tcp_socket =
|
47
|
-
TCPSocket.
|
46
|
+
@tcp_socket = double(:tcp_socket, :close => nil, :puts => nil, :write => nil, :setsockopt => nil, :flush => true)
|
47
|
+
allow(TCPSocket).to receive(:open).and_return @tcp_socket
|
48
48
|
@connection = Stomp::Connection.new(normal_parameters)
|
49
49
|
end
|
50
50
|
|
@@ -68,13 +68,13 @@ describe Stomp::Connection do
|
|
68
68
|
}
|
69
69
|
|
70
70
|
it "should call flush on the socket when autoflush is true" do
|
71
|
-
@tcp_socket.
|
71
|
+
expect(@tcp_socket).to receive(:flush)
|
72
72
|
@connection = Stomp::Connection.new(parameter_hash.merge("autoflush" => true))
|
73
73
|
@connection.publish "/queue", "message", :suppress_content_length => false
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should not call flush on the socket when autoflush is false" do
|
77
|
-
@tcp_socket.
|
77
|
+
expect(@tcp_socket).not_to receive(:flush)
|
78
78
|
@connection = Stomp::Connection.new(parameter_hash)
|
79
79
|
@connection.publish "/queue", "message", :suppress_content_length => false
|
80
80
|
end
|
@@ -108,61 +108,61 @@ describe Stomp::Connection do
|
|
108
108
|
}
|
109
109
|
|
110
110
|
@connection = Stomp::Connection.new(used_hash)
|
111
|
-
@connection.instance_variable_get(:@parameters).
|
111
|
+
expect(@connection.instance_variable_get(:@parameters)).to eq(@parameters)
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should start with first host in array" do
|
115
|
-
@connection.instance_variable_get(:@host).
|
115
|
+
expect(@connection.instance_variable_get(:@host)).to eq("localhost")
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should change host to next one with randomize false" do
|
119
119
|
@connection.send(:change_host) # use .send(:name) to test a private method!
|
120
|
-
@connection.instance_variable_get(:@host).
|
120
|
+
expect(@connection.instance_variable_get(:@host)).to eq("remotehost")
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should use default port (61613) if none is given" do
|
124
124
|
hash = {:hosts => [{:login => "login2", :passcode => "passcode2", :host => "remotehost", :ssl => false}]}
|
125
125
|
@connection = Stomp::Connection.new hash
|
126
|
-
@connection.instance_variable_get(:@port).
|
126
|
+
expect(@connection.instance_variable_get(:@port)).to eq(61613)
|
127
127
|
end
|
128
128
|
|
129
129
|
context "should be able pass reliable as part of hash" do
|
130
130
|
it "should be false if reliable is set to false" do
|
131
131
|
hash = @parameters.merge({:reliable => false })
|
132
132
|
connection = Stomp::Connection.new(hash)
|
133
|
-
connection.instance_variable_get(:@reliable).
|
133
|
+
expect(connection.instance_variable_get(:@reliable)).to be false
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should be true if reliable is set to true" do
|
137
137
|
hash = @parameters.merge({:reliable => true })
|
138
138
|
connection = Stomp::Connection.new(hash)
|
139
|
-
connection.instance_variable_get(:@reliable).
|
139
|
+
expect(connection.instance_variable_get(:@reliable)).to be true
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should be true if reliable is not set" do
|
143
143
|
connection = Stomp::Connection.new(@parameters)
|
144
|
-
connection.instance_variable_get(:@reliable).
|
144
|
+
expect(connection.instance_variable_get(:@reliable)).to be true
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
148
|
context "when dealing with content-length header" do
|
149
149
|
it "should not suppress it when receiving :suppress_content_length => false" do
|
150
|
-
@tcp_socket.
|
150
|
+
expect(@tcp_socket).to receive(:puts).with("content-length:7")
|
151
151
|
@connection.publish "/queue", "message", :suppress_content_length => false
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should not suppress it when :suppress_content_length is nil" do
|
155
|
-
@tcp_socket.
|
155
|
+
expect(@tcp_socket).to receive(:puts).with("content-length:7")
|
156
156
|
@connection.publish "/queue", "message"
|
157
157
|
end
|
158
158
|
|
159
159
|
it "should suppress it when receiving :suppress_content_length => true" do
|
160
|
-
@tcp_socket.
|
160
|
+
expect(@tcp_socket).not_to receive(:puts).with("content-length:7")
|
161
161
|
@connection.publish "/queue", "message", :suppress_content_length => true
|
162
162
|
end
|
163
163
|
|
164
164
|
it "should get the correct byte length when dealing with Unicode characters" do
|
165
|
-
@tcp_socket.
|
165
|
+
expect(@tcp_socket).to receive(:puts).with("content-length:18")
|
166
166
|
@connection.publish "/queue", "сообщение" # 'сообщение' is 'message' in Russian
|
167
167
|
end
|
168
168
|
end
|
@@ -184,31 +184,31 @@ describe Stomp::Connection do
|
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should use a transaction" do
|
187
|
-
@connection.
|
188
|
-
@connection.
|
187
|
+
expect(@connection).to receive(:begin).with(@transaction_id).ordered
|
188
|
+
expect(@connection).to receive(:commit).with(@transaction_id).ordered
|
189
189
|
@connection.unreceive @message
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should acknowledge the original message if ack mode is client" do
|
193
|
-
@connection.
|
193
|
+
expect(@connection).to receive(:ack).with(@message.headers["message-id"], :transaction => @transaction_id)
|
194
194
|
@connection.subscribe(@message.headers["destination"], :ack => "client")
|
195
195
|
@connection.unreceive @message
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should acknowledge the original message if forced" do
|
199
199
|
@connection.subscribe(@message.headers["destination"])
|
200
|
-
@connection.
|
200
|
+
expect(@connection).to receive(:ack)
|
201
201
|
@connection.unreceive(@message, :force_client_ack => true)
|
202
202
|
end
|
203
203
|
|
204
204
|
it "should not acknowledge the original message if ack mode is not client or it did not subscribe to the queue" do
|
205
205
|
@connection.subscribe(@message.headers["destination"], :ack => "client")
|
206
|
-
@connection.
|
206
|
+
expect(@connection).to receive(:ack)
|
207
207
|
@connection.unreceive @message
|
208
208
|
|
209
209
|
# At this time the message headers are symbolized
|
210
210
|
@connection.unsubscribe(@message.headers[:destination])
|
211
|
-
@connection.
|
211
|
+
expect(@connection).not_to receive(:ack)
|
212
212
|
@connection.unreceive @message
|
213
213
|
@connection.subscribe(@message.headers[:destination], :ack => "individual")
|
214
214
|
@connection.unreceive @message
|
@@ -216,14 +216,14 @@ describe Stomp::Connection do
|
|
216
216
|
|
217
217
|
it "should send the message back to the queue it came" do
|
218
218
|
@connection.subscribe(@message.headers["destination"], :ack => "client")
|
219
|
-
@connection.
|
219
|
+
expect(@connection).to receive(:publish).with(@message.headers["destination"], @message.body, @retry_headers)
|
220
220
|
@connection.unreceive @message
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should increment the retry_count header" do
|
224
224
|
@message.headers["retry_count"] = 4
|
225
225
|
@connection.unreceive @message
|
226
|
-
@message.headers[:retry_count].
|
226
|
+
expect(@message.headers[:retry_count]).to eq(5)
|
227
227
|
end
|
228
228
|
|
229
229
|
it "should not send the message to the dead letter queue as persistent if retry_count is less than max redeliveries" do
|
@@ -233,7 +233,7 @@ describe Stomp::Connection do
|
|
233
233
|
@message.headers["retry_count"] = max_redeliveries - 1
|
234
234
|
transaction_id = "transaction-#{@message.headers["message-id"]}-#{@message.headers["retry_count"]}"
|
235
235
|
@retry_headers = @retry_headers.merge :transaction => transaction_id, :retry_count => @message.headers["retry_count"] + 1
|
236
|
-
@connection.
|
236
|
+
expect(@connection).to receive(:publish).with(@message.headers["destination"], @message.body, @retry_headers)
|
237
237
|
@connection.unreceive @message, :dead_letter_queue => dead_letter_queue, :max_redeliveries => max_redeliveries
|
238
238
|
end
|
239
239
|
|
@@ -245,14 +245,14 @@ describe Stomp::Connection do
|
|
245
245
|
@message.headers["retry_count"] = max_redeliveries
|
246
246
|
transaction_id = "transaction-#{@message.headers["message-id"]}-#{@message.headers["retry_count"]}"
|
247
247
|
@retry_headers = @retry_headers.merge :persistent => true, :transaction => transaction_id, :retry_count => @message.headers["retry_count"] + 1, :original_destination=> @message.headers["destination"]
|
248
|
-
@connection.
|
248
|
+
expect(@connection).to receive(:publish).with(dead_letter_queue, @message.body, @retry_headers)
|
249
249
|
@connection.unreceive @message, :dead_letter_queue => dead_letter_queue, :max_redeliveries => max_redeliveries
|
250
250
|
end
|
251
251
|
|
252
252
|
it "should rollback the transaction and raise the exception if happened during transaction" do
|
253
|
-
@connection.
|
254
|
-
@connection.
|
255
|
-
|
253
|
+
expect(@connection).to receive(:publish).and_raise "Error"
|
254
|
+
expect(@connection).to receive(:abort).with(@transaction_id)
|
255
|
+
expect {@connection.unreceive @message}.to raise_error("Error")
|
256
256
|
end
|
257
257
|
|
258
258
|
end
|
@@ -260,9 +260,9 @@ describe Stomp::Connection do
|
|
260
260
|
describe "when sending a nil message body" do
|
261
261
|
it "should should not raise an error" do
|
262
262
|
@connection = Stomp::Connection.new("niluser", "nilpass", "localhost", 61613)
|
263
|
-
|
263
|
+
expect {
|
264
264
|
@connection.publish("/queue/nilq", nil)
|
265
|
-
}.
|
265
|
+
}.not_to raise_error
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
@@ -284,55 +284,55 @@ describe Stomp::Connection do
|
|
284
284
|
|
285
285
|
before(:each) do
|
286
286
|
ssl_parameters = {:hosts => [{:login => "login2", :passcode => "passcode2", :host => "remotehost", :ssl => true}]}
|
287
|
-
@ssl_socket =
|
287
|
+
@ssl_socket = double(:ssl_socket, :puts => nil, :write => nil,
|
288
288
|
:setsockopt => nil, :flush => true)
|
289
|
-
@ssl_socket.
|
289
|
+
allow(@ssl_socket).to receive(:sync_close=)
|
290
290
|
|
291
|
-
TCPSocket.
|
292
|
-
OpenSSL::SSL::SSLSocket.
|
293
|
-
@ssl_socket.
|
291
|
+
expect(TCPSocket).to receive(:open).and_return @tcp_socket
|
292
|
+
expect(OpenSSL::SSL::SSLSocket).to receive(:new).and_return(@ssl_socket)
|
293
|
+
expect(@ssl_socket).to receive(:connect)
|
294
294
|
|
295
295
|
@connection = Stomp::Connection.new ssl_parameters
|
296
296
|
end
|
297
297
|
|
298
298
|
it "should use ssl socket if ssl use is enabled" do
|
299
|
-
@connection.instance_variable_get(:@socket).
|
299
|
+
expect(@connection.instance_variable_get(:@socket)).to eq(@ssl_socket)
|
300
300
|
end
|
301
301
|
|
302
302
|
it "should use default port for ssl (61612) if none is given" do
|
303
|
-
@connection.instance_variable_get(:@port).
|
303
|
+
expect(@connection.instance_variable_get(:@port)).to eq(61612)
|
304
304
|
end
|
305
305
|
|
306
306
|
end
|
307
307
|
|
308
308
|
describe "when called to increase reconnect delay" do
|
309
309
|
it "should exponentialy increase when use_exponential_back_off is true" do
|
310
|
-
@connection.send(:increase_reconnect_delay).
|
311
|
-
@connection.send(:increase_reconnect_delay).
|
312
|
-
@connection.send(:increase_reconnect_delay).
|
310
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(0.02)
|
311
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(0.04)
|
312
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(0.08)
|
313
313
|
end
|
314
314
|
it "should not increase when use_exponential_back_off is false" do
|
315
315
|
@parameters[:use_exponential_back_off] = false
|
316
316
|
@connection = Stomp::Connection.new(@parameters)
|
317
|
-
@connection.send(:increase_reconnect_delay).
|
318
|
-
@connection.send(:increase_reconnect_delay).
|
317
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(0.01)
|
318
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(0.01)
|
319
319
|
end
|
320
320
|
it "should not increase when max_reconnect_delay is reached" do
|
321
321
|
@parameters[:initial_reconnect_delay] = 8.0
|
322
322
|
@connection = Stomp::Connection.new(@parameters)
|
323
|
-
@connection.send(:increase_reconnect_delay).
|
324
|
-
@connection.send(:increase_reconnect_delay).
|
323
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(16.0)
|
324
|
+
expect(@connection.send(:increase_reconnect_delay)).to eq(30.0)
|
325
325
|
end
|
326
326
|
|
327
327
|
it "should change to next host on socket error" do
|
328
328
|
@connection.instance_variable_set(:@failure, "some exception")
|
329
329
|
#retries the same host
|
330
|
-
TCPSocket.
|
330
|
+
expect(TCPSocket).to receive(:open).and_raise "exception"
|
331
331
|
#tries the new host
|
332
|
-
TCPSocket.
|
332
|
+
expect(TCPSocket).to receive(:open).and_return @tcp_socket
|
333
333
|
|
334
334
|
@connection.send(:socket)
|
335
|
-
@connection.instance_variable_get(:@host).
|
335
|
+
expect(@connection.instance_variable_get(:@host)).to eq("remotehost")
|
336
336
|
end
|
337
337
|
|
338
338
|
it "should use default options if those where not given" do
|
@@ -373,7 +373,7 @@ describe Stomp::Connection do
|
|
373
373
|
}
|
374
374
|
|
375
375
|
@connection = Stomp::Connection.new(used_hash)
|
376
|
-
@connection.instance_variable_get(:@parameters).
|
376
|
+
expect(@connection.instance_variable_get(:@parameters)).to eq(expected_hash)
|
377
377
|
end
|
378
378
|
|
379
379
|
it "should use the given options instead of default ones" do
|
@@ -415,7 +415,7 @@ describe Stomp::Connection do
|
|
415
415
|
received_hash.delete(:hosts)
|
416
416
|
used_hash.delete(:hosts)
|
417
417
|
|
418
|
-
received_hash.
|
418
|
+
expect(received_hash).to eq(used_hash)
|
419
419
|
end
|
420
420
|
|
421
421
|
end
|
@@ -424,12 +424,12 @@ describe Stomp::Connection do
|
|
424
424
|
|
425
425
|
describe "when closing a socket" do
|
426
426
|
it "should close the tcp connection" do
|
427
|
-
@tcp_socket.
|
428
|
-
@connection.__send__(:close_socket).
|
427
|
+
expect(@tcp_socket).to receive(:close)
|
428
|
+
expect(@connection.__send__(:close_socket)).to be true # Use Object.__send__
|
429
429
|
end
|
430
430
|
it "should ignore exceptions" do
|
431
|
-
@tcp_socket.
|
432
|
-
@connection.__send__(:close_socket).
|
431
|
+
expect(@tcp_socket).to receive(:close).and_raise "exception"
|
432
|
+
expect(@connection.__send__(:close_socket)).to be true # Use Object.__send__
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
@@ -438,11 +438,11 @@ describe Stomp::Connection do
|
|
438
438
|
host = @parameters[:hosts][0]
|
439
439
|
@connection = Stomp::Connection.new(host[:login], host[:passcode], host[:host], host[:port], reliable = true, 5, connect_headers = {})
|
440
440
|
@connection.instance_variable_set(:@connection_attempts, 10000)
|
441
|
-
@connection.send(:max_reconnect_attempts?).
|
441
|
+
expect(@connection.send(:max_reconnect_attempts?)).to be false
|
442
442
|
end
|
443
443
|
it "should return false if max_reconnect_attempts = 0" do
|
444
444
|
@connection.instance_variable_set(:@connection_attempts, 10000)
|
445
|
-
@connection.send(:max_reconnect_attempts?).
|
445
|
+
expect(@connection.send(:max_reconnect_attempts?)).to be false
|
446
446
|
end
|
447
447
|
it "should return true if connection attempts > max_reconnect_attempts" do
|
448
448
|
limit = 10000
|
@@ -450,17 +450,17 @@ describe Stomp::Connection do
|
|
450
450
|
@connection = Stomp::Connection.new(@parameters)
|
451
451
|
|
452
452
|
@connection.instance_variable_set(:@connection_attempts, limit-1)
|
453
|
-
@connection.send(:max_reconnect_attempts?).
|
453
|
+
expect(@connection.send(:max_reconnect_attempts?)).to be false
|
454
454
|
|
455
455
|
@connection.instance_variable_set(:@connection_attempts, limit)
|
456
|
-
@connection.send(:max_reconnect_attempts?).
|
456
|
+
expect(@connection.send(:max_reconnect_attempts?)).to be true
|
457
457
|
end
|
458
458
|
# These should be raised for the user to deal with
|
459
459
|
it "should not rescue MaxReconnectAttempts" do
|
460
460
|
@connection = Stomp::Connection.new(@parameters)
|
461
|
-
@connection.
|
461
|
+
allow(@connection).to receive(:socket).and_raise(Stomp::Error::MaxReconnectAttempts)
|
462
462
|
|
463
|
-
expect { @connection.receive() }.to raise_error
|
463
|
+
expect { @connection.receive() }.to raise_error(RuntimeError)
|
464
464
|
end
|
465
465
|
end
|
466
466
|
|
data/spec/message_spec.rb
CHANGED
@@ -9,11 +9,12 @@ describe Stomp::Message do
|
|
9
9
|
context 'with invalid parameters' do
|
10
10
|
it 'should return an empty message when receiving an empty string or nil parameter' do
|
11
11
|
message = Stomp::Message.new('')
|
12
|
-
message.
|
12
|
+
expect(message).to be_empty
|
13
|
+
# message.should be_empty
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'should raise Stomp::Error::InvalidFormat when receiving a invalid formated message' do
|
16
|
-
|
17
|
+
expect{ Stomp::Message.new('any invalid format') }.to raise_error(Stomp::Error::InvalidFormat)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -24,15 +25,15 @@ describe Stomp::Message do
|
|
24
25
|
end
|
25
26
|
|
26
27
|
it 'should parse the headers' do
|
27
|
-
subject.headers.
|
28
|
+
expect(subject.headers).to eq({'session' => 'host_address'})
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'should parse the body' do
|
31
|
-
subject.body.
|
32
|
+
expect(subject.body).to eq(@message[3])
|
32
33
|
end
|
33
34
|
|
34
35
|
it 'should parse the command' do
|
35
|
-
subject.command.
|
36
|
+
expect(subject.command).to eq(@message[0].chomp)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -43,15 +44,15 @@ describe Stomp::Message do
|
|
43
44
|
end
|
44
45
|
|
45
46
|
it 'should parse the headers' do
|
46
|
-
subject.headers.
|
47
|
+
expect(subject.headers).to eq({'session' => 'host_address'})
|
47
48
|
end
|
48
49
|
|
49
50
|
it 'should parse the body' do
|
50
|
-
subject.body.
|
51
|
+
expect(subject.body).to eq(@message[3])
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'should parse the command' do
|
54
|
-
subject.command.
|
55
|
+
expect(subject.command).to eq(@message[0].chomp)
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
data/spec/spec_helper.rb
CHANGED
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.3.
|
8
|
+
s.version = "1.3.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{
|
12
|
+
s.date = %q{2016-03-02}
|
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"]
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"CHANGELOG.rdoc",
|
18
18
|
"LICENSE",
|
19
19
|
"README.rdoc",
|
20
|
+
"examples/amqdurasub.rb",
|
20
21
|
"examples/client11_ex1.rb",
|
21
22
|
"examples/client11_putget1.rb",
|
22
23
|
"examples/conn11_ex1.rb",
|
@@ -80,6 +81,7 @@ Gem::Specification.new do |s|
|
|
80
81
|
"Rakefile",
|
81
82
|
"bin/catstomp",
|
82
83
|
"bin/stompcat",
|
84
|
+
"examples/amqdurasub.rb",
|
83
85
|
"examples/client11_ex1.rb",
|
84
86
|
"examples/client11_putget1.rb",
|
85
87
|
"examples/conn11_ex1.rb",
|
@@ -154,12 +156,12 @@ Gem::Specification.new do |s|
|
|
154
156
|
s.specification_version = 3
|
155
157
|
|
156
158
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
157
|
-
s.add_development_dependency(%q<rspec>, [">= 2.
|
159
|
+
s.add_development_dependency(%q<rspec>, [">= 2.14.1"])
|
158
160
|
else
|
159
|
-
s.add_dependency(%q<rspec>, [">= 2.
|
161
|
+
s.add_dependency(%q<rspec>, [">= 2.14.1"])
|
160
162
|
end
|
161
163
|
else
|
162
|
-
s.add_dependency(%q<rspec>, [">= 2.
|
164
|
+
s.add_dependency(%q<rspec>, [">= 2.14.1"])
|
163
165
|
end
|
164
166
|
end
|
165
167
|
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 5
|
10
|
+
version: 1.3.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:
|
21
|
+
date: 2016-03-02 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,11 +29,12 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
hash:
|
32
|
+
hash: 53
|
33
33
|
segments:
|
34
34
|
- 2
|
35
|
-
-
|
36
|
-
|
35
|
+
- 14
|
36
|
+
- 1
|
37
|
+
version: 2.14.1
|
37
38
|
type: :development
|
38
39
|
version_requirements: *id001
|
39
40
|
description: Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.
|
@@ -51,6 +52,7 @@ extra_rdoc_files:
|
|
51
52
|
- CHANGELOG.rdoc
|
52
53
|
- LICENSE
|
53
54
|
- README.rdoc
|
55
|
+
- examples/amqdurasub.rb
|
54
56
|
- examples/client11_ex1.rb
|
55
57
|
- examples/client11_putget1.rb
|
56
58
|
- examples/conn11_ex1.rb
|
@@ -113,6 +115,7 @@ files:
|
|
113
115
|
- Rakefile
|
114
116
|
- bin/catstomp
|
115
117
|
- bin/stompcat
|
118
|
+
- examples/amqdurasub.rb
|
116
119
|
- examples/client11_ex1.rb
|
117
120
|
- examples/client11_putget1.rb
|
118
121
|
- examples/conn11_ex1.rb
|