public void testLoadFile() { try { String datadir = System.getProperty("planworks.test.data.dir") .concat(System.getProperty("file.separator")) .concat("loadTest") .concat(System.getProperty("file.separator")); checkConstraintLoad(datadir); checkConstraintVarMapLoad(datadir); checkObjectLoad(datadir); checkPartialPlanLoad(datadir); checkProjectLoad(datadir); checkSequenceLoad(datadir); checkTokenLoad(datadir); checkVariableLoad(datadir); // checkTransactionLoad(datadir); checkPartialPlanStatsLoad(datadir); checkResourceInstantsLoad(datadir); checkRulesLoad(datadir); checkRuleInstanceLoad(datadir); checkDecisionLoad(datadir); // catch assert errors and Exceptions here, since JUnit seems to not do it } catch (AssertionFailedError err) { err.printStackTrace(); System.exit(-1); } catch (Exception excp) { excp.printStackTrace(); System.exit(-1); } }
public void testFailure() { selenium.setContext( "A real negative test, using the real Selenium on the browser side served by Jetty, driven from Java", SeleniumLogLevels.DEBUG); selenium.open("/selenium-server/tests/html/test_click_page1.html"); String badElementName = "This element doesn't exist, so Selenium should throw an exception"; try { selenium.getText(badElementName); fail("No exception was thrown!"); } catch (SeleniumException se) { assertTrue( "Exception message isn't as expected: " + se.getMessage(), se.getMessage().indexOf(badElementName + " not found") != -1); } try { assertTrue( "Negative test", selenium.isTextPresent("Negative test: verify non-existent text")); fail("No exception was thrown!"); } catch (AssertionFailedError se) { assertTrue( "Exception message isn't as expected: " + se.getMessage(), se.getMessage().indexOf("Negative test") != -1); } }
/** Sleeps until the given time has elapsed. Throws AssertionFailedError if interrupted. */ void sleep(long millis) { try { delay(millis); } catch (InterruptedException ie) { AssertionFailedError afe = new AssertionFailedError("Unexpected InterruptedException"); afe.initCause(ie); throw afe; } }
/** * Records the given exception using {@link #threadRecordFailure}, then rethrows the exception, * wrapping it in an AssertionFailedError if necessary. */ public void threadUnexpectedException(Throwable t) { threadRecordFailure(t); t.printStackTrace(); if (t instanceof RuntimeException) throw (RuntimeException) t; else if (t instanceof Error) throw (Error) t; else { AssertionFailedError afe = new AssertionFailedError("unexpected exception: " + t); afe.initCause(t); throw afe; } }
public int await() { try { return super.await(2 * LONG_DELAY_MS, MILLISECONDS); } catch (TimeoutException e) { throw new AssertionFailedError("timed out"); } catch (Exception e) { AssertionFailedError afe = new AssertionFailedError("Unexpected exception: " + e); afe.initCause(e); throw afe; } }
/** * Extra checks that get done for all test cases. * * <p>Triggers test case failure if any thread assertions have failed, by rethrowing, in the test * harness thread, any exception recorded earlier by threadRecordFailure. * * <p>Triggers test case failure if interrupt status is set in the main thread. */ public void tearDown() throws Exception { Throwable t = threadFailure.getAndSet(null); if (t != null) { if (t instanceof Error) throw (Error) t; else if (t instanceof RuntimeException) throw (RuntimeException) t; else if (t instanceof Exception) throw (Exception) t; else { AssertionFailedError afe = new AssertionFailedError(t.toString()); afe.initCause(t); throw afe; } } if (Thread.interrupted()) throw new AssertionFailedError("interrupt status set in main thread"); }
public void addFailure(Test test, AssertionFailedError t) { StringBuffer sb = new StringBuffer(); sb.append(test.toString()); sb.append("\n"); StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw, true)); sb.append(sw.toString()); Log.getLogWriter().severe("zzzzzFAILURE IN " + test, t); // reportFailure(test, sb.toString()); lastFailClass = getClassName(test); lastFailMethod = getMethodName(test); lastThrowable = t; }