Refine search
static void fail(Throwable cause, Object message) { AssertionFailedError assertionFailedError = new AssertionFailedError(String.valueOf(message)); assertionFailedError.initCause(cause); throw assertionFailedError; }
/** * Returns "..." in place of common prefix and "..." in * place of common suffix between expected and actual. * * @see Throwable#getMessage() */ @Override public String getMessage() { return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage()); }
@Override public String toString() { throw new AssertionFailedError(); } };
public TerminalTestCase assertLinesAre(String... lines) { assertEquals(lines.length, mTerminal.getScreen().mScreenRows); for (int i = 0; i < lines.length; i++) try { assertLineIs(i, lines[i]); } catch (AssertionFailedError e) { throw new AssertionFailedError("Line: " + i + " - " + e.getMessage()); } return this; }
protected void validate(URI ivorn, Node resource) throws ServletException { Element resElem; NodeList nl; if(resource.getNodeType() == org.w3c.dom.Node.DOCUMENT_NODE) { System.out.println("doc from validate in RegistrarServlet = " + DomHelper.DocumentToString((Document)resource) ); resElem = ((Document)resource).getDocumentElement(); }else if(resource.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) { System.out.println("element from validate in RegistrarServlet = " + DomHelper.ElementToString((Element)resource) ); resElem = (Element)resource; }else { throw new ServletException("Cound not validate document, the registration is not a type understood to validate."); } try { System.out.println("validating local name = " + resElem.getLocalName()); RegistryValidator.isValid(resElem,resElem.getLocalName()); }catch(AssertionFailedError afe) { afe.printStackTrace(); log.error("Error invalid document = " + afe.getMessage()); throw new ServletException("Invalid update, document not valid " + afe.getMessage()); }//catch }
@Override public void addFailure(Test test, AssertionFailedError arg1) { System.out.println("** Failure: "+test); if ( arg1 != null ) { if ( arg1.getMessage() != null ) System.out.println(" "+arg1.getMessage()) ; StackTraceElement st = arg1.getStackTrace()[0] ; System.out.println(st) ; } }
/** prints stack trace of assertion error and nested exception * @param err PrintWriter where to print stack trace */ public void printStackTrace(PrintWriter err) { synchronized (err) { super.printStackTrace(err); err.println("\nNested Exception is:"); nestedException.printStackTrace(err); } }
@Override public Iterator<Integer> iterator() { throw new AssertionFailedError("Don't iterate me!"); } };
afe.printStackTrace(); validateSingleResources = true; log.warn("Error invalid document = " + afe.getMessage()); log.warn("though validation error occurred, Resource Elements will be revalidated individually to better see the error."); returnString += "Invalid Resource that did not get updated - ivo://" + RegistryDOMHelper.getAuthorityID( ((Element)nl.item(loopi)) ) + "/" + RegistryDOMHelper.getResourceKey( ((Element)nl.item(loopi)) ) + " \r\n Error:" + afe.getMessage() + "\r\n";
/** prints stack trace of assertion error and nested exception * @param err PrintStream where to print stack trace */ public void printStackTrace(PrintStream err) { synchronized (err) { super.printStackTrace(err); err.println("\nNested Exception is:"); nestedException.printStackTrace(err); } } }
private static AssertionFailedError sanityError( Class<?> cls, List<String> explicitTestNames, String description, Throwable e) { String message = String.format( Locale.ROOT, "Error in automated %s of %s\n" + "If the class is better tested explicitly, you can add %s() to %sTest", description, cls, explicitTestNames.get(0), cls.getName()); AssertionFailedError error = new AssertionFailedError(message); error.initCause(e); return error; }
@Override public boolean apply(Integer i) { throw new AssertionFailedError("This predicate should never have been evaluated"); } };
/** * Returns "..." in place of common prefix and "..." in * place of common suffix between expected and actual. * * @see Throwable#getMessage() */ @Override public String getMessage() { return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage()); }
afe.printStackTrace(); log.error("Error invalid document = " + afe.getMessage()); throw new SOAPFaultException("Server Error: " + "Invalid update, document not valid ","Server Error: " + "Invalid update, document not valid " + afe.getMessage(), adminwsdlNS, SOAPFaultException.ADMINSOAP_TYPE);
@Override public synchronized void addFailure(final Test test, final AssertionFailedError assertionFailedError) { // throw new RuntimeException(assertionFailedError.getMessage()); assertionFailedError.printStackTrace(); } };
Object getResult() { if (throwable != null) { throw (AssertionFailedError) new AssertionFailedError().initCause(throwable); } return result; }
@Override public int compareTo(DontCompareMe o) { throw new AssertionFailedError(); } }
private void assertBadUseOfReferentialEquality(Class<?> cls) throws Exception { try { tester.testEquals(cls); } catch (AssertionFailedError expected) { assertThat(expected.getMessage()).contains(cls.getSimpleName() + "("); return; } fail("should have failed for " + cls); }
@Override public synchronized void addFailure(final Test test, final AssertionFailedError assertionFailedError) { // throw new RuntimeException(assertionFailedError.getMessage()); assertionFailedError.printStackTrace(); } };
static AssertionFailedError failureWithCause(Throwable cause, String message) { AssertionFailedError failure = new AssertionFailedError(message); failure.initCause(cause); return failure; }