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
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Secure connections
|
2
|
+
In order connect to an SSL protected broker
|
3
|
+
As a client
|
4
|
+
I want secure connections
|
5
|
+
|
6
|
+
Scenario: SSL connection without verifying broker
|
7
|
+
Given a Stomp 1.1 SSL broker
|
8
|
+
When a connection is created for the SSL broker
|
9
|
+
And no SSL verification is performed
|
10
|
+
And an SSL post connection check is not performed
|
11
|
+
And the connection is told to connect
|
12
|
+
Then the connection should be connected
|
13
|
+
|
14
|
+
Scenario: SSL connection verifying hostname
|
15
|
+
Given a Stomp 1.1 SSL broker
|
16
|
+
When a connection is created for the SSL broker
|
17
|
+
And no SSL verification is performed
|
18
|
+
And an SSL post connection check is performed on "My Broker"
|
19
|
+
And the connection is told to connect
|
20
|
+
Then the connection should be connected
|
21
|
+
|
22
|
+
Scenario: SSL connection verifying hostname failure
|
23
|
+
Given a Stomp 1.1 SSL broker
|
24
|
+
When a connection is created for the SSL broker
|
25
|
+
And the broker's host is "My Broker"
|
26
|
+
And no SSL verification is performed
|
27
|
+
And an SSL post connection check is performed on "Some Other Common Name"
|
28
|
+
Then connecting should raise an openssl error
|
29
|
+
|
30
|
+
Scenario: SSL broker certificate verification
|
31
|
+
Given a Stomp 1.1 SSL broker
|
32
|
+
When a connection is created for the SSL broker
|
33
|
+
And the broker's host is "My Broker"
|
34
|
+
And an SSL post connection check is performed on "My Broker"
|
35
|
+
And the broker's certificate is verified by CA
|
36
|
+
And SSL verification is performed
|
37
|
+
And the connection is told to connect
|
38
|
+
Then the connection should be connected
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Send and message
|
2
|
+
In order exchange information
|
3
|
+
As a client
|
4
|
+
I want to be able to transmit SEND and receive MESSAGE frames
|
5
|
+
|
6
|
+
Scenario Outline: sending and receiving messages with content-types
|
7
|
+
Given a 1.1 connection between client and broker
|
8
|
+
And the client subscribes to <destination>
|
9
|
+
When the client sends a <content-type> <body> to <destination>
|
10
|
+
And the frame exchange is completed
|
11
|
+
Then the client should have received a <content-type> message of <body>
|
12
|
+
|
13
|
+
Examples:
|
14
|
+
| destination | content-type | body |
|
15
|
+
| /queue/test1 | "text/plain" | "hello world" |
|
16
|
+
| /queue/test2 | "application/xml" | "<xml></xml>" |
|
17
|
+
|
18
|
+
Scenario Outline: sending and receiving messages with encodings
|
19
|
+
Given a 1.1 connection between client and broker
|
20
|
+
And the client subscribes to <destination>
|
21
|
+
When the client sends a <body> encoded as <encoding> to <destination>
|
22
|
+
And the frame exchange is completed
|
23
|
+
Then the client should have received a <content-type> message of <body> encoded as <final encoding>
|
24
|
+
|
25
|
+
Examples:
|
26
|
+
| destination | content-type | body | encoding | final encoding |
|
27
|
+
| /queue/test1 | "text/plain" | "hello world" | "UTF-8" | "UTF-8" |
|
28
|
+
| /queue/test2 | "" | "hello world" | "ASCII-8BIT" | "ASCII-8BIT" |
|
@@ -0,0 +1,39 @@
|
|
1
|
+
When /^the client acks a message by ID "([^"]*)"$/ do |message_id|
|
2
|
+
@connection.ack message_id
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^the client acks the last MESSAGE$/ do
|
6
|
+
@connection.ack @received_frames.select { |f| f.command == "MESSAGE" }.last
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the client nacking the last MESSAGE should raise an unsupported command error$/ do
|
10
|
+
lambda { @connection.nack @received_frames.select { |f| f.command == "MESSAGE" }.last }.should raise_error(Stomper::Errors::UnsupportedCommandError)
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^the client acks a message by ID "([^"]*)" and subscription "([^"]*)"$/ do |message_id, subscription|
|
14
|
+
@connection.ack message_id, subscription
|
15
|
+
end
|
16
|
+
|
17
|
+
When /^the client nacks the last MESSAGE$/ do
|
18
|
+
@connection.nack @received_frames.select { |f| f.command == "MESSAGE" }.last
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^the client nacks a message by ID "([^"]*)" and subscription "([^"]*)"$/ do |message_id, subscription|
|
22
|
+
@connection.nack message_id, subscription
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^the client acking a message by ID "([^"]*)" should raise an argument error$/ do |message_id|
|
26
|
+
lambda { @connection.ack message_id }.should raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
Then /^the client nacking a message by ID "([^"]*)" should raise an argument error$/ do |message_id|
|
30
|
+
lambda { @connection.nack message_id }.should raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
|
33
|
+
Then /^the client acking the last MESSAGE should raise an argument error$/ do
|
34
|
+
lambda { @connection.ack @received_frames.select { |f| f.command == "MESSAGE" }.last }.should raise_error(ArgumentError)
|
35
|
+
end
|
36
|
+
|
37
|
+
Then /^the client nacking the last MESSAGE should raise an argument error$/ do
|
38
|
+
lambda { @connection.nack @received_frames.select { |f| f.command == "MESSAGE" }.last }.should raise_error(ArgumentError)
|
39
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
After do |s|
|
2
|
+
@connection && @connection.stop rescue nil
|
3
|
+
@broker && @broker.force_stop
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^a (\d+\.\d+)?\s*connection between client and broker$/ do |version|
|
7
|
+
version ||= '1.0'
|
8
|
+
@broker_uri_string = "stomp:///"
|
9
|
+
@broker_uri = URI.parse(@broker_uri_string)
|
10
|
+
@broker = TestStompServer.new(version)
|
11
|
+
@broker.start
|
12
|
+
@connection = Stomper::Connection.new(@broker_uri)
|
13
|
+
@received_frames = []
|
14
|
+
@sent_frames = []
|
15
|
+
@connection.before_transmitting do |c, f|
|
16
|
+
@sent_frames << f
|
17
|
+
end
|
18
|
+
@connection.after_receiving do |c, f|
|
19
|
+
@received_frames << f
|
20
|
+
end
|
21
|
+
@connection.start
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
Given /^a Stomp (\d+\.\d+)?\s*broker$/ do |version|
|
26
|
+
version ||= '1.0'
|
27
|
+
@broker_uri_string = "stomp:///"
|
28
|
+
@broker_uri = URI.parse(@broker_uri_string)
|
29
|
+
@broker = TestStompServer.new(version)
|
30
|
+
@broker.start
|
31
|
+
@connection = Stomper::Connection.new(@broker_uri)
|
32
|
+
end
|
33
|
+
|
34
|
+
Given /^an erroring Stomp broker$/ do
|
35
|
+
@broker_uri_string = "stomp:///"
|
36
|
+
@broker_uri = URI.parse(@broker_uri_string)
|
37
|
+
@broker = TestStompServer.new('1.0')
|
38
|
+
@broker.session_class = TestStompServer::StompErrorOnConnectSession
|
39
|
+
@broker.start
|
40
|
+
@connection = Stomper::Connection.new(@broker_uri)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
When /^a connection is created from the broker's URI$/ do
|
45
|
+
#@connection = Stomper::Connection.new(@broker_uri)
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^a connection is created from the broker's URI string$/ do
|
49
|
+
@connection = Stomper::Connection.new(@broker_uri_string)
|
50
|
+
end
|
51
|
+
|
52
|
+
When /^the connection is told to connect$/ do
|
53
|
+
@connection.connect
|
54
|
+
end
|
55
|
+
|
56
|
+
Then /^the connection should be connected$/ do
|
57
|
+
@connection.connected?.should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
Then /^the connection should be using the (\d+\.\d+) protocol$/ do |version|
|
61
|
+
@connection.version.should == version
|
62
|
+
end
|
63
|
+
|
64
|
+
Then /^connecting should raise an unsupported protocol version error$/ do
|
65
|
+
lambda { @connection.connect }.should raise_error(Stomper::Errors::UnsupportedProtocolVersionError)
|
66
|
+
end
|
67
|
+
|
68
|
+
Then /^the (connection|client) should not be connected$/ do |arbitrary_name|
|
69
|
+
@connection.connected?.should be_false
|
70
|
+
end
|
71
|
+
|
72
|
+
Then /^connecting should raise an connect failed error$/ do
|
73
|
+
lambda { @connection.connect }.should raise_error(Stomper::Errors::ConnectFailedError)
|
74
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Then /^the broker should have received an? "([^"]*)" frame$/ do |command|
|
2
|
+
Then "the broker should have received a \"#{command}\" frame with headers", table(%{
|
3
|
+
| header-name | header-value |
|
4
|
+
})
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^the broker should have received an? "([^"]*)" frame with headers$/ do |command, table|
|
8
|
+
headers = table_to_headers table
|
9
|
+
@broker.session.received_frames.any? do |f|
|
10
|
+
f.command == command && headers.all? { |(k,v)| headers[k] == f[k] }
|
11
|
+
end.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^the client should have received an? "([^"]*)" frame with headers$/ do |command, table|
|
15
|
+
headers = table_to_headers table
|
16
|
+
@received_frames.any? do |f|
|
17
|
+
f.command == command && headers.all? { |(k,v)| headers[k] == f[k] }
|
18
|
+
end.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
When /^the broker sends a "([^"]*)" frame with headers$/ do |command, table|
|
22
|
+
headers = table_to_headers table
|
23
|
+
@broker.session.send_frame command, headers
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^the frame exchange is completed$/ do
|
27
|
+
@connection.disconnect(:receipt => 'TERMINATE_POLITELY_12345')
|
28
|
+
@connection.stop
|
29
|
+
@broker.stop
|
30
|
+
end
|
31
|
+
|
32
|
+
When /^the frame exchange is completed without client disconnect$/ do
|
33
|
+
@connection.stop
|
34
|
+
@broker.stop
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^a connection is established$/ do
|
2
|
+
@connection.connect
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^an unversioned Stomp broker$/ do
|
6
|
+
@broker_uri_string = "stomp:///"
|
7
|
+
@broker_uri = URI.parse(@broker_uri_string)
|
8
|
+
@broker = TestStompServer.new(nil)
|
9
|
+
@broker.start
|
10
|
+
@connection = Stomper::Connection.new(@broker_uri)
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^the client protocol version is "([^"]*)"$/ do |arg1|
|
14
|
+
@connection.versions = arg1.split(",")
|
15
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
When /^the client sends a receipted message "([^"]*)" to "([^"]*)"$/ do |body, destination|
|
2
|
+
@receipts_received ||= {}
|
3
|
+
@connection.send(destination, body) do |r|
|
4
|
+
@receipts_received[r[:'receipt-id']] = r
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
Then /^the client should have received a receipt for the last "([^"]*)"$/ do |command|
|
9
|
+
fr = @sent_frames.select { |f| f.command == command }.last
|
10
|
+
(@receipts_received && @receipts_received[fr[:'receipt']]).should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^the client subscribes to "([^"]*)" with a receipt$/ do |destination|
|
14
|
+
@receipts_received ||= {}
|
15
|
+
@connection.with_receipt do |r|
|
16
|
+
@receipts_received[r[:'receipt-id']] = r
|
17
|
+
end.subscribe(destination)
|
18
|
+
end
|
19
|
+
|
20
|
+
When /^the client unsubscribes from "([^"]*)" with a receipt$/ do |subscription|
|
21
|
+
@receipts_received ||= {}
|
22
|
+
@connection.with_receipt do |r|
|
23
|
+
@receipts_received[r[:'receipt-id']] = r
|
24
|
+
end.unsubscribe(subscription)
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^the client begins transaction "([^"]*)" with a receipt$/ do |tx|
|
28
|
+
@receipts_received ||= {}
|
29
|
+
@connection.with_receipt do |r|
|
30
|
+
@receipts_received[r[:'receipt-id']] = r
|
31
|
+
end.begin(tx)
|
32
|
+
end
|
33
|
+
|
34
|
+
When /^the client aborts transaction "([^"]*)" with a receipt$/ do |tx|
|
35
|
+
@receipts_received ||= {}
|
36
|
+
@connection.with_receipt do |r|
|
37
|
+
@receipts_received[r[:'receipt-id']] = r
|
38
|
+
end.abort(tx)
|
39
|
+
end
|
40
|
+
|
41
|
+
When /^the client commits transaction "([^"]*)" with a receipt$/ do |tx|
|
42
|
+
@receipts_received ||= {}
|
43
|
+
@connection.with_receipt do |r|
|
44
|
+
@receipts_received[r[:'receipt-id']] = r
|
45
|
+
end.commit(tx)
|
46
|
+
end
|
47
|
+
|
48
|
+
When /^the client acks message "([^"]*)" from "([^"]*)" with a receipt$/ do |m_id, sub_id|
|
49
|
+
@receipts_received ||= {}
|
50
|
+
@connection.with_receipt do |r|
|
51
|
+
@receipts_received[r[:'receipt-id']] = r
|
52
|
+
end.ack(m_id, sub_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
When /^the client nacks message "([^"]*)" from "([^"]*)" with a receipt$/ do |m_id, sub_id|
|
56
|
+
@receipts_received ||= {}
|
57
|
+
@connection.with_receipt do |r|
|
58
|
+
@receipts_received[r[:'receipt-id']] = r
|
59
|
+
end.nack(m_id, sub_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
When /^the client disconnects with a receipt$/ do
|
63
|
+
@receipts_received ||= {}
|
64
|
+
@connection.with_receipt do |r|
|
65
|
+
@receipts_received[r[:'receipt-id']] = r
|
66
|
+
end.disconnect
|
67
|
+
end
|
68
|
+
|
69
|
+
When /^the client connects with a receipt$/ do
|
70
|
+
@receipts_received ||= {}
|
71
|
+
@connection.with_receipt do |r|
|
72
|
+
@receipts_received[r[:'receipt-id']] = r
|
73
|
+
end.transmit(Stomper::Frame.new('CONNECT'))
|
74
|
+
end
|
75
|
+
|
76
|
+
Then /^the client should not have added a receipt header to the last "([^"]*)"$/ do |command|
|
77
|
+
fr = @sent_frames.select { |f| f.command == command }.last
|
78
|
+
fr[:receipt].should be_nil
|
79
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
Given /^a header scope with headers$/ do |table|
|
2
|
+
headers = table_to_headers table
|
3
|
+
@scope = @connection.with_headers(headers)
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^the client acks a message by ID "([^"]*)" and subscription "([^"]*)" within the scope$/ do |message_id, subscription|
|
7
|
+
@scope.ack message_id, subscription
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^the client subscribes to "([^"]*)" with headers within the scope$/ do |dest, table|
|
11
|
+
@subscribe_frames ||= []
|
12
|
+
headers = table_to_headers table
|
13
|
+
@default_subscription_triggered = 0
|
14
|
+
@subscribe_frames << @scope.subscribe(dest, headers) do |m|
|
15
|
+
@default_subscription_triggered += 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Given /^a transaction scope named "([^"]*)"$/ do |tx|
|
20
|
+
@scope = @connection.with_transaction(:transaction => tx)
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^the client begins the transaction scope$/ do
|
24
|
+
@scope.begin
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^the client nacks a message by ID "([^"]*)" and subscription "([^"]*)" within the scope$/ do |message_id, subscription|
|
28
|
+
@scope.nack message_id, subscription
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^the client aborts the transaction scope$/ do
|
32
|
+
@scope.abort
|
33
|
+
end
|
34
|
+
|
35
|
+
When /^the client executes a successful transaction block named "([^"]*)"$/ do |tx|
|
36
|
+
@connection.with_transaction(:transaction => tx) do |t|
|
37
|
+
t.ack "message-id", "subscription-id"
|
38
|
+
t.send "/queue/transaction/test", "message"
|
39
|
+
t.nack "message-id-2", "subscription-id-2"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^the client executes an unsuccessful transaction block named "([^"]*)"$/ do |tx|
|
44
|
+
lambda do
|
45
|
+
@connection.with_transaction(:transaction => tx) do |t|
|
46
|
+
t.ack "message-id", "subscription-id"
|
47
|
+
t.send "/queue/transaction/test", "message"
|
48
|
+
t.nack "message-id-2", "subscription-id-2"
|
49
|
+
raise "transaction will now fail"
|
50
|
+
end
|
51
|
+
end.should raise_error("transaction will now fail")
|
52
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Given /^a Stomp (\d+\.\d+)?\s*SSL broker$/ do |version|
|
2
|
+
@broker = TestSSLStompServer.new(version)
|
3
|
+
@broker.start
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^a connection is created for the SSL broker$/ do
|
7
|
+
@connection = Stomper::Connection.new("stomp+ssl:///")
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^the broker's host is "([^"]*)"$/ do |hostname|
|
11
|
+
@connection.host = hostname
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^no SSL verification is performed$/ do
|
15
|
+
@connection.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^SSL verification is performed$/ do
|
19
|
+
@connection.ssl[:verify_mode] = ::OpenSSL::SSL::VERIFY_PEER | ::OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^an SSL post connection check is performed on "([^"]*)"$/ do |host|
|
23
|
+
@connection.ssl[:post_connection_check] = host
|
24
|
+
end
|
25
|
+
|
26
|
+
Then /^connecting should raise an openssl error$/ do
|
27
|
+
lambda { @connection.connect }.should raise_error(OpenSSL::SSL::SSLError)
|
28
|
+
end
|
29
|
+
|
30
|
+
When /^an SSL post connection check is not performed$/ do
|
31
|
+
@connection.ssl[:post_connection_check] = false
|
32
|
+
end
|
33
|
+
|
34
|
+
When /^the broker's certificate is verified by CA$/ do
|
35
|
+
@connection.ssl[:ca_file] = File.expand_path('../../support/ssl/demoCA/cacert.pem', __FILE__)
|
36
|
+
end
|
37
|
+
|
38
|
+
When /^the client's certificate and key are specified$/ do
|
39
|
+
@connection.ssl[:cert] = OpenSSL::X509::Certificate.new(File.read(File.expand_path('../../support/ssl/client_cert.pem', __FILE__)))
|
40
|
+
@connection.ssl[:key] = OpenSSL::PKey::RSA.new(File.read(File.expand_path('../../support/ssl/client_key.pem', __FILE__)))
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Given /^the client subscribes to (\/.*)$/ do |dest|
|
2
|
+
@messages_for_subscription ||= []
|
3
|
+
@connection.subscribe(dest) do |m|
|
4
|
+
sub = m[:subscription]
|
5
|
+
@messages_for_subscription << m
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^the client sends a "([^"]*)" "([^"]*)" to (\/.*)$/ do |ct, body, dest|
|
10
|
+
@connection.send(dest, body, :'content-type' => ct)
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^the client should have received a "([^"]*)" message of "([^"]*)"$/ do |ct, body|
|
14
|
+
@messages_for_subscription.any? do |m|
|
15
|
+
m.content_type == ct && m.body == body
|
16
|
+
end.should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^the client sends a "([^"]*)" encoded as "([^"]*)" to (\/.*)$/ do |body, enc, dest|
|
20
|
+
body.force_encoding(enc) if body.respond_to?(:force_encoding)
|
21
|
+
@connection.send(dest, body)
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^the client should have received a "([^"]*)" message of "([^"]*)" encoded as "([^"]*)"$/ do |ct, body, enc|
|
25
|
+
@messages_for_subscription.any? do |m|
|
26
|
+
ct_check = (m.content_type == ct || m.content_type.nil? && ct.empty?)
|
27
|
+
b_check = body == m.body
|
28
|
+
if body.respond_to?(:encoding)
|
29
|
+
ct_check && b_check && m.body.encoding.name == enc
|
30
|
+
else
|
31
|
+
ct_check && b_check
|
32
|
+
end
|
33
|
+
end.should be_true
|
34
|
+
end
|
35
|
+
|