Search in sources :

Example 6 with AssertionFailedError

use of junit.framework.AssertionFailedError in project hibernate-orm by hibernate.

the class QueryRegionImplTest method testQueryUpdate.

@Test
public void testQueryUpdate() throws Exception {
    withQueryRegion((sessionFactory, region) -> {
        ExceptionHolder holder = new ExceptionHolder();
        CyclicBarrier barrier = new CyclicBarrier(2);
        withSession(sessionFactory, session -> region.put(session, KEY, VALUE1));
        Thread updater = new Thread() {

            @Override
            public void run() {
                try {
                    withSession(sessionFactory, (session) -> {
                        assertEquals(VALUE1, region.get(session, KEY));
                        region.put(session, KEY, VALUE2);
                        assertEquals(VALUE2, region.get(session, KEY));
                        barrier.await(5, TimeUnit.SECONDS);
                        barrier.await(5, TimeUnit.SECONDS);
                        region.put(session, KEY, VALUE3);
                        assertEquals(VALUE3, region.get(session, KEY));
                        barrier.await(5, TimeUnit.SECONDS);
                        barrier.await(5, TimeUnit.SECONDS);
                    });
                } catch (AssertionFailedError e) {
                    holder.addAssertionFailure(e);
                    barrier.reset();
                } catch (Exception e) {
                    holder.addException(e);
                    barrier.reset();
                }
            }
        };
        Thread reader = new Thread() {

            @Override
            public void run() {
                try {
                    withSession(sessionFactory, (session) -> {
                        assertEquals(VALUE1, region.get(session, KEY));
                        barrier.await(5, TimeUnit.SECONDS);
                        assertEquals(VALUE1, region.get(session, KEY));
                        barrier.await(5, TimeUnit.SECONDS);
                        barrier.await(5, TimeUnit.SECONDS);
                        assertEquals(VALUE1, region.get(session, KEY));
                        barrier.await(5, TimeUnit.SECONDS);
                    });
                } catch (AssertionFailedError e) {
                    holder.addAssertionFailure(e);
                    barrier.reset();
                } catch (Exception e) {
                    holder.addException(e);
                    barrier.reset();
                }
            }
        };
        updater.start();
        reader.start();
        updater.join();
        reader.join();
        holder.checkExceptions();
        assertEquals(VALUE3, callWithSession(sessionFactory, session -> region.get(session, KEY)));
    });
}
Also used : InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) QueryResultsRegionImpl(org.hibernate.cache.infinispan.query.QueryResultsRegionImpl) Logger(org.jboss.logging.Logger) CacheEntryModifiedEvent(org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent) CacheEntryVisitedEvent(org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent) Session(org.hibernate.Session) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) QueryResultsRegion(org.hibernate.cache.spi.QueryResultsRegion) ArrayList(java.util.ArrayList) Transaction(org.hibernate.Transaction) TestForIssue(org.hibernate.testing.TestForIssue) CacheEntryVisited(org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited) AdvancedCache(org.infinispan.AdvancedCache) CacheEntryModified(org.infinispan.notifications.cachelistener.annotation.CacheEntryModified) CyclicBarrier(java.util.concurrent.CyclicBarrier) Properties(java.util.Properties) Listener(org.infinispan.notifications.Listener) SessionFactory(org.hibernate.SessionFactory) CacheTestUtil(org.hibernate.test.cache.infinispan.util.CacheTestUtil) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AssertionFailedError(junit.framework.AssertionFailedError) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) StandardQueryCache(org.hibernate.cache.internal.StandardQueryCache) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) CacheDataDescription(org.hibernate.cache.spi.CacheDataDescription) IsolationLevel(org.infinispan.util.concurrent.IsolationLevel) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Region(org.hibernate.cache.spi.Region) AbstractGeneralDataRegionTest(org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTest) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) AssertionFailedError(junit.framework.AssertionFailedError) CyclicBarrier(java.util.concurrent.CyclicBarrier) Test(org.junit.Test) AbstractGeneralDataRegionTest(org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTest)

Example 7 with AssertionFailedError

use of junit.framework.AssertionFailedError in project junit4 by junit-team.

the class OldTestClassAdaptingListenerTest method addFailureDelegatesToNotifier.

@Test
public void addFailureDelegatesToNotifier() {
    Result result = new Result();
    RunListener listener = result.createListener();
    RunNotifier notifier = new RunNotifier();
    notifier.addFirstListener(listener);
    TestCase testCase = new TestCase() {
    };
    TestListener adaptingListener = new JUnit38ClassRunner(testCase).createAdaptingListener(notifier);
    adaptingListener.addFailure(testCase, new AssertionFailedError());
    assertEquals(1, result.getFailureCount());
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) TestCase(junit.framework.TestCase) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) TestListener(junit.framework.TestListener) AssertionFailedError(junit.framework.AssertionFailedError) Result(org.junit.runner.Result) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 8 with AssertionFailedError

use of junit.framework.AssertionFailedError in project junit4 by junit-team.

the class AssertionFailedErrorTest method testCreateErrorWithoutMessage.

public void testCreateErrorWithoutMessage() throws Exception {
    AssertionFailedError error = new AssertionFailedError();
    assertNull(error.getMessage());
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Example 9 with AssertionFailedError

use of junit.framework.AssertionFailedError in project junit4 by junit-team.

the class AssertionFailedErrorTest method testCreateErrorWithoutMessageInsteadOfNull.

public void testCreateErrorWithoutMessageInsteadOfNull() throws Exception {
    AssertionFailedError error = new AssertionFailedError(null);
    assertEquals("", error.getMessage());
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError)

Example 10 with AssertionFailedError

use of junit.framework.AssertionFailedError in project junit4 by junit-team.

the class AssertionFailedErrorTest method testCreateErrorWithMessage.

public void testCreateErrorWithMessage() throws Exception {
    AssertionFailedError error = new AssertionFailedError(ARBITRARY_MESSAGE);
    assertEquals(ARBITRARY_MESSAGE, error.getMessage());
}
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