diff --git a/utilities/acceptance-tests/script/output_manager.rb b/utilities/acceptance-tests/script/output_manager.rb
new file mode 100644
index 00000000..0280596d
--- /dev/null
+++ b/utilities/acceptance-tests/script/output_manager.rb
@@ -0,0 +1,88 @@
+=begin
+--------------------------------------------------------------------------------
+
+Stop the Vitro application, delete all MySQL tables from the Vitro database, and
+start the application again.
+
+--------------------------------------------------------------------------------
+
+Parameters:
+ tomcat_stop_command
+ A "shell" command that will stop the Tomcat server.
+ tomcat_stop_delay
+ Number of seconds to wait after the tomcat_stop_command returns before
+ proceeding.
+ tomcat_start_command
+ A "shell" command that will start the Tomcat server.
+ tomcat_start_delay
+ Number of seconds to wait after the tomcat_start_command returns before
+ proceeding.
+ mysql_username
+ A user account that has authority to drop the Vitro database in MySQL.
+ mysql_password
+ The password for mysql_username.
+ database_name
+ The name of the Vitro database in MySQL.
+
+--------------------------------------------------------------------------------
+=end
+
+class OutputManager
+ # ------------------------------------------------------------------------------------
+ private
+ # ------------------------------------------------------------------------------------
+ #
+ # Confirm that the output directory parameter is reasonable.
+ #
+ def sanity_checks_on_parameters()
+ if @output_directory == nil
+ raise("Properties file must contain a value for 'output_directory'")
+ end
+
+ if !File.exist?(@output_directory)
+ raise "Output directory '#{@output_directory}' does not exist."
+ end
+
+ if !File.readable?(@output_directory)
+ raise "Output directory '#{@output_directory}' is not readable."
+ end
+
+ if !File.directory?(@output_directory)
+ raise "Output directory '#{@output_directory}' is not a directory."
+ end
+
+ if !File.writable?(@output_directory)
+ raise "Output directory '#{@output_directory}' is not writable."
+ end
+ end
+
+ # ------------------------------------------------------------------------------------
+ public
+
+ # ------------------------------------------------------------------------------------
+ # Set up and get ready to process.
+ #
+ def initialize(properties)
+ @output_directory = properties['output_directory']
+
+ sanity_checks_on_parameters()
+
+ @log_file = File.expand_path("log_file.txt", @output_directory)
+ @output_summary_file = File.expand_path("summary.html", @output_directory)
+ end
+
+ # Write a message to the log file
+ #
+ def log(level, message)
+ File.open(@log_file, File::CREAT | File::APPEND | File::WRONLY) do |f|
+ f.print("#{level} #{message}\n")
+ end
+ end
+
+ def output_filename(suite_name)
+ File.expand_path("#{suite_name}_output.html", @output_directory)
+ end
+
+ def summarize()
+ end
+end
\ No newline at end of file
diff --git a/utilities/acceptance-tests/script/run_acceptance_tests.rb b/utilities/acceptance-tests/script/run_acceptance_tests.rb
index 5be89b1d..9a3cfa96 100644
--- a/utilities/acceptance-tests/script/run_acceptance_tests.rb
+++ b/utilities/acceptance-tests/script/run_acceptance_tests.rb
@@ -38,8 +38,10 @@ What are we doing?
--------------------------------------------------------------------------------
=end
require 'open-uri'
+require 'date'
require File.expand_path('database_cleanser', File.dirname(File.expand_path(__FILE__)))
require File.expand_path('property_file_reader', File.dirname(File.expand_path(__FILE__)))
+require File.expand_path('output_manager', File.dirname(File.expand_path(__FILE__)))
=begin
Test suite results
@@ -79,7 +81,6 @@ class AcceptanceRunner
def sanity_checks_on_parameters()
raise("Properties file must contain a value for 'website_url'") if @website_url == nil
raise("Properties file must contain a value for 'test_root_directory'") if @test_root_directory == nil
- raise("Properties file must contain a value for 'output_directory'") if @output_directory == nil
raise("Properties file must contain a value for 'user_extensions_path'") if @user_extensions_path == nil
raise("Properties file must contain a value for 'firefox_profile_template_path'") if @firefox_profile_template_path == nil
raise("Properties file must contain a value for 'suite_timeout_limit'") if @suite_timeout_limit == nil
@@ -90,11 +91,6 @@ class AcceptanceRunner
raise "Test root directory '#{@test_root_directory}' has no sub-directories."
end
- confirm_is_readable_directory(@output_directory, "Output directory")
- if !File.writable?(@output_directory)
- raise "Output directory '#{@output_directory}' is not writable."
- end
-
if File.basename(@user_extensions_path) != "user-extensions.js"
raise "User extensions file must be named 'user-extensions.js', not '#{File.basename(@user_extensions_path)}'"
end
@@ -155,26 +151,30 @@ class AcceptanceRunner
# the test suite.
#
def run_all_suites()
+ time_stamp("Start time")
get_sub_directories(@test_root_directory).each do |suite_path|
suite_file_path = File.expand_path("Suite.html", suite_path)
if File.exist?(suite_file_path)
- cleanse_data_model()
+ # BOGUS - disable the tests.
+ # cleanse_data_model()
+ # BOGUS - disable the tests.
run_test_suite(suite_file_path)
+ else
+ log_warn("No suite file found in #{suite_path}")
end
end
+ time_stamp("End time")
end
# Before each suite, call the cleanser.
def cleanse_data_model()
- # puts "BOGUS cleanse_data_model()"
@database_cleanser.cleanse()
end
def run_test_suite(suite_file_path)
- puts "BOGUS run_test_suite(#{suite_file_path})"
-
suite_name = File.basename(File.dirname(suite_file_path))
- output_file = File.expand_path("#{suite_name}_output.html", @output_directory)
+ log_info("Running suite #{suite_name}")
+ output_file = @output_manager.output_filename(suite_name)
args = []
args << "-jar" << @selenium_jar_path
@@ -184,26 +184,31 @@ class AcceptanceRunner
args << "-firefoxProfileTemplate" << @firefox_profile_template_path
args << "-htmlSuite" << "*firefox" << @website_url << suite_file_path << output_file
- result = system("java", *args)
- raise("Can't find the 'java' command!") if result == nil
- if !result
- puts ">>>> result: #{result}"
- puts ">>>> $?: #{$?}"
- log_error("Can't run the suite at '#{suite_file_path}: command was 'java' #{args}") if !result
- elsif $?.exitstatus != 0
- log_error("Suite failed at '#{suite_file_path}: return code was #{$?.exitstatus}, command was 'java' #{args}")
- end
+ # result = system("java", *args)
+ # raise("Can't find the 'java' command!") if result == nil
+ # if $?.exitstatus != 0
+ # log_error("Suite failed at '#{suite_file_path}: return code was #{$?.exitstatus}, command was 'java' #{args}")
+ # end
end
- def create_summary_html()
- puts "BOGUS create_summary_html()"
+ def time_stamp(label)
+ log_info("#{label}: #{DateTime.now.strftime('%Y/%m/%d %H:%M:%S')}")
+ end
+
+ def log_info(message)
+ @output_manager.log("INFO ", message)
+ end
+
+ def log_warn(message)
+ @output_manager.log("WARN ", message)
end
def log_error(message)
- File.open(@log_file, File::CREAT | File::APPEND | File::WRONLY) do |f|
- f.print(message + "\n")
- end
- puts "LOG LOG: '#{message}'"
+ @output_manager.log("ERROR", message)
+ end
+
+ def create_summary_html()
+ @output_manager.summarize()
end
# ------------------------------------------------------------------------------------
@@ -215,7 +220,6 @@ class AcceptanceRunner
def initialize(properties)
@website_url = properties['website_url']
@test_root_directory = properties['test_root_directory']
- @output_directory = properties['output_directory']
@user_extensions_path = properties['user_extensions_path']
@firefox_profile_template_path = properties['firefox_profile_template_path']
@suite_timeout_limit = properties['suite_timeout_limit'].to_i
@@ -224,8 +228,7 @@ class AcceptanceRunner
sanity_checks_on_parameters()
@database_cleanser = DatabaseCleanser.new(properties)
-
- @log_file = File.expand_path("log_file.txt", @output_directory)
+ @output_manager = OutputManager.new(properties)
end