NIHVIVO-222 Embed the CSS file in the source, so we don't need to configure it.

This commit is contained in:
jeb228 2010-08-17 15:47:50 +00:00
parent dddc423a9e
commit 6f978160cf
7 changed files with 108 additions and 37 deletions

View file

@ -117,7 +117,10 @@ run - Run the tester.
fork="yes"
dir="${acceptance.dir}"
failonerror="true">
<classpath location="${build.dir}" />
<classpath >
<pathelement location="${build.dir}"/>
<pathelement location="${source.dir}"/>
</classpath>
<arg file="${acceptance.properties.file}" />
<arg value="${acceptance.interactive.arg}" />
</java>

View file

@ -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

View file

@ -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();

View file

@ -59,7 +59,7 @@ public class OutputManager {
*/
public Status summarizeOutput() {
LogStats log = LogStats.parse(parms.getLogFile());
List<SuiteStats> suites = new ArrayList<SuiteStats>();
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);

View file

@ -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(" <table cellspacing=\"0\">");
if ((!log.hasErrors()) && (!log.hasWarnings())) {
writer
.println(" <tr><td colspan=\"2\">No errors or warnings</td></tr>");
writer.println(" <tr><td colspan=\"2\">No errors or warnings</td></tr>");
} else {
for (String e : log.getErrors()) {
writer.println(" <tr class=\"" + errorClass

View file

@ -44,7 +44,6 @@ public class SeleniumRunnerParameters {
private final Collection<File> suiteParentDirectories;
private final ModelCleanerProperties modelCleanerProperties;
private final IgnoredTests ignoredTests;
private final File summaryCssFile;
private Collection<File> 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<File> getSuiteParentDirectories() {
return suiteParentDirectories;
}

View file

@ -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;
}