throw new MojoExecutionException("Cannot resolve host " + jooUnitSeleniumRCHost +
". Please specify a host running the selenium remote control or skip tests" +
" by -DskipTests", e);
}
getLog().info("JooTest report directory: " + testResultOutputDirectory.getAbsolutePath());
Selenium selenium = new DefaultSelenium(jooUnitSeleniumRCHost, jooUnitSeleniumRCPort, jooUnitSeleniumBrowserStartCommand, testsHtmlUrl);
try {
selenium.start();
getLog().debug("Opening " + testsHtmlUrl);
selenium.open(testsHtmlUrl);
getLog().debug("Waiting for test results for " + jooUnitTestExecutionTimeout + "ms ...");
selenium.waitForCondition("selenium.browserbot.getCurrentWindow().result != null || selenium.browserbot.getCurrentWindow().classLoadingError != null", "" + jooUnitTestExecutionTimeout);
String classLoadingError = selenium.getEval("selenium.browserbot.getCurrentWindow().classLoadingError");
if (classLoadingError != null && !classLoadingError.equals("null")) {
throw new MojoExecutionException(classLoadingError);
}
String testResultXml = selenium.getEval("selenium.browserbot.getCurrentWindow().result");
writeResultToFile(testResultXml);
evalTestOutput(new StringReader(testResultXml));
} catch (IOException e) {
throw new MojoExecutionException("Cannot write test results to file", e);
} catch (ParserConfigurationException e) {
throw new MojoExecutionException("Cannot create a simple XML Builder", e);
} catch (SAXException e) {
throw new MojoExecutionException("Cannot parse test result", e);
} catch (SeleniumException e) {
throw new MojoExecutionException("Selenium setup exception", e);
} finally {
selenium.stop();
}
}