test/test_anonymous.rb in stomp-1.4.3 vs test/test_anonymous.rb in stomp-1.4.4
- old
+ new
@@ -31,11 +31,13 @@
assert_not_nil @conn
end
# Test asynchronous polling.
def test_poll_async
- @conn.subscribe("/queue/do.not.put.messages.on.this.queue", :id => "a.no.messages.queue")
+ sq = ENV['STOMP_ARTEMIS'] ? "jms.queue.queue.do.not.put.messages.on.this.queue" :
+ "/queue/do.not.put.messages.on.this.queue"
+ @conn.subscribe(sq, :id => "a.no.messages.queue")
# If the test 'hangs' here, Connection#poll is broken.
m = @conn.poll
assert m.nil?
end
@@ -72,15 +74,13 @@
end
# Test asking for a receipt on disconnect.
def test_disconnect_receipt
@conn.disconnect :receipt => "abc123"
- assert_nothing_raised {
- assert_not_nil(@conn.disconnect_receipt, "should have a receipt")
- assert_equal(@conn.disconnect_receipt.headers['receipt-id'],
- "abc123", "receipt sent and received should match")
- }
+ assert_not_nil(@conn.disconnect_receipt, "should have a receipt")
+ assert_equal(@conn.disconnect_receipt.headers['receipt-id'],
+ "abc123", "receipt sent and received should match")
end
# Test ACKs for Stomp 1.0
def test_client_ack_with_symbol_10
if @conn.protocol != Stomp::SPL_10
@@ -89,15 +89,13 @@
end
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 {
- # 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']
- }
+ # 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
@@ -108,17 +106,15 @@
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 => msg.headers['subscription']
- }
+ # 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 => msg.headers['subscription']
checkEmsg(@conn)
end
# Test ACKs for Stomp 1.2
def test_client_ack_with_symbol_12
@@ -129,15 +125,13 @@
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']
- }
+ # 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.
def test_embedded_null
@@ -385,13 +379,11 @@
end unless RUBY_ENGINE =~ /jruby/
# Test using a nil body.
def test_nil_body
dest = make_destination
- assert_nothing_raised {
- @conn.publish dest, nil
- }
+ @conn.publish dest, nil
conn_subscribe dest
msg = @conn.receive
assert_equal "", msg.body
checkEmsg(@conn)
end
@@ -410,11 +402,11 @@
@conn.commit "txA"
msg = @conn.receive
assert_equal "txn message", msg.body
checkEmsg(@conn)
- end
+ end unless ENV['STOMP_ARTEMIS'] # See Artemis docs for 1.3, page 222
# Test duplicate subscriptions.
def test_duplicate_subscription
@conn.disconnect # not reliable
@conn = Stomp::Connection.open(nil, nil, host, port, true, nil, nil) # reliable
@@ -429,13 +421,11 @@
# Test nil 1.1 connection parameters.
def test_nil_connparms
@conn.disconnect
#
- assert_nothing_raised do
- @conn = Stomp::Connection.open(nil, nil, host, port, false, 5, nil)
- end
+ @conn = Stomp::Connection.open(nil, nil, host, port, false, 5, nil)
checkEmsg(@conn)
end
# Basic NAK test.
def test_nack11p_0010
@@ -452,21 +442,17 @@
@conn.subscribe dest, :ack => :client, :id => sid
msg = @conn.receive
assert_equal smsg, msg.body
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
- }
+ @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
- }
+ @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()
@@ -474,11 +460,11 @@
@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
+ end unless (ENV['STOMP_AMQ11'] || ENV['STOMP_ARTEMIS'])
# 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
@@ -490,24 +476,20 @@
],
:connect_headers => {"accept-version" => "1.0", "host" => vhost},
:reliable => false,
}
c = nil
- assert_nothing_raised {
- c = Stomp::Connection.new(hash)
- }
+ c = Stomp::Connection.new(hash)
c.disconnect if c
#
hash = { :hosts => [
{:host => host, :port => port, :ssl => false},
],
:connect_headers => {"accept-version" => "3.14159,1.0,12.0", "host" => vhost},
:reliable => false,
}
c = nil
- assert_nothing_raised {
- c = Stomp::Connection.new(hash)
- }
+ c = Stomp::Connection.new(hash)
c.disconnect if c
end
# test JRuby detection
def test_jruby_presence