stomper 1.0.0 → 2.0.0
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/.gitignore +5 -0
- data/{spec/spec.opts → .rspec} +0 -2
- data/Gemfile +4 -0
- data/LICENSE +201 -201
- data/README.md +130 -0
- data/Rakefile +5 -0
- data/examples/basic.rb +38 -0
- data/examples/events.rb +54 -0
- data/features/acking_messages.feature +147 -0
- data/features/disconnecting.feature +12 -0
- data/features/establish_connection.feature +44 -0
- data/features/protocol_version_negotiation.feature +61 -0
- data/features/receipts.feature +72 -0
- data/features/scopes.feature +32 -0
- data/features/secure_connections.feature +38 -0
- data/features/send_and_message.feature +28 -0
- data/features/steps/acking_messages_steps.rb +39 -0
- data/features/steps/disconnecting_steps.rb +8 -0
- data/features/steps/establish_connection_steps.rb +74 -0
- data/features/steps/frame_transmission_steps.rb +35 -0
- data/features/steps/protocol_version_negotiation_steps.rb +15 -0
- data/features/steps/receipts_steps.rb +79 -0
- data/features/steps/scopes_steps.rb +52 -0
- data/features/steps/secure_connections_steps.rb +41 -0
- data/features/steps/send_and_message_steps.rb +35 -0
- data/features/steps/subscribing_steps.rb +36 -0
- data/features/steps/threaded_receiver_steps.rb +8 -0
- data/features/steps/transactions_steps.rb +0 -0
- data/features/subscribing.feature +151 -0
- data/features/support/env.rb +11 -0
- data/features/support/header_helpers.rb +12 -0
- data/features/support/ssl/README +6 -0
- data/features/support/ssl/broker_cert.csr +17 -0
- data/features/support/ssl/broker_cert.pem +72 -0
- data/features/support/ssl/broker_key.pem +27 -0
- data/features/support/ssl/client_cert.csr +17 -0
- data/features/support/ssl/client_cert.pem +72 -0
- data/features/support/ssl/client_key.pem +27 -0
- data/features/support/ssl/demoCA/cacert.pem +17 -0
- data/features/support/ssl/demoCA/index.txt +2 -0
- data/features/support/ssl/demoCA/index.txt.attr +1 -0
- data/features/support/ssl/demoCA/index.txt.attr.old +1 -0
- data/features/support/ssl/demoCA/index.txt.old +1 -0
- data/features/support/ssl/demoCA/newcerts/01.pem +72 -0
- data/features/support/ssl/demoCA/newcerts/02.pem +72 -0
- data/features/support/ssl/demoCA/private/cakey.pem +17 -0
- data/features/support/ssl/demoCA/serial +1 -0
- data/features/support/ssl/demoCA/serial.old +1 -0
- data/features/support/test_stomp_server.rb +150 -0
- data/features/threaded_receiver.feature +11 -0
- data/features/transactions.feature +66 -0
- data/lib/stomper.rb +30 -20
- data/lib/stomper/connection.rb +442 -102
- data/lib/stomper/errors.rb +59 -0
- data/lib/stomper/extensions.rb +10 -0
- data/lib/stomper/extensions/common.rb +258 -0
- data/lib/stomper/extensions/events.rb +213 -0
- data/lib/stomper/extensions/heartbeat.rb +101 -0
- data/lib/stomper/extensions/scoping.rb +56 -0
- data/lib/stomper/frame.rb +54 -0
- data/lib/stomper/frame_serializer.rb +217 -0
- data/lib/stomper/headers.rb +15 -0
- data/lib/stomper/receipt_manager.rb +36 -0
- data/lib/stomper/receivers.rb +7 -0
- data/lib/stomper/receivers/threaded.rb +71 -0
- data/lib/stomper/scopes.rb +9 -0
- data/lib/stomper/scopes/header_scope.rb +49 -0
- data/lib/stomper/scopes/receipt_scope.rb +44 -0
- data/lib/stomper/scopes/transaction_scope.rb +109 -0
- data/lib/stomper/sockets.rb +66 -28
- data/lib/stomper/subscription_manager.rb +79 -0
- data/lib/stomper/support.rb +68 -0
- data/lib/stomper/support/1.8/frame_serializer.rb +53 -0
- data/lib/stomper/support/1.8/headers.rb +183 -0
- data/lib/stomper/support/1.9/frame_serializer.rb +64 -0
- data/lib/stomper/support/1.9/headers.rb +172 -0
- data/lib/stomper/support/ruby.rb +13 -0
- data/lib/stomper/uris.rb +49 -0
- data/lib/stomper/version.rb +7 -0
- data/spec/spec_helper.rb +13 -9
- data/spec/stomper/connection_spec.rb +712 -0
- data/spec/stomper/extensions/common_spec.rb +187 -0
- data/spec/stomper/extensions/events_spec.rb +78 -0
- data/spec/stomper/extensions/heartbeat_spec.rb +103 -0
- data/spec/stomper/extensions/scoping_spec.rb +21 -0
- data/spec/stomper/frame_serializer_1.8_spec.rb +318 -0
- data/spec/stomper/frame_serializer_spec.rb +316 -0
- data/spec/stomper/frame_spec.rb +36 -0
- data/spec/stomper/headers_spec.rb +224 -0
- data/spec/stomper/receipt_manager_spec.rb +91 -0
- data/spec/stomper/receivers/threaded_spec.rb +116 -0
- data/spec/stomper/scopes/header_scope_spec.rb +42 -0
- data/spec/stomper/scopes/receipt_scope_spec.rb +51 -0
- data/spec/stomper/scopes/transaction_scope_spec.rb +183 -0
- data/spec/stomper/sockets_spec.rb +113 -0
- data/spec/stomper/subscription_manager_spec.rb +107 -0
- data/spec/stomper/support_spec.rb +69 -0
- data/spec/stomper/uris_spec.rb +54 -0
- data/spec/stomper_spec.rb +9 -0
- data/spec/support/custom_argument_matchers.rb +57 -0
- data/spec/support/existential_frame_matchers.rb +19 -0
- data/spec/support/frame_header_matchers.rb +10 -0
- data/stomper.gemspec +30 -0
- metadata +272 -97
- data/AUTHORS +0 -21
- data/CHANGELOG +0 -20
- data/README.rdoc +0 -120
- data/lib/stomper/client.rb +0 -34
- data/lib/stomper/frame_reader.rb +0 -73
- data/lib/stomper/frame_writer.rb +0 -21
- data/lib/stomper/frames.rb +0 -39
- data/lib/stomper/frames/abort.rb +0 -10
- data/lib/stomper/frames/ack.rb +0 -25
- data/lib/stomper/frames/begin.rb +0 -11
- data/lib/stomper/frames/client_frame.rb +0 -89
- data/lib/stomper/frames/commit.rb +0 -10
- data/lib/stomper/frames/connect.rb +0 -10
- data/lib/stomper/frames/connected.rb +0 -30
- data/lib/stomper/frames/disconnect.rb +0 -10
- data/lib/stomper/frames/error.rb +0 -21
- data/lib/stomper/frames/message.rb +0 -48
- data/lib/stomper/frames/receipt.rb +0 -19
- data/lib/stomper/frames/send.rb +0 -10
- data/lib/stomper/frames/server_frame.rb +0 -38
- data/lib/stomper/frames/subscribe.rb +0 -42
- data/lib/stomper/frames/unsubscribe.rb +0 -19
- data/lib/stomper/open_uri_interface.rb +0 -41
- data/lib/stomper/receipt_handlers.rb +0 -23
- data/lib/stomper/receiptor.rb +0 -38
- data/lib/stomper/subscriber.rb +0 -76
- data/lib/stomper/subscription.rb +0 -128
- data/lib/stomper/subscriptions.rb +0 -95
- data/lib/stomper/threaded_receiver.rb +0 -59
- data/lib/stomper/transaction.rb +0 -185
- data/lib/stomper/transactor.rb +0 -50
- data/lib/stomper/uri.rb +0 -55
- data/spec/client_spec.rb +0 -29
- data/spec/connection_spec.rb +0 -22
- data/spec/frame_reader_spec.rb +0 -37
- data/spec/frame_writer_spec.rb +0 -27
- data/spec/frames/client_frame_spec.rb +0 -66
- data/spec/frames/indirect_frame_spec.rb +0 -45
- data/spec/frames/server_frame_spec.rb +0 -85
- data/spec/open_uri_interface_spec.rb +0 -132
- data/spec/receiptor_spec.rb +0 -35
- data/spec/shared_connection_examples.rb +0 -79
- data/spec/subscriber_spec.rb +0 -77
- data/spec/subscription_spec.rb +0 -157
- data/spec/subscriptions_spec.rb +0 -145
- data/spec/threaded_receiver_spec.rb +0 -33
- data/spec/transaction_spec.rb +0 -139
- data/spec/transactor_spec.rb +0 -46
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Stomper
|
4
|
-
describe ThreadedReceiver do
|
5
|
-
before(:each) do
|
6
|
-
@connection = mock("connection")
|
7
|
-
@connection.extend Stomper::ThreadedReceiver
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "expected interface" do
|
11
|
-
it "should provide a start method" do
|
12
|
-
@connection.should respond_to(:start)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should provide a stop method" do
|
16
|
-
@connection.should respond_to(:stop)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "reading on a thread" do
|
21
|
-
it "should start receiving when started, and stop when stopped." do
|
22
|
-
@connection.should_receive(:connected?).once.and_return(false)
|
23
|
-
@connection.should_receive(:connect).once.and_return(true)
|
24
|
-
@connection.should_receive(:connected?).any_number_of_times.and_return(true)
|
25
|
-
@connection.should_receive(:receive).at_least(:once).and_return(nil)
|
26
|
-
@connection.start
|
27
|
-
sleep(0.5)
|
28
|
-
@connection.stop
|
29
|
-
@connection.should_not_receive(:receive)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/transaction_spec.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
|
-
|
3
|
-
module Stomper
|
4
|
-
describe Transaction do
|
5
|
-
before(:each) do
|
6
|
-
@mock_client = mock("client")
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "initialization with blocks" do
|
10
|
-
before(:each) do
|
11
|
-
@mock_client.should_receive(:begin).once.with(an_instance_of(String)).and_return(nil)
|
12
|
-
@mock_client.should_receive(:send).once.with("/queue/test/1","a message", an_instance_of(Hash)).and_return(nil)
|
13
|
-
@mock_client.should_receive(:commit).once.with(an_instance_of(String)).and_return(nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
it "should provide a DSL when a block with no arguments is given" do
|
18
|
-
lambda do
|
19
|
-
Transaction.new(@mock_client) do
|
20
|
-
send("/queue/test/1", "a message")
|
21
|
-
end
|
22
|
-
end.should_not raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should yield itself when a block with arguments is given" do
|
26
|
-
lambda do
|
27
|
-
Transaction.new(@mock_client) do |t|
|
28
|
-
t.send("/queue/test/1", "a message")
|
29
|
-
end
|
30
|
-
end.should_not raise_error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "explicitly named" do
|
35
|
-
before(:each) do
|
36
|
-
@transaction_name = "tx-test"
|
37
|
-
@mock_client.should_receive(:begin).once.with(@transaction_name).and_return(nil)
|
38
|
-
@mock_client.should_receive(:send).once.with("/queue/test/1","test message", hash_including(:transaction => @transaction_name)).and_return(nil)
|
39
|
-
@mock_client.should_receive(:commit).once.with(@transaction_name).and_return(nil)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should use the given transaction ID as the transaction header in stomp messages" do
|
43
|
-
Transaction.new(@mock_client, @transaction_name) do |t|
|
44
|
-
t.send("/queue/test/1", "test message")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "aborting failed transactions" do
|
50
|
-
before(:each) do
|
51
|
-
@transaction_name = "tx-test-2"
|
52
|
-
@mock_client.should_receive(:begin).once.with(@transaction_name).and_return(nil)
|
53
|
-
@mock_client.should_receive(:send).once.with("/queue/test/1","test message", hash_including(:transaction => @transaction_name)).and_return(nil)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should abort when an exception is raised" do
|
57
|
-
@mock_client.should_receive(:abort).once.with(@transaction_name).and_return(nil)
|
58
|
-
@mock_client.should_not_receive(:commit)
|
59
|
-
lambda do
|
60
|
-
Transaction.new(@mock_client, @transaction_name) do |t|
|
61
|
-
t.send("/queue/test/1", "test message")
|
62
|
-
raise "Never to be completed!"
|
63
|
-
end
|
64
|
-
end.should raise_error(TransactionAborted)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should abort and raise an error when explicitly aborted" do
|
68
|
-
@mock_client.should_receive(:abort).once.with(@transaction_name).and_return(nil)
|
69
|
-
@mock_client.should_not_receive(:commit)
|
70
|
-
lambda do
|
71
|
-
Transaction.new(@mock_client, @transaction_name) do |t|
|
72
|
-
t.send("/queue/test/1", "test message")
|
73
|
-
t.abort
|
74
|
-
# This should never be reached.
|
75
|
-
t.commit
|
76
|
-
end
|
77
|
-
end.should raise_error(TransactionAborted)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should not raise an exception when explicitly aborted after a commit" do
|
81
|
-
@mock_client.should_not_receive(:abort)
|
82
|
-
@mock_client.should_receive(:commit).once.with(@transaction_name).and_return(nil)
|
83
|
-
lambda do
|
84
|
-
Transaction.new(@mock_client, @transaction_name) do |t|
|
85
|
-
t.send("/queue/test/1", "test message")
|
86
|
-
t.commit
|
87
|
-
t.abort
|
88
|
-
end
|
89
|
-
end.should_not raise_error(TransactionAborted)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "nested transactions" do
|
94
|
-
before(:each) do
|
95
|
-
@transaction_name = "tx-test-3"
|
96
|
-
@inner_transaction_name = "#{@transaction_name}-inner"
|
97
|
-
@inner_inner_transaction_name = "#{@transaction_name}-inner-inner"
|
98
|
-
@mock_client.should_receive(:begin).with(@transaction_name).once.and_return(nil)
|
99
|
-
@mock_client.should_receive(:begin).with(@inner_transaction_name).once.and_return(nil)
|
100
|
-
@mock_client.should_receive(:send).with("/queue/test/1","test message", hash_including(:transaction => @transaction_name)).once.and_return(nil)
|
101
|
-
@mock_client.should_receive(:send).with("/queue/test/2","inner message", hash_including(:transaction => @inner_transaction_name)).once.and_return(nil)
|
102
|
-
end
|
103
|
-
it "no transaction should succeed when an inner one fails" do
|
104
|
-
@mock_client.should_receive(:abort).once.with(@transaction_name).and_return(nil)
|
105
|
-
@mock_client.should_receive(:abort).once.with(@inner_transaction_name).and_return(nil)
|
106
|
-
@mock_client.should_not_receive(:commit)
|
107
|
-
lambda do
|
108
|
-
Transaction.new(@mock_client, @transaction_name) do |t|
|
109
|
-
t.send("/queue/test/1", "test message")
|
110
|
-
t.transaction(@inner_transaction_name) do |nt|
|
111
|
-
nt.send("/queue/test/2", "inner message")
|
112
|
-
raise "failure"
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end.should raise_error(TransactionAborted)
|
116
|
-
end
|
117
|
-
it "no transaction should succeed when an inner one is explicitly aborted" do
|
118
|
-
@mock_client.should_receive(:begin).with(@inner_inner_transaction_name).once.and_return(nil)
|
119
|
-
@mock_client.should_receive(:send).with("/queue/test/3","inner-inner message", hash_including(:transaction => @inner_inner_transaction_name)).once.and_return(nil)
|
120
|
-
@mock_client.should_receive(:abort).once.with(@transaction_name).and_return(nil)
|
121
|
-
@mock_client.should_receive(:abort).once.with(@inner_transaction_name).and_return(nil)
|
122
|
-
@mock_client.should_receive(:abort).once.with(@inner_inner_transaction_name).and_return(nil)
|
123
|
-
@mock_client.should_not_receive(:commit)
|
124
|
-
lambda do
|
125
|
-
Transaction.new(@mock_client, @transaction_name) do |t|
|
126
|
-
t.send("/queue/test/1", "test message")
|
127
|
-
t.transaction(@inner_transaction_name) do |nt|
|
128
|
-
nt.send("/queue/test/2", "inner message")
|
129
|
-
nt.transaction(@inner_inner_transaction_name) do |nnt|
|
130
|
-
nnt.send("/queue/test/3", "inner-inner message")
|
131
|
-
nnt.abort
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end.should raise_error(TransactionAborted)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
data/spec/transactor_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
|
-
|
3
|
-
module Stomper
|
4
|
-
describe Transactor do
|
5
|
-
class MockConcreteTransactor
|
6
|
-
include Stomper::Transactor
|
7
|
-
end
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
@client = MockConcreteTransactor.new
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "expected interface" do
|
14
|
-
it "should provide a transaction method" do
|
15
|
-
@client.should respond_to(:transaction)
|
16
|
-
end
|
17
|
-
it "should provide a begin method" do
|
18
|
-
@client.should respond_to(:begin)
|
19
|
-
@client.should_receive(:transmit).with(an_instance_of(Stomper::Frames::Begin)).once.and_return(nil)
|
20
|
-
@client.begin("tx-001")
|
21
|
-
end
|
22
|
-
it "should proivde an abort method" do
|
23
|
-
@client.should respond_to(:abort)
|
24
|
-
@client.should_receive(:transmit).with(an_instance_of(Stomper::Frames::Abort)).once.and_return(nil)
|
25
|
-
@client.abort("tx-001")
|
26
|
-
end
|
27
|
-
it "should provide a commit method" do
|
28
|
-
@client.should respond_to(:commit)
|
29
|
-
@client.should_receive(:transmit).with(an_instance_of(Stomper::Frames::Commit)).once.and_return(nil)
|
30
|
-
@client.commit("tx-001")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "transactions" do
|
35
|
-
it "should provide a transaction method that generates a new Transaction" do
|
36
|
-
@client.should_receive(:begin)
|
37
|
-
@client.should_receive(:commit)
|
38
|
-
@evaluated = false
|
39
|
-
@client.transaction do |t|
|
40
|
-
@evaluated = true
|
41
|
-
end
|
42
|
-
@evaluated.should be_true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|