diff --git a/utilities/testrunner/build.xml b/utilities/testrunner/build.xml index 4060cbbd8..e6f5f87c9 100644 --- a/utilities/testrunner/build.xml +++ b/utilities/testrunner/build.xml @@ -117,7 +117,10 @@ run - Run the tester. fork="yes" dir="${acceptance.dir}" failonerror="true"> - + + + + diff --git a/utilities/testrunner/example.acceptance_tests.properties b/utilities/testrunner/example.acceptance_tests.properties index d4fd569e8..3118a4105 100644 --- a/utilities/testrunner/example.acceptance_tests.properties +++ b/utilities/testrunner/example.acceptance_tests.properties @@ -34,4 +34,3 @@ upload_directory = /Vivoweb_Stuff/test_deploy/uploads # These properties control the output formatting of the tests. # ignored_tests_file = /eclipseVitroWorkspace/vivo/utilities/acceptance-tests/suites/ignored_tests.txt -summary_css_file = /eclipseVitroWorkspace/vivo/utilities/acceptance-tests/script/output_summary.css \ No newline at end of file diff --git a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/FileHelper.java b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/FileHelper.java index 029a3788b..38b4deba6 100644 --- a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/FileHelper.java +++ b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/FileHelper.java @@ -97,17 +97,11 @@ public class FileHelper { */ public static void copy(File source, File target) throws IOException { InputStream input = null; - OutputStream output = null; try { input = new FileInputStream(source); - output = new FileOutputStream(target); - int howMany; - byte[] buffer = new byte[4096]; - while (-1 != (howMany = input.read(buffer))) { - output.write(buffer, 0, howMany); - } - }finally { + copy(input, target); + } finally { if (input != null) { try { input.close(); @@ -115,6 +109,24 @@ public class FileHelper { e1.printStackTrace(); } } + } + } + + /** + * Copy the contents of an InputStream to a file. If the target file already + * exists, it will be over-written. Doesn't close the input stream. + */ + public static void copy(InputStream input, File target) throws IOException { + OutputStream output = null; + + try { + output = new FileOutputStream(target); + int howMany; + byte[] buffer = new byte[4096]; + while (-1 != (howMany = input.read(buffer))) { + output.write(buffer, 0, howMany); + } + } finally { if (output != null) { try { output.close(); diff --git a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputManager.java b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputManager.java index 3c4febcad..b94b700e3 100644 --- a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputManager.java +++ b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputManager.java @@ -59,7 +59,7 @@ public class OutputManager { */ public Status summarizeOutput() { LogStats log = LogStats.parse(parms.getLogFile()); - + List suites = new ArrayList(); for (File outputFile : parms.getOutputDirectory().listFiles( new HtmlFileFilter())) { @@ -68,7 +68,7 @@ public class OutputManager { suites.add(suite); } } - + OutputSummaryFormatter formatter = new OutputSummaryFormatter(parms); formatter.format(log, suites); return formatter.figureOverallStatus(log, suites); diff --git a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputSummaryFormatter.java b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputSummaryFormatter.java index f73f1b0aa..62f76b6df 100644 --- a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputSummaryFormatter.java +++ b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/OutputSummaryFormatter.java @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.utilities.testrunner; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.io.PrintWriter; import java.io.Reader; import java.text.SimpleDateFormat; @@ -76,13 +77,20 @@ public class OutputSummaryFormatter { * Copy the CSS file into the output directory. */ private void copyCssFile() { - File cssSource = parms.getSummaryCssFile(); - File cssTarget = new File(parms.getOutputDirectory(), + InputStream cssStream = this.getClass().getResourceAsStream( SUMMARY_CSS_FILENAME); - try { - FileHelper.copy(cssSource, cssTarget); - } catch (IOException e) { - e.printStackTrace(); + if (cssStream == null) { + System.out.println("Couldn't find the CSS file: '" + + SUMMARY_CSS_FILENAME + "'"); + } else { + File cssTarget = new File(parms.getOutputDirectory(), + SUMMARY_CSS_FILENAME); + try { + FileHelper.copy(cssStream, cssTarget); + cssStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } } } @@ -200,8 +208,7 @@ public class OutputSummaryFormatter { writer.println(" "); if ((!log.hasErrors()) && (!log.hasWarnings())) { - writer - .println(" "); + writer.println(" "); } else { for (String e : log.getErrors()) { writer.println(" suiteParentDirectories; private final ModelCleanerProperties modelCleanerProperties; private final IgnoredTests ignoredTests; - private final File summaryCssFile; private Collection selectedSuites = Collections.emptySet(); private boolean cleanModel = true; @@ -70,8 +69,6 @@ public class SeleniumRunnerParameters { this.uploadDirectory = checkReadWriteDirectory(props, PROP_UPLOAD_DIRECTORY); - this.summaryCssFile = checkSummaryCssFile(props); - this.outputDirectory = checkOutputDirectory(props); this.logFile = new File(this.outputDirectory, LOGFILE_NAME); this.listener = new Listener(this.logFile); @@ -116,16 +113,6 @@ public class SeleniumRunnerParameters { } } - /** - * The CSS file must be specified, must exist, and must be readable. - */ - private File checkSummaryCssFile(Properties props) { - String summaryCssPath = getRequiredProperty(props, PROP_SUMMARY_CSS); - File cssFile = new File(summaryCssPath); - FileHelper.checkReadableFile(cssFile, "File '" + summaryCssPath + "'"); - return cssFile; - } - /** * If there is a parameter for this key, it should point to a readable * directory. @@ -361,10 +348,6 @@ public class SeleniumRunnerParameters { return logFile; } - public File getSummaryCssFile() { - return summaryCssFile; - } - public Collection getSuiteParentDirectories() { return suiteParentDirectories; } diff --git a/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/summary.css b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/summary.css new file mode 100644 index 000000000..b313edc42 --- /dev/null +++ b/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/summary.css @@ -0,0 +1,67 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +/* + Formats for the output summary from the acceptance tests. +*/ +body { + background: rgb(95%, 95%, 95%); + font-family: sans-serif; +} + +.heading { + border: groove; + background: white; + padding: 10px 20px 8px 20px; + margin-top: 50px; + font-size: large; +} + +table { + border: thin double gray; + background: white; +} + +td,th { + padding: 4px 12px 2px 12px; +} + +th { + border-bottom: 1px solid black; +} + +table.summary { + border: none; + background: inherit; +} + +table.summary td { + padding-right: 30; + border: none; + vertical-align: top; +} + +.section { + background: rgb(70%, 85%, 85%); + font-size: larger; + margin: 50px 0px 15px 0px; + padding: 4px 12px 2px 12px; +} + +.good { + background: rgb(60%, 100%, 60%); +} + +.bad { + background: rgb(100%, 60%, 60%); +} + +.fair { + background: rgb(100%, 100%, 60%); +} + +.one-word { + width: 20%; + text-align: center; + margin: 15px 0px 0px 0px; + border: 1px solid black; +} \ No newline at end of file
No errors or warnings
No errors or warnings