use of org.junit.runner.notification.Failure in project sling by apache.
the class TeleporterHttpClient method runTests.
void runTests(String testSelectionPath, int testReadyTimeoutSeconds) throws MalformedURLException, IOException, MultipleFailureException {
final String testUrl = baseUrl + "/" + testServletPath + testSelectionPath + ".junit_result";
// Wait for non-404 response that signals that test bundle is ready
final long timeout = System.currentTimeMillis() + (testReadyTimeoutSeconds * 1000L);
final ExponentialBackoffDelay delay = new ExponentialBackoffDelay(25, 1000);
while (true) {
if (getHttpGetStatus(testUrl).getStatus() == 200) {
break;
}
if (System.currentTimeMillis() > timeout) {
fail("Timeout waiting for test at " + testUrl + " (" + testReadyTimeoutSeconds + " seconds)");
break;
}
delay.waitNextDelay();
}
final HttpURLConnection c = (HttpURLConnection) new URL(testUrl).openConnection();
try {
setConnectionCredentials(c);
c.setRequestMethod("POST");
c.setUseCaches(false);
c.setDoOutput(true);
c.setDoInput(true);
c.setInstanceFollowRedirects(false);
final int status = c.getResponseCode();
if (status != 200) {
throw new IOException("Got status code " + status + " for " + testUrl);
}
final Result result = (Result) new ObjectInputStream(c.getInputStream()).readObject();
if (result.getFailureCount() > 0) {
final List<Throwable> failures = new ArrayList<Throwable>(result.getFailureCount());
for (Failure f : result.getFailures()) {
failures.add(f.getException());
}
throw new MultipleFailureException(failures);
}
} catch (ClassNotFoundException e) {
throw new IOException("Exception reading test results:" + e, e);
} finally {
cleanup(c);
}
}
use of org.junit.runner.notification.Failure in project sling by apache.
the class PerformanceRunnerTest method assertTestFails.
private void assertTestFails(Class<?> testClass, String message) {
Result result = runTest(testClass);
boolean isInitializationError = false;
for (Failure failure : result.getFailures()) {
isInitializationError = isInitializationError || failure.getException().getMessage().equals(message);
}
Assert.assertEquals(true, isInitializationError);
}
use of org.junit.runner.notification.Failure in project bayou by capergroup.
the class FloodGage method run.
/**
* Parses "trials.xml" as found as a resource on the current class path and executes the trials against
* the given Synthesizer reporting progress to the given View.
*
* Expects a trialpack to be on the current classpath.
*
* @param synthesizer the Synthesizer to use for creating programs from draft programs identified in trials.
* @param view the UI component for reporting execution progress.
* @throws IOException if there is a program reading resources (like "trails.xml") on the classpath.
* @throws ParseException if "trials.xml" is not of the expected format
* @throws ClassCastException if "PassProgram" or "PassProgramTest" cannot be loaded from teh current classpath.
*/
void run(Synthesizer synthesizer, View view) throws IOException, ParseException, ClassNotFoundException {
if (synthesizer == null)
throw new NullPointerException("synthesizer");
if (view == null)
throw new NullPointerException("view");
/*
* Parse trials.xml from inside the trialpack (assumed to be on classpath) into a Directive structure.
*/
Directive directive;
{
// We expect the trialpack jar file to be on the classpath. That jar file should have a
// trails.xml file its root directory. So look for it at just "trails.xml" path.
String trailsXml = new String(getResource("trials.xml"), StandardCharsets.UTF_8);
directive = DirectiveXmlV1Parser.makeDefault().parse(trailsXml);
}
/*
* Test the test suite by asserting that all test cases pass when given the pass program.
*
* Stop the program if this is not the case.
*/
// expect PassProgram class inside the trailpack which is assumed to be on the class path
Class passProgram = getClass().getClassLoader().loadClass("PassProgram");
// expect PassProgramTest class inside the trailpack which is assumed to be on the class path
Class passProgramTestSuite = getClass().getClassLoader().loadClass("PassProgramTest");
view.declareTestingTestSuite(passProgramTestSuite, passProgram);
// run the test cases against PassProgram
Result result = new JUnitCore().run(passProgramTestSuite);
view.declareNumberOfTestCasesInSuite(result.getRunCount());
if (// if the pass program did not pass the test suite
result.getFailureCount() > 0) {
for (Failure f : result.getFailures()) view.declarePassProgramTestFailure(f.getTrace());
} else // pass program did pass the test suite, proceed to running the user specified trials
{
List<Trial> trials = makeTrials(directive, DraftBuilderBayou1_1_0::new);
TrialsRunner.runTrails(trials, synthesizer, view);
}
}
use of org.junit.runner.notification.Failure in project codeu_project_2017 by PabloG6.
the class TestRunner method main.
public static void main(String[] args) {
final Result result = JUnitCore.runClasses(codeu.chat.common.SecretTest.class, codeu.chat.relay.ServerTest.class, codeu.chat.server.BasicControllerTest.class, codeu.chat.server.RawControllerTest.class, codeu.chat.util.TimeTest.class, codeu.chat.util.UuidTest.class, codeu.chat.util.store.StoreTest.class);
for (final Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
}
use of org.junit.runner.notification.Failure in project vcell by virtualcell.
the class MathVisitor method main.
public static void main(String[] args) {
Request req = Request.method(MathVisitor.class, "batchScan");
JUnitCore core = new JUnitCore();
Result res = core.run(req);
for (Failure f : res.getFailures()) {
System.err.println("Failure: " + f.toString());
}
System.exit(0);
}
Aggregations