Search in sources :

Example 36 with AssertionFailedError

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());
}
Also used : AbstractMapTester(com.google.common.collect.testing.AbstractMapTester) ZERO(com.google.common.collect.testing.features.CollectionSize.ZERO) ALLOWS_NULL_VALUES(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES) GwtIncompatible(com.google.common.annotations.GwtIncompatible) AssertionFailedError(junit.framework.AssertionFailedError) ALLOWS_NULL_KEYS(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS) CollectionSize(com.google.common.collect.testing.features.CollectionSize) GwtCompatible(com.google.common.annotations.GwtCompatible) Helpers(com.google.common.collect.testing.Helpers) Map(java.util.Map) SUPPORTS_PUT(com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT) SUPPORTS_REMOVE(com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE) MapFeature(com.google.common.collect.testing.features.MapFeature) Method(java.lang.reflect.Method) AssertionFailedError(junit.framework.AssertionFailedError)

Example 37 with AssertionFailedError

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()));
}
Also used : AbstractMapTester(com.google.common.collect.testing.AbstractMapTester) ZERO(com.google.common.collect.testing.features.CollectionSize.ZERO) ALLOWS_NULL_VALUES(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUES) GwtIncompatible(com.google.common.annotations.GwtIncompatible) AssertionFailedError(junit.framework.AssertionFailedError) ALLOWS_NULL_KEYS(com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEYS) CollectionSize(com.google.common.collect.testing.features.CollectionSize) GwtCompatible(com.google.common.annotations.GwtCompatible) Helpers(com.google.common.collect.testing.Helpers) Map(java.util.Map) SUPPORTS_PUT(com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT) SUPPORTS_REMOVE(com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE) MapFeature(com.google.common.collect.testing.features.MapFeature) Method(java.lang.reflect.Method) AssertionFailedError(junit.framework.AssertionFailedError)

Example 38 with AssertionFailedError

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;
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Example 39 with AssertionFailedError

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;
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Example 40 with AssertionFailedError

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();
    }
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)787 TestFailureException (org.apache.openejb.test.TestFailureException)503 JMSException (javax.jms.JMSException)336 EJBException (javax.ejb.EJBException)334 RemoteException (java.rmi.RemoteException)268 InitialContext (javax.naming.InitialContext)168 RemoveException (javax.ejb.RemoveException)80 CreateException (javax.ejb.CreateException)77 NamingException (javax.naming.NamingException)65 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)42 Test (org.junit.Test)42 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 CountDownLatch (java.util.concurrent.CountDownLatch)28 EntityManager (javax.persistence.EntityManager)21 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 IOException (java.io.IOException)16 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15