Search in sources :

Example 21 with TestFailureException

use of org.apache.openejb.test.TestFailureException in project tomee by apache.

the class ContextLookupStatefulPojoBean method lookupPersistenceContext.

public void lookupPersistenceContext() throws TestFailureException {
    try {
        try {
            final EntityManager em = (EntityManager) ejbContext.lookup("persistence/TestContext");
            Assert.assertNotNull("The EntityManager is null", em);
            // call a do nothing method to assure entity manager actually exists
            em.getFlushMode();
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) JMSException(javax.jms.JMSException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 22 with TestFailureException

use of org.apache.openejb.test.TestFailureException in project tomee by apache.

the class ContextLookupStatefulPojoBean method lookupStatelessBean.

public void lookupStatelessBean() throws TestFailureException {
    try {
        try {
            final BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateful/beanReferences/stateless");
            Assert.assertNotNull("The EJBHome looked up is null", home);
            final BasicStatelessObject object = home.createObject();
            Assert.assertNotNull("The EJBObject is null", object);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : BasicStatelessObject(org.apache.openejb.test.stateless.BasicStatelessObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) BasicStatelessHome(org.apache.openejb.test.stateless.BasicStatelessHome) JMSException(javax.jms.JMSException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 23 with TestFailureException

use of org.apache.openejb.test.TestFailureException in project tomee by apache.

the class ContextLookupStatefulPojoBean method lookupStatelessBusinessLocal.

public void lookupStatelessBusinessLocal() throws TestFailureException {
    try {
        try {
            final BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateless-business-local");
            Assert.assertNotNull("The EJB BusinessLocal is null", object);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : BasicStatelessBusinessLocal(org.apache.openejb.test.stateless.BasicStatelessBusinessLocal) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) JMSException(javax.jms.JMSException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 24 with TestFailureException

use of org.apache.openejb.test.TestFailureException in project tomee by apache.

the class ContextLookupStatefulPojoBean method lookupStringEntry.

public void lookupStringEntry() throws TestFailureException {
    try {
        try {
            final String expected = new String("1");
            final String actual = (String) ejbContext.lookup("stateful/references/String");
            Assert.assertNotNull("The String looked up is null", actual);
            Assert.assertEquals(expected, actual);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) JMSException(javax.jms.JMSException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 25 with TestFailureException

use of org.apache.openejb.test.TestFailureException in project tomee by apache.

the class ContextLookupStatefulPojoBean method lookupJMSConnectionFactory.

public void lookupJMSConnectionFactory() throws TestFailureException {
    try {
        try {
            Object obj = ejbContext.lookup("jms");
            Assert.assertNotNull("The JMS ConnectionFactory is null", obj);
            Assert.assertTrue("Not an instance of ConnectionFactory", obj instanceof ConnectionFactory);
            final ConnectionFactory connectionFactory = (ConnectionFactory) obj;
            testJmsConnection(connectionFactory.createConnection());
            obj = ejbContext.lookup("TopicCF");
            Assert.assertNotNull("The JMS TopicConnectionFactory is null", obj);
            Assert.assertTrue("Not an instance of TopicConnectionFactory", obj instanceof TopicConnectionFactory);
            final TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
            testJmsConnection(topicConnectionFactory.createConnection());
            obj = ejbContext.lookup("QueueCF");
            Assert.assertNotNull("The JMS QueueConnectionFactory is null", obj);
            Assert.assertTrue("Not an instance of QueueConnectionFactory", obj instanceof QueueConnectionFactory);
            final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
            testJmsConnection(queueConnectionFactory.createConnection());
        } catch (final Exception e) {
            e.printStackTrace();
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : TopicConnectionFactory(javax.jms.TopicConnectionFactory) QueueConnectionFactory(javax.jms.QueueConnectionFactory) TopicConnectionFactory(javax.jms.TopicConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) QueueConnectionFactory(javax.jms.QueueConnectionFactory) BasicStatelessObject(org.apache.openejb.test.stateless.BasicStatelessObject) BasicBmpObject(org.apache.openejb.test.entity.bmp.BasicBmpObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) JMSException(javax.jms.JMSException) TestFailureException(org.apache.openejb.test.TestFailureException)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)503 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 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 EntityManager (javax.persistence.EntityManager)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15 QueueConnectionFactory (javax.jms.QueueConnectionFactory)15 TopicConnectionFactory (javax.jms.TopicConnectionFactory)15 EJBContext (javax.ejb.EJBContext)12 BasicBmpHome (org.apache.openejb.test.entity.bmp.BasicBmpHome)12