You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/03/05 18:59:13 UTC

svn commit: r514750 [2/2] - in /incubator/openejb/trunk/openejb3: assembly/openejb-standalone/src/main/resources/ container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/config/...

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java?view=diff&rev=514750&r1=514749&r2=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbBean.java Mon Mar  5 09:59:11 2007
@@ -16,32 +16,235 @@
  */
 package org.apache.openejb.test.mdb;
 
+import org.apache.openejb.test.ApplicationException;
+import org.apache.openejb.test.object.OperationsPolicy;
+
 import javax.ejb.EJBException;
 import javax.ejb.MessageDrivenBean;
 import javax.ejb.MessageDrivenContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import java.util.Hashtable;
+import java.util.Properties;
+
+/**
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class BasicMdbBean implements BasicMdbObject, MessageDrivenBean, MessageListener {
+	private MessageDrivenContext mdbContext = null;
+    private Hashtable allowedOperationsTable = new Hashtable();
+    protected MdbInvoker mdbInvoker;
+
+
+    public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
+        this.mdbContext = ctx;
+        testAllowedOperations("setMessageDrivenContext");
+        try {
+            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) {
+        try {
+//            System.out.println("\n" +
+//                    "***************************************\n" +
+//                    "Got message: " + message + "\n" +
+//                    "***************************************\n\n");
+            try {
+                message.acknowledge();
+            } catch (JMSException e) {
+                e.printStackTrace();
+            }
+            mdbInvoker.onMessage(message);
+        } catch (Throwable e) {
+            e.printStackTrace();  
+        }
+    }
+
+    //=============================
+    // Home interface methods
+    //
+    //
+    // Home interface methods
+    //=============================
+
+
+    //=============================
+    // Remote interface methods
+    //
+
+    /**
+     * Maps to BasicStatelessObject.businessMethod
+     */
+    public String businessMethod(String text){
+        testAllowedOperations("businessMethod");
+        StringBuffer b = new StringBuffer(text);
+        return b.reverse().toString();
+    }
+
+
+    /**
+     * Throws an ApplicationException when invoked
+     *
+     */
+    public void throwApplicationException() throws ApplicationException{
+        throw new ApplicationException("Testing ability to throw Application Exceptions");
+    }
+
+    /**
+     * Throws a java.lang.NullPointerException when invoked
+     * This is a system exception and should result in the
+     * destruction of the instance and invalidation of the
+     * remote reference.
+     *
+     */
+    public void throwSystemException_NullPointer() {
+        throw new NullPointerException("Testing ability to throw System Exceptions");
+    }
+
+    /**
+     * Maps to BasicStatelessObject.getPermissionsReport
+     *
+     * Returns a report of the bean's
+     * runtime permissions
+     *
+     * @return
+     */
+    public Properties getPermissionsReport(){
+        /* TO DO: */
+        return null;
+    }
+
+    /**
+     * Maps to BasicStatelessObject.getAllowedOperationsReport
+     *
+     * 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){
+        return (OperationsPolicy) allowedOperationsTable.get(methodName);
+    }
+
+    //
+    // Remote interface methods
+    //=============================
+
+
+    //================================
+    // MessageDrivenBean interface methods
+    //
+
+    /**
+     * A container invokes this method before it ends the life of the session
+     * object. This happens as a result of a client's invoking a remove
+     * operation, or when a container decides to terminate the session object
+     * after a timeout.
+     */
+    public void ejbRemove() throws EJBException {
+        testAllowedOperations("ejbRemove");
+    }
+
+    //
+    // SessionBean interface methods
+    //================================
+
+	protected void testAllowedOperations(String methodName) {
+		OperationsPolicy policy = new OperationsPolicy();
+
+		/*[0] Test getEJBHome /////////////////*/
+		try {
+			mdbContext.getEJBHome();
+			policy.allow(policy.Context_getEJBHome);
+		} catch (IllegalStateException ise) {
+		}
+
+		/*[1] Test getCallerPrincipal /////////*/
+		try {
+			mdbContext.getCallerPrincipal();
+			policy.allow( policy.Context_getCallerPrincipal );
+		} catch (IllegalStateException ise) {
+		}
+
+		/*[2] Test isCallerInRole /////////////*/
+		try {
+			mdbContext.isCallerInRole("ROLE");
+			policy.allow( policy.Context_isCallerInRole );
+		} catch (IllegalStateException ise) {
+		}
+
+		/*[3] Test getRollbackOnly ////////////*/
+		try {
+			mdbContext.getRollbackOnly();
+			policy.allow( policy.Context_getRollbackOnly );
+		} catch (IllegalStateException ise) {
+		}
+
+		/*[4] Test setRollbackOnly ////////////*/
+        // Rollback causes message redelivery
+
+		/*[5] Test getUserTransaction /////////*/
+		try {
+			mdbContext.getUserTransaction();
+			policy.allow( policy.Context_getUserTransaction );
+		} catch (IllegalStateException ise) {
+		}
+
+		/*[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( policy.JNDI_access_to_java_comp_env );
+		} catch (IllegalStateException ise) {
+		} catch (javax.naming.NamingException ne) {
+		}
+
+		/*[9] Test Resource_manager_access ///////////////*/
+		try {
+			InitialContext jndiContext = new InitialContext( );
+
+			DataSource ds = (DataSource)jndiContext.lookup("java:comp/env/stateless/references/Resource_manager_access");
+
+			policy.allow( policy.Resource_manager_access );
+		} catch (IllegalStateException ise) {
+		} catch (javax.naming.NamingException ne) {
+		}
+
+		/*[10] Test Enterprise_bean_access ///////////////*/
+		try {
+			InitialContext jndiContext = new InitialContext( );
+
+			Object obj = jndiContext.lookup("java:comp/env/stateless/beanReferences/Enterprise_bean_access");
+
+			policy.allow( policy.Enterprise_bean_access );
+		} catch (IllegalStateException ise) {
+		} catch (javax.naming.NamingException ne) {
+		}
 
-import junit.framework.Assert;
-
-public class BasicMdbBean implements MessageDrivenBean, MessageListener {
-
-	MessageDrivenContext ctx = null;
-	
-	
-	public void ejbRemove() throws EJBException {
-		// TODO Auto-generated method stub
-
-	}
-
-	public void setMessageDrivenContext(MessageDrivenContext ctx)
-			throws EJBException {
-		this.ctx = ctx;
-	}
-
-	public void onMessage(Message msg) {
-		Assert.assertNotNull("The MessageDrivenContext is null", ctx );
-		
+		allowedOperationsTable.put(methodName, policy);
 	}
 
 }

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbObject.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbObject.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbObject.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/BasicMdbObject.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,64 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import org.apache.openejb.test.ApplicationException;
+import org.apache.openejb.test.object.OperationsPolicy;
+
+import java.util.Properties;
+
+public interface BasicMdbObject {
+    /**
+     * Reverses the string passed in then returns it
+     *
+     * @return string
+     */
+    String businessMethod(String text);
+
+    /**
+     * Throws an ApplicationException when invoked
+     *
+     */
+    void throwApplicationException() throws ApplicationException;
+
+    /**
+     * Throws a java.lang.NullPointerException when invoked
+     * This is a system exception and should result in the
+     * destruction of the instance and invalidation of the
+     * remote reference.
+     *
+     */
+    void throwSystemException_NullPointer();
+
+    /**
+     * Returns a report of the bean's
+     * runtime permissions
+     *
+     * @return properties
+     */
+    Properties getPermissionsReport();
+
+    /**
+     * 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 operations policy
+     */
+    OperationsPolicy getAllowedOperationsReport(String methodName);
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbInvoker.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,132 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+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.ObjectMessage;
+import javax.jms.Session;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class MdbInvoker implements MessageListener {
+    private final Map<String, Method> signatures = new TreeMap<String, Method>();
+    private final Object target;
+    private Connection connection;
+    private Session session;
+
+    public MdbInvoker(ConnectionFactory connectionFactory, Object target) throws JMSException {
+        this.target = target;
+        connection = connectionFactory.createConnection();
+        connection.start();
+
+        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        for (Method method : target.getClass().getMethods()) {
+            String signature = MdbUtil.getSignature(method);
+            signatures.put(signature, method);
+        }
+    }
+
+    public synchronized void destroy() {
+        MdbUtil.close(session);
+        session = null;
+        MdbUtil.close(connection);
+        connection = null;
+    }
+
+    private synchronized Session getSession() {
+        return session;
+    }
+
+    public void onMessage(Message message) {
+        if (!(message instanceof ObjectMessage)) return;
+
+        try {
+            Session session = getSession();
+            if (session == null) throw new IllegalStateException("Invoker has been destroyed");
+
+            if (message == null) throw new NullPointerException("request message is null");
+            if (!(message instanceof ObjectMessage)) throw new IllegalArgumentException("Expected a ObjectMessage request but got a " + message.getClass().getName());
+            ObjectMessage responseMessage = (ObjectMessage) message;
+            Serializable object = responseMessage.getObject();
+            if (object == null) throw new NullPointerException("object in ObjectMessage is null");
+            if (!(object instanceof Map)) {
+                if (message instanceof ObjectMessage) throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage request but got a " + object.getClass().getName());
+            }
+            Map request = (Map) object;
+
+            String signature = (String) request.get("method");
+            if (signature == null) throw new NullPointerException("method property is null");
+            Method method = signatures.get(signature);
+            if (method == null) throw new IllegalArgumentException("no such method " + method + "; known methods are " + signatures.keySet());
+            Object[] args = (Object[]) request.get("args");
+
+            boolean exception = false;
+            Object result = null;
+            try {
+                result = method.invoke(target, args);
+            } catch (IllegalAccessException e) {
+                result = e;
+                exception = true;
+            } catch (InvocationTargetException e) {
+                result = e.getCause();
+                if (result == null) result = e;
+                exception = true;
+            }
+
+            MessageProducer producer = null;
+            try {
+                // create response
+                Map<String, Object> response = new TreeMap<String, Object>();
+                if (exception) {
+                    response.put("exception", "true");
+                }
+                response.put("return", result);
+
+                // create response message
+                ObjectMessage resMessage = session.createObjectMessage();
+                resMessage.setJMSCorrelationID(responseMessage.getJMSCorrelationID());
+                resMessage.setObject((Serializable) response);
+
+                // send response message
+                producer = session.createProducer(responseMessage.getJMSReplyTo());
+                producer.send(resMessage);
+//                System.out.println("\n" +
+//                        "***************************************\n" +
+//                        "Sent response message: " + responseMessage + "\n" +
+//                        "         response map: " + response + "\n" +
+//                        "             to queue: " + message.getJMSReplyTo() + "\n" +
+//                        "***************************************\n\n");
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                MdbUtil.close(producer);
+            }
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbProxy.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,168 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.Destination;
+import javax.jms.DeliveryMode;
+import javax.jms.ObjectMessage;
+import javax.jms.MessageConsumer;
+import javax.jms.Message;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
+import java.io.Serializable;
+
+public class MdbProxy {
+    @SuppressWarnings({"unchecked"})
+    public static <T> T newProxyInstance(Class<T> type, ConnectionFactory connectionFactory, String requestQueueName) throws JMSException {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader == null) classLoader = type.getClassLoader();
+        if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader();
+
+        InvocationHandler invocationHandler = new MdbInvocationHandler(connectionFactory, requestQueueName);
+        Object proxy = Proxy.newProxyInstance(classLoader, new Class[]{type}, invocationHandler);
+        return (T) proxy;
+    }
+
+    public static void destroyProxy(Object proxy) {
+        InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+        if (handler instanceof MdbProxy) {
+            MdbInvocationHandler mdbInvocationHandler = (MdbInvocationHandler) handler;
+            mdbInvocationHandler.destroy();
+        }
+    }
+
+    private static class MdbInvocationHandler implements InvocationHandler {
+        private static final int MAX_RESPONSE_WAIT = 1000;
+        private Connection connection;
+        private Session session;
+        private MessageProducer producer;
+        private Destination requestQueue;
+
+        public MdbInvocationHandler(ConnectionFactory connectionFactory, String requestQueueName) throws JMSException {
+            // open a connection
+            connection = connectionFactory.createConnection();
+            connection.start();
+
+            // create a session
+            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            // create the request queue
+            requestQueue = session.createQueue(requestQueueName);
+
+            // create a producer which is used to send requests
+            producer = session.createProducer(requestQueue);
+            producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+        }
+
+        public synchronized void destroy() {
+            MdbUtil.close(producer);
+            producer = null;
+            MdbUtil.close(session);
+            session = null;
+            MdbUtil.close(connection);
+            connection = null;
+        }
+
+        private synchronized Session getSession() {
+            return session;
+        }
+
+        public synchronized MessageProducer getProducer() {
+            return producer;
+        }
+
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            Session session = getSession();
+            if (session == null) throw new IllegalStateException("Proxy has been destroyed");
+
+            // create request
+            Map<String,Object> request = new TreeMap<String,Object>();
+            String signature = MdbUtil.getSignature(method);
+            request.put("method", signature);
+            request.put("args", args);
+
+            // create a new temp response queue and consumer
+            // this is very inefficient, but eliminates a whole class of errors
+            Destination responseQueue = session.createTemporaryQueue();
+
+            // Create a messages
+            ObjectMessage requestMessage = session.createObjectMessage();
+            requestMessage.setJMSReplyTo(responseQueue);
+            String correlationId = UUID.randomUUID().toString();
+            requestMessage.setJMSCorrelationID(correlationId);
+            requestMessage.setObject((Serializable) request);
+
+
+            // create a producer and consumers used to send requests and receive response
+            MessageConsumer consumer = null;
+            try {
+                // Send the request
+                getProducer().send(requestMessage);
+
+//                System.out.println("\n" + "***************************************\n" +
+//                        "Sent request message: " + requestMessage + "\n" +
+//                        "         request map: " + request + "\n" +
+//                        "            to queue: " + requestQueue + "\n" +
+//                        "***************************************\n\n");
+//
+                // Wait for a message
+                // Again this is quite inefficient
+                consumer = session.createConsumer(responseQueue);
+
+                // wait for the message
+                Message message = consumer.receive(MdbProxy.MdbInvocationHandler.MAX_RESPONSE_WAIT);
+
+                // verify message
+                if (message == null) throw new NullPointerException("message is null");
+                if (!correlationId.equals(message.getJMSCorrelationID())) {
+                    throw new IllegalStateException("Recieved a response message with the wrong correlation id");
+                }
+                if (!(message instanceof ObjectMessage)) throw new IllegalArgumentException("Expected a ObjectMessage response but got a " + message.getClass().getName());
+                ObjectMessage resMessage = (ObjectMessage) message;
+                Serializable object = resMessage.getObject();
+                if (object == null) throw new NullPointerException("object in ObjectMessage is null");
+                if (!(object instanceof Map)) {
+                    if (message instanceof ObjectMessage) throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage response but got a " + object.getClass().getName());
+                }
+                Map response = (Map) object;
+
+                // process results
+                boolean exception = response.containsKey("exception");
+                Object returnValue = response.get("return");
+                if (exception) {
+                    throw (Throwable) returnValue;
+                }
+                return returnValue;
+            } finally {
+                MdbUtil.close(consumer);
+            }
+        }
+    }
+
+    private MdbProxy() {
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/java/org/apache/openejb/test/mdb/MdbUtil.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,78 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import javax.jms.MessageProducer;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.jms.Connection;
+import java.lang.reflect.Method;
+
+public class MdbUtil {
+    public static String getSignature(Method method){
+        StringBuilder builder = new StringBuilder();
+        builder.append(method.getName()).append("(");
+        boolean first = true;
+        for (Class<?> type : method.getParameterTypes()) {
+            if (!first) {
+                builder.append(",");
+            }
+            builder.append(type.getName());
+            first = false;
+        }
+        builder.append(")");
+        return builder.toString();
+    }
+
+    public static void close(MessageProducer closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (JMSException e) {
+            }
+        }
+    }
+
+    public static void close(MessageConsumer closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (JMSException e) {
+            }
+        }
+    }
+
+    public static void close(Session closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (JMSException e) {
+            }
+        }
+    }
+
+    public static void close(Connection closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (JMSException e) {
+            }
+        }
+    }
+}

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=514750&r1=514749&r2=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/ejb-jar.xml Mon Mar  5 09:59:11 2007
@@ -3596,13 +3596,18 @@
       <messaging-type>javax.jms.MessageListener</messaging-type>
       <transaction-type>Container</transaction-type>
       <message-destination-type>javax.jms.Queue</message-destination-type>
-      <message-destination-link>SendReceiveQueue</message-destination-link>
+      <message-destination-link>request</message-destination-link>
       <activation-config>
         <activation-config-property>
           <activation-config-property-name>destination</activation-config-property-name>
-          <activation-config-property-value>SendReceiveQueue</activation-config-property-value>
+          <activation-config-property-value>request</activation-config-property-value>
         </activation-config-property>
       </activation-config>
+      <resource-ref>
+        <res-ref-name>jms</res-ref-name>
+        <res-type>javax.jms.ConnectionFactory</res-type>
+        <res-auth>Container</res-auth>
+      </resource-ref>
     </message-driven>
   </enterprise-beans>
 

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/pom.xml?view=diff&rev=514750&r1=514749&r2=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/pom.xml (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/pom.xml Mon Mar  5 09:59:11 2007
@@ -53,6 +53,10 @@
       <version>${version}</version>
     </dependency>
     <dependency>
+        <groupId>org.apache.activemq</groupId>
+        <artifactId>activemq-core</artifactId>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqTestJms.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqTestJms.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqTestJms.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/ActiveMqTestJms.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,32 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+import javax.jms.ConnectionFactory;
+import java.util.Properties;
+
+public class ActiveMqTestJms implements TestJms {
+    public void init(Properties props) {
+    }
+
+    public ConnectionFactory getConnectionFactory() {
+        return new ActiveMQConnectionFactory();
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestJms.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestJms.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestJms.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestJms.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,26 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test;
+
+import javax.jms.ConnectionFactory;
+import java.util.Properties;
+
+public interface TestJms {
+    void init(Properties props);
+    ConnectionFactory getConnectionFactory();
+}

Modified: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java?view=diff&rev=514750&r1=514749&r2=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java (original)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/TestManager.java Mon Mar  5 09:59:11 2007
@@ -19,6 +19,8 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.Properties;
+import java.security.PrivilegedAction;
+import java.security.AccessController;
 
 /**
  * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
@@ -29,6 +31,7 @@
     
     private static TestServer server;
     private static TestDatabase database;
+    private static TestJms jms;
     private static boolean warn = true;
 
     public static void init(String propertiesFileName) throws Exception{
@@ -59,6 +62,7 @@
         }
         initServer(props);
         initDatabase(props);
+        initJms(props);
     }
     
     public static void start() throws Exception{
@@ -108,8 +112,8 @@
     }
 
     private static ClassLoader getContextClassLoader() {
-        return (ClassLoader) java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
-            public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run() {
                 return Thread.currentThread().getContextClassLoader();
             }
         });
@@ -145,6 +149,20 @@
         }
     }
 
+    private static void initJms(Properties props){
+        try{
+            String className = props.getProperty("openejb.test.jms");
+            if (className == null) className = "org.apache.openejb.test.ActiveMqTestJms";
+            ClassLoader cl = getContextClassLoader();
+            Class<?> testJmsClass = Class.forName( className , true, cl);
+            jms = (TestJms)testJmsClass.newInstance();
+            jms.init( props );
+        } catch (Exception e){
+            if (warn) System.out.println("Cannot instantiate or initialize the test jms: "+e.getClass().getName()+" "+e.getMessage());
+            throw new RuntimeException("Cannot instantiate or initialize the test jms: "+e.getClass().getName()+" "+e.getMessage(),e);
+        }
+    }
+
 
     public static TestServer getServer(){
         return server;
@@ -153,7 +171,11 @@
     public static TestDatabase getDatabase(){
         return database;
     }
-    
+
+    public static TestJms getJms() {
+        return jms;
+    }
+
     public static Properties getContextEnvironment(){
         return server.getContextEnvironment();
     }

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTestClient.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTestClient.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTestClient.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTestClient.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,31 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+public abstract class BasicMdbTestClient extends MdbTestClient {
+    protected BasicMdbObject basicMdbObject;
+
+    public BasicMdbTestClient(String name){
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        basicMdbObject = MdbProxy.newProxyInstance(BasicMdbObject.class, connectionFactory, "request");
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/BasicMdbTests.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,115 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+/**
+ * [5] Should be run as the fifth test suite of the BasicStatelessTestClients
+ *
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public class BasicMdbTests extends BasicMdbTestClient {
+
+    public BasicMdbTests(){
+        super("BasicMdb.");
+    }
+
+    //=================================
+    // Test remote interface methods
+    //
+    public void test01_businessMethod(){
+        try{
+            String expected = "Success";
+            String actual = basicMdbObject.businessMethod("sseccuS");
+            assertEquals(expected, actual);
+        } catch (Exception e){
+            e.printStackTrace();
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    /**
+     * Throw an application exception and make sure the exception
+     * reaches the bean nicely.
+     */
+    public void Xtest02_throwApplicationException(){
+        try{
+            basicMdbObject.throwApplicationException();
+        } catch (org.apache.openejb.test.ApplicationException e){
+            //Good.  This is the correct behaviour
+            return;
+        } catch (Throwable e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+        fail("An ApplicationException should have been thrown.");
+    }
+
+    /**
+     * After an application exception we should still be able to
+     * use our bean
+     */
+    public void test03_invokeAfterApplicationException(){
+        try{
+        String expected = "Success";
+        String actual   = basicMdbObject.businessMethod("sseccuS");
+        assertEquals(expected, actual);
+        } catch (Throwable e){
+            e.printStackTrace();
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+
+    public void Xtest04_throwSystemException(){
+        try{
+            basicMdbObject.throwSystemException_NullPointer();
+        } catch (Exception e){
+            //Good, so far.
+            Throwable n = e.getCause();
+            assertNotNull("Nested exception should not be is null", n );
+            assertTrue("Nested exception should be an instance of NullPointerException, but exception is "+n.getClass().getName(), (n instanceof NullPointerException));
+            return;
+        } catch (Throwable e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+        fail("A NullPointerException should have been thrown.");
+    }
+
+    /**
+     * After a system exception the intance should be garbage collected
+     * and the remote reference should be invalidated.
+     *
+     * This one seems to fail. we should double-check the spec on this.
+     */
+    public void TODO_test05_invokeAfterSystemException(){
+        try{
+        basicMdbObject.businessMethod("This refernce is invalid");
+        fail("A java.rmi.NoSuchObjectException should have been thrown.");
+        } catch (Exception e){
+            // Good.
+        } catch (Throwable e){
+            fail("Received Exception "+e.getClass()+ " : "+e.getMessage());
+        }
+    }
+    //
+    // Test remote interface methods
+    //=================================
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbConnectionFactoryTests.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,113 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class MdbConnectionFactoryTests extends BasicMdbTestClient {
+    public MdbConnectionFactoryTests() {
+        super("ConnectionFactory.");
+    }
+
+    public void test01_createConnection() throws Exception {
+        Connection connection = createConnection();
+        try {
+            assertNotNull("Jms connection is null.", connection);
+        } finally {
+            MdbUtil.close(connection);
+        }
+    }
+
+    public void test02_directRpc() throws Exception {
+        Connection connection = createConnection();
+        Session session = null;
+        MessageProducer producer = null;
+        MessageConsumer consumer = null;
+        try {
+
+            // create request
+            Map<String, Object> request = new TreeMap<String, Object>();
+            request.put("method", "businessMethod(java.lang.String)");
+            request.put("args", new Object[]{"cheese"});
+
+            // initialize session
+            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            Destination requestQueue = session.createQueue("request");
+            Destination responseQueue = session.createTemporaryQueue();
+//            Destination responseQueue = session.createQueue("blah");
+
+            // Create a request messages
+            ObjectMessage requestMessage = session.createObjectMessage();
+            requestMessage.setJMSReplyTo(responseQueue);
+            requestMessage.setObject((Serializable) request);
+
+            // Send the request message
+            producer = session.createProducer(requestQueue);
+            producer.send(requestMessage);
+
+//            System.out.println("\n" + "***************************************\n" +
+//                    "Sent request message: " + requestMessage + "\n" +
+//                    "         request map: " + request + "\n" +
+//                    "            to queue: " + requestQueue + "\n" +
+//                    "***************************************\n\n");
+
+            // create consumer
+            consumer = session.createConsumer(responseQueue);
+//            System.out.println("\n" + "***************************************\n" +
+//                    "Listening for response at : " + responseQueue + "\n" +
+//                    "***************************************\n\n");
+
+            // wait for response mesage
+            Message message = consumer.receive(1000);
+
+            // verify message
+            assertNotNull("Did not get a response message", message);
+            assertTrue("Response message is not an ObjectMessage", message instanceof ObjectMessage);
+            ObjectMessage responseMessage = (ObjectMessage) message;
+            Serializable object = responseMessage.getObject();
+            assertNotNull("Response ObjectMessage contains a null object");
+            assertTrue("Response ObjectMessage does not contain an instance of Map", object instanceof Map);
+            Map response = (Map) object;
+
+            // process results
+            if (response.containsKey("exception")) {
+                throw (Exception) response.get("return");
+            }
+            String returnValue = (String) response.get("return");
+            assertEquals("eseehc", returnValue);
+        } finally {
+            MdbUtil.close(producer);
+            MdbUtil.close(session);
+            MdbUtil.close(connection);
+        }
+    }
+
+    public void test03_proxy() throws Exception {
+        String returnValue = basicMdbObject.businessMethod("blah");
+        assertEquals("halb", returnValue);
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestClient.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestClient.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestClient.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestClient.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,51 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import org.apache.openejb.test.TestManager;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+/**
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ */
+public abstract class MdbTestClient extends org.apache.openejb.test.NamedTestCase {
+    protected ConnectionFactory connectionFactory;
+
+
+    public MdbTestClient(String name) {
+        super("Stateless." + name);
+    }
+
+    /**
+     * Sets up the fixture, for example, open a network connection.
+     * This method is called before a test is executed.
+     */
+    protected void setUp() throws Exception {
+        connectionFactory = TestManager.getJms().getConnectionFactory();
+    }
+
+    protected Connection createConnection() throws JMSException {
+        Connection connection = connectionFactory.createConnection();
+        connection.start();
+        return connection;
+    }
+}

Added: incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java?view=auto&rev=514750
==============================================================================
--- incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java (added)
+++ incubator/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/mdb/MdbTestSuite.java Mon Mar  5 09:59:11 2007
@@ -0,0 +1,72 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.test.mdb;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
+ * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
+ *
+ * @version $Rev: 499359 $ $Date: 2007-01-24 03:19:37 -0800 (Wed, 24 Jan 2007) $
+ */
+public class MdbTestSuite extends junit.framework.TestCase {
+    public MdbTestSuite(String name){
+        super(name);
+    }
+
+    public static junit.framework.Test suite() {
+        TestSuite suite = new TestSuite();
+        suite.addTest(new MdbConnectionFactoryTests());
+//        suite.addTest(new BasicMdbTests());
+//        suite.addTest(new StatelessPojoRemoteJndiTests());
+//        suite.addTest(new StatelessHomeIntfcTests());
+//        suite.addTest(new StatelessPojoHomeIntfcTests());
+//        suite.addTest(new StatelessRemoteBusinessIntfcTests());
+//        suite.addTest(new StatelessEjbHomeTests() );
+//        suite.addTest(new StatelessPojoEjbHomeTests() );
+//        suite.addTest(new StatelessEjbObjectTests());
+//        suite.addTest(new StatelessPojoEjbObjectTests());
+//        suite.addTest(new StatelessRemoteIntfcTests());
+//        suite.addTest(new StatelessPojoRemoteIntrfcTests());
+//        suite.addTest(new StatelessHomeHandleTests());
+//        suite.addTest(new StatelessPojoHomeHandleTests());
+//        suite.addTest(new StatelessHandleTests());
+//        suite.addTest(new StatelessPojoHandleTests());
+//        suite.addTest(new StatelessEjbMetaDataTests());
+//        suite.addTest(new StatelessPojoEjbMetaDataTests());
+//        suite.addTest(new StatelessAllowedOperationsTests());
+//        suite.addTest(new BMTStatelessAllowedOperationsTests());
+//        suite.addTest(new StatelessBeanTxTests());
+//        suite.addTest(new StatelessJndiEncTests());
+//        suite.addTest(new StatelessContextLookupTests());
+//        suite.addTest(new StatelessPojoContextLookupTests());
+//        suite.addTest(new StatelessFieldInjectionTests());
+//        suite.addTest(new StatelessSetterInjectionTests());
+//        suite.addTest(new StatelessAnnotatedFieldInjectionTests());
+//        suite.addTest(new StatelessRmiIiopTests());
+//        suite.addTest(new MiscEjbTests());
+//        /* TO DO
+//        suite.addTest(new StatelessEjbContextTests());
+//        suite.addTest(new BMTStatelessEjbContextTests());
+//        suite.addTest(new BMTStatelessEncTests());
+//        suite.addTest(new StatelessContainerManagedTransactionTests());
+//        */
+        return suite;
+    }
+}