tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andygumbre...@apache.org
Subject svn commit: r1414258 [1/2] - in /openejb/trunk/openejb: container/openejb-core/src/test/java/org/apache/openejb/ container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ container/openejb-loader/src/main/java/org/apache/openejb/loader...
Date Tue, 27 Nov 2012 16:47:42 GMT
Author: andygumbrecht
Date: Tue Nov 27 16:47:37 2012
New Revision: 1414258

URL: http://svn.apache.org/viewvc?rev=1414258&view=rev
Log:
Ensure the JMS connection gets closed.

Modified:
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
    openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
    openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java
    openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/AnnotatedFieldInjectionMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbPojoBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/EncMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/FieldInjectionMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/InterceptorMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java
    openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/SetterInjectionMdbBean.java
    openejb/trunk/openejb/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqLocalTestJms.java
    openejb/trunk/openejb/tomee/apache-tomee-deb-package/src/main/java/org/apache/tomee/debian/PackageBuilder.java

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/iTest.java Tue Nov 27 16:47:37 2012
@@ -38,6 +38,7 @@ public class iTest extends org.apache.op
      * To run this from your ide, set -Dopenejb.home=target/test-classes/
      * @throws Exception
      */
+    @Override
     protected void setUp() throws Exception {
         try {
             OpenEJB.destroy();
@@ -69,6 +70,7 @@ public class iTest extends org.apache.op
         TestManager.start();
     }
 
+    @Override
     protected void tearDown() throws Exception {
         TestManager.stop();
         OpenEJB.destroy();

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java Tue Nov 27 16:47:37 2012
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit;
 public class ActiveMQResourceAdapterTest extends TestCase {
     public void test() throws Exception {
         ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
-        resourceAdapter.setServerUrl("vm://localhost?waitForStart=20000&async=true");
+        resourceAdapter.setServerUrl("vm://localhost?waitForStart=30000&async=false");
 
         String brokerAddress = NetworkUtil.getLocalAddress("broker:(tcp://", ")?useJmx=false");
         resourceAdapter.setBrokerXmlConfig(brokerAddress);

Modified: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java Tue Nov 27 16:47:37 2012
@@ -16,25 +16,7 @@
  */
 package org.apache.openejb.loader;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.Flushable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
 import java.net.Proxy;
 import java.net.ProxySelector;
 import java.net.URI;
@@ -97,6 +79,7 @@ public class IO {
 
     /**
      * Reads and closes the input stream
+     *
      * @param in
      * @param properties
      * @return
@@ -107,7 +90,7 @@ public class IO {
         if (properties == null) throw new NullPointerException("Properties is null");
         try {
             properties.load(in);
-        } finally{
+        } finally {
             close(in);
         }
         return properties;
@@ -183,10 +166,10 @@ public class IO {
         if (destDir == null) {
             throw new NullPointerException("Destination must not be null");
         }
-        if (srcDir.exists() == false) {
+        if (!srcDir.exists()) {
             throw new FileNotFoundException("Source '" + srcDir + "' does not exist");
         }
-        if (srcDir.isDirectory() == false) {
+        if (!srcDir.isDirectory()) {
             throw new IOException("Source '" + srcDir + "' exists but is not a directory");
         }
         if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) {
@@ -214,15 +197,15 @@ public class IO {
             throw new IOException("Failed to list contents of " + srcDir);
         }
         if (destDir.exists()) {
-            if (destDir.isDirectory() == false) {
+            if (!destDir.isDirectory()) {
                 throw new IOException("Destination '" + destDir + "' exists but is not a directory");
             }
         } else {
-            if (destDir.mkdirs() == false) {
+            if (!destDir.mkdirs()) {
                 throw new IOException("Destination '" + destDir + "' directory cannot be created");
             }
         }
-        if (destDir.canWrite() == false) {
+        if (!destDir.canWrite()) {
             throw new IOException("Destination '" + destDir + "' cannot be written to");
         }
         for (File file : files) {
@@ -303,14 +286,16 @@ public class IO {
     public static void close(Closeable closeable) {
         if (closeable == null) return;
         try {
-            if (closeable instanceof Flushable) {
+            if (Flushable.class.isInstance(closeable)) {
                 ((Flushable) closeable).flush();
             }
-        } catch (IOException e) {
+        } catch (Throwable e) {
+            //Ignore
         }
         try {
             closeable.close();
-        } catch (IOException e) {
+        } catch (Throwable e) {
+            //Ignore
         }
     }
 

Modified: openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java (original)
+++ openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/java/org/superbiz/enricher/maven/Enrichers.java Tue Nov 27 16:47:37 2012
@@ -17,8 +17,6 @@
  */
 package org.superbiz.enricher.maven;
 
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
 import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
 
@@ -52,10 +50,10 @@ public final class Enrichers {
         return CACHE.get(pom);
     }
 
-    public static WebArchive wrap(final Archive<?> archive) {
-        if (!(WebArchive.class.isInstance(archive))) {
+    public static org.jboss.shrinkwrap.api.spec.WebArchive wrap(final org.jboss.shrinkwrap.api.Archive<?> archive) {
+        if (!(org.jboss.shrinkwrap.api.spec.WebArchive.class.isInstance(archive))) {
             throw new IllegalArgumentException("Unsupported archive type: " + archive.getClass().getName());
         }
-        return (WebArchive) archive;
+        return (org.jboss.shrinkwrap.api.spec.WebArchive) archive.shallowCopy();
     }
 }

Modified: openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml (original)
+++ openejb/trunk/openejb/examples/multi-jpa-provider-testing/src/test/resources/hibernate-pom.xml Tue Nov 27 16:47:37 2012
@@ -27,7 +27,7 @@
     <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-entitymanager</artifactId>
-      <version>4.1.6.Final</version>
+      <version>4.1.8.Final</version>
       <exclusions>
         <exclusion>
           <groupId>org.hibernate.javax.persistence</groupId>

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/AnnotatedFieldInjectionMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/AnnotatedFieldInjectionMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/AnnotatedFieldInjectionMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/AnnotatedFieldInjectionMdbBean.java Tue Nov 27 16:47:37 2012
@@ -17,44 +17,43 @@
  */
 package org.apache.openejb.test.mdb;
 
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.TestFailureException;
 import org.apache.openejb.test.entity.bmp.BasicBmpHome;
-import org.apache.openejb.test.stateful.BasicStatefulHome;
 import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
 import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
-import org.apache.openejb.test.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
 import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
 import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
-import org.apache.openejb.test.TestFailureException;
+import org.apache.openejb.test.stateless.BasicStatelessHome;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
 import javax.ejb.EJB;
+import javax.ejb.EJBException;
 import javax.ejb.MessageDriven;
 import javax.ejb.MessageDrivenContext;
-import javax.ejb.EJBException;
-import javax.ejb.ActivationConfigProperty;
-import javax.annotation.Resource;
-import javax.annotation.PostConstruct;
-import javax.sql.DataSource;
 import javax.jms.ConnectionFactory;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.TopicConnectionFactory;
 import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.QueueConnectionFactory;
 import javax.jms.Session;
 import javax.jms.Topic;
-import javax.jms.MessageProducer;
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.persistence.PersistenceUnit;
+import javax.jms.TopicConnectionFactory;
+import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.PersistenceContext;
-import javax.persistence.EntityManager;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
+import javax.persistence.PersistenceUnit;
+import javax.sql.DataSource;
 
 @MessageDriven(activationConfig = {
-        @ActivationConfigProperty(propertyName="destinationType", propertyValue = "javax.jms.Queue"),
-        @ActivationConfigProperty(propertyName="destination", propertyValue = "AnnotatedFieldInjectionMdb")})
+        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+        @ActivationConfigProperty(propertyName = "destination", propertyValue = "AnnotatedFieldInjectionMdb")})
 public class AnnotatedFieldInjectionMdbBean implements MessageListener {
     @Resource
     private MessageDrivenContext mdbContext;
@@ -75,11 +74,11 @@ public class AnnotatedFieldInjectionMdbB
     @Resource
     private Integer inteeger = 1;
     @Resource
-    private Short shoort = (short)1;
+    private Short shoort = (short) 1;
     @Resource
     private Boolean booolean = true;
     @Resource
-    private Byte byyte = (byte)1;
+    private Byte byyte = (byte) 1;
     @Resource
     private Character chaaracter = 'D';
     @Resource
@@ -114,7 +113,19 @@ public class AnnotatedFieldInjectionMdbB
         }
     }
 
-    public void onMessage(Message message) {
+    @PreDestroy
+    public void preDestroy() {
+        if (null != mdbInvoker) {
+            try {
+                mdbInvoker.destroy();
+            } catch (Throwable e) {
+                //Ignore
+            }
+        }
+    }
+
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
@@ -189,7 +200,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupStringEntry() throws TestFailureException {
         try {
-            String expected = new String("1");
+            final String expected = "1";
             Assert.assertNotNull("The String looked up is null", striing);
             Assert.assertEquals(expected, striing);
         } catch (AssertionFailedError afe) {
@@ -199,7 +210,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupDoubleEntry() throws TestFailureException {
         try {
-            Double expected = new Double(1.0D);
+            final Double expected = 1.0D;
 
             Assert.assertNotNull("The Double looked up is null", doouble);
             Assert.assertEquals(expected, doouble);
@@ -211,7 +222,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupLongEntry() throws TestFailureException {
         try {
-            Long expected = new Long(1L);
+            final Long expected = 1L;
 
             Assert.assertNotNull("The Long looked up is null", loong);
             Assert.assertEquals(expected, loong);
@@ -222,7 +233,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupFloatEntry() throws TestFailureException {
         try {
-            Float expected = new Float(1.0F);
+            final Float expected = 1.0F;
 
             Assert.assertNotNull("The Float looked up is null", flooat);
             Assert.assertEquals(expected, flooat);
@@ -233,7 +244,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupIntegerEntry() throws TestFailureException {
         try {
-            Integer expected = new Integer(1);
+            final Integer expected = 1;
 
             Assert.assertNotNull("The Integer looked up is null", inteeger);
             Assert.assertEquals(expected, inteeger);
@@ -245,7 +256,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupShortEntry() throws TestFailureException {
         try {
-            Short expected = new Short((short) 1);
+            final Short expected = (short) 1;
 
             Assert.assertNotNull("The Short looked up is null", shoort);
             Assert.assertEquals(expected, shoort);
@@ -256,7 +267,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupBooleanEntry() throws TestFailureException {
         try {
-            Boolean expected = new Boolean(true);
+            final Boolean expected = true;
 
             Assert.assertNotNull("The Boolean looked up is null", booolean);
             Assert.assertEquals(expected, booolean);
@@ -267,7 +278,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupByteEntry() throws TestFailureException {
         try {
-            Byte expected = new Byte((byte) 1);
+            final Byte expected = (byte) 1;
 
             Assert.assertNotNull("The Byte looked up is null", byyte);
             Assert.assertEquals(expected, byyte);
@@ -278,7 +289,7 @@ public class AnnotatedFieldInjectionMdbB
 
     public void lookupCharacterEntry() throws TestFailureException {
         try {
-            Character expected = new Character('D');
+            final Character expected = 'D';
 
             Assert.assertNotNull("The Character looked up is null", chaaracter);
             Assert.assertEquals(expected, chaaracter);
@@ -295,25 +306,25 @@ public class AnnotatedFieldInjectionMdbB
         }
     }
 
-    public void lookupJMSConnectionFactory() throws TestFailureException{
-        try{
-            try{
+    public void lookupJMSConnectionFactory() throws TestFailureException {
+        try {
+            try {
                 testJmsConnection(coonnectionFactory.createConnection());
                 testJmsConnection(queueCoonnectionFactory.createConnection());
                 testJmsConnection(topicCoonnectionFactory.createConnection());
-            } catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    private void testJmsConnection(javax.jms.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 javax.jms.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();

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java Tue Nov 27 16:47:37 2012
@@ -19,7 +19,6 @@ package org.apache.openejb.test.mdb;
 import org.apache.openejb.test.ApplicationException;
 import org.apache.openejb.test.object.OperationsPolicy;
 
-import javax.annotation.PreDestroy;
 import javax.ejb.EJBException;
 import javax.ejb.MessageDrivenBean;
 import javax.ejb.MessageDrivenContext;
@@ -28,26 +27,28 @@ import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
 import javax.naming.InitialContext;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Properties;
 
 public class BasicMdbBean implements BasicMdbObject, MessageDrivenBean, MessageListener {
-	private MessageDrivenContext mdbContext = null;
-    private static Hashtable allowedOperationsTable = new Hashtable();
+    private MessageDrivenContext mdbContext = null;
+    private static final HashMap<String, OperationsPolicy> allowedOperationsTable = new HashMap<String, OperationsPolicy>();
     protected MdbInvoker mdbInvoker;
 
-    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+    @Override
+    public void setMessageDrivenContext(final MessageDrivenContext ctx) throws EJBException {
         this.mdbContext = ctx;
         testAllowedOperations("setMessageDrivenContext");
         try {
-            ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
+            final ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
             mdbInvoker = new MdbInvoker(connectionFactory, this);
         } catch (Exception e) {
             throw new EJBException(e);
         }
     }
 
-    public void onMessage(Message message) {
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
@@ -60,7 +61,7 @@ public class BasicMdbBean implements Bas
             }
             mdbInvoker.onMessage(message);
         } catch (Throwable e) {
-            e.printStackTrace();  
+            e.printStackTrace();
         }
     }
 
@@ -79,18 +80,19 @@ public class BasicMdbBean implements Bas
     /**
      * Maps to BasicStatelessObject.businessMethod
      */
-    public String businessMethod(String text){
+    @Override
+    public String businessMethod(final String text) {
         testAllowedOperations("businessMethod");
-        StringBuffer b = new StringBuffer(text);
+        final StringBuffer b = new StringBuffer(text);
         return b.reverse().toString();
     }
 
 
     /**
      * Throws an ApplicationException when invoked
-     *
      */
-    public void throwApplicationException() throws ApplicationException{
+    @Override
+    public void throwApplicationException() throws ApplicationException {
         throw new ApplicationException("Testing ability to throw Application Exceptions");
     }
 
@@ -99,35 +101,37 @@ public class BasicMdbBean implements Bas
      * This is a system exception and should result in the
      * destruction of the instance and invalidation of the
      * remote reference.
-     *
      */
+    @Override
     public void throwSystemException_NullPointer() {
         throw new NullPointerException("Testing ability to throw System Exceptions");
     }
 
     /**
      * Maps to BasicStatelessObject.getPermissionsReport
-     *
+     * <p/>
      * Returns a report of the bean's
      * runtime permissions
      *
      * @return
      */
-    public Properties getPermissionsReport(){
+    @Override
+    public Properties getPermissionsReport() {
         /* TO DO: */
         return null;
     }
 
     /**
      * Maps to BasicStatelessObject.getAllowedOperationsReport
-     *
+     * <p/>
      * Returns a report of the allowed opperations
      * for one of the bean's methods.
      *
      * @param methodName The method for which to get the allowed opperations report
      * @return
      */
-    public OperationsPolicy getAllowedOperationsReport(String methodName){
+    @Override
+    public OperationsPolicy getAllowedOperationsReport(final String methodName) {
         return (OperationsPolicy) allowedOperationsTable.get(methodName);
     }
 
@@ -140,11 +144,17 @@ public class BasicMdbBean implements Bas
     // MessageDrivenBean interface methods
     //
 
-    public void ejbCreate() throws javax.ejb.CreateException{
+    public void ejbCreate() throws javax.ejb.CreateException {
         testAllowedOperations("ejbCreate");
     }
 
+    @Override
     public void ejbRemove() throws EJBException {
+
+        if (null != mdbInvoker) {
+            mdbInvoker.destroy();
+        }
+
         testAllowedOperations("ejbRemove");
     }
 
@@ -152,67 +162,67 @@ public class BasicMdbBean implements Bas
     // SessionBean interface methods
     //================================
 
-	protected void testAllowedOperations(String methodName) {
-		OperationsPolicy policy = new OperationsPolicy();
+    protected void testAllowedOperations(final String methodName) {
+        final OperationsPolicy policy = new OperationsPolicy();
+
+        /*[0] Test getEJBHome /////////////////*/
+        try {
+            mdbContext.getEJBHome();
+            policy.allow(OperationsPolicy.Context_getEJBHome);
+        } catch (IllegalStateException ignored) {
+        }
+
+        /*[1] Test getCallerPrincipal /////////*/
+        try {
+            mdbContext.getCallerPrincipal();
+            policy.allow(OperationsPolicy.Context_getCallerPrincipal);
+        } catch (IllegalStateException ignored) {
+        }
+
+        /*[2] Test isCallerInRole /////////////*/
+        try {
+            mdbContext.isCallerInRole("TheMan");
+            policy.allow(OperationsPolicy.Context_isCallerInRole);
+        } catch (IllegalStateException ignored) {
+        }
 
-		/*[0] Test getEJBHome /////////////////*/
-		try {
-			mdbContext.getEJBHome();
-			policy.allow(OperationsPolicy.Context_getEJBHome);
-		} catch (IllegalStateException ignored) {
-		}
-
-		/*[1] Test getCallerPrincipal /////////*/
-		try {
-			mdbContext.getCallerPrincipal();
-			policy.allow(OperationsPolicy.Context_getCallerPrincipal);
-		} catch (IllegalStateException ignored) {
-		}
-
-		/*[2] Test isCallerInRole /////////////*/
-		try {
-			mdbContext.isCallerInRole("TheMan");
-			policy.allow(OperationsPolicy.Context_isCallerInRole);
-		} catch (IllegalStateException ignored) {
-		}
-
-		/*[3] Test getRollbackOnly ////////////*/
-		try {
-			mdbContext.getRollbackOnly();
-			policy.allow(OperationsPolicy.Context_getRollbackOnly);
-		} catch (IllegalStateException ignored) {
-		}
+        /*[3] Test getRollbackOnly ////////////*/
+        try {
+            mdbContext.getRollbackOnly();
+            policy.allow(OperationsPolicy.Context_getRollbackOnly);
+        } catch (IllegalStateException ignored) {
+        }
 
-		/*[4] Test setRollbackOnly ////////////*/
+        /*[4] Test setRollbackOnly ////////////*/
         // Rollback causes message redelivery
 
-		/*[5] Test getUserTransaction /////////*/
-		try {
-			mdbContext.getUserTransaction();
-			policy.allow(OperationsPolicy.Context_getUserTransaction);
-		} catch (IllegalStateException ignored) {
-		}
-
-		/*[6] Test getEJBObject ///////////////
-		 *
-		 * MDBs don't have an ejbObject
-		 */
-
-		/*[7] Test Context_getPrimaryKey ///////////////
-		 *
-		 * Can't really do this
-		 */
-
-		/*[8] Test JNDI_access_to_java_comp_env ///////////////*/
-		try {
-			InitialContext jndiContext = new InitialContext();
-
-			String actual = (String)jndiContext.lookup("java:comp/env/stateless/references/JNDI_access_to_java_comp_env");
-
-			policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
-		} catch (IllegalStateException ignored) {
-		} catch (javax.naming.NamingException ignored) {
-		}
+        /*[5] Test getUserTransaction /////////*/
+        try {
+            mdbContext.getUserTransaction();
+            policy.allow(OperationsPolicy.Context_getUserTransaction);
+        } catch (IllegalStateException ignored) {
+        }
+
+        /*[6] Test getEJBObject ///////////////
+           *
+           * MDBs don't have an ejbObject
+           */
+
+        /*[7] Test Context_getPrimaryKey ///////////////
+           *
+           * Can't really do this
+           */
+
+        /*[8] Test JNDI_access_to_java_comp_env ///////////////*/
+        try {
+            final InitialContext jndiContext = new InitialContext();
+
+            final String actual = (String) jndiContext.lookup("java:comp/env/stateless/references/JNDI_access_to_java_comp_env");
+
+            policy.allow(OperationsPolicy.JNDI_access_to_java_comp_env);
+        } catch (IllegalStateException ignored) {
+        } catch (javax.naming.NamingException ignored) {
+        }
 
         /*[11] Test lookup /////////*/
         try {
@@ -221,7 +231,7 @@ public class BasicMdbBean implements Bas
         } catch (IllegalArgumentException ignored) {
         }
 
-		allowedOperationsTable.put(methodName, policy);
+        allowedOperationsTable.put(methodName, policy);
 
     }
 

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbBean.java Tue Nov 27 16:47:37 2012
@@ -17,56 +17,56 @@
  */
 package org.apache.openejb.test.mdb;
 
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
 import org.apache.openejb.test.TestFailureException;
-import org.apache.openejb.test.stateless.BasicStatelessHome;
-import org.apache.openejb.test.stateless.BasicStatelessObject;
-import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
-import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
-import org.apache.openejb.test.stateful.BasicStatefulHome;
-import org.apache.openejb.test.stateful.BasicStatefulObject;
-import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
-import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
 import org.apache.openejb.test.entity.bmp.BasicBmpHome;
 import org.apache.openejb.test.entity.bmp.BasicBmpObject;
+import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
+import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
+import org.apache.openejb.test.stateful.BasicStatefulObject;
+import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
+import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
+import org.apache.openejb.test.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateless.BasicStatelessObject;
 
-import javax.annotation.PreDestroy;
 import javax.ejb.EJBContext;
 import javax.ejb.EJBException;
 import javax.ejb.MessageDrivenBean;
 import javax.ejb.MessageDrivenContext;
-import javax.sql.DataSource;
-import javax.jms.ConnectionFactory;
-import javax.jms.TopicConnectionFactory;
-import javax.jms.QueueConnectionFactory;
 import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.QueueConnectionFactory;
 import javax.jms.Session;
 import javax.jms.Topic;
-import javax.jms.MessageProducer;
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityManager;
+import javax.jms.TopicConnectionFactory;
 import javax.naming.InitialContext;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
 
 public class ContextLookupMdbBean implements EncMdbObject, MessageDrivenBean, MessageListener {
-	private MessageDrivenContext mdbContext = null;
+    private MessageDrivenContext mdbContext = null;
     private MdbInvoker mdbInvoker;
 
-    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+    @Override
+    public void setMessageDrivenContext(final MessageDrivenContext ctx) throws EJBException {
         this.mdbContext = ctx;
         try {
-            ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
+            final ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
             mdbInvoker = new MdbInvoker(connectionFactory, this);
         } catch (Exception e) {
             throw new EJBException(e);
         }
     }
 
-    public void onMessage(Message message) {
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
@@ -83,13 +83,14 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupEntityBean() throws TestFailureException {
         try {
             try {
-                BasicBmpHome home = (BasicBmpHome) mdbContext.lookup("stateless/beanReferences/bmp_entity");
+                final BasicBmpHome home = (BasicBmpHome) mdbContext.lookup("stateless/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) {
                 Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
@@ -99,13 +100,14 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupStatefulBean() throws TestFailureException {
         try {
             try {
-                BasicStatefulHome home = (BasicStatefulHome) mdbContext.lookup("stateless/beanReferences/stateful");
+                final BasicStatefulHome home = (BasicStatefulHome) mdbContext.lookup("stateless/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) {
                 Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
@@ -115,13 +117,14 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupStatelessBean() throws TestFailureException {
         try {
             try {
-                BasicStatelessHome home = (BasicStatelessHome) mdbContext.lookup("stateless/beanReferences/stateless");
+                final BasicStatelessHome home = (BasicStatelessHome) mdbContext.lookup("stateless/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) {
                 Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
@@ -131,63 +134,68 @@ public class ContextLookupMdbBean implem
         }
     }
 
-    public void lookupStatelessBusinessLocal() throws TestFailureException{
-        try{
-            try{
-            BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) mdbContext.lookup("stateless/beanReferences/stateless-business-local");
-            Assert.assertNotNull("The EJB BusinessLocal is null", object );
-            } catch (Exception e){
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+    @Override
+    public void lookupStatelessBusinessLocal() throws TestFailureException {
+        try {
+            try {
+                final BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) mdbContext.lookup("stateless/beanReferences/stateless-business-local");
+                Assert.assertNotNull("The EJB BusinessLocal is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatelessBusinessRemote() throws TestFailureException{
-        try{
-            try{
-            BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) mdbContext.lookup("stateless/beanReferences/stateless-business-remote");
-            Assert.assertNotNull("The EJB BusinessRemote is null", object );
-            } catch (Exception e){
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+    @Override
+    public void lookupStatelessBusinessRemote() throws TestFailureException {
+        try {
+            try {
+                final BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) mdbContext.lookup("stateless/beanReferences/stateless-business-remote");
+                Assert.assertNotNull("The EJB BusinessRemote is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessLocal() throws TestFailureException{
-        try{
-            try{
-            BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) mdbContext.lookup("stateless/beanReferences/stateful-business-local");
-            Assert.assertNotNull("The EJB BusinessLocal is null", object );
-            } catch (Exception e){
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+    @Override
+    public void lookupStatefulBusinessLocal() throws TestFailureException {
+        try {
+            try {
+                final BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) mdbContext.lookup("stateless/beanReferences/stateful-business-local");
+                Assert.assertNotNull("The EJB BusinessLocal is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessRemote() throws TestFailureException{
-        try{
-            try{
-            BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) mdbContext.lookup("stateless/beanReferences/stateful-business-remote");
-            Assert.assertNotNull("The EJB BusinessRemote is null", object );
-            } catch (Exception e){
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+    @Override
+    public void lookupStatefulBusinessRemote() throws TestFailureException {
+        try {
+            try {
+                final BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) mdbContext.lookup("stateless/beanReferences/stateful-business-remote");
+                Assert.assertNotNull("The EJB BusinessRemote is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
+    @Override
     public void lookupStringEntry() throws TestFailureException {
         try {
             try {
-                String expected = new String("1");
-                String actual = (String) mdbContext.lookup("stateless/references/String");
+                final String expected = "1";
+                final String actual = (String) mdbContext.lookup("stateless/references/String");
 
                 Assert.assertNotNull("The String looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -200,11 +208,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupDoubleEntry() throws TestFailureException {
         try {
             try {
-                Double expected = new Double(1.0D);
-                Double actual = (Double) mdbContext.lookup("stateless/references/Double");
+                final Double expected = 1.0D;
+                final Double actual = (Double) mdbContext.lookup("stateless/references/Double");
 
                 Assert.assertNotNull("The Double looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -217,11 +226,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupLongEntry() throws TestFailureException {
         try {
             try {
-                Long expected = new Long(1L);
-                Long actual = (Long) mdbContext.lookup("stateless/references/Long");
+                final Long expected = 1L;
+                final Long actual = (Long) mdbContext.lookup("stateless/references/Long");
 
                 Assert.assertNotNull("The Long looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -234,11 +244,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupFloatEntry() throws TestFailureException {
         try {
             try {
-                Float expected = new Float(1.0F);
-                Float actual = (Float) mdbContext.lookup("stateless/references/Float");
+                final Float expected = 1.0F;
+                final Float actual = (Float) mdbContext.lookup("stateless/references/Float");
 
                 Assert.assertNotNull("The Float looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -251,11 +262,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupIntegerEntry() throws TestFailureException {
         try {
             try {
-                Integer expected = new Integer(1);
-                Integer actual = (Integer) mdbContext.lookup("stateless/references/Integer");
+                final Integer expected = 1;
+                final Integer actual = (Integer) mdbContext.lookup("stateless/references/Integer");
 
                 Assert.assertNotNull("The Integer looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -268,11 +280,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupShortEntry() throws TestFailureException {
         try {
             try {
-                Short expected = new Short((short) 1);
-                Short actual = (Short) mdbContext.lookup("stateless/references/Short");
+                final Short expected = (short) 1;
+                final Short actual = (Short) mdbContext.lookup("stateless/references/Short");
 
                 Assert.assertNotNull("The Short looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -285,11 +298,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupBooleanEntry() throws TestFailureException {
         try {
             try {
-                Boolean expected = new Boolean(true);
-                Boolean actual = (Boolean) mdbContext.lookup("stateless/references/Boolean");
+                final Boolean expected = true;
+                final Boolean actual = (Boolean) mdbContext.lookup("stateless/references/Boolean");
 
                 Assert.assertNotNull("The Boolean looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -302,11 +316,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupByteEntry() throws TestFailureException {
         try {
             try {
-                Byte expected = new Byte((byte) 1);
-                Byte actual = (Byte) mdbContext.lookup("stateless/references/Byte");
+                final Byte expected = (byte) 1;
+                final Byte actual = (Byte) mdbContext.lookup("stateless/references/Byte");
 
                 Assert.assertNotNull("The Byte looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -319,11 +334,12 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupCharacterEntry() throws TestFailureException {
         try {
             try {
-                Character expected = new Character('D');
-                Character actual = (Character) mdbContext.lookup("stateless/references/Character");
+                final Character expected = 'D';
+                final Character actual = (Character) mdbContext.lookup("stateless/references/Character");
 
                 Assert.assertNotNull("The Character looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -336,10 +352,11 @@ public class ContextLookupMdbBean implem
         }
     }
 
+    @Override
     public void lookupResource() throws TestFailureException {
         try {
             try {
-                Object obj = mdbContext.lookup("datasource");
+                final Object obj = mdbContext.lookup("datasource");
                 Assert.assertNotNull("The DataSource is null", obj);
                 Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource);
             } catch (Exception e) {
@@ -350,95 +367,99 @@ public class ContextLookupMdbBean implem
         }
     }
 
-    public void lookupJMSConnectionFactory() throws TestFailureException{
-        try{
-            try{
+    @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);
-                ConnectionFactory connectionFactory = (ConnectionFactory) obj;
+                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);
-                TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
+                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);
-                QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
+                final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
                 testJmsConnection(queueConnectionFactory.createConnection());
-            } catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (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) mdbContext.lookup("persistence/TestUnit");
-                Assert.assertNotNull("The EntityManagerFactory is null", emf );
+    @Override
+    public void lookupPersistenceUnit() throws TestFailureException {
+        try {
+            try {
+                final EntityManagerFactory emf = (EntityManagerFactory) mdbContext.lookup("persistence/TestUnit");
+                Assert.assertNotNull("The EntityManagerFactory is null", emf);
 
-            } catch (Exception e){
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupPersistenceContext() throws TestFailureException{
-        try{
-            try{
-                EntityManager em = (EntityManager) mdbContext.lookup("persistence/TestContext");
+    @Override
+    public void lookupPersistenceContext() throws TestFailureException {
+        try {
+            try {
+                final EntityManager em = (EntityManager) mdbContext.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 (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupMessageDrivenContext() throws TestFailureException{
-        try{
-            try{
-                InitialContext ctx = new InitialContext();
+    @Override
+    public void lookupMessageDrivenContext() throws TestFailureException {
+        try {
+            try {
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
 
                 // lookup in enc
-                MessageDrivenContext sctx = (MessageDrivenContext)ctx.lookup("java:comp/env/mdbcontext");
-                Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx );
+                final MessageDrivenContext sctx = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
+                Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx);
 
                 // lookup using global name
-                EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext");
-                Assert.assertNotNull("The MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx );
+                final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
+                Assert.assertNotNull("The MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx);
 
                 // verify context was set via legacy set method
                 Assert.assertNotNull("The MessageDrivenContext is null from setter method", mdbContext);
-            } catch (Exception e){
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
 
@@ -447,6 +468,11 @@ public class ContextLookupMdbBean implem
     public void ejbCreate() throws javax.ejb.CreateException {
     }
 
+    @Override
     public void ejbRemove() throws EJBException {
+
+        if (null != mdbInvoker) {
+            mdbInvoker.destroy();
+        }
     }
 }

Modified: openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbPojoBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbPojoBean.java?rev=1414258&r1=1414257&r2=1414258&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbPojoBean.java (original)
+++ openejb/trunk/openejb/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/ContextLookupMdbPojoBean.java Tue Nov 27 16:47:37 2012
@@ -17,54 +17,60 @@
  */
 package org.apache.openejb.test.mdb;
 
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
 import org.apache.openejb.test.TestFailureException;
-import org.apache.openejb.test.stateless.BasicStatelessHome;
-import org.apache.openejb.test.stateless.BasicStatelessObject;
-import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
-import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
-import org.apache.openejb.test.stateful.BasicStatefulHome;
-import org.apache.openejb.test.stateful.BasicStatefulObject;
-import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
-import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
 import org.apache.openejb.test.entity.bmp.BasicBmpHome;
 import org.apache.openejb.test.entity.bmp.BasicBmpObject;
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
+import org.apache.openejb.test.stateful.BasicStatefulBusinessLocal;
+import org.apache.openejb.test.stateful.BasicStatefulBusinessRemote;
+import org.apache.openejb.test.stateful.BasicStatefulHome;
+import org.apache.openejb.test.stateful.BasicStatefulObject;
+import org.apache.openejb.test.stateless.BasicStatelessBusinessLocal;
+import org.apache.openejb.test.stateless.BasicStatelessBusinessRemote;
+import org.apache.openejb.test.stateless.BasicStatelessHome;
+import org.apache.openejb.test.stateless.BasicStatelessObject;
 
-import javax.annotation.PreDestroy;
-import javax.sql.DataSource;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityManager;
 import javax.ejb.EJBContext;
 import javax.ejb.EJBException;
 import javax.ejb.MessageDrivenContext;
-import javax.jms.MessageListener;
+import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
-import javax.jms.Message;
 import javax.jms.JMSException;
-import javax.jms.TopicConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
 import javax.jms.QueueConnectionFactory;
-import javax.jms.Connection;
 import javax.jms.Session;
 import javax.jms.Topic;
-import javax.jms.MessageProducer;
-import java.rmi.RemoteException;
+import javax.jms.TopicConnectionFactory;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
 
 public class ContextLookupMdbPojoBean implements MessageListener {
-    private MdbInvoker mdbInvoker;
+    private final MdbInvoker mdbInvoker;
 
     public ContextLookupMdbPojoBean() {
         try {
-            ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
+            final ConnectionFactory connectionFactory = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms");
             mdbInvoker = new MdbInvoker(connectionFactory, this);
         } catch (Exception e) {
             throw new EJBException(e);
         }
     }
 
-    public void onMessage(Message message) {
+    public void ejbRemove() throws EJBException {
+
+        if (null != mdbInvoker) {
+            mdbInvoker.destroy();
+        }
+    }
+
+    @Override
+    public void onMessage(final Message message) {
         try {
 //            System.out.println("\n" +
 //                    "***************************************\n" +
@@ -85,10 +91,10 @@ public class ContextLookupMdbPojoBean im
     public void lookupEntityBean() throws TestFailureException {
         try {
             try {
-                BasicBmpHome home = (BasicBmpHome) getMessageDrivenContext().lookup("stateless/beanReferences/bmp_entity");
+                final BasicBmpHome home = (BasicBmpHome) getMessageDrivenContext().lookup("stateless/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) {
                 Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
@@ -101,10 +107,10 @@ public class ContextLookupMdbPojoBean im
     public void lookupStatefulBean() throws TestFailureException {
         try {
             try {
-                BasicStatefulHome home = (BasicStatefulHome) getMessageDrivenContext().lookup("stateless/beanReferences/stateful");
+                final BasicStatefulHome home = (BasicStatefulHome) getMessageDrivenContext().lookup("stateless/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) {
                 Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
@@ -117,10 +123,10 @@ public class ContextLookupMdbPojoBean im
     public void lookupStatelessBean() throws TestFailureException {
         try {
             try {
-                BasicStatelessHome home = (BasicStatelessHome) getMessageDrivenContext().lookup("stateless/beanReferences/stateless");
+                final BasicStatelessHome home = (BasicStatelessHome) getMessageDrivenContext().lookup("stateless/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) {
                 Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
@@ -130,54 +136,54 @@ public class ContextLookupMdbPojoBean im
         }
     }
 
-    public void lookupStatelessBusinessLocal() throws TestFailureException{
-        try{
-            try{
-            BasicStatelessBusinessLocal object = (BasicStatelessBusinessLocal) getMessageDrivenContext().lookup("stateless/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) getMessageDrivenContext().lookup("stateless/beanReferences/stateless-business-local");
+                Assert.assertNotNull("The EJB BusinessLocal is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatelessBusinessRemote() throws TestFailureException{
-        try{
-            try{
-            BasicStatelessBusinessRemote object = (BasicStatelessBusinessRemote) getMessageDrivenContext().lookup("stateless/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) getMessageDrivenContext().lookup("stateless/beanReferences/stateless-business-remote");
+                Assert.assertNotNull("The EJB BusinessRemote is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessLocal() throws TestFailureException{
-        try{
-            try{
-            BasicStatefulBusinessLocal object = (BasicStatefulBusinessLocal) getMessageDrivenContext().lookup("stateless/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) getMessageDrivenContext().lookup("stateless/beanReferences/stateful-business-local");
+                Assert.assertNotNull("The EJB BusinessLocal is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupStatefulBusinessRemote() throws TestFailureException{
-        try{
-            try{
-            BasicStatefulBusinessRemote object = (BasicStatefulBusinessRemote) getMessageDrivenContext().lookup("stateless/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) getMessageDrivenContext().lookup("stateless/beanReferences/stateful-business-remote");
+                Assert.assertNotNull("The EJB BusinessRemote is null", object);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
@@ -186,8 +192,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupStringEntry() throws TestFailureException {
         try {
             try {
-                String expected = new String("1");
-                String actual = (String) getMessageDrivenContext().lookup("stateless/references/String");
+                final String expected = "1";
+                final String actual = (String) getMessageDrivenContext().lookup("stateless/references/String");
 
                 Assert.assertNotNull("The String looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -203,8 +209,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupDoubleEntry() throws TestFailureException {
         try {
             try {
-                Double expected = new Double(1.0D);
-                Double actual = (Double) getMessageDrivenContext().lookup("stateless/references/Double");
+                final Double expected = 1.0D;
+                final Double actual = (Double) getMessageDrivenContext().lookup("stateless/references/Double");
 
                 Assert.assertNotNull("The Double looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -220,8 +226,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupLongEntry() throws TestFailureException {
         try {
             try {
-                Long expected = new Long(1L);
-                Long actual = (Long) getMessageDrivenContext().lookup("stateless/references/Long");
+                final Long expected = 1L;
+                final Long actual = (Long) getMessageDrivenContext().lookup("stateless/references/Long");
 
                 Assert.assertNotNull("The Long looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -237,8 +243,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupFloatEntry() throws TestFailureException {
         try {
             try {
-                Float expected = new Float(1.0F);
-                Float actual = (Float) getMessageDrivenContext().lookup("stateless/references/Float");
+                final Float expected = 1.0F;
+                final Float actual = (Float) getMessageDrivenContext().lookup("stateless/references/Float");
 
                 Assert.assertNotNull("The Float looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -254,8 +260,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupIntegerEntry() throws TestFailureException {
         try {
             try {
-                Integer expected = new Integer(1);
-                Integer actual = (Integer) getMessageDrivenContext().lookup("stateless/references/Integer");
+                final Integer expected = 1;
+                final Integer actual = (Integer) getMessageDrivenContext().lookup("stateless/references/Integer");
 
                 Assert.assertNotNull("The Integer looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -271,8 +277,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupShortEntry() throws TestFailureException {
         try {
             try {
-                Short expected = new Short((short) 1);
-                Short actual = (Short) getMessageDrivenContext().lookup("stateless/references/Short");
+                final Short expected = (short) 1;
+                final Short actual = (Short) getMessageDrivenContext().lookup("stateless/references/Short");
 
                 Assert.assertNotNull("The Short looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -288,8 +294,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupBooleanEntry() throws TestFailureException {
         try {
             try {
-                Boolean expected = new Boolean(true);
-                Boolean actual = (Boolean) getMessageDrivenContext().lookup("stateless/references/Boolean");
+                final Boolean expected = true;
+                final Boolean actual = (Boolean) getMessageDrivenContext().lookup("stateless/references/Boolean");
 
                 Assert.assertNotNull("The Boolean looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -305,8 +311,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupByteEntry() throws TestFailureException {
         try {
             try {
-                Byte expected = new Byte((byte) 1);
-                Byte actual = (Byte) getMessageDrivenContext().lookup("stateless/references/Byte");
+                final Byte expected = (byte) 1;
+                final Byte actual = (Byte) getMessageDrivenContext().lookup("stateless/references/Byte");
 
                 Assert.assertNotNull("The Byte looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -322,8 +328,8 @@ public class ContextLookupMdbPojoBean im
     public void lookupCharacterEntry() throws TestFailureException {
         try {
             try {
-                Character expected = new Character('D');
-                Character actual = (Character) getMessageDrivenContext().lookup("stateless/references/Character");
+                final Character expected = 'D';
+                final Character actual = (Character) getMessageDrivenContext().lookup("stateless/references/Character");
 
                 Assert.assertNotNull("The Character looked up is null", actual);
                 Assert.assertEquals(expected, actual);
@@ -339,7 +345,7 @@ public class ContextLookupMdbPojoBean im
     public void lookupResource() throws TestFailureException {
         try {
             try {
-                Object obj = getMessageDrivenContext().lookup("datasource");
+                final Object obj = getMessageDrivenContext().lookup("datasource");
                 Assert.assertNotNull("The DataSource is null", obj);
                 Assert.assertTrue("Not an instance of DataSource", obj instanceof DataSource);
             } catch (Exception e) {
@@ -350,97 +356,97 @@ public class ContextLookupMdbPojoBean im
         }
     }
 
-    public void lookupJMSConnectionFactory() throws TestFailureException{
-        try{
-            try{
+    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);
-                ConnectionFactory connectionFactory = (ConnectionFactory) obj;
+                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);
-                TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) obj;
+                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);
-                QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
+                final QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) obj;
                 testJmsConnection(queueConnectionFactory.createConnection());
-            } catch (Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
-                Assert.fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (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{
-                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 (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
 
-    public void lookupMessageDrivenContext() throws TestFailureException{
-        try{
-            try{
-                InitialContext ctx = new InitialContext();
+    public void lookupMessageDrivenContext() throws TestFailureException {
+        try {
+            try {
+                final InitialContext ctx = new InitialContext();
                 Assert.assertNotNull("The InitialContext is null", ctx);
 
                 // lookup in enc
-                MessageDrivenContext sctx = (MessageDrivenContext)ctx.lookup("java:comp/env/mdbcontext");
-                Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx );
+                final MessageDrivenContext sctx = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
+                Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx);
 
                 // lookup using global name
-                EJBContext ejbCtx = (EJBContext)ctx.lookup("java:comp/EJBContext");
-                Assert.assertNotNull("The MessageDrivenContext 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 MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx);
+            } catch (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (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 (Exception e) {
+                Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
             }
-        } catch (AssertionFailedError afe){
+        } catch (AssertionFailedError afe) {
             throw new TestFailureException(afe);
         }
     }
@@ -449,7 +455,7 @@ public class ContextLookupMdbPojoBean im
      * Set the associated message driven context. The container calls this method
      * after the instance creation.
      */
-    public MessageDrivenContext getMessageDrivenContext() throws EJBException, RemoteException {
+    public MessageDrivenContext getMessageDrivenContext() throws EJBException {
         MessageDrivenContext ejbContext = null;
         try {
             ejbContext = (MessageDrivenContext) new InitialContext().lookup("java:comp/EJBContext");



Mime
View raw message