You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2012/05/19 05:45:46 UTC

[4/5] DELTASPIKE-175 and DELTASPIKE-178

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedMultiTransactionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedMultiTransactionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedMultiTransactionTest.java
new file mode 100644
index 0000000..eb3b190
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedMultiTransactionTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.multipleinjection.nested;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+public class NestedMultiTransactionTest
+{
+    @Inject
+    private FirstLevelTransactionBean firstLevelTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "nestedMultiTransactionTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(NestedMultiTransactionTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void nestedMultiTransactionTest()
+    {
+        TestEntityManager firstEntityManager = this.entityManagerProducer.getFirstEntityManager();
+        TestEntityManager secondEntityManager = this.entityManagerProducer.getSecondEntityManager();
+
+        Assert.assertNotNull(firstEntityManager);
+        TestEntityTransaction firstTransaction = (TestEntityTransaction) (firstEntityManager).getTransaction();
+
+        Assert.assertEquals(false, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(false, firstTransaction.isStarted());
+        Assert.assertEquals(false, firstTransaction.isCommitted());
+        Assert.assertEquals(false, firstTransaction.isRolledBack());
+
+        Assert.assertNotNull(secondEntityManager);
+        TestEntityTransaction secondTransaction = (TestEntityTransaction) (secondEntityManager).getTransaction();
+
+        Assert.assertEquals(false, secondEntityManager.isFlushed());
+        Assert.assertEquals(false, secondTransaction.isActive());
+        Assert.assertEquals(false, secondTransaction.isStarted());
+        Assert.assertEquals(false, secondTransaction.isCommitted());
+        Assert.assertEquals(false, secondTransaction.isRolledBack());
+
+        this.firstLevelTransactionBean.executeInTransaction();
+
+        Assert.assertEquals(true, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(true, firstTransaction.isStarted());
+        Assert.assertEquals(true, firstTransaction.isCommitted());
+        Assert.assertEquals(false, firstTransaction.isRolledBack());
+
+        Assert.assertEquals(true, secondEntityManager.isFlushed());
+        Assert.assertEquals(false, secondTransaction.isActive());
+        Assert.assertEquals(true, secondTransaction.isStarted());
+        Assert.assertEquals(true, secondTransaction.isCommitted());
+        Assert.assertEquals(false, secondTransaction.isRolledBack());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedTransactionBean.java
new file mode 100644
index 0000000..5ff7d68
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/NestedTransactionBean.java
@@ -0,0 +1,38 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.multipleinjection.nested;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+import org.apache.deltaspike.test.jpa.api.shared.Second;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class NestedTransactionBean
+{
+    @Inject
+    private @Second EntityManager secondEntityManager;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/TestEntityManagerProducer.java
new file mode 100644
index 0000000..ace816b
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/multipleinjection/nested/TestEntityManagerProducer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.multipleinjection.nested;
+
+import org.apache.deltaspike.test.jpa.api.shared.First;
+import org.apache.deltaspike.test.jpa.api.shared.Second;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@RequestScoped
+public class TestEntityManagerProducer
+{
+    private TestEntityManager firstEntityManager = new TestEntityManager();
+
+    private TestEntityManager secondEntityManager = new TestEntityManager();
+
+    @Produces
+    @First
+    protected EntityManager firstEntityManager()
+    {
+        return this.firstEntityManager;
+    }
+
+    @Produces
+    @Second
+    protected EntityManager secondEntityManager()
+    {
+        return this.secondEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    public TestEntityManager getSecondEntityManager()
+    {
+        return secondEntityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/FirstLevelTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/FirstLevelTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/FirstLevelTransactionBean.java
new file mode 100644
index 0000000..78192aa
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/FirstLevelTransactionBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.nested;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class FirstLevelTransactionBean
+{
+    @Inject
+    private @First EntityManager firstEntityManager;
+
+    @Inject
+    private NestedTransactionBean nestedTransactionBean;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+        this.nestedTransactionBean.executeInTransaction();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionBean.java
new file mode 100644
index 0000000..28148a9
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionBean.java
@@ -0,0 +1,38 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.nested;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class NestedTransactionBean
+{
+    @Inject
+    private @First EntityManager firstEntityManager;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionTest.java
new file mode 100644
index 0000000..37f5624
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/NestedTransactionTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.nested;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+public class NestedTransactionTest
+{
+    @Inject
+    private FirstLevelTransactionBean firstLevelTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "nestedTransaction.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(NestedTransactionTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void nestedTransaction()
+    {
+        TestEntityManager firstEntityManager = this.entityManagerProducer.getFirstEntityManager();
+
+        Assert.assertNotNull(firstEntityManager);
+        TestEntityTransaction firstTransaction = (TestEntityTransaction) (firstEntityManager).getTransaction();
+
+        Assert.assertEquals(false, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(false, firstTransaction.isStarted());
+        Assert.assertEquals(false, firstTransaction.isCommitted());
+        Assert.assertEquals(false, firstTransaction.isRolledBack());
+
+        this.firstLevelTransactionBean.executeInTransaction();
+
+        Assert.assertEquals(true, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(true, firstTransaction.isStarted());
+        Assert.assertEquals(true, firstTransaction.isCommitted());
+        Assert.assertEquals(false, firstTransaction.isRolledBack());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/TestEntityManagerProducer.java
new file mode 100644
index 0000000..8b86475
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/nested/TestEntityManagerProducer.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.deltaspike.test.jpa.api.transactional.nested;
+
+import org.apache.deltaspike.test.jpa.api.shared.First;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@RequestScoped
+public class TestEntityManagerProducer
+{
+    private TestEntityManager firstEntityManager = new TestEntityManager();
+
+    @Produces
+    @First
+    protected EntityManager firstEntityManager()
+    {
+        return this.firstEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/Repository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/Repository.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/Repository.java
new file mode 100644
index 0000000..46ae3df
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/Repository.java
@@ -0,0 +1,42 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.stereotype;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+
+//cdi annotations
+@Stereotype
+@Transactional
+@ApplicationScoped
+public @interface Repository
+{
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/StereotypeTransactionalTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/StereotypeTransactionalTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/StereotypeTransactionalTest.java
new file mode 100644
index 0000000..f3b12ff
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/StereotypeTransactionalTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.stereotype;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@RunWith(Arquillian.class)
+public class StereotypeTransactionalTest
+{
+    @Inject
+    private TransactionalBean transactionalBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "stereotypeTransactionalTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(StereotypeTransactionalTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void transactionalBeanViaStereotype()
+    {
+        EntityManager injectedEntityManager = this.entityManagerProducer.getEntityManager();
+
+        Assert.assertNotNull(injectedEntityManager);
+        Assert.assertTrue(injectedEntityManager instanceof TestEntityManager);
+        TestEntityTransaction testTransaction = (TestEntityTransaction) (injectedEntityManager).getTransaction();
+
+        Assert.assertEquals(false, ((TestEntityManager) injectedEntityManager).isFlushed());
+        Assert.assertEquals(false, testTransaction.isActive());
+        Assert.assertEquals(false, testTransaction.isStarted());
+        Assert.assertEquals(false, testTransaction.isCommitted());
+        Assert.assertEquals(false, testTransaction.isRolledBack());
+
+        this.transactionalBean.executeInTransaction();
+
+        Assert.assertEquals(true, ((TestEntityManager) injectedEntityManager).isFlushed());
+        Assert.assertEquals(false, testTransaction.isActive());
+        Assert.assertEquals(true, testTransaction.isStarted());
+        Assert.assertEquals(true, testTransaction.isCommitted());
+        Assert.assertEquals(false, testTransaction.isRolledBack());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TestEntityManagerProducer.java
new file mode 100644
index 0000000..ae47cf2
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TestEntityManagerProducer.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.stereotype;
+
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@RequestScoped
+public class TestEntityManagerProducer
+{
+    private EntityManager entityManager = new TestEntityManager();
+    
+    @Produces
+    protected EntityManager getEntityManager()
+    {
+        return this.entityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TransactionalBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TransactionalBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TransactionalBean.java
new file mode 100644
index 0000000..e34d17b
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/stereotype/TransactionalBean.java
@@ -0,0 +1,33 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactional.stereotype;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@Repository
+public class TransactionalBean
+{
+    @Inject
+    private EntityManager entityManager;
+
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/DefaultTransactionScopedEntityManagerInjectionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/DefaultTransactionScopedEntityManagerInjectionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/DefaultTransactionScopedEntityManagerInjectionTest.java
new file mode 100644
index 0000000..1a80e50
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/DefaultTransactionScopedEntityManagerInjectionTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultinjection;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@RunWith(Arquillian.class)
+public class DefaultTransactionScopedEntityManagerInjectionTest
+{
+    @Inject
+    private TransactionalBean transactionalBean;
+
+    @Inject
+    private EntityManager entityManager;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "defaultTransactionScopedInjectionTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(DefaultTransactionScopedEntityManagerInjectionTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void defaultTransactionScopedEntityManagerInjection()
+    {
+        this.transactionalBean.executeInTransaction();
+
+        TestEntityTransaction testTransaction =
+            (TestEntityTransaction)this.entityManagerProducer.getEntityManager().getTransaction();
+
+        Assert.assertEquals(false, testTransaction.isActive());
+        Assert.assertEquals(true, testTransaction.isStarted());
+        Assert.assertEquals(true, testTransaction.isCommitted());
+        Assert.assertEquals(false, testTransaction.isRolledBack());
+
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCount());
+    }
+
+    @Test
+    public void entityManagerUsageWithoutTransaction()
+    {
+        try
+        {
+            //not available because there is no transactional method
+            this.entityManager.getTransaction();
+            Assert.fail(ContextNotActiveException.class.getName() + " expected!");
+        }
+        catch (ContextNotActiveException e)
+        {
+            //expected
+        }
+    }
+
+    @Test
+    public void invalidEntityManagerUsageAfterTransaction()
+    {
+        try
+        {
+            //not available because there is no transactional method
+            this.entityManager.getTransaction();
+            Assert.fail(ContextNotActiveException.class.getName() + " expected!");
+        }
+        catch (ContextNotActiveException e)
+        {
+            //expected
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TestEntityManagerProducer.java
new file mode 100644
index 0000000..22dbe8d
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TestEntityManagerProducer.java
@@ -0,0 +1,67 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultinjection;
+
+import org.apache.deltaspike.jpa.api.TransactionScoped;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@RequestScoped
+public class TestEntityManagerProducer
+{
+    private TestEntityManager entityManager;
+
+    private int closeEntityManagerCount = 0;
+    
+    @Produces
+    @TransactionScoped
+    protected EntityManager entityManager()
+    {
+        if (this.entityManager == null)
+        {
+            this.entityManager = new TestEntityManager();
+            return this.entityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    protected void closeEntityManager(@Disposes EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCount++;
+    }
+
+    public int getCloseEntityManagerCount()
+    {
+        return closeEntityManagerCount;
+    }
+
+    public TestEntityManager getEntityManager()
+    {
+        return entityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TransactionalBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TransactionalBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TransactionalBean.java
new file mode 100644
index 0000000..20aa008
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultinjection/TransactionalBean.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultinjection;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class TransactionalBean
+{
+    @Inject
+    private EntityManager entityManager;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/DefaultTransactionScopedNestedTransactionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/DefaultTransactionScopedNestedTransactionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/DefaultTransactionScopedNestedTransactionTest.java
new file mode 100644
index 0000000..97f936a
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/DefaultTransactionScopedNestedTransactionTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultnested;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+public class DefaultTransactionScopedNestedTransactionTest
+{
+    @Inject
+    private FirstLevelTransactionBean firstLevelTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "defaultTransactionScopedNestedTransactionTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(DefaultTransactionScopedNestedTransactionTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void defaultTransactionScopedNestedTransaction()
+    {
+        this.firstLevelTransactionBean.executeInTransaction();
+
+        TestEntityTransaction testTransaction =
+            (TestEntityTransaction)this.entityManagerProducer.getEntityManager().getTransaction();
+
+        Assert.assertEquals(false, testTransaction.isActive());
+        Assert.assertEquals(true, testTransaction.isStarted());
+        Assert.assertEquals(true, testTransaction.isCommitted());
+        Assert.assertEquals(false, testTransaction.isRolledBack());
+
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCount());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/FirstLevelTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/FirstLevelTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/FirstLevelTransactionBean.java
new file mode 100644
index 0000000..3076b9e
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/FirstLevelTransactionBean.java
@@ -0,0 +1,41 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultnested;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class FirstLevelTransactionBean
+{
+    @Inject
+    private EntityManager entityManager;
+
+    @Inject
+    private NestedTransactionBean nestedTransactionBean;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+        this.nestedTransactionBean.executeInTransaction();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/NestedTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/NestedTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/NestedTransactionBean.java
new file mode 100644
index 0000000..2e5028b
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/NestedTransactionBean.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultnested;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class NestedTransactionBean
+{
+    @Inject
+    private EntityManager entityManager;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/TestEntityManagerProducer.java
new file mode 100644
index 0000000..db4b34b
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/defaultnested/TestEntityManagerProducer.java
@@ -0,0 +1,67 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.defaultnested;
+
+import org.apache.deltaspike.jpa.api.TransactionScoped;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@RequestScoped
+public class TestEntityManagerProducer
+{
+    private TestEntityManager entityManager;
+
+    private int closeEntityManagerCount = 0;
+
+    @Produces
+    @TransactionScoped
+    protected EntityManager entityManager()
+    {
+        if (this.entityManager == null)
+        {
+            this.entityManager = new TestEntityManager();
+            return this.entityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    protected void closeEntityManager(@Disposes EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCount++;
+    }
+
+    public int getCloseEntityManagerCount()
+    {
+        return closeEntityManagerCount;
+    }
+
+    public TestEntityManager getEntityManager()
+    {
+        return entityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultiTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultiTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultiTransactionBean.java
new file mode 100644
index 0000000..2719d6f
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultiTransactionBean.java
@@ -0,0 +1,45 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.auto;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+import org.apache.deltaspike.test.jpa.api.shared.Second;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class MultiTransactionBean
+{
+    @Inject
+    private EntityManager defaultEntityManager;
+
+    @Inject
+    private @First EntityManager firstEntityManager;
+
+    @Inject
+    private @Second EntityManager secondEntityManager;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultipleTransactionScopedEntityManagerInjectionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultipleTransactionScopedEntityManagerInjectionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultipleTransactionScopedEntityManagerInjectionTest.java
new file mode 100644
index 0000000..4b33b1a
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/MultipleTransactionScopedEntityManagerInjectionTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.auto;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+public class MultipleTransactionScopedEntityManagerInjectionTest
+{
+    @Inject
+    private MultiTransactionBean multiTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "autoTransactionScopedInjectionTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(MultipleTransactionScopedEntityManagerInjectionTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void autoTransactionScopedEntityManagerInjection()
+    {
+        this.multiTransactionBean.executeInTransaction();
+
+        TestEntityManager defaultEntityManager = this.entityManagerProducer.getDefaultEntityManager();
+        TestEntityTransaction defaultTransaction = (TestEntityTransaction)defaultEntityManager.getTransaction();
+
+        TestEntityManager firstEntityManager = this.entityManagerProducer.getFirstEntityManager();
+        TestEntityTransaction firstTransaction = (TestEntityTransaction)firstEntityManager.getTransaction();
+
+        TestEntityManager secondEntityManager = this.entityManagerProducer.getSecondEntityManager();
+        TestEntityTransaction secondTransaction = (TestEntityTransaction)secondEntityManager.getTransaction();
+
+        Assert.assertEquals(true, defaultEntityManager.isFlushed());
+        Assert.assertEquals(false, defaultTransaction.isActive());
+        Assert.assertEquals(true, defaultTransaction.isStarted());
+        Assert.assertEquals(true, defaultTransaction.isCommitted());
+        Assert.assertEquals(false, defaultTransaction.isRolledBack());
+
+        Assert.assertEquals(true, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(true, firstTransaction.isStarted());
+        Assert.assertEquals(true, firstTransaction.isCommitted());
+        Assert.assertEquals(false, firstTransaction.isRolledBack());
+
+        Assert.assertEquals(true, secondEntityManager.isFlushed());
+        Assert.assertEquals(false, secondTransaction.isActive());
+        Assert.assertEquals(true, secondTransaction.isStarted());
+        Assert.assertEquals(true, secondTransaction.isCommitted());
+        Assert.assertEquals(false, secondTransaction.isRolledBack());
+
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCountDefaultEntityManager());
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCountFirstEntityManager());
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCountSecondEntityManager());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/TestEntityManagerProducer.java
new file mode 100644
index 0000000..e74d84f
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/auto/TestEntityManagerProducer.java
@@ -0,0 +1,143 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.auto;
+
+import org.apache.deltaspike.jpa.api.TransactionScoped;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+import org.apache.deltaspike.test.jpa.api.shared.Second;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@RequestScoped
+public class TestEntityManagerProducer
+{
+    private TestEntityManager defaultEntityManager;
+
+    private TestEntityManager firstEntityManager;
+
+    private TestEntityManager secondEntityManager;
+
+    private int closeEntityManagerCountDefaultEntityManager = 0;
+
+    private int closeEntityManagerCountFirstEntityManager = 0;
+
+    private int closeEntityManagerCountSecondEntityManager = 0;
+
+    @Produces
+    @TransactionScoped
+    protected EntityManager defaultEntityManager()
+    {
+        if (this.defaultEntityManager == null)
+        {
+            this.defaultEntityManager = new TestEntityManager();
+            return this.defaultEntityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    @Produces
+    @First
+    @TransactionScoped
+    protected EntityManager firstEntityManager()
+    {
+        if (this.firstEntityManager == null)
+        {
+            this.firstEntityManager = new TestEntityManager();
+            return this.firstEntityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    @Produces
+    @Second
+    @TransactionScoped
+    protected EntityManager secondEntityManager()
+    {
+        if (this.secondEntityManager == null)
+        {
+            this.secondEntityManager = new TestEntityManager();
+            return this.secondEntityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    protected void closeDefaultEntityManager(@Disposes EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCountDefaultEntityManager++;
+    }
+
+    protected void closeFirstEntityManager(@Disposes @First EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCountFirstEntityManager++;
+    }
+
+    protected void closeSecondEntityManager(@Disposes @Second EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCountSecondEntityManager++;
+    }
+
+    public TestEntityManager getDefaultEntityManager()
+    {
+        return defaultEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    public TestEntityManager getSecondEntityManager()
+    {
+        return secondEntityManager;
+    }
+
+    public int getCloseEntityManagerCountDefaultEntityManager()
+    {
+        return closeEntityManagerCountDefaultEntityManager;
+    }
+
+    public int getCloseEntityManagerCountFirstEntityManager()
+    {
+        return closeEntityManagerCountFirstEntityManager;
+    }
+
+    public int getCloseEntityManagerCountSecondEntityManager()
+    {
+        return closeEntityManagerCountSecondEntityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionBean.java
new file mode 100644
index 0000000..0bc4b37
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionBean.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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.manual;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+import org.apache.deltaspike.test.jpa.api.shared.Second;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class ManualTransactionBean
+{
+    @Inject
+    private EntityManager defaultEntityManager;
+
+    @Inject
+    private @First EntityManager firstEntityManager;
+
+    @Inject
+    private @Second EntityManager secondEntityManager;
+
+    @Transactional(qualifier = Default.class)
+    public void executeInDefaultTransaction()
+    {
+    }
+
+    @Transactional(qualifier = First.class)
+    public void executeInFirstTransaction()
+    {
+    }
+
+    @Transactional(qualifier = Second.class)
+    public void executeInSecondTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionScopedTransactionTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionScopedTransactionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionScopedTransactionTest.java
new file mode 100644
index 0000000..748fd8c
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/ManualTransactionScopedTransactionTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.manual;
+
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+public class ManualTransactionScopedTransactionTest
+{
+    @Inject
+    private ManualTransactionBean manualTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        new BeanManagerProvider()
+        {
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "manualTransactionScopedTransactionTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(ManualTransactionScopedTransactionTest.class.getPackage().getName())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class)
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndJpaArchive())
+                .addAsLibraries(testJar)
+                .addAsServiceProvider(Extension.class, TransactionContextExtension.class)
+                .addAsWebInfResource(ArchiveUtils.getBeansXml(), "beans.xml");
+    }
+
+    @Test
+    public void manualTransactionScopedTransactionTest()
+    {
+        this.manualTransactionBean.executeInDefaultTransaction();
+        this.manualTransactionBean.executeInFirstTransaction();
+        this.manualTransactionBean.executeInSecondTransaction();
+
+        TestEntityManager defaultEntityManager = this.entityManagerProducer.getDefaultEntityManager();
+        TestEntityTransaction defaultTransaction = (TestEntityTransaction)defaultEntityManager.getTransaction();
+
+        TestEntityManager firstEntityManager = this.entityManagerProducer.getFirstEntityManager();
+        TestEntityTransaction firstTransaction = (TestEntityTransaction)firstEntityManager.getTransaction();
+
+        TestEntityManager secondEntityManager = this.entityManagerProducer.getSecondEntityManager();
+        TestEntityTransaction secondTransaction = (TestEntityTransaction)secondEntityManager.getTransaction();
+
+        Assert.assertEquals(true, defaultEntityManager.isFlushed());
+        Assert.assertEquals(false, defaultTransaction.isActive());
+        Assert.assertEquals(true, defaultTransaction.isStarted());
+        Assert.assertEquals(true, defaultTransaction.isCommitted());
+        Assert.assertEquals(false, defaultTransaction.isRolledBack());
+
+        Assert.assertEquals(true, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(true, firstTransaction.isStarted());
+        Assert.assertEquals(true, firstTransaction.isCommitted());
+        Assert.assertEquals(false, firstTransaction.isRolledBack());
+
+        Assert.assertEquals(true, secondEntityManager.isFlushed());
+        Assert.assertEquals(false, secondTransaction.isActive());
+        Assert.assertEquals(true, secondTransaction.isStarted());
+        Assert.assertEquals(true, secondTransaction.isCommitted());
+        Assert.assertEquals(false, secondTransaction.isRolledBack());
+
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCountDefaultEntityManager());
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCountFirstEntityManager());
+        Assert.assertEquals(1, this.entityManagerProducer.getCloseEntityManagerCountSecondEntityManager());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/TestEntityManagerProducer.java
new file mode 100644
index 0000000..9364c93
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/manual/TestEntityManagerProducer.java
@@ -0,0 +1,143 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.manual;
+
+import org.apache.deltaspike.jpa.api.TransactionScoped;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+import org.apache.deltaspike.test.jpa.api.shared.Second;
+import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class TestEntityManagerProducer
+{
+    private TestEntityManager defaultEntityManager;
+
+    private TestEntityManager firstEntityManager;
+
+    private TestEntityManager secondEntityManager;
+
+    private int closeEntityManagerCountDefaultEntityManager = 0;
+
+    private int closeEntityManagerCountFirstEntityManager = 0;
+
+    private int closeEntityManagerCountSecondEntityManager = 0;
+
+    @Produces
+    @TransactionScoped
+    protected EntityManager defaultEntityManager()
+    {
+        if (this.defaultEntityManager == null)
+        {
+            this.defaultEntityManager = new TestEntityManager();
+            return this.defaultEntityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    @Produces
+    @First
+    @TransactionScoped
+    protected EntityManager firstEntityManager()
+    {
+        if (this.firstEntityManager == null)
+        {
+            this.firstEntityManager = new TestEntityManager();
+            return this.firstEntityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    @Produces
+    @Second
+    @TransactionScoped
+    protected EntityManager secondEntityManager()
+    {
+        if (this.secondEntityManager == null)
+        {
+            this.secondEntityManager = new TestEntityManager();
+            return this.secondEntityManager;
+        }
+
+        throw new IllegalStateException("a second producer call isn't allowed");
+    }
+
+    protected void closeDefaultEntityManager(@Disposes EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCountDefaultEntityManager++;
+    }
+
+    protected void closeFirstEntityManager(@Disposes @First EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCountFirstEntityManager++;
+    }
+
+    protected void closeSecondEntityManager(@Disposes @Second EntityManager entityManager)
+    {
+        if (entityManager.isOpen())
+        {
+            entityManager.close();
+        }
+        this.closeEntityManagerCountSecondEntityManager++;
+    }
+
+    public TestEntityManager getDefaultEntityManager()
+    {
+        return defaultEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    public TestEntityManager getSecondEntityManager()
+    {
+        return secondEntityManager;
+    }
+
+    public int getCloseEntityManagerCountDefaultEntityManager()
+    {
+        return closeEntityManagerCountDefaultEntityManager;
+    }
+
+    public int getCloseEntityManagerCountFirstEntityManager()
+    {
+        return closeEntityManagerCountFirstEntityManager;
+    }
+
+    public int getCloseEntityManagerCountSecondEntityManager()
+    {
+        return closeEntityManagerCountSecondEntityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/FirstLevelTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/FirstLevelTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/FirstLevelTransactionBean.java
new file mode 100644
index 0000000..c318c6f
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/FirstLevelTransactionBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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.deltaspike.test.jpa.api.transactionscoped.multipleinjection.nested;
+
+import org.apache.deltaspike.jpa.api.Transactional;
+import org.apache.deltaspike.test.jpa.api.shared.First;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@ApplicationScoped
+public class FirstLevelTransactionBean
+{
+    @Inject
+    private @First EntityManager firstEntityManager;
+
+    @Inject
+    private NestedTransactionBean nestedTransactionBean;
+
+    @Transactional
+    public void executeInTransaction()
+    {
+        this.nestedTransactionBean.executeInTransaction();
+    }
+}