You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by tv...@apache.org on 2018/01/18 15:44:10 UTC

[22/50] tomee git commit: Demonstrate a resource adapter that does not make any attempt whatsoever to pool endpoints

Demonstrate a resource adapter that does not make any attempt whatsoever to pool endpoints


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/dab7b791
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/dab7b791
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/dab7b791

Branch: refs/heads/master
Commit: dab7b791b87c1a46370e977f6b1e45693cdc7c09
Parents: e6dcfc3
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Tue Dec 19 13:37:12 2017 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Tue Dec 19 13:37:12 2017 +0000

----------------------------------------------------------------------
 .../core/mdb/PoolEndpointHandlerTest.java       |  74 +++++-----
 .../core/mdb/connector/api/InboundListener.java |  24 ++++
 .../mdb/connector/api/SampleConnection.java     |  26 ++++
 .../connector/api/SampleConnectionFactory.java  |  28 ++++
 .../connector/impl/SampleActivationSpec.java    |  54 ++++++++
 .../impl/SampleConnectionFactoryImpl.java       |  69 ++++++++++
 .../connector/impl/SampleConnectionImpl.java    |  44 ++++++
 .../connector/impl/SampleManagedConnection.java | 134 +++++++++++++++++++
 .../impl/SampleManagedConnectionFactory.java    |  99 ++++++++++++++
 .../impl/SampleManagedConnectionMetaData.java   |  56 ++++++++
 .../connector/impl/SampleResourceAdapter.java   | 117 ++++++++++++++++
 11 files changed, 683 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/PoolEndpointHandlerTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/PoolEndpointHandlerTest.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/PoolEndpointHandlerTest.java
index a716ef4..f5e36e5 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/PoolEndpointHandlerTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/PoolEndpointHandlerTest.java
@@ -16,6 +16,12 @@
  */
 package org.apache.openejb.core.mdb;
 
+import org.apache.openejb.core.mdb.connector.api.InboundListener;
+import org.apache.openejb.core.mdb.connector.api.SampleConnection;
+import org.apache.openejb.core.mdb.connector.api.SampleConnectionFactory;
+import org.apache.openejb.core.mdb.connector.impl.SampleActivationSpec;
+import org.apache.openejb.core.mdb.connector.impl.SampleManagedConnectionFactory;
+import org.apache.openejb.core.mdb.connector.impl.SampleResourceAdapter;
 import org.apache.openejb.jee.MessageDrivenBean;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.monitoring.LocalMBeanServer;
@@ -30,15 +36,7 @@ import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import javax.ejb.ActivationConfigProperty;
 import javax.ejb.MessageDriven;
-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.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
 import javax.management.ObjectName;
 import java.util.List;
 import java.util.Properties;
@@ -60,19 +58,18 @@ public class PoolEndpointHandlerTest {
     public Properties config() {
         return new PropertiesBuilder()
 
-                .p("amq", "new://Resource?type=ActiveMQResourceAdapter")
-                .p("amq.DataSource", "")
-                .p("amq.BrokerXmlConfig", "broker:(vm://localhost)")
+            .p("sra", "new://Resource?class-name=" + SampleResourceAdapter.class.getName())
 
-                .p("target", "new://Resource?type=Queue")
+            .p("mdbs", "new://Container?type=MESSAGE")
+            .p("mdbs.ResourceAdapter", "sra")
+            .p("mdbs.pool", "false")
+            .p("mdbs.ActivationSpecClass", SampleActivationSpec.class.getName())
+            .p("mdbs.MessageListenerInterface", InboundListener.class.getName())
 
-                .p("mdbs", "new://Container?type=MESSAGE")
-                .p("mdbs.ResourceAdapter", "amq")
-                .p("mdbs.pool", "true")
-
-                .p("cf", "new://Resource?type=" + ConnectionFactory.class.getName())
-                .p("cf.ResourceAdapter", "amq")
-                .build();
+            .p("cf", "new://Resource?type=" + SampleConnectionFactory.class.getName() + "&class-name=" + SampleManagedConnectionFactory.class.getName())
+            .p("cf.ResourceAdapter", "sra")
+            .p("cf.TransactionSupport", "none")
+            .build();
     }
 
     @Module
@@ -84,7 +81,7 @@ public class PoolEndpointHandlerTest {
     private Queue destination;
 
     @Resource(name = "cf")
-    private ConnectionFactory cf;
+    private SampleConnectionFactory cf;
 
     @Before
     public void resetLatch() {
@@ -95,12 +92,10 @@ public class PoolEndpointHandlerTest {
     public void shouldSendMessage() throws Exception {
         assertNotNull(cf);
 
-        for (int i = 0; i < 1_000; i++) {
-            final Connection connection = cf.createConnection();
+        for (int i = 0; i < 100; i++) {
+            final SampleConnection connection = cf.getConnection();
             try {
-                final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-                final MessageProducer producer = session.createProducer(destination);
-                producer.send(session.createTextMessage(TEXT));
+                connection.sendMessage(TEXT);
             } finally {
                 connection.close();
             }
@@ -120,12 +115,10 @@ public class PoolEndpointHandlerTest {
     }
 
     @MessageDriven(activationConfig = {
-            @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
-            @ActivationConfigProperty(propertyName = "destination", propertyValue = "target"),
             @ActivationConfigProperty(propertyName = "DeliveryActive", propertyValue = "false"),
             @ActivationConfigProperty(propertyName = "MdbJMXControl", propertyValue = "default:type=test")
     })
-    public static class Listener implements MessageListener {
+    public static class Listener implements InboundListener {
         public static CountDownLatch latch;
         private static final List<Boolean> BOOLEANS = new CopyOnWriteArrayList<>();
 
@@ -136,21 +129,8 @@ public class PoolEndpointHandlerTest {
             COUNTER.incrementAndGet();
         }
 
-        @Override
-        public void onMessage(final Message message) {
-            try {
-                try {
-                    boolean ok = TextMessage.class.isInstance(message) && TEXT.equals(TextMessage.class.cast(message).getText());
-                    BOOLEANS.add(ok);
-                } catch (final JMSException e) {
-                }
-            } finally {
-                latch.countDown();
-            }
-        }
-
         public static void reset() {
-            latch = new CountDownLatch(1000);
+            latch = new CountDownLatch(100);
             BOOLEANS.clear();
         }
 
@@ -163,6 +143,16 @@ public class PoolEndpointHandlerTest {
             }
             return true;
         }
+
+        @Override
+        public void receiveMessage(String message) {
+            try {
+                boolean ok = TEXT.equals(message);
+                BOOLEANS.add(ok);
+            } finally {
+                latch.countDown();
+            }
+        }
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/InboundListener.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/InboundListener.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/InboundListener.java
new file mode 100644
index 0000000..9988048
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/InboundListener.java
@@ -0,0 +1,24 @@
+/*
+ * 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.core.mdb.connector.api;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public interface InboundListener {
+    public void receiveMessage(final String message);
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnection.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnection.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnection.java
new file mode 100755
index 0000000..7d30e56
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnection.java
@@ -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.core.mdb.connector.api;
+
+public interface SampleConnection {
+    public void sendMessage(final String message);
+
+    public void close();
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnectionFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnectionFactory.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnectionFactory.java
new file mode 100755
index 0000000..77a07f0
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/api/SampleConnectionFactory.java
@@ -0,0 +1,28 @@
+/*
+ * 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.core.mdb.connector.api;
+
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+import java.io.Serializable;
+
+public interface SampleConnectionFactory extends Serializable, Referenceable {
+    public SampleConnection getConnection() throws ResourceException;
+
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleActivationSpec.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleActivationSpec.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleActivationSpec.java
new file mode 100644
index 0000000..17d56a3
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleActivationSpec.java
@@ -0,0 +1,54 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import org.apache.openejb.core.mdb.connector.api.InboundListener;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.Activation;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.InvalidPropertyException;
+import javax.resource.spi.ResourceAdapter;
+
+@Activation(messageListeners = InboundListener.class)
+public class SampleActivationSpec implements ActivationSpec {
+
+    private ResourceAdapter resourceAdapter;
+    private Class beanClass;
+
+    public Class getBeanClass() {
+        return beanClass;
+    }
+
+    public void setBeanClass(Class beanClass) {
+        this.beanClass = beanClass;
+    }
+
+    @Override
+    public void validate() throws InvalidPropertyException {
+    }
+
+    @Override
+    public ResourceAdapter getResourceAdapter() {
+        return resourceAdapter;
+    }
+
+    @Override
+    public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
+        this.resourceAdapter = ra;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionFactoryImpl.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionFactoryImpl.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionFactoryImpl.java
new file mode 100755
index 0000000..e4b3f2d
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionFactoryImpl.java
@@ -0,0 +1,69 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import org.apache.openejb.core.mdb.connector.api.SampleConnection;
+import org.apache.openejb.core.mdb.connector.api.SampleConnectionFactory;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import java.util.logging.Logger;
+
+public class SampleConnectionFactoryImpl implements SampleConnectionFactory {
+    private static final long serialVersionUID = 1L;
+
+    private static Logger log = Logger.getLogger(SampleConnectionFactoryImpl.class.getName());
+
+    private Reference reference;
+
+    private SampleManagedConnectionFactory mcf;
+
+    private ConnectionManager connectionManager;
+
+    public SampleConnectionFactoryImpl() {
+
+    }
+
+    public SampleConnectionFactoryImpl(SampleManagedConnectionFactory mcf, ConnectionManager cxManager) {
+        this.mcf = mcf;
+        this.connectionManager = cxManager;
+    }
+
+    @Override
+    public SampleConnection getConnection() throws ResourceException {
+        log.finest("getConnection()");
+        return (SampleConnection) connectionManager.allocateConnection(mcf, null);
+    }
+
+    @Override
+    public Reference getReference() throws NamingException {
+        log.finest("getReference()");
+        return reference;
+    }
+
+    @Override
+    public void setReference(Reference reference) {
+        log.finest("setReference()");
+        this.reference = reference;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionImpl.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionImpl.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionImpl.java
new file mode 100755
index 0000000..9b7681a
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleConnectionImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import org.apache.openejb.core.mdb.connector.api.SampleConnection;
+
+import java.util.logging.Logger;
+
+public class SampleConnectionImpl implements SampleConnection {
+    private static Logger log = Logger.getLogger(SampleConnectionImpl.class.getName());
+
+    private SampleManagedConnection mc;
+
+    private SampleManagedConnectionFactory mcf;
+
+    public SampleConnectionImpl(SampleManagedConnection mc, SampleManagedConnectionFactory mcf) {
+        this.mc = mc;
+        this.mcf = mcf;
+    }
+
+    public void sendMessage(final String message) {
+        mc.sendMessage(message);
+    }
+
+    public void close() {
+        mc.closeHandle(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnection.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnection.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnection.java
new file mode 100755
index 0000000..97098dd
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnection.java
@@ -0,0 +1,134 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import org.apache.openejb.core.mdb.connector.api.SampleConnection;
+
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.*;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class SampleManagedConnection implements ManagedConnection {
+
+    private static Logger log = Logger.getLogger(SampleManagedConnection.class.getName());
+
+    private PrintWriter logwriter;
+
+    private SampleManagedConnectionFactory mcf;
+
+    private List<ConnectionEventListener> listeners;
+
+    private SampleConnectionImpl connection;
+
+    public SampleManagedConnection(SampleManagedConnectionFactory mcf) {
+        this.mcf = mcf;
+        this.logwriter = null;
+        this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1));
+        this.connection = null;
+    }
+
+    public Object getConnection(Subject subject,
+                                ConnectionRequestInfo cxRequestInfo) throws ResourceException {
+        log.finest("getConnection()");
+        connection = new SampleConnectionImpl(this, mcf);
+        return connection;
+    }
+
+    public void associateConnection(Object connection) throws ResourceException {
+        log.finest("associateConnection()");
+
+        if (connection == null)
+            throw new ResourceException("Null connection handle");
+
+        if (!(connection instanceof SampleConnectionImpl))
+            throw new ResourceException("Wrong connection handle");
+
+        this.connection = (SampleConnectionImpl) connection;
+    }
+
+    public void cleanup() throws ResourceException {
+        log.finest("cleanup()");
+    }
+
+    public void destroy() throws ResourceException {
+        log.finest("destroy()");
+    }
+
+    public void addConnectionEventListener(ConnectionEventListener listener) {
+        log.finest("addConnectionEventListener()");
+
+        if (listener == null) {
+            throw new IllegalArgumentException("Listener is null");
+        }
+
+        listeners.add(listener);
+    }
+
+    public void removeConnectionEventListener(ConnectionEventListener listener) {
+        log.finest("removeConnectionEventListener()");
+        if (listener == null)
+            throw new IllegalArgumentException("Listener is null");
+        listeners.remove(listener);
+    }
+
+    void closeHandle(SampleConnection handle) {
+        ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+        event.setConnectionHandle(handle);
+        for (ConnectionEventListener cel : listeners) {
+            cel.connectionClosed(event);
+        }
+    }
+
+    public PrintWriter getLogWriter() throws ResourceException {
+        log.finest("getLogWriter()");
+        return logwriter;
+    }
+
+    public void setLogWriter(PrintWriter out) throws ResourceException {
+        log.finest("setLogWriter()");
+        logwriter = out;
+    }
+
+    public LocalTransaction getLocalTransaction() throws ResourceException {
+        throw new NotSupportedException("getLocalTransaction() not supported");
+    }
+
+    public XAResource getXAResource() throws ResourceException {
+        throw new NotSupportedException("getXAResource() not supported");
+    }
+
+    public ManagedConnectionMetaData getMetaData() throws ResourceException {
+        log.finest("getMetaData()");
+        return new SampleManagedConnectionMetaData();
+    }
+
+    void sendMessage(final String message) {
+        log.finest("sendMessage()");
+
+        final SampleResourceAdapter resourceAdapter = (SampleResourceAdapter) mcf.getResourceAdapter();
+        resourceAdapter.sendMessage(message);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionFactory.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionFactory.java
new file mode 100755
index 0000000..02acb96
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionFactory.java
@@ -0,0 +1,99 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import org.apache.openejb.core.mdb.connector.api.SampleConnection;
+import org.apache.openejb.core.mdb.connector.api.SampleConnectionFactory;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.*;
+import javax.security.auth.Subject;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.logging.Logger;
+
+@ConnectionDefinition(connectionFactory = SampleConnectionFactory.class,
+        connectionFactoryImpl = SampleConnectionFactoryImpl.class,
+        connection = SampleConnection.class,
+        connectionImpl = SampleConnectionImpl.class)
+public class SampleManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation {
+
+    private static final long serialVersionUID = 1L;
+
+    private static Logger log = Logger.getLogger(SampleManagedConnectionFactory.class.getName());
+
+    private ResourceAdapter ra;
+
+    private PrintWriter logwriter;
+
+    public SampleManagedConnectionFactory() {
+
+    }
+
+    public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException {
+        log.finest("createConnectionFactory()");
+        return new SampleConnectionFactoryImpl(this, cxManager);
+    }
+
+    public Object createConnectionFactory() throws ResourceException {
+        throw new ResourceException("This resource adapter doesn't support non-managed environments");
+    }
+
+    public ManagedConnection createManagedConnection(Subject subject,
+                                                     ConnectionRequestInfo cxRequestInfo) throws ResourceException {
+        log.finest("createManagedConnection()");
+        return new SampleManagedConnection(this);
+    }
+
+    public ManagedConnection matchManagedConnections(Set connectionSet,
+                                                     Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
+        log.finest("matchManagedConnections()");
+        ManagedConnection result = null;
+        Iterator it = connectionSet.iterator();
+        while (result == null && it.hasNext()) {
+            ManagedConnection mc = (ManagedConnection) it.next();
+            if (mc instanceof SampleManagedConnection) {
+                result = mc;
+            }
+
+        }
+        return result;
+    }
+
+    public PrintWriter getLogWriter() throws ResourceException {
+        log.finest("getLogWriter()");
+        return logwriter;
+    }
+
+    public void setLogWriter(PrintWriter out) throws ResourceException {
+        log.finest("setLogWriter()");
+        logwriter = out;
+    }
+
+    public ResourceAdapter getResourceAdapter() {
+        log.finest("getResourceAdapter()");
+        return ra;
+    }
+
+    public void setResourceAdapter(ResourceAdapter ra) {
+        log.finest("setResourceAdapter()");
+        this.ra = ra;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionMetaData.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionMetaData.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionMetaData.java
new file mode 100755
index 0000000..f439fcb
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleManagedConnectionMetaData.java
@@ -0,0 +1,56 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionMetaData;
+import java.util.logging.Logger;
+
+public class SampleManagedConnectionMetaData implements ManagedConnectionMetaData {
+
+    private static Logger log = Logger.getLogger(SampleManagedConnectionMetaData.class.getName());
+
+    public SampleManagedConnectionMetaData() {
+
+    }
+
+    @Override
+    public String getEISProductName() throws ResourceException {
+        log.finest("getEISProductName()");
+        return null; //TODO
+    }
+
+    @Override
+    public String getEISProductVersion() throws ResourceException {
+        log.finest("getEISProductVersion()");
+        return null; //TODO
+    }
+
+    @Override
+    public int getMaxConnections() throws ResourceException {
+        log.finest("getMaxConnections()");
+        return 0; //TODO
+    }
+
+    @Override
+    public String getUserName() throws ResourceException {
+        log.finest("getUserName()");
+        return null; //TODO
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dab7b791/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleResourceAdapter.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleResourceAdapter.java b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleResourceAdapter.java
new file mode 100644
index 0000000..fdf011e
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/connector/impl/SampleResourceAdapter.java
@@ -0,0 +1,117 @@
+/*
+ * 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.core.mdb.connector.impl;
+
+import org.apache.openejb.core.mdb.connector.api.InboundListener;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.Connector;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Connector(description = "Sample Resource Adapter", displayName = "Sample Resource Adapter", eisType = "Sample Resource Adapter", version = "1.0")
+public class SampleResourceAdapter implements ResourceAdapter {
+
+    private final Map<SampleActivationSpec, MessageEndpointFactory> targets = new ConcurrentHashMap<SampleActivationSpec, MessageEndpointFactory>();
+    private final ExecutorService threadPool = Executors.newFixedThreadPool(10);
+
+    public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
+    }
+
+    public void stop() {
+    }
+
+    public void endpointActivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec)
+            throws ResourceException
+    {
+        final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;
+
+        try {
+            targets.put(sampleActivationSpec, messageEndpointFactory);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
+        final SampleActivationSpec sampleActivationSpec = (SampleActivationSpec) activationSpec;
+        targets.remove(sampleActivationSpec);
+        threadPool.shutdownNow();
+    }
+
+    public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
+        return new XAResource[0];
+    }
+
+    public void sendMessage(final String message) {
+        threadPool.submit(new MessageSender(message));
+    }
+
+    public static class EndpointTarget {
+        private final MessageEndpoint messageEndpoint;
+
+        public EndpointTarget(final MessageEndpoint messageEndpoint) {
+            this.messageEndpoint = messageEndpoint;
+        }
+
+        public void invoke(final String message) {
+            ((InboundListener)this.messageEndpoint).receiveMessage(message);
+        }
+    }
+
+    public class MessageSender implements Runnable {
+        private final String message;
+
+        public MessageSender(final String message) {
+            this.message = message;
+        }
+
+        @Override
+        public void run() {
+            while (targets.isEmpty()) {
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                    // ignore
+                }
+            }
+
+            final Collection<MessageEndpointFactory> messageEndpointFactories = targets.values();
+            for (final MessageEndpointFactory messageEndpointFactory : messageEndpointFactories) {
+                try {
+                    final MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
+                    final EndpointTarget endpointTarget = new EndpointTarget(endpoint);
+                    endpointTarget.invoke(message);
+                    endpoint.release();
+                } catch (UnavailableException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+}