test/helper.rb in spqr-0.2.4 vs test/helper.rb in spqr-0.3.0
- old
+ new
@@ -8,26 +8,38 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'spqr/spqr'
require 'spqr/app'
+$QMFENGINE_CONSOLE_SUPPORTS_EVENTS = (::ENV["QMFENGINE_CONSOLE_SUPPORTS_EVENTS"] && ::ENV["QMFENGINE_CONSOLE_SUPPORTS_EVENTS"] == "1")
+
module QmfTestHelpers
- DEBUG = (::ENV["SPQR_TESTS_DEBUG"] and ::ENV["SPQR_TESTS_DEBUG"].downcase == "yes")
+ DEBUG = (::ENV["SPQR_TESTS_DEBUG"] && ((::ENV["SPQR_TESTS_DEBUG"].downcase == "yes" && "yes") || (::ENV["SPQR_TESTS_DEBUG"].downcase == "trace" && "trace")))
class AgentNotifyHandler < Qmf::ConsoleHandler
def initialize
@q = Queue.new
+ @eq = Queue.new
end
def queue
@q
end
+
+ def event_queue
+ @eq
+ end
def agent_added(agent)
puts "GOT AN AGENT: #{agent} at #{Time.now.utc}" if DEBUG
@q << agent
end
+
+ def event_received(event)
+ puts "GOT AN EVENT: #{event} at #{Time.now.utc}"
+ @eq << event
+ end
end
def app_setup(*classes)
unless $broker
$notify_handler = AgentNotifyHandler.new
@@ -45,17 +57,17 @@
# replace stdin/stdout/stderr
$stdin.reopen("/dev/null", "r")
$stdout.reopen("/dev/null", "w")
$stderr.reopen("/dev/null", "w")
else
- ENV['QPID_TRACE'] = "1"
+ ENV['QPID_TRACE'] = "1" if DEBUG == "trace"
end
exec("#{File.dirname(__FILE__)}/generic-agent.rb", *classes.map {|cl| cl.to_s})
exit! 127
@app = SPQR::App.new(:loglevel => (DEBUG ? :debug : :fatal), :appname=>"#{classes.join("")}[#{Process.pid}]")
- @app.register *classes
+ @app.register(*classes)
@app.main
end
begin