Java Code Examples for org.junit.ComparisonFailure#setStackTrace()
The following examples show how to use
org.junit.ComparisonFailure#setStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewAssertions.java From litho with Apache License 2.0 | 6 votes |
public void matches(ViewMatchNode root) { final MatchNode.DebugTraceContext debugTraceContext = new MatchNode.DebugTraceContext(); try { root.assertMatches(mView, debugTraceContext); } catch (AssertionError e) { String viewHierarchy = getHierarchyAsString(mView); String matchNodeList = getDebugMatchNodeString(debugTraceContext); String context = "View hierarchy: " + viewHierarchy + "\nMatchNode hierarchy:\n" + matchNodeList; if (e instanceof ComparisonFailure) { ComparisonFailure withContext = new ComparisonFailure( "\n" + context + "\n" + e.getMessage(), ((ComparisonFailure) e).getExpected(), ((ComparisonFailure) e).getActual()); withContext.setStackTrace(e.getStackTrace()); throw withContext; } else { System.err.println("ViewAssertion Context:\n" + context); throw e; } } }
Example 2
Source File: FormatterSmokeSuite.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void processFile(String data) throws Exception { byte[] hash = ((MessageDigest) messageDigest.clone()).digest(data.getBytes("UTF-8")); if (seen.add(new BigInteger(hash))) { XtextResourceSet resourceSet = resourceSetProvider.get(); resourceSet.setClasspathURIContext(classLoader); XtendFile file = parseHelper.parse(data, resourceSet); if (file != null) { try { XtextResource resource = (XtextResource) file.eResource(); ITextRegionAccess regions = regionBuilder.get().forNodeModel(resource).create(); FormatterRequest request = new FormatterRequest().setTextRegionAccess(regions); request.setExceptionHandler(ExceptionAcceptor.IGNORING); formatter.format(request); } catch (Exception e) { e.printStackTrace(); ComparisonFailure error = new ComparisonFailure(e.getMessage(), data, ""); error.setStackTrace(e.getStackTrace()); throw error; } } } }
Example 3
Source File: Oven.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void fireproof(String input) throws Exception { try { EObject file = parseHelper.parse(input); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(file); Assert.assertNotNull(resolvedTypes); if (file != null) { TreeIterator<EObject> allContents = file.eAllContents(); while (allContents.hasNext()) { EObject content = allContents.next(); if (content instanceof XAbstractFeatureCall) { assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes); XAbstractFeatureCall abstractFeatureCall = (XAbstractFeatureCall) content; if (abstractFeatureCall.getImplicitReceiver() != null) { assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitReceiver(), resolvedTypes); } if (abstractFeatureCall.getImplicitFirstArgument() != null) { assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitFirstArgument(), resolvedTypes); } } else if (content instanceof XClosure) { assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes); for (JvmFormalParameter it : ((XClosure) content).getImplicitFormalParameters()) { assertIdentifiableTypeIsResolved(it, resolvedTypes); } } else if (content instanceof XExpression) { assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes); } else if (content instanceof JvmIdentifiableElement) { assertIdentifiableTypeIsResolved(((JvmIdentifiableElement) content), resolvedTypes); } } } } catch (Throwable e) { ComparisonFailure error = new ComparisonFailure(e.getMessage(), input, ""); error.setStackTrace(e.getStackTrace()); throw error; } }
Example 4
Source File: Oven.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void fireproof(String input) throws Exception { try { EObject file = parseHelper.parse(input); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(file); Assert.assertNotNull(resolvedTypes); if (file != null) { TreeIterator<EObject> allContents = file.eAllContents(); while (allContents.hasNext()) { EObject content = allContents.next(); if (content instanceof XAbstractFeatureCall) { assertExpressionTypeIsResolved((XExpression) content, resolvedTypes); XAbstractFeatureCall abstractFeatureCall = (XAbstractFeatureCall) content; if (abstractFeatureCall.getImplicitReceiver() != null) { assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitReceiver(), resolvedTypes); } if (abstractFeatureCall.getImplicitFirstArgument() != null) { assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitFirstArgument(), resolvedTypes); } } else if (content instanceof XClosure) { assertExpressionTypeIsResolved((XExpression) content, resolvedTypes); for (JvmFormalParameter p : ((XClosure) content).getImplicitFormalParameters()) { assertIdentifiableTypeIsResolved(p, resolvedTypes); } } else if (content instanceof XExpression) { assertExpressionTypeIsResolved((XExpression) content, resolvedTypes); } else if (content instanceof JvmIdentifiableElement) { assertIdentifiableTypeIsResolved((JvmIdentifiableElement) content, resolvedTypes); } } } } catch (Throwable e) { ComparisonFailure error = new ComparisonFailure(e.getMessage(), input, ""); error.setStackTrace(e.getStackTrace()); throw error; } }
Example 5
Source File: Oven.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void fireproof(String input) throws Exception { try { EObject file = parseHelper.parse(input); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(file); Assert.assertNotNull(resolvedTypes); if (file == null) { return; } for (EObject content : IteratorExtensions.toIterable(file.eAllContents())) { if (content instanceof XAbstractFeatureCall) { assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes); XAbstractFeatureCall abstractFeatureCall = (XAbstractFeatureCall) content; if (abstractFeatureCall.getImplicitReceiver() != null) { assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitReceiver(), resolvedTypes); } if (abstractFeatureCall.getImplicitFirstArgument() != null) { assertExpressionTypeIsResolved(abstractFeatureCall.getImplicitFirstArgument(), resolvedTypes); } } else if (content instanceof XClosure) { assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes); ((XClosure) content).getImplicitFormalParameters() .forEach((JvmFormalParameter it) -> assertIdentifiableTypeIsResolved(it, resolvedTypes)); } else if (content instanceof XExpression) { assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes); } else if (content instanceof JvmIdentifiableElement) { assertIdentifiableTypeIsResolved(((JvmIdentifiableElement) content), resolvedTypes); } } } catch (Throwable e) { ComparisonFailure error = new ComparisonFailure(e.getMessage(), input, ""); error.setStackTrace(e.getStackTrace()); throw error; } }
Example 6
Source File: Oven.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public void fireproof(final String input) throws Exception { try { final EObject file = this._parseHelper.parse(input); final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file); Assert.assertNotNull(resolvedTypes); if ((file != null)) { Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(file.eAllContents()); for (final EObject content : _iterable) { boolean _matched = false; if (content instanceof XAbstractFeatureCall) { _matched=true; this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes); XExpression _implicitReceiver = ((XAbstractFeatureCall)content).getImplicitReceiver(); boolean _tripleNotEquals = (_implicitReceiver != null); if (_tripleNotEquals) { this.assertExpressionTypeIsResolved(((XAbstractFeatureCall)content).getImplicitReceiver(), resolvedTypes); } XExpression _implicitFirstArgument = ((XAbstractFeatureCall)content).getImplicitFirstArgument(); boolean _tripleNotEquals_1 = (_implicitFirstArgument != null); if (_tripleNotEquals_1) { this.assertExpressionTypeIsResolved(((XAbstractFeatureCall)content).getImplicitFirstArgument(), resolvedTypes); } } if (!_matched) { if (content instanceof XClosure) { _matched=true; this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes); final Consumer<JvmFormalParameter> _function = (JvmFormalParameter it) -> { this.assertIdentifiableTypeIsResolved(it, resolvedTypes); }; ((XClosure)content).getImplicitFormalParameters().forEach(_function); } } if (!_matched) { if (content instanceof XExpression) { _matched=true; this.assertExpressionTypeIsResolved(((XExpression)content), resolvedTypes); } } if (!_matched) { if (content instanceof JvmIdentifiableElement) { _matched=true; this.assertIdentifiableTypeIsResolved(((JvmIdentifiableElement)content), resolvedTypes); } } } } } catch (final Throwable _t) { if (_t instanceof Throwable) { final Throwable e = (Throwable)_t; String _message = e.getMessage(); final ComparisonFailure error = new ComparisonFailure(_message, input, ""); error.setStackTrace(e.getStackTrace()); throw error; } else { throw Exceptions.sneakyThrow(_t); } } }