Modified: tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java?rev=1608563&r1=1608562&r2=1608563&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java (original) +++ tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulBean.java Mon Jul 7 19:07:41 2014 @@ -66,7 +66,7 @@ public class ContextLookupStatefulBean i * @throws javax.ejb.CreateException * @see EncStatefulHome#create */ - public void ejbCreate(String name) throws CreateException { + public void ejbCreate(final String name) throws CreateException { this.name = name; } // @@ -80,15 +80,15 @@ public class ContextLookupStatefulBean i public void lookupEntityBean() throws TestFailureException { try { try { - BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateful/beanReferences/bmp_entity"); + final BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateful/beanReferences/bmp_entity"); Assert.assertNotNull("The EJBHome looked up is null", home); - BasicBmpObject object = home.createObject("Enc Bean"); + final BasicBmpObject object = home.createObject("Enc Bean"); Assert.assertNotNull("The EJBObject is null", object); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -96,15 +96,15 @@ public class ContextLookupStatefulBean i public void lookupStatefulBean() throws TestFailureException { try { try { - BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateful/beanReferences/stateful"); + final BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateful/beanReferences/stateful"); Assert.assertNotNull("The EJBHome looked up is null", home); - BasicStatefulObject object = home.createObject("Enc Bean"); + final BasicStatefulObject object = home.createObject("Enc Bean"); Assert.assertNotNull("The EJBObject is null", object); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -112,93 +112,93 @@ public class ContextLookupStatefulBean i public void lookupStatelessBean() throws TestFailureException { try { try { - BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateful/beanReferences/stateless"); + final BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateful/beanReferences/stateless"); Assert.assertNotNull("The EJBHome looked up is null", home); - BasicStatelessObject object = home.createObject(); + final BasicStatelessObject object = home.createObject(); Assert.assertNotNull("The EJBObject is null", object); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatelessBusinessLocal() throws TestFailureException{ - try{ - try{ - BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateless-business-local"); - Assert.assertNotNull("The EJB BusinessLocal is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + 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 (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatelessBusinessLocalBean() throws TestFailureException{ - try{ - try{ - BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateless-business-local"); - Assert.assertNotNull("The EJB BusinessLocalBean is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatelessBusinessLocalBean() throws TestFailureException { + try { + try { + final BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateless-business-local"); + Assert.assertNotNull("The EJB BusinessLocalBean is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatelessBusinessRemote() throws TestFailureException{ - try{ - try{ - BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateless-business-remote"); - Assert.assertNotNull("The EJB BusinessRemote is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatelessBusinessRemote() throws TestFailureException { + try { + try { + final BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateless-business-remote"); + Assert.assertNotNull("The EJB BusinessRemote is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatefulBusinessLocal() throws TestFailureException{ - try{ - try{ - BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateful-business-local"); - Assert.assertNotNull("The EJB BusinessLocal is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatefulBusinessLocal() throws TestFailureException { + try { + try { + final BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateful-business-local"); + Assert.assertNotNull("The EJB BusinessLocal is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatefulBusinessLocalBean() throws TestFailureException{ - try{ - try{ - BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateful-business-localbean"); - Assert.assertNotNull("The EJB BusinessLocalBean is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatefulBusinessLocalBean() throws TestFailureException { + try { + try { + final BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateful-business-localbean"); + Assert.assertNotNull("The EJB BusinessLocalBean is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatefulBusinessRemote() throws TestFailureException{ - try{ - try{ - BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateful-business-remote"); - Assert.assertNotNull("The EJB BusinessRemote is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatefulBusinessRemote() throws TestFailureException { + try { + try { + final BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateful-business-remote"); + Assert.assertNotNull("The EJB BusinessRemote is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -206,16 +206,16 @@ public class ContextLookupStatefulBean i public void lookupStringEntry() throws TestFailureException { try { try { - String expected = new String("1"); - String actual = (String) ejbContext.lookup("stateful/references/String"); + 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 (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -223,16 +223,16 @@ public class ContextLookupStatefulBean i public void lookupDoubleEntry() throws TestFailureException { try { try { - Double expected = new Double(1.0D); - Double actual = (Double) ejbContext.lookup("stateful/references/Double"); + final Double expected = new Double(1.0D); + final Double actual = (Double) ejbContext.lookup("stateful/references/Double"); Assert.assertNotNull("The Double looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -240,16 +240,16 @@ public class ContextLookupStatefulBean i public void lookupLongEntry() throws TestFailureException { try { try { - Long expected = new Long(1L); - Long actual = (Long) ejbContext.lookup("stateful/references/Long"); + final Long expected = new Long(1L); + final Long actual = (Long) ejbContext.lookup("stateful/references/Long"); Assert.assertNotNull("The Long looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -257,16 +257,16 @@ public class ContextLookupStatefulBean i public void lookupFloatEntry() throws TestFailureException { try { try { - Float expected = new Float(1.0F); - Float actual = (Float) ejbContext.lookup("stateful/references/Float"); + final Float expected = new Float(1.0F); + final Float actual = (Float) ejbContext.lookup("stateful/references/Float"); Assert.assertNotNull("The Float looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -274,16 +274,16 @@ public class ContextLookupStatefulBean i public void lookupIntegerEntry() throws TestFailureException { try { try { - Integer expected = new Integer(1); - Integer actual = (Integer) ejbContext.lookup("stateful/references/Integer"); + final Integer expected = new Integer(1); + final Integer actual = (Integer) ejbContext.lookup("stateful/references/Integer"); Assert.assertNotNull("The Integer looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -291,16 +291,16 @@ public class ContextLookupStatefulBean i public void lookupShortEntry() throws TestFailureException { try { try { - Short expected = new Short((short) 1); - Short actual = (Short) ejbContext.lookup("stateful/references/Short"); + final Short expected = new Short((short) 1); + final Short actual = (Short) ejbContext.lookup("stateful/references/Short"); Assert.assertNotNull("The Short looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -308,16 +308,16 @@ public class ContextLookupStatefulBean i public void lookupBooleanEntry() throws TestFailureException { try { try { - Boolean expected = new Boolean(true); - Boolean actual = (Boolean) ejbContext.lookup("stateful/references/Boolean"); + final Boolean expected = new Boolean(true); + final Boolean actual = (Boolean) ejbContext.lookup("stateful/references/Boolean"); Assert.assertNotNull("The Boolean looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -325,16 +325,16 @@ public class ContextLookupStatefulBean i public void lookupByteEntry() throws TestFailureException { try { try { - Byte expected = new Byte((byte) 1); - Byte actual = (Byte) ejbContext.lookup("stateful/references/Byte"); + final Byte expected = new Byte((byte) 1); + final Byte actual = (Byte) ejbContext.lookup("stateful/references/Byte"); Assert.assertNotNull("The Byte looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -342,16 +342,16 @@ public class ContextLookupStatefulBean i public void lookupCharacterEntry() throws TestFailureException { try { try { - Character expected = new Character('D'); - Character actual = (Character) ejbContext.lookup("stateful/references/Character"); + final Character expected = new Character('D'); + final Character actual = (Character) ejbContext.lookup("stateful/references/Character"); Assert.assertNotNull("The Character looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -359,112 +359,112 @@ public class ContextLookupStatefulBean i public void lookupResource() throws TestFailureException { try { try { - Object obj = ejbContext.lookup("datasource"); + final Object obj = ejbContext.lookup("datasource"); Assert.assertNotNull("The DataSource is null", obj); Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - - public void lookupJMSConnectionFactory() throws TestFailureException{ - try{ - try{ + + 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); - ConnectionFactory connectionFactory = (ConnectionFactory) obj; + 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); - TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj; + 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); - QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj; + final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj; testJmsConnection(queueConnectionFactory.createConnection()); - } catch (Exception e){ + } catch (final Exception e) { e.printStackTrace(); - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - private void testJmsConnection(Connection connection) throws JMSException { - Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); - Topic topic = session.createTopic("test"); - MessageProducer producer = session.createProducer(topic); + private void testJmsConnection(final Connection connection) throws JMSException { + final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); + final Topic topic = session.createTopic("test"); + final MessageProducer producer = session.createProducer(topic); producer.send(session.createMessage()); producer.close(); session.close(); connection.close(); } - public void lookupPersistenceUnit() throws TestFailureException{ - try{ - try{ - EntityManagerFactory emf = (EntityManagerFactory)ejbContext.lookup("persistence/TestUnit"); - Assert.assertNotNull("The EntityManagerFactory is null", emf ); + public void lookupPersistenceUnit() throws TestFailureException { + try { + try { + final EntityManagerFactory emf = (EntityManagerFactory) ejbContext.lookup("persistence/TestUnit"); + Assert.assertNotNull("The EntityManagerFactory is null", emf); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - - public void lookupPersistenceContext() throws TestFailureException{ - try{ - try{ - EntityManager em = (EntityManager)ejbContext.lookup("persistence/TestContext"); + + 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 (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupSessionContext() throws TestFailureException{ - try{ - try{ - InitialContext ctx = new InitialContext(); + public void lookupSessionContext() throws TestFailureException { + try { + try { + final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); // lookup in enc - SessionContext sctx = (SessionContext)ctx.lookup("java:comp/env/sessioncontext"); - Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx ); + final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext"); + Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx); // lookup using global name - EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext"); - Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx ); + final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext"); + Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx); // verify context was set via legacy set method - Assert.assertNotNull("The SessionContext is null from setter method", ejbContext ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + Assert.assertNotNull("The SessionContext is null from setter method", ejbContext); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } - + } - + // // Remote interface methods //============================= @@ -477,7 +477,7 @@ public class ContextLookupStatefulBean i * Set the associated session context. The container calls this method * after the instance creation. */ - public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException { + public void setSessionContext(final SessionContext ctx) throws EJBException, RemoteException { ejbContext = ctx; } @@ -534,7 +534,7 @@ public class ContextLookupStatefulBean i * transaction commit protocol has completed, and tells the instance * whether the transaction has been committed or rolled back. */ - public void afterCompletion(boolean committed) throws EJBException, RemoteException { + public void afterCompletion(final boolean committed) throws EJBException, RemoteException { } // // SessionSynchronization interface methods
Modified: tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulPojoBean.java URL: http://svn.apache.org/viewvc/tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulPojoBean.java?rev=1608563&r1=1608562&r2=1608563&view=diff ============================================================================== --- tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulPojoBean.java (original) +++ tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/stateful/ContextLookupStatefulPojoBean.java Mon Jul 7 19:07:41 2014 @@ -49,30 +49,30 @@ public class ContextLookupStatefulPojoBe private SessionContext ejbContext; - public void create(String name) { + public void create(final String name) { } @Remove - public void remove(){ + public void remove() { } - + @Resource - public void setSessionContext(SessionContext ejbContext) { + public void setSessionContext(final SessionContext ejbContext) { this.ejbContext = ejbContext; } public void lookupEntityBean() throws TestFailureException { try { try { - BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateful/beanReferences/bmp_entity"); + final BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("stateful/beanReferences/bmp_entity"); Assert.assertNotNull("The EJBHome looked up is null", home); - BasicBmpObject object = home.createObject("Enc Bean"); + final BasicBmpObject object = home.createObject("Enc Bean"); Assert.assertNotNull("The EJBObject is null", object); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -80,15 +80,15 @@ public class ContextLookupStatefulPojoBe public void lookupStatefulBean() throws TestFailureException { try { try { - BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateful/beanReferences/stateful"); + final BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("stateful/beanReferences/stateful"); Assert.assertNotNull("The EJBHome looked up is null", home); - BasicStatefulObject object = home.createObject("Enc Bean"); + final BasicStatefulObject object = home.createObject("Enc Bean"); Assert.assertNotNull("The EJBObject is null", object); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -96,93 +96,93 @@ public class ContextLookupStatefulPojoBe public void lookupStatelessBean() throws TestFailureException { try { try { - BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateful/beanReferences/stateless"); + final BasicStatelessHome home = (BasicStatelessHome) ejbContext.lookup("stateful/beanReferences/stateless"); Assert.assertNotNull("The EJBHome looked up is null", home); - BasicStatelessObject object = home.createObject(); + final BasicStatelessObject object = home.createObject(); Assert.assertNotNull("The EJBObject is null", object); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatelessBusinessLocal() throws TestFailureException{ - try{ - try{ - BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateless-business-local"); - Assert.assertNotNull("The EJB BusinessLocal is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + 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 (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatelessBusinessLocalBean() throws TestFailureException{ - try{ - try{ - BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateless-business-localbean"); - Assert.assertNotNull("The EJB BusinessLocal is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatelessBusinessLocalBean() throws TestFailureException { + try { + try { + final BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateless-business-localbean"); + Assert.assertNotNull("The EJB BusinessLocal is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatelessBusinessRemote() throws TestFailureException{ - try{ - try{ - BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateless-business-remote"); - Assert.assertNotNull("The EJB BusinessRemote is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatelessBusinessRemote() throws TestFailureException { + try { + try { + final BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateless-business-remote"); + Assert.assertNotNull("The EJB BusinessRemote is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatefulBusinessLocal() throws TestFailureException{ - try{ - try{ - BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateful-business-local"); - Assert.assertNotNull("The EJB BusinessLocal is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatefulBusinessLocal() throws TestFailureException { + try { + try { + final BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) ejbContext.lookup("stateful/beanReferences/stateful-business-local"); + Assert.assertNotNull("The EJB BusinessLocal is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatefulBusinessLocalBean() throws TestFailureException{ - try{ - try{ - BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateful-business-localbean"); - Assert.assertNotNull("The EJB BusinessLocalBean is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatefulBusinessLocalBean() throws TestFailureException { + try { + try { + final BasicStatefulPojoBean object = (BasicStatefulPojoBean) ejbContext.lookup("stateful/beanReferences/stateful-business-localbean"); + Assert.assertNotNull("The EJB BusinessLocalBean is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupStatefulBusinessRemote() throws TestFailureException{ - try{ - try{ - BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateful-business-remote"); - Assert.assertNotNull("The EJB BusinessRemote is null", object ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + public void lookupStatefulBusinessRemote() throws TestFailureException { + try { + try { + final BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) ejbContext.lookup("stateful/beanReferences/stateful-business-remote"); + Assert.assertNotNull("The EJB BusinessRemote is null", object); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -190,16 +190,16 @@ public class ContextLookupStatefulPojoBe public void lookupStringEntry() throws TestFailureException { try { try { - String expected = new String("1"); - String actual = (String) ejbContext.lookup("stateful/references/String"); + 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 (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -207,16 +207,16 @@ public class ContextLookupStatefulPojoBe public void lookupDoubleEntry() throws TestFailureException { try { try { - Double expected = new Double(1.0D); - Double actual = (Double) ejbContext.lookup("stateful/references/Double"); + final Double expected = new Double(1.0D); + final Double actual = (Double) ejbContext.lookup("stateful/references/Double"); Assert.assertNotNull("The Double looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -224,16 +224,16 @@ public class ContextLookupStatefulPojoBe public void lookupLongEntry() throws TestFailureException { try { try { - Long expected = new Long(1L); - Long actual = (Long) ejbContext.lookup("stateful/references/Long"); + final Long expected = new Long(1L); + final Long actual = (Long) ejbContext.lookup("stateful/references/Long"); Assert.assertNotNull("The Long looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -241,16 +241,16 @@ public class ContextLookupStatefulPojoBe public void lookupFloatEntry() throws TestFailureException { try { try { - Float expected = new Float(1.0F); - Float actual = (Float) ejbContext.lookup("stateful/references/Float"); + final Float expected = new Float(1.0F); + final Float actual = (Float) ejbContext.lookup("stateful/references/Float"); Assert.assertNotNull("The Float looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -258,16 +258,16 @@ public class ContextLookupStatefulPojoBe public void lookupIntegerEntry() throws TestFailureException { try { try { - Integer expected = new Integer(1); - Integer actual = (Integer) ejbContext.lookup("stateful/references/Integer"); + final Integer expected = new Integer(1); + final Integer actual = (Integer) ejbContext.lookup("stateful/references/Integer"); Assert.assertNotNull("The Integer looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -275,16 +275,16 @@ public class ContextLookupStatefulPojoBe public void lookupShortEntry() throws TestFailureException { try { try { - Short expected = new Short((short) 1); - Short actual = (Short) ejbContext.lookup("stateful/references/Short"); + final Short expected = new Short((short) 1); + final Short actual = (Short) ejbContext.lookup("stateful/references/Short"); Assert.assertNotNull("The Short looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -292,16 +292,16 @@ public class ContextLookupStatefulPojoBe public void lookupBooleanEntry() throws TestFailureException { try { try { - Boolean expected = new Boolean(true); - Boolean actual = (Boolean) ejbContext.lookup("stateful/references/Boolean"); + final Boolean expected = new Boolean(true); + final Boolean actual = (Boolean) ejbContext.lookup("stateful/references/Boolean"); Assert.assertNotNull("The Boolean looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -309,16 +309,16 @@ public class ContextLookupStatefulPojoBe public void lookupByteEntry() throws TestFailureException { try { try { - Byte expected = new Byte((byte) 1); - Byte actual = (Byte) ejbContext.lookup("stateful/references/Byte"); + final Byte expected = new Byte((byte) 1); + final Byte actual = (Byte) ejbContext.lookup("stateful/references/Byte"); Assert.assertNotNull("The Byte looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -326,16 +326,16 @@ public class ContextLookupStatefulPojoBe public void lookupCharacterEntry() throws TestFailureException { try { try { - Character expected = new Character('D'); - Character actual = (Character) ejbContext.lookup("stateful/references/Character"); + final Character expected = new Character('D'); + final Character actual = (Character) ejbContext.lookup("stateful/references/Character"); Assert.assertNotNull("The Character looked up is null", actual); Assert.assertEquals(expected, actual); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } @@ -343,108 +343,108 @@ public class ContextLookupStatefulPojoBe public void lookupResource() throws TestFailureException { try { try { - Object obj = ejbContext.lookup("datasource"); + final Object obj = ejbContext.lookup("datasource"); Assert.assertNotNull("The DataSource is null", obj); Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource); - } catch (Exception e) { + } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe) { + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupJMSConnectionFactory() throws TestFailureException{ - try{ - try{ + 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); - ConnectionFactory connectionFactory = (ConnectionFactory) obj; + 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); - TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj; + 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); - QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj; + final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj; testJmsConnection(queueConnectionFactory.createConnection()); - } catch (Exception e){ + } catch (final Exception e) { e.printStackTrace(); - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - private void testJmsConnection(Connection connection) throws JMSException { - Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); - Topic topic = session.createTopic("test"); - MessageProducer producer = session.createProducer(topic); + private void testJmsConnection(final Connection connection) throws JMSException { + final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE); + final Topic topic = session.createTopic("test"); + final MessageProducer producer = session.createProducer(topic); producer.send(session.createMessage()); producer.close(); session.close(); connection.close(); } - public void lookupPersistenceUnit() throws TestFailureException{ - try{ - try{ - EntityManagerFactory emf = (EntityManagerFactory)ejbContext.lookup("persistence/TestUnit"); - Assert.assertNotNull("The EntityManagerFactory is null", emf ); + public void lookupPersistenceUnit() throws TestFailureException { + try { + try { + final EntityManagerFactory emf = (EntityManagerFactory) ejbContext.lookup("persistence/TestUnit"); + Assert.assertNotNull("The EntityManagerFactory is null", emf); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupPersistenceContext() throws TestFailureException{ - try{ - try{ - EntityManager em = (EntityManager)ejbContext.lookup("persistence/TestContext"); + 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 (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } } - public void lookupSessionContext() throws TestFailureException{ - try{ - try{ - InitialContext ctx = new InitialContext(); - Assert.assertNotNull("The InitialContext is null", ctx); + public void lookupSessionContext() throws TestFailureException { + try { + try { + final InitialContext ctx = new InitialContext(); + Assert.assertNotNull("The InitialContext is null", ctx); // lookup in enc - SessionContext sctx = (SessionContext)ctx.lookup("java:comp/env/sessioncontext"); - Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx ); + final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext"); + Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx); // lookup using global name - EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext"); - Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx ); + final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext"); + Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx); // verify context was set via legacy set method - Assert.assertNotNull("The SessionContext is null from setter method", ejbContext ); - } catch (Exception e){ - Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); + Assert.assertNotNull("The SessionContext is null from setter method", ejbContext); + } catch (final Exception e) { + Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } - } catch (AssertionFailedError afe){ + } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } - + } }
