Search in sources :

Example 6 with TopicConnectionFactory

use of javax.jms.TopicConnectionFactory in project tomee by apache.

the class ContextLookupStatelessBean 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) BasicStatefulObject(org.apache.openejb.test.stateful.BasicStatefulObject) BasicBmpObject(org.apache.openejb.test.entity.bmp.BasicBmpObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) JMSException(javax.jms.JMSException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 7 with TopicConnectionFactory

use of javax.jms.TopicConnectionFactory in project tomee by apache.

the class EncSingletonBean method lookupJMSConnectionFactory.

public void lookupJMSConnectionFactory() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            Object obj = ctx.lookup("java:comp/env/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 = ctx.lookup("java:comp/env/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 = ctx.lookup("java:comp/env/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) BasicStatefulObject(org.apache.openejb.test.stateful.BasicStatefulObject) BasicBmpObject(org.apache.openejb.test.entity.bmp.BasicBmpObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) InitialContext(javax.naming.InitialContext) JMSException(javax.jms.JMSException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 8 with TopicConnectionFactory

use of javax.jms.TopicConnectionFactory in project tomee by apache.

the class EncCmpBean method lookupJMSConnectionFactory.

public void lookupJMSConnectionFactory() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            Object obj = ctx.lookup("java:comp/env/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 = ctx.lookup("java:comp/env/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 = ctx.lookup("java:comp/env/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) BasicStatefulObject(org.apache.openejb.test.stateful.BasicStatefulObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) InitialContext(javax.naming.InitialContext) RemoveException(javax.ejb.RemoveException) JMSException(javax.jms.JMSException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 9 with TopicConnectionFactory

use of javax.jms.TopicConnectionFactory in project tomee by apache.

the class ContextLookupMdbBean method lookupJMSConnectionFactory.

@Override
public void lookupJMSConnectionFactory() throws TestFailureException {
    try {
        try {
            Object obj = mdbContext.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 = mdbContext.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 = mdbContext.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) BasicStatefulObject(org.apache.openejb.test.stateful.BasicStatefulObject) BasicBmpObject(org.apache.openejb.test.entity.bmp.BasicBmpObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) JMSException(javax.jms.JMSException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 10 with TopicConnectionFactory

use of javax.jms.TopicConnectionFactory in project tomee by apache.

the class ContextLookupMdbPojoBean method lookupJMSConnectionFactory.

public void lookupJMSConnectionFactory() throws TestFailureException {
    try {
        try {
            Object obj = getMessageDrivenContext().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 = getMessageDrivenContext().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 = getMessageDrivenContext().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) BasicStatefulObject(org.apache.openejb.test.stateful.BasicStatefulObject) BasicBmpObject(org.apache.openejb.test.entity.bmp.BasicBmpObject) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) NamingException(javax.naming.NamingException) JMSException(javax.jms.JMSException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Aggregations

TopicConnectionFactory (javax.jms.TopicConnectionFactory)22 ConnectionFactory (javax.jms.ConnectionFactory)18 QueueConnectionFactory (javax.jms.QueueConnectionFactory)18 JMSException (javax.jms.JMSException)15 AssertionFailedError (junit.framework.AssertionFailedError)15 TestFailureException (org.apache.openejb.test.TestFailureException)15 EJBException (javax.ejb.EJBException)13 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)11 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)11 RemoteException (java.rmi.RemoteException)10 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)10 InitialContext (javax.naming.InitialContext)8 TopicConnection (javax.jms.TopicConnection)6 RemoveException (javax.ejb.RemoveException)4 CreateException (javax.ejb.CreateException)3 Connection (javax.jms.Connection)3 QueueConnection (javax.jms.QueueConnection)3 Test (org.junit.Test)3 TopicSession (javax.jms.TopicSession)2 Destination (javax.jms.Destination)1