test/test_helper.rb in stomp-1.2.6 vs test/test_helper.rb in stomp-1.2.7
- old
+ new
@@ -62,55 +62,83 @@
end
# Get a Stomp Connection.
def get_connection()
ch = get_conn_headers()
- conn = Stomp::Connection.open(user, passcode, host, port, false, 5, ch)
+ hash = { :hosts => [
+ {:login => user, :passcode => passcode, :host => host, :port => port, :ssl => nil},
+ ],
+ :reliable => false,
+ :connect_headers => ch,
+ :stompconn => get_stomp_conn(),
+ :usecrlf => get_crlf(),
+ }
+ conn = Stomp::Connection.open(hash)
conn
end
# Get a Stomp SSL Connection.
def get_ssl_connection()
ch = get_conn_headers()
ssl_params = Stomp::SSLParams.new # S/B safe for all Ruby versions tested
hash = { :hosts => [
{:login => user, :passcode => passcode, :host => host, :port => ssl_port, :ssl => ssl_params},
],
- :connect_headers => ch
+ :connect_headers => ch,
+ :stompconn => get_stomp_conn(),
+ :usecrlf => get_crlf(),
}
conn = Stomp::Connection.new(hash)
conn
end
# Get a Stomp Client.
def get_client()
hash = { :hosts => [
{:login => user, :passcode => passcode, :host => host, :port => port},
],
- :connect_headers => get_conn_headers()
+ :connect_headers => get_conn_headers(),
+ :stompconn => get_stomp_conn(),
+ :usecrlf => get_crlf(),
}
client = Stomp::Client.new(hash)
client
end
# Get a connection headers hash.
def get_conn_headers()
ch = {}
- if ENV['STOMP_TEST11']
+ if ENV['STOMP_TEST11p']
#
- if Stomp::SUPPORTED.index(ENV['STOMP_TEST11'])
- ch['accept-version'] = ENV['STOMP_TEST11']
+ raise "Invalid 1.1 plus test protocol" if ENV['STOMP_TEST11p'] == Stomp::SPL_10
+ #
+ if Stomp::SUPPORTED.index(ENV['STOMP_TEST11p'])
+ ch['accept-version'] = ENV['STOMP_TEST11p']
else
- ch['accept-version'] = Stomp::SPL_11
+ ch['accept-version'] = Stomp::SPL_11 # Just use 1.1
end
#
ch['host'] = ENV['STOMP_RABBIT'] ? "/" : host
end
ch
end
+ # Determine if tests should use STOMP instead of CONNECT
+ def get_stomp_conn()
+ usc = false
+ usc = true if ENV['STOMP_TEST11p'] && Stomp::SUPPORTED.index(ENV['STOMP_TEST11p']) && ENV['STOMP_TEST11p'] >= Stomp::SPL_11 && ENV['STOMP_CONN']
+ usc
+ end
+
+ # Determine if tests should \r\n as line ends
+ def get_crlf()
+ ucr = false
+ ucr = true if ENV['STOMP_TEST11p'] && Stomp::SUPPORTED.index(ENV['STOMP_TEST11p']) && ENV['STOMP_TEST11p'] >= Stomp::SPL_12 && ENV['STOMP_CRLF']
+ ucr
+ end
+
# Subscribe to a destination.
def conn_subscribe(dest, headers = {})
if @conn.protocol >= Stomp::SPL_11
headers[:id] = @conn.uuid() unless headers[:id]
end
@@ -119,9 +147,17 @@
# Get a dynamic destination name.
def make_destination
name = caller_method_name unless name
qname = ENV['STOMP_DOTQUEUE'] ? "/queue/test.ruby.stomp." + name : "/queue/test/ruby/stomp/" + name
+ end
+
+ #
+ def checkEmsg(cc)
+ m = cc.poll
+ if m
+ assert m.command != Stomp::CMD_ERROR
+ end
end
end