use of junit.framework.AssertionFailedError in project guava by google.
the class MapMergeTester method testAbsent.
@MapFeature.Require(SUPPORTS_PUT)
public void testAbsent() {
assertEquals("Map.merge(absent, value, function) should return value", v3(), getMap().merge(k3(), v3(), (oldV, newV) -> {
throw new AssertionFailedError("Should not call merge function if key was absent");
}));
expectAdded(e3());
}
use of junit.framework.AssertionFailedError in project guava by google.
the class MapMergeTester method testMappedToNull.
@MapFeature.Require({ SUPPORTS_PUT, ALLOWS_NULL_VALUES })
@CollectionSize.Require(absent = ZERO)
public void testMappedToNull() {
initMapWithNullValue();
assertEquals("Map.merge(keyMappedToNull, value, function) should return value", v3(), getMap().merge(getKeyForNullValue(), v3(), (oldV, newV) -> {
throw new AssertionFailedError("Should not call merge function if key was mapped to null");
}));
expectReplacement(entry(getKeyForNullValue(), v3()));
}
use of junit.framework.AssertionFailedError in project guava by google.
the class AbstractPackageSanityTests method sanityError.
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;
}
use of junit.framework.AssertionFailedError in project guava by google.
the class AbstractFutureTest method findStackFrame.
private static int findStackFrame(ExecutionException e, String clazz, String method) {
StackTraceElement[] elements = e.getStackTrace();
for (int i = 0; i < elements.length; i++) {
StackTraceElement element = elements[i];
if (element.getClassName().equals(clazz) && element.getMethodName().equals(method)) {
return i;
}
}
AssertionFailedError failure = new AssertionFailedError("Expected element " + clazz + "." + method + " not found in stack trace");
failure.initCause(e);
throw failure;
}
use of junit.framework.AssertionFailedError in project gradle by gradle.
the class MultithreadedTestRule method testThreadFinished.
private void testThreadFinished(Thread thread, Throwable failure) {
lock.lock();
try {
active.remove(thread);
Matcher<? extends Throwable> matcher = expectedFailure.get();
if (failure != null) {
if (matcher != null && matcher.matches(failure)) {
LOGGER.debug("Finished {} with expected failure.", thread);
} else {
LOGGER.error(String.format("Failure in %s", thread), failure);
failures.add(failure);
}
} else {
if (matcher != null) {
String message = String.format("Did not get expected failure in %s", thread);
LOGGER.error(message);
failures.add(new AssertionFailedError(message));
} else {
LOGGER.debug("Finished {}", thread);
}
}
condition.signalAll();
} finally {
lock.unlock();
}
}
Aggregations