[DRE-commits] [SCM] ruby-stomp.git branch, master, updated. debian/1.2.6-1-7-g6915b9f
Jonas Genannt
jonas at brachium-system.net
Tue Nov 6 19:11:59 UTC 2012
The following commit has been merged in the master branch:
commit 6fdf9ac904c59e98c6f2220dc11cda4131d7aa68
Merge: 75cf39bc847720d20bfbaa0502e1fc80123ff8f6 5437954867b056568b1481762c796bef2d4477b9
Author: Jonas Genannt <jonas at brachium-system.net>
Date: Tue Nov 6 19:46:26 2012 +0100
Merge branch 'upstream'
* upstream:
Imported Upstream version 1.2.7
Adding upstream version 1.2.6.
Adding upstream version 1.2.5.
Adding upstream version 1.2.4.
Adding upstream version 1.2.2.
diff --combined test/test_connection.rb
index e10cb01,216e26f..f990299
--- a/test/test_connection.rb
+++ b/test/test_connection.rb
@@@ -53,6 -53,7 +53,7 @@@ class TestConnection < Test::Unit::Test
else
assert_equal "test_stomp#test_\000_length", msg2.body
end
+ checkEmsg(@conn)
end unless ENV['STOMP_RABBIT']
# Test direct / explicit receive.
@@@ -68,6 -69,7 +69,7 @@@
conn_subscribe make_destination, :receipt => "abc"
msg = @conn.receive
assert_equal "abc", msg.headers['receipt-id']
+ checkEmsg(@conn)
end
# Test asking for a receipt on disconnect.
@@@ -80,23 -82,62 +82,62 @@@
}
end
- # Test ACKs using symbols for header keys.
- def test_client_ack_with_symbol
- if @conn.protocol == Stomp::SPL_10
- @conn.subscribe make_destination, :ack => :client
- else
- sid = @conn.uuid()
- @conn.subscribe make_destination, :ack => :client, :id => sid
+ # Test ACKs for Stomp 1.0
+ def test_client_ack_with_symbol_10
+ if @conn.protocol != Stomp::SPL_10
+ assert true
+ return
end
- @conn.publish make_destination, "test_stomp#test_client_ack_with_symbol"
+ queue = make_destination()
+ @conn.subscribe queue, :ack => :client
+ @conn.publish queue, "test_stomp#test_client_ack_with_symbol_10"
msg = @conn.receive
assert_nothing_raised {
- if @conn.protocol == Stomp::SPL_10
- @conn.ack msg.headers['message-id']
- else
- @conn.ack msg.headers['message-id'], :subscription => sid
- end
+ # ACK has one required header, message-id, which must contain a value
+ # matching the message-id for the MESSAGE being acknowledged.
+ @conn.ack msg.headers['message-id']
+ }
+ checkEmsg(@conn)
+ end
+
+ # Test ACKs for Stomp 1.1
+ def test_client_ack_with_symbol_11
+ if @conn.protocol != Stomp::SPL_11
+ assert true
+ return
+ end
+ sid = @conn.uuid()
+ queue = make_destination()
+ @conn.subscribe queue, :ack => :client, :id => sid
+ @conn.publish queue, "test_stomp#test_client_ack_with_symbol_11"
+ msg = @conn.receive
+ assert_nothing_raised {
+ # ACK has two REQUIRED headers: message-id, which MUST contain a value
+ # matching the message-id for the MESSAGE being acknowledged and
+ # subscription, which MUST be set to match the value of the subscription's
+ # id header.
+ @conn.ack msg.headers['message-id'], :subscription => sid
}
+ checkEmsg(@conn)
+ end
+
+ # Test ACKs for Stomp 1.2
+ def test_client_ack_with_symbol_12
+ if @conn.protocol != Stomp::SPL_12
+ assert true
+ return
+ end
+ sid = @conn.uuid()
+ queue = make_destination()
+ @conn.subscribe queue, :ack => :client, :id => sid
+ @conn.publish queue, "test_stomp#test_client_ack_with_symbol_11"
+ msg = @conn.receive
+ assert_nothing_raised {
+ # The ACK frame MUST include an id header matching the ack header
+ # of the MESSAGE being acknowledged.
+ @conn.ack msg.headers['ack']
+ }
+ checkEmsg(@conn)
end
# Test a message with 0x00 embedded in the body.
@@@ -105,6 -146,7 +146,7 @@@
@conn.publish make_destination, "a\0"
msg = @conn.receive
assert_equal "a\0" , msg.body
+ checkEmsg(@conn)
end
# Test connection open checking.
@@@ -176,6 -218,7 +218,7 @@@
@conn.publish make_destination, "a\0"
msg = @conn.receive
assert_instance_of Stomp::Message , msg
+ checkEmsg(@conn)
end
# Test converting a Message to a string.
@@@ -184,6 -227,7 +227,7 @@@
@conn.publish make_destination, "a\0"
msg = @conn.receive
assert_match /^<Stomp::Message headers=/ , msg.to_s
+ checkEmsg(@conn)
end
# Test that a connection frame is present.
@@@ -202,6 -246,7 +246,7 @@@
assert_equal "a\n\n", msg_a.body
assert_equal "b\n\na\n\n", msg_b.body
+ checkEmsg(@conn)
end
# Test publishing multiple messages.
@@@ -214,6 -259,7 +259,7 @@@
assert_equal "a\0", msg_a.body
assert_equal "b\0", msg_b.body
+ checkEmsg(@conn)
end
def test_thread_hang_one
@@@ -230,6 -276,7 +276,7 @@@
sleep 1
assert_not_nil received
assert_equal message, received.body
+ checkEmsg(@conn)
end
# Test polling with a single thread.
@@@ -251,6 -298,7 +298,7 @@@
sleep max_sleep+1
assert_not_nil received
assert_equal message, received.body
+ checkEmsg(@conn)
end
# Test receiving with multiple threads.
@@@ -289,6 -337,7 +337,7 @@@
sleep sleep_incr
end
assert_equal @max_msgs, msg_ctr
+ checkEmsg(@conn)
end unless RUBY_ENGINE =~ /jruby/
# Test polling with multiple threads.
@@@ -333,6 -382,7 +382,7 @@@
sleep sleep_incr
end
assert_equal @max_msgs, msg_ctr
+ checkEmsg(@conn)
end unless RUBY_ENGINE =~ /jruby/
# Test using a nil body.
@@@ -343,7 -393,8 +393,8 @@@
}
conn_subscribe dest
msg = @conn.receive
- assert_equal "", msg.body
+ assert_equal "", msg.body
+ checkEmsg(@conn)
end
# Test transaction message sequencing.
@@@ -361,6 -412,7 +412,7 @@@
@conn.commit "txA"
msg = @conn.receive
assert_equal "txn message", msg.body
+ checkEmsg(@conn)
end
# Test duplicate subscriptions.
@@@ -373,6 -425,7 +425,7 @@@
assert_raise Stomp::Error::DuplicateSubscription do
conn_subscribe dest
end
+ checkEmsg(@conn)
end
# Test nil 1.1 connection parameters.
@@@ -382,6 -435,7 +435,7 @@@
assert_nothing_raised do
@conn = Stomp::Connection.open(user, passcode, host, port, false, 5, nil)
end
+ checkEmsg(@conn)
end
# Basic NAK test.
@@@ -391,18 -445,29 +445,29 @@@
@conn.nack "dummy msg-id"
end
else
- sid = @conn.uuid()
dest = make_destination
- @conn.subscribe dest, :ack => :client, :id => sid
smsg = "test_stomp#test_nack01: #{Time.now.to_f}"
- @conn.publish make_destination, smsg
+ @conn.publish dest, smsg
+ #
+ sid = @conn.uuid()
+ @conn.subscribe dest, :ack => :client, :id => sid
msg = @conn.receive
assert_equal smsg, msg.body
- assert_nothing_raised {
- @conn.nack msg.headers["message-id"], :subscription => sid
- sleep 0.05 # Give racy brokers a chance to handle the last nack before unsubscribe
- @conn.unsubscribe dest, :id => sid
- }
+ case @conn.protocol
+ when Stomp::SPL_12
+ assert_nothing_raised {
+ @conn.nack msg.headers["ack"]
+ sleep 0.05 # Give racy brokers a chance to handle the last nack before unsubscribe
+ @conn.unsubscribe dest, :id => sid
+ }
+ else # Stomp::SPL_11
+ assert_nothing_raised {
+ @conn.nack msg.headers["message-id"], :subscription => sid
+ sleep 0.05 # Give racy brokers a chance to handle the last nack before unsubscribe
+ @conn.unsubscribe dest, :id => sid
+ }
+ end
+
# phase 2
teardown()
setup()
@@@ -410,6 -475,7 +475,7 @@@
@conn.subscribe dest, :ack => :auto, :id => sid
msg2 = @conn.receive
assert_equal smsg, msg2.body
+ checkEmsg(@conn)
end
end unless ENV['STOMP_AMQ11'] # AMQ sends NACK'd messages to a DLQ
@@@ -443,5 -509,6 +509,36 @@@
}
c.disconnect if c
end
+
++ # Test to illustrate Issue #44. Prior to a fix for #44, these tests would
++ # fail only when connecting to a pure STOMP 1.0 server that does not
++ # return a 'version' header at all.
++ def test_conn10_simple
++ @conn.disconnect
++ #
++ hash = { :hosts => [
++ {:login => user, :passcode => passcode, :host => host, :port => port, :ssl => false},
++ ],
++ :connect_headers => {"accept-version" => "1.0", "host" => host},
++ :reliable => false,
++ }
++ c = nil
++ assert_nothing_raised {
++ c = Stomp::Connection.new(hash)
++ }
++ c.disconnect if c
++ #
++ hash = { :hosts => [
++ {:login => user, :passcode => passcode, :host => host, :port => port, :ssl => false},
++ ],
++ :connect_headers => {"accept-version" => "3.14159,1.0,12.0", "host" => host},
++ :reliable => false,
++ }
++ c = nil
++ assert_nothing_raised {
++ c = Stomp::Connection.new(hash)
++ }
++ c.disconnect if c
++ end
end
--
ruby-stomp.git
More information about the Pkg-ruby-extras-commits
mailing list