All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Search JAR files by class name

Source code of the class part of junit version 4.12

Go to download Show more of this group Show artifacts with the name junit
package org.junit.internal.matchers;

import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

 * A matcher that applies a delegate matcher to the cause of the current Throwable, returning the result of that
 * match.
 * @param  the type of the throwable being matched
public class ThrowableCauseMatcher extends
        TypeSafeMatcher {

    private final Matcher causeMatcher;

    public ThrowableCauseMatcher(Matcher causeMatcher) {
        this.causeMatcher = causeMatcher;

    public void describeTo(Description description) {
        description.appendText("exception with cause ");

    protected boolean matchesSafely(T item) {
        return causeMatcher.matches(item.getCause());

    protected void describeMismatchSafely(T item, Description description) {
        description.appendText("cause ");
        causeMatcher.describeMismatch(item.getCause(), description);

     * Returns a matcher that verifies that the outer exception has a cause for which the supplied matcher
     * evaluates to true.
     * @param matcher to apply to the cause of the outer exception
     * @param  type of the outer exception
    public static  Matcher hasCause(final Matcher matcher) {
        return new ThrowableCauseMatcher(matcher);

© 2018 Weber Informatics LLC