test/test_helper.rb in stomp-1.1.10 vs test/test_helper.rb in stomp-1.2.0

- old
+ new

@@ -1,11 +1,20 @@ +# -*- encoding: utf-8 -*- + $:.unshift(File.join(File.dirname(__FILE__), "..", "lib")) require 'test/unit' require 'timeout' require 'stomp' +require 'tlogger' +begin + dummy = RUBY_ENGINE +rescue NameError => ne + RUBY_ENGINE = "unknown" +end + # Helper routines module TestBase def user ENV['STOMP_USER'] || "guest" end @@ -31,9 +40,48 @@ line = Regexp.last_match[2].to_i method = Regexp.last_match[3] method.gsub!(" ","_") [file, line, method] end + end + + def get_connection() + ch = get_conn_headers() + conn = Stomp::Connection.open(user, passcode, host, port, false, 5, ch) + conn + end + + def get_client() + hash = { :hosts => [ + {:login => user, :passcode => passcode, :host => host, :port => port}, + ], + :connect_headers => get_conn_headers() + } + + client = Stomp::Client.new(hash) + client + end + + def get_conn_headers() + ch = {} + if ENV['STOMP_TEST11'] + # + if Stomp::SUPPORTED.index(ENV['STOMP_TEST11']) + ch['accept-version'] = ENV['STOMP_TEST11'] + else + ch['accept-version'] = Stomp::SPL_11 + end + # + ch['host'] = ENV['STOMP_RABBIT'] ? "/" : host + end + ch + end + + def conn_subscribe(dest, headers = {}) + if @conn.protocol >= Stomp::SPL_11 + headers[:id] = @conn.uuid() unless headers[:id] + end + @conn.subscribe dest, headers end # Test helper methods def make_destination