deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [1/2] deltaspike git commit: DELTASPIKE-915 added tests for Transactional#readOnly
Date Thu, 04 Jun 2015 13:12:30 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 067718763 -> b19d1b62a


DELTASPIKE-915 added tests for Transactional#readOnly


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

Branch: refs/heads/master
Commit: 937ddb203b7b88f51d0686f8b438535c8ae6d863
Parents: 0677187
Author: gpetracek <gpetracek@apache.org>
Authored: Thu Jun 4 15:01:04 2015 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Thu Jun 4 15:10:32 2015 +0200

----------------------------------------------------------------------
 .../readonly/auto/MultiTransactionBean.java     |  45 +++++++
 ...tipleEntityManagerInjectionReadOnlyTest.java | 132 +++++++++++++++++++
 .../auto/TestEntityManagerProducer.java         |  72 ++++++++++
 .../norollback/FirstLevelTransactionBean.java   |  42 ++++++
 ...dMultiTransactionReadOnlyNoRollbackTest.java | 115 ++++++++++++++++
 .../norollback/NestedTransactionBean.java       |  38 ++++++
 .../norollback/TestEntityManagerProducer.java   |  59 +++++++++
 .../rollback/FirstLevelTransactionBean.java     |  42 ++++++
 ...tedMultiTransactionReadOnlyRollbackTest.java | 115 ++++++++++++++++
 .../nested/rollback/NestedTransactionBean.java  |  38 ++++++
 .../rollback/TestEntityManagerProducer.java     |  59 +++++++++
 11 files changed, 757 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultiTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultiTransactionBean.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultiTransactionBean.java
new file mode 100644
index 0000000..ddc5b59
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/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.transactional.readonly.auto;
+
+import org.apache.deltaspike.jpa.api.transaction.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(readOnly = true)
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultipleEntityManagerInjectionReadOnlyTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultipleEntityManagerInjectionReadOnlyTest.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultipleEntityManagerInjectionReadOnlyTest.java
new file mode 100644
index 0000000..6f3e947
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/MultipleEntityManagerInjectionReadOnlyTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jpa.api.transactional.readonly.auto;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.core.util.ProjectStageProducer;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionBeanStorage;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.category.SeCategory;
+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.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+//different classes needed due to arquillian restriction
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class MultipleEntityManagerInjectionReadOnlyTest
+{
+    @Inject
+    private MultiTransactionBean multiTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "multipleEntityManagerInjectionReadOnlyTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(MultipleEntityManagerInjectionReadOnlyTest.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");
+    }
+
+    @Before
+    public void init()
+    {
+        ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
+    }
+
+    @Test
+    public void autoInjectionReadOnlyTest()
+    {
+        TestEntityManager defaultEntityManager = entityManagerProducer.getDefaultEntityManager();
+        TestEntityManager firstEntityManager = entityManagerProducer.getFirstEntityManager();
+        TestEntityManager secondEntityManager = entityManagerProducer.getSecondEntityManager();
+
+        Assert.assertNotNull(defaultEntityManager);
+        TestEntityTransaction defaultTransaction = (TestEntityTransaction) (defaultEntityManager).getTransaction();
+
+        Assert.assertEquals(false, defaultEntityManager.isFlushed());
+        Assert.assertEquals(false, defaultTransaction.isActive());
+        Assert.assertEquals(false, defaultTransaction.isStarted());
+        Assert.assertEquals(false, defaultTransaction.isCommitted());
+        Assert.assertEquals(false, defaultTransaction.isRolledBack());
+
+        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());
+
+        multiTransactionBean.executeInTransaction();
+
+        Assert.assertEquals(false, defaultEntityManager.isFlushed());
+        Assert.assertEquals(false, defaultTransaction.isActive());
+        Assert.assertEquals(true, defaultTransaction.isStarted());
+        Assert.assertEquals(false, defaultTransaction.isCommitted());
+        Assert.assertEquals(true, defaultTransaction.isRolledBack());
+
+        Assert.assertEquals(false, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(true, firstTransaction.isStarted());
+        Assert.assertEquals(false, firstTransaction.isCommitted());
+        Assert.assertEquals(true, firstTransaction.isRolledBack());
+
+        Assert.assertEquals(false, secondEntityManager.isFlushed());
+        Assert.assertEquals(false, secondTransaction.isActive());
+        Assert.assertEquals(true, secondTransaction.isStarted());
+        Assert.assertEquals(false, secondTransaction.isCommitted());
+        Assert.assertEquals(true, secondTransaction.isRolledBack());
+
+        Assert.assertEquals(false, TransactionBeanStorage.isOpen());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/TestEntityManagerProducer.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/TestEntityManagerProducer.java
new file mode 100644
index 0000000..5edf4b6
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/auto/TestEntityManagerProducer.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jpa.api.transactional.readonly.auto;
+
+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 defaultEntityManager = new TestEntityManager();
+
+    private TestEntityManager firstEntityManager = new TestEntityManager();
+
+    private TestEntityManager secondEntityManager = new TestEntityManager();
+
+    @Produces
+    protected EntityManager defaultEntityManager()
+    {
+        return defaultEntityManager;
+    }
+
+    @Produces
+    @First
+    protected EntityManager firstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    @Produces
+    @Second
+    protected EntityManager secondEntityManager()
+    {
+        return secondEntityManager;
+    }
+
+    public TestEntityManager getDefaultEntityManager()
+    {
+        return defaultEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    public TestEntityManager getSecondEntityManager()
+    {
+        return secondEntityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/FirstLevelTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/FirstLevelTransactionBean.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/FirstLevelTransactionBean.java
new file mode 100644
index 0000000..7957998
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/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.readonly.nested.norollback;
+
+import org.apache.deltaspike.jpa.api.transaction.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()
+    {
+        nestedTransactionBean.executeInTransaction();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedMultiTransactionReadOnlyNoRollbackTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedMultiTransactionReadOnlyNoRollbackTest.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedMultiTransactionReadOnlyNoRollbackTest.java
new file mode 100644
index 0000000..6a6a51e
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedMultiTransactionReadOnlyNoRollbackTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jpa.api.transactional.readonly.nested.norollback;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.core.util.ProjectStageProducer;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionBeanStorage;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.category.SeCategory;
+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.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class NestedMultiTransactionReadOnlyNoRollbackTest
+{
+    @Inject
+    private FirstLevelTransactionBean firstLevelTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "nestedMultiTransactionReadOnlyNoRollbackTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(NestedMultiTransactionReadOnlyNoRollbackTest.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");
+    }
+
+    @Before
+    public void init()
+    {
+        ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
+    }
+
+    @Test
+    public void nestedMultiTransactionReadOnlyNoRollbackTest()
+    {
+        TestEntityManager firstEntityManager = entityManagerProducer.getFirstEntityManager();
+        TestEntityManager secondEntityManager = 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());
+
+        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());
+
+        Assert.assertEquals(false, TransactionBeanStorage.isOpen());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedTransactionBean.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/NestedTransactionBean.java
new file mode 100644
index 0000000..f591420
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/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.readonly.nested.norollback;
+
+import org.apache.deltaspike.jpa.api.transaction.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(readOnly = true)
+    public void executeInTransaction()
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/TestEntityManagerProducer.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/TestEntityManagerProducer.java
new file mode 100644
index 0000000..42ba60c
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/norollback/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.readonly.nested.norollback;
+
+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 firstEntityManager;
+    }
+
+    @Produces
+    @Second
+    protected EntityManager secondEntityManager()
+    {
+        return secondEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    public TestEntityManager getSecondEntityManager()
+    {
+        return secondEntityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/FirstLevelTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/FirstLevelTransactionBean.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/FirstLevelTransactionBean.java
new file mode 100644
index 0000000..cf9a5ed
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/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.readonly.nested.rollback;
+
+import org.apache.deltaspike.jpa.api.transaction.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(readOnly = true)
+    public void executeInTransaction()
+    {
+        nestedTransactionBean.executeInTransaction();
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedMultiTransactionReadOnlyRollbackTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedMultiTransactionReadOnlyRollbackTest.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedMultiTransactionReadOnlyRollbackTest.java
new file mode 100644
index 0000000..9b33b12
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedMultiTransactionReadOnlyRollbackTest.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.jpa.api.transactional.readonly.nested.rollback;
+
+import org.apache.deltaspike.core.api.projectstage.ProjectStage;
+import org.apache.deltaspike.core.util.ProjectStageProducer;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionBeanStorage;
+import org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension;
+import org.apache.deltaspike.test.category.SeCategory;
+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.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class NestedMultiTransactionReadOnlyRollbackTest
+{
+    @Inject
+    private FirstLevelTransactionBean firstLevelTransactionBean;
+
+    @Inject
+    private TestEntityManagerProducer entityManagerProducer;
+
+    @Deployment
+    public static WebArchive deploy()
+    {
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "nestedMultiTransactionReadOnlyRollbackTest.jar")
+                .addPackage(ArchiveUtils.SHARED_PACKAGE)
+                .addPackage(NestedMultiTransactionReadOnlyRollbackTest.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");
+    }
+
+    @Before
+    public void init()
+    {
+        ProjectStageProducer.setProjectStage(ProjectStage.UnitTest);
+    }
+
+    @Test
+    public void nestedMultiTransactionReadOnlyRollbackTest()
+    {
+        TestEntityManager firstEntityManager = entityManagerProducer.getFirstEntityManager();
+        TestEntityManager secondEntityManager = 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());
+
+        firstLevelTransactionBean.executeInTransaction();
+
+        Assert.assertEquals(false, firstEntityManager.isFlushed());
+        Assert.assertEquals(false, firstTransaction.isActive());
+        Assert.assertEquals(true, firstTransaction.isStarted());
+        Assert.assertEquals(false, firstTransaction.isCommitted());
+        Assert.assertEquals(true, firstTransaction.isRolledBack());
+
+        Assert.assertEquals(false, secondEntityManager.isFlushed());
+        Assert.assertEquals(false, secondTransaction.isActive());
+        Assert.assertEquals(true, secondTransaction.isStarted());
+        Assert.assertEquals(false, secondTransaction.isCommitted());
+        Assert.assertEquals(true, secondTransaction.isRolledBack());
+
+        Assert.assertEquals(false, TransactionBeanStorage.isOpen());
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedTransactionBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedTransactionBean.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/NestedTransactionBean.java
new file mode 100644
index 0000000..5817b9e
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/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.readonly.nested.rollback;
+
+import org.apache.deltaspike.jpa.api.transaction.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/deltaspike/blob/937ddb20/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/TestEntityManagerProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/TestEntityManagerProducer.java
b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/TestEntityManagerProducer.java
new file mode 100644
index 0000000..3e04aad
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactional/readonly/nested/rollback/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.readonly.nested.rollback;
+
+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 firstEntityManager;
+    }
+
+    @Produces
+    @Second
+    protected EntityManager secondEntityManager()
+    {
+        return secondEntityManager;
+    }
+
+    public TestEntityManager getFirstEntityManager()
+    {
+        return firstEntityManager;
+    }
+
+    public TestEntityManager getSecondEntityManager()
+    {
+        return secondEntityManager;
+    }
+}


Mime
View raw message