Module: TestBase

### Home Classes Methods

### In Files

- test/test_helper.rb

### Methods

- #caller_method_name
- #checkEmsg
- #conn_subscribe
- #get_client
- #get_conn_headers
- #get_connection
- #get_crlf
- #get_ssl_connection
- #get_stomp_conn
- #host
- #jruby?
- #make_destination
- #parse_caller
- #passcode
- #port
- #ssl_port
- #user

### Files

- CHANGELOG.rdoc
- LICENSE

### Class/Module Index

Quicksearch

- Stomp
- Stomp::Client
- Stomp::Connection
- Stomp::Error
- Stomp::Error::ConnectReadTimeout
- Stomp::Error::DuplicateSubscription
- Stomp::Error::InvalidFormat
- Stomp::Error::InvalidHeartBeatHeaderError
- Stomp::Error::InvalidMessageLength
- Stomp::Error::InvalidServerCommand
- Stomp::Error::LoggerConnectionError
- Stomp::Error::MalformedFailoverOptionsError
- Stomp::Error::MaxReconnectAttempts
- Stomp::Error::MessageIDRequiredError
- Stomp::Error::NilMessageError
- Stomp::Error::NoCurrentConnection
- Stomp::Error::PacketParsingTimeout
- Stomp::Error::ProtocolError11p
- Stomp::Error::ProtocolErrorConnect
- Stomp::Error::SSLClientParamsError
- Stomp::Error::SSLNoCertFileError
- Stomp::Error::SSLNoKeyFileError
- Stomp::Error::SSLNoTruststoreFileError
- Stomp::Error::SSLUnreadableCertFileError
- Stomp::Error::SSLUnreadableKeyFileError
- Stomp::Error::SSLUnreadableTruststoreFileError
- Stomp::Error::SocketOpenTimeout
- Stomp::Error::StompServerError
- Stomp::Error::SubscriptionRequiredError
- Stomp::Error::UTF8ValidationError
- Stomp::Error::UnsupportedProtocolError
- Stomp::HeaderCodec
- Stomp::Message
- Stomp::SSLParams
- Client11Example1
- Client11PutGet1
- Connection11Example1
- Connection11Example2
- ExampleConsumer
- ExamplePublisher
- ExampleRubyCiphers
- ExampleSSL1
- ExampleSSL1C
- ExampleSSL2
- ExampleSSL2C
- ExampleSSL3
- ExampleSSL3C
- ExampleSSL4
- ExampleSSL4C
- ExampleTopicConsumer
- ExampleTopicPublisher
- Hash
- HeartBeatExample1
- LoggerExample
- Object
- Publish11Example1
- Receive11Example1
- Receive11Example2
- RepeatedHeadersExample
- SSLLoggerExample
- Slogger
- Stomp11Common
- TestBase
- TestClient
- TestConnection
- TestConnection1P
- TestMessage
- TestSSL
- TestURLLogins
- Tlogger

No matching classes.

# TestBase

Test helper methods.

### Public Instance Methods

caller_method_name() click to toggle source

Helper for minitest on 1.9

    # File test/test_helper.rb, line 53
    def caller_method_name
      parse_caller(caller(2).first).last
    end

checkEmsg(cc) click to toggle source

    # File test/test_helper.rb, line 159
    def checkEmsg(cc)
      m = cc.poll
      if m
        assert m.command != Stomp::CMD_ERROR
      end
    end

conn_subscribe(dest, headers = {}) click to toggle source

Subscribe to a destination.

    # File test/test_helper.rb, line 145
    def conn_subscribe(dest, headers = {})
      if @conn.protocol >= Stomp::SPL_11
        headers[:id] = @conn.uuid() unless headers[:id]
      end
      @conn.subscribe dest, headers
    end

get_client() click to toggle source

Get a Stomp Client.

    # File test/test_helper.rb, line 99
    def get_client()
      hash = { :hosts => [
            {:login => user, :passcode => passcode, :host => host, :port => port},
            ],
            :connect_headers => get_conn_headers(),
            :stompconn => get_stomp_conn(),
            :usecrlf => get_crlf(),
          }

      client = Stomp::Client.new(hash)
      client
    end

get_conn_headers() click to toggle source

Get a connection headers hash.

    # File test/test_helper.rb, line 113
    def get_conn_headers()
      ch = {}
      if ENV['STOMP_TEST11p']
        #
        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 # Just use 1.1
        end
        #
        ch['host'] = ENV['STOMP_RABBIT'] ? "/" : host
      end
      ch
    end

get_connection() click to toggle source

Get a Stomp Connection.

    # File test/test_helper.rb, line 69
    def get_connection()
      ch = get_conn_headers()
      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_crlf() click to toggle source

Determine if tests should rn as line ends

    # File test/test_helper.rb, line 138
    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

get_ssl_connection() click to toggle source

Get a Stomp SSL Connection.

    # File test/test_helper.rb, line 84
    def get_ssl_connection()
      ch = get_conn_headers()
      ssl_params = Stomp::SSLParams.new(:use_ruby_ciphers => jruby?())
      hash = { :hosts => [
        {:login => user, :passcode => passcode, :host => host, :port => ssl_port, :ssl => ssl_params},
        ],
        :connect_headers => ch,
        :stompconn => get_stomp_conn(),
        :usecrlf => get_crlf(),
      }
      conn = Stomp::Connection.new(hash)
      conn
    end

get_stomp_conn() click to toggle source

Determine if tests should use STOMP instead of CONNECT

    # File test/test_helper.rb, line 131
    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

host() click to toggle source

Get host

    # File test/test_helper.rb, line 38
    def host
      ENV['STOMP_HOST'] || "localhost"
    end

jruby?() click to toggle source

Check for JRuby before a connection exists

    # File test/test_helper.rb, line 167
    def jruby?()
      jr = defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/ ? true : false
    end

make_destination() click to toggle source

Get a dynamic destination name.

    # File test/test_helper.rb, line 153
    def make_destination
      name = caller_method_name unless name
      qname = ENV['STOMP_DOTQUEUE'] ? "/queue/test.ruby.stomp." + name : "/queue/test/ruby/stomp/" + name
    end

parse_caller(at) click to toggle source

Helper for minitest on 1.9

    # File test/test_helper.rb, line 58
    def parse_caller(at)
      if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
        file = Regexp.last_match[1]
        line = Regexp.last_match[2].to_i
        method = Regexp.last_match[3]
        method.gsub!(" ","_")
        [file, line, method]
      end
    end

passcode() click to toggle source

Gete passcode

    # File test/test_helper.rb, line 33
    def passcode
      ENV['STOMP_PASSCODE'] || "guest"
    end

port() click to toggle source

Get port

    # File test/test_helper.rb, line 43
    def port
      (ENV['STOMP_PORT'] || 61613).to_i
    end

ssl_port() click to toggle source

Get SSL port

    # File test/test_helper.rb, line 48
    def ssl_port
      (ENV['STOMP_SSLPORT'] || 61612).to_i
    end

user() click to toggle source

Get user

    # File test/test_helper.rb, line 28
    def user
      ENV['STOMP_USER'] || "guest"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.