You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2014/07/07 21:07:53 UTC
svn commit: r1608563 [11/38] - in /tomee/tomee/branches/tomee-1.7.x/itests:
failover-ejb/src/main/java/org/apache/openejb/itest/failover/ejb/
failover/src/main/java/org/apache/openejb/itest/failover/
failover/src/main/java/org/apache/openejb/server/con...
Modified: tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/singleton/ContextLookupSingletonBean.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/singleton/ContextLookupSingletonBean.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/singleton/ContextLookupSingletonBean.java (original)
+++ tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/singleton/ContextLookupSingletonBean.java Mon Jul 7 19:07:41 2014
@@ -59,15 +59,15 @@ public class ContextLookupSingletonBean
public void lookupEntityBean() throws TestFailureException {
try {
try {
- BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("singleton/beanReferences/bmp_entity");
+ final BasicBmpHome home = (BasicBmpHome) ejbContext.lookup("singleton/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);
}
}
@@ -75,15 +75,15 @@ public class ContextLookupSingletonBean
public void lookupStatefulBean() throws TestFailureException {
try {
try {
- BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("singleton/beanReferences/stateful");
+ final BasicStatefulHome home = (BasicStatefulHome) ejbContext.lookup("singleton/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);
}
}
@@ -91,93 +91,93 @@ public class ContextLookupSingletonBean
public void lookupSingletonBean() throws TestFailureException {
try {
try {
- BasicSingletonHome home = (BasicSingletonHome) ejbContext.lookup("singleton/beanReferences/singleton");
+ final BasicSingletonHome home = (BasicSingletonHome) ejbContext.lookup("singleton/beanReferences/singleton");
Assert.assertNotNull("The EJBHome looked up is null", home);
- BasicSingletonObject object = home.createObject();
+ final BasicSingletonObject 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 lookupSingletonBusinessLocal() throws TestFailureException{
- try{
- try{
- BasicSingletonBusinessLocal object = (BasicSingletonBusinessLocal) ejbContext.lookup("singleton/beanReferences/singleton-business-local");
- Assert.assertNotNull("The EJB BusinessLocal is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupSingletonBusinessLocal() throws TestFailureException {
+ try {
+ try {
+ final BasicSingletonBusinessLocal object = (BasicSingletonBusinessLocal) ejbContext.lookup("singleton/beanReferences/singleton-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 lookupSingletonBusinessLocalBean() throws TestFailureException{
- try{
- try{
- BasicSingletonPojoBean object = (BasicSingletonPojoBean) ejbContext.lookup("singleton/beanReferences/singleton-business-localbean");
- Assert.assertNotNull("The EJB BusinessLocalBean is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupSingletonBusinessLocalBean() throws TestFailureException {
+ try {
+ try {
+ final BasicSingletonPojoBean object = (BasicSingletonPojoBean) ejbContext.lookup("singleton/beanReferences/singleton-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 lookupSingletonBusinessRemote() throws TestFailureException{
- try{
- try{
- BasicSingletonBusinessRemote object = (BasicSingletonBusinessRemote) ejbContext.lookup("singleton/beanReferences/singleton-business-remote");
- Assert.assertNotNull("The EJB BusinessRemote is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupSingletonBusinessRemote() throws TestFailureException {
+ try {
+ try {
+ final BasicSingletonBusinessRemote object = (BasicSingletonBusinessRemote) ejbContext.lookup("singleton/beanReferences/singleton-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("singleton/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("singleton/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("singleton/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("singleton/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("singleton/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("singleton/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);
}
}
@@ -185,16 +185,16 @@ public class ContextLookupSingletonBean
public void lookupStringEntry() throws TestFailureException {
try {
try {
- String expected = new String("1");
- String actual = (String) ejbContext.lookup("singleton/references/String");
+ final String expected = new String("1");
+ final String actual = (String) ejbContext.lookup("singleton/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);
}
}
@@ -202,16 +202,16 @@ public class ContextLookupSingletonBean
public void lookupDoubleEntry() throws TestFailureException {
try {
try {
- Double expected = new Double(1.0D);
- Double actual = (Double) ejbContext.lookup("singleton/references/Double");
+ final Double expected = new Double(1.0D);
+ final Double actual = (Double) ejbContext.lookup("singleton/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);
}
}
@@ -219,16 +219,16 @@ public class ContextLookupSingletonBean
public void lookupLongEntry() throws TestFailureException {
try {
try {
- Long expected = new Long(1L);
- Long actual = (Long) ejbContext.lookup("singleton/references/Long");
+ final Long expected = new Long(1L);
+ final Long actual = (Long) ejbContext.lookup("singleton/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);
}
}
@@ -236,16 +236,16 @@ public class ContextLookupSingletonBean
public void lookupFloatEntry() throws TestFailureException {
try {
try {
- Float expected = new Float(1.0F);
- Float actual = (Float) ejbContext.lookup("singleton/references/Float");
+ final Float expected = new Float(1.0F);
+ final Float actual = (Float) ejbContext.lookup("singleton/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);
}
}
@@ -253,16 +253,16 @@ public class ContextLookupSingletonBean
public void lookupIntegerEntry() throws TestFailureException {
try {
try {
- Integer expected = new Integer(1);
- Integer actual = (Integer) ejbContext.lookup("singleton/references/Integer");
+ final Integer expected = new Integer(1);
+ final Integer actual = (Integer) ejbContext.lookup("singleton/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);
}
}
@@ -270,16 +270,16 @@ public class ContextLookupSingletonBean
public void lookupShortEntry() throws TestFailureException {
try {
try {
- Short expected = new Short((short) 1);
- Short actual = (Short) ejbContext.lookup("singleton/references/Short");
+ final Short expected = new Short((short) 1);
+ final Short actual = (Short) ejbContext.lookup("singleton/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);
}
}
@@ -287,16 +287,16 @@ public class ContextLookupSingletonBean
public void lookupBooleanEntry() throws TestFailureException {
try {
try {
- Boolean expected = new Boolean(true);
- Boolean actual = (Boolean) ejbContext.lookup("singleton/references/Boolean");
+ final Boolean expected = new Boolean(true);
+ final Boolean actual = (Boolean) ejbContext.lookup("singleton/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);
}
}
@@ -304,16 +304,16 @@ public class ContextLookupSingletonBean
public void lookupByteEntry() throws TestFailureException {
try {
try {
- Byte expected = new Byte((byte) 1);
- Byte actual = (Byte) ejbContext.lookup("singleton/references/Byte");
+ final Byte expected = new Byte((byte) 1);
+ final Byte actual = (Byte) ejbContext.lookup("singleton/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);
}
}
@@ -321,16 +321,16 @@ public class ContextLookupSingletonBean
public void lookupCharacterEntry() throws TestFailureException {
try {
try {
- Character expected = new Character('D');
- Character actual = (Character) ejbContext.lookup("singleton/references/Character");
+ final Character expected = new Character('D');
+ final Character actual = (Character) ejbContext.lookup("singleton/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);
}
}
@@ -338,112 +338,112 @@ public class ContextLookupSingletonBean
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);
}
-
+
}
-
-
+
+
//
// Remote interface methods
//=============================
@@ -456,7 +456,7 @@ public class ContextLookupSingletonBean
* 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;
}
@@ -497,8 +497,8 @@ public class ContextLookupSingletonBean
//
// SessionBean interface methods
//================================
-
- public String remove(String arg) {
+
+ public String remove(final String arg) {
return arg;
}
}
Modified: tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/singleton/ContextLookupSingletonPojoBean.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/singleton/ContextLookupSingletonPojoBean.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/singleton/ContextLookupSingletonPojoBean.java (original)
+++ tomee/tomee/branches/tomee-1.7.x/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/singleton/ContextLookupSingletonPojoBean.java Mon Jul 7 19:07:41 2014
@@ -40,15 +40,15 @@ public class ContextLookupSingletonPojoB
public void lookupEntityBean() throws TestFailureException {
try {
try {
- BasicBmpHome home = (BasicBmpHome) getSessionContext().lookup("singleton/beanReferences/bmp_entity");
+ final BasicBmpHome home = (BasicBmpHome) getSessionContext().lookup("singleton/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);
}
}
@@ -56,15 +56,15 @@ public class ContextLookupSingletonPojoB
public void lookupStatefulBean() throws TestFailureException {
try {
try {
- BasicStatefulHome home = (BasicStatefulHome) getSessionContext().lookup("singleton/beanReferences/stateful");
+ final BasicStatefulHome home = (BasicStatefulHome) getSessionContext().lookup("singleton/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);
}
}
@@ -72,93 +72,93 @@ public class ContextLookupSingletonPojoB
public void lookupSingletonBean() throws TestFailureException {
try {
try {
- BasicSingletonHome home = (BasicSingletonHome) getSessionContext().lookup("singleton/beanReferences/singleton");
+ final BasicSingletonHome home = (BasicSingletonHome) getSessionContext().lookup("singleton/beanReferences/singleton");
Assert.assertNotNull("The EJBHome looked up is null", home);
- BasicSingletonObject object = home.createObject();
+ final BasicSingletonObject 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 lookupSingletonBusinessLocal() throws TestFailureException{
- try{
- try{
- BasicSingletonBusinessLocal object = (BasicSingletonBusinessLocal) getSessionContext().lookup("singleton/beanReferences/singleton-business-local");
- Assert.assertNotNull("The EJB BusinessLocal is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupSingletonBusinessLocal() throws TestFailureException {
+ try {
+ try {
+ final BasicSingletonBusinessLocal object = (BasicSingletonBusinessLocal) getSessionContext().lookup("singleton/beanReferences/singleton-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 lookupSingletonBusinessLocalBean() throws TestFailureException{
- try{
- try{
- BasicSingletonPojoBean object = (BasicSingletonPojoBean) getSessionContext().lookup("singleton/beanReferences/singleton-business-localbean");
- Assert.assertNotNull("The EJB BusinessLocalBean is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupSingletonBusinessLocalBean() throws TestFailureException {
+ try {
+ try {
+ final BasicSingletonPojoBean object = (BasicSingletonPojoBean) getSessionContext().lookup("singleton/beanReferences/singleton-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 lookupSingletonBusinessRemote() throws TestFailureException{
- try{
- try{
- BasicSingletonBusinessRemote object = (BasicSingletonBusinessRemote) getSessionContext().lookup("singleton/beanReferences/singleton-business-remote");
- Assert.assertNotNull("The EJB BusinessRemote is null", object );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ public void lookupSingletonBusinessRemote() throws TestFailureException {
+ try {
+ try {
+ final BasicSingletonBusinessRemote object = (BasicSingletonBusinessRemote) getSessionContext().lookup("singleton/beanReferences/singleton-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) getSessionContext().lookup("singleton/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) getSessionContext().lookup("singleton/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) getSessionContext().lookup("singleton/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) getSessionContext().lookup("singleton/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) getSessionContext().lookup("singleton/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) getSessionContext().lookup("singleton/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);
}
}
@@ -167,16 +167,16 @@ public class ContextLookupSingletonPojoB
public void lookupStringEntry() throws TestFailureException {
try {
try {
- String expected = new String("1");
- String actual = (String) getSessionContext().lookup("singleton/references/String");
+ final String expected = new String("1");
+ final String actual = (String) getSessionContext().lookup("singleton/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);
}
}
@@ -184,16 +184,16 @@ public class ContextLookupSingletonPojoB
public void lookupDoubleEntry() throws TestFailureException {
try {
try {
- Double expected = new Double(1.0D);
- Double actual = (Double) getSessionContext().lookup("singleton/references/Double");
+ final Double expected = new Double(1.0D);
+ final Double actual = (Double) getSessionContext().lookup("singleton/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);
}
}
@@ -201,16 +201,16 @@ public class ContextLookupSingletonPojoB
public void lookupLongEntry() throws TestFailureException {
try {
try {
- Long expected = new Long(1L);
- Long actual = (Long) getSessionContext().lookup("singleton/references/Long");
+ final Long expected = new Long(1L);
+ final Long actual = (Long) getSessionContext().lookup("singleton/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);
}
}
@@ -218,16 +218,16 @@ public class ContextLookupSingletonPojoB
public void lookupFloatEntry() throws TestFailureException {
try {
try {
- Float expected = new Float(1.0F);
- Float actual = (Float) getSessionContext().lookup("singleton/references/Float");
+ final Float expected = new Float(1.0F);
+ final Float actual = (Float) getSessionContext().lookup("singleton/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);
}
}
@@ -235,16 +235,16 @@ public class ContextLookupSingletonPojoB
public void lookupIntegerEntry() throws TestFailureException {
try {
try {
- Integer expected = new Integer(1);
- Integer actual = (Integer) getSessionContext().lookup("singleton/references/Integer");
+ final Integer expected = new Integer(1);
+ final Integer actual = (Integer) getSessionContext().lookup("singleton/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);
}
}
@@ -252,16 +252,16 @@ public class ContextLookupSingletonPojoB
public void lookupShortEntry() throws TestFailureException {
try {
try {
- Short expected = new Short((short) 1);
- Short actual = (Short) getSessionContext().lookup("singleton/references/Short");
+ final Short expected = new Short((short) 1);
+ final Short actual = (Short) getSessionContext().lookup("singleton/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);
}
}
@@ -269,16 +269,16 @@ public class ContextLookupSingletonPojoB
public void lookupBooleanEntry() throws TestFailureException {
try {
try {
- Boolean expected = new Boolean(true);
- Boolean actual = (Boolean) getSessionContext().lookup("singleton/references/Boolean");
+ final Boolean expected = new Boolean(true);
+ final Boolean actual = (Boolean) getSessionContext().lookup("singleton/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);
}
}
@@ -286,16 +286,16 @@ public class ContextLookupSingletonPojoB
public void lookupByteEntry() throws TestFailureException {
try {
try {
- Byte expected = new Byte((byte) 1);
- Byte actual = (Byte) getSessionContext().lookup("singleton/references/Byte");
+ final Byte expected = new Byte((byte) 1);
+ final Byte actual = (Byte) getSessionContext().lookup("singleton/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);
}
}
@@ -303,16 +303,16 @@ public class ContextLookupSingletonPojoB
public void lookupCharacterEntry() throws TestFailureException {
try {
try {
- Character expected = new Character('D');
- Character actual = (Character) getSessionContext().lookup("singleton/references/Character");
+ final Character expected = new Character('D');
+ final Character actual = (Character) getSessionContext().lookup("singleton/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);
}
}
@@ -320,69 +320,69 @@ public class ContextLookupSingletonPojoB
public void lookupResource() throws TestFailureException {
try {
try {
- Object obj = getSessionContext().lookup("datasource");
+ final Object obj = getSessionContext().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 lookupPersistenceUnit() throws TestFailureException{
- try{
- try{
- InitialContext ctx = new InitialContext();
+ public void lookupPersistenceUnit() throws TestFailureException {
+ try {
+ try {
+ final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
- EntityManagerFactory emf = (EntityManagerFactory)ctx.lookup("java:comp/env/persistence/TestUnit");
- Assert.assertNotNull("The EntityManagerFactory is null", emf );
+ final EntityManagerFactory emf = (EntityManagerFactory) ctx.lookup("java:comp/env/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 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 );
- } catch (Exception e){
- Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+ final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
+ Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
+ } 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{
- InitialContext ctx = new InitialContext();
+ }
+
+ public void lookupPersistenceContext() throws TestFailureException {
+ try {
+ try {
+ final InitialContext ctx = new InitialContext();
Assert.assertNotNull("The InitialContext is null", ctx);
- EntityManager em = (EntityManager)ctx.lookup("java:comp/env/persistence/TestContext");
+ final EntityManager em = (EntityManager) ctx.lookup("java:comp/env/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);
}
}
@@ -395,7 +395,7 @@ public class ContextLookupSingletonPojoB
SessionContext ejbContext = null;
try {
ejbContext = (SessionContext) new InitialContext().lookup("java:comp/EJBContext");
- } catch (NamingException e) {
+ } catch (final NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}