Return-Path: X-Original-To: apmail-incubator-deltaspike-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltaspike-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D2DA1CDDF for ; Sat, 19 May 2012 03:45:51 +0000 (UTC) Received: (qmail 24001 invoked by uid 500); 19 May 2012 03:45:51 -0000 Delivered-To: apmail-incubator-deltaspike-commits-archive@incubator.apache.org Received: (qmail 23911 invoked by uid 500); 19 May 2012 03:45:51 -0000 Mailing-List: contact deltaspike-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltaspike-dev@incubator.apache.org Delivered-To: mailing list deltaspike-commits@incubator.apache.org Received: (qmail 23763 invoked by uid 99); 19 May 2012 03:45:47 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 May 2012 03:45:47 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 49BA016D64; Sat, 19 May 2012 03:45:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gpetracek@apache.org To: deltaspike-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [5/5] DELTASPIKE-175 and DELTASPIKE-178 Message-Id: <20120519034547.49BA016D64@tyr.zones.apache.org> Date: Sat, 19 May 2012 03:45:47 +0000 (UTC) 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/NestedMultiTransactionScopedTransactionTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/NestedMultiTransactionScopedTransactionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/NestedMultiTransactionScopedTransactionTest.java new file mode 100644 index 0000000..4d2c99e --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/NestedMultiTransactionScopedTransactionTest.java @@ -0,0 +1,101 @@ +/* + * 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.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 NestedMultiTransactionScopedTransactionTest +{ + @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, "nestedMultiTransactionScopedTransactionTest.jar") + .addPackage(ArchiveUtils.SHARED_PACKAGE) + .addPackage(NestedMultiTransactionScopedTransactionTest.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 nestedMultiTransactionScopedTransactionTest() + { + this.firstLevelTransactionBean.executeInTransaction(); + + TestEntityManager firstEntityManager = this.entityManagerProducer.getFirstEntityManager(); + TestEntityManager secondEntityManager = this.entityManagerProducer.getSecondEntityManager(); + + Assert.assertNotNull(firstEntityManager); + TestEntityTransaction firstTransaction = (TestEntityTransaction) (firstEntityManager).getTransaction(); + + Assert.assertNotNull(secondEntityManager); + TestEntityTransaction secondTransaction = (TestEntityTransaction) (secondEntityManager).getTransaction(); + + 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.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/nested/NestedTransactionBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/NestedTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/NestedTransactionBean.java new file mode 100644 index 0000000..5cf047d --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/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.transactionscoped.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/transactionscoped/multipleinjection/nested/TestEntityManagerProducer.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/TestEntityManagerProducer.java new file mode 100644 index 0000000..afb938b --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/multipleinjection/nested/TestEntityManagerProducer.java @@ -0,0 +1,107 @@ +/* + * 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.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 firstEntityManager; + + private TestEntityManager secondEntityManager; + + private int closeEntityManagerCountFirstEntityManager = 0; + + private int closeEntityManagerCountSecondEntityManager = 0; + + @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 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 getFirstEntityManager() + { + return firstEntityManager; + } + + public TestEntityManager getSecondEntityManager() + { + return secondEntityManager; + } + + 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/nested/FirstLevelTransactionBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/FirstLevelTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/FirstLevelTransactionBean.java new file mode 100644 index 0000000..16d914d --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/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.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/transactionscoped/nested/NestedTransactionBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/NestedTransactionBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/NestedTransactionBean.java new file mode 100644 index 0000000..08312c5 --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/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.transactionscoped.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/transactionscoped/nested/NestedTransactionScopedTransactionTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/NestedTransactionScopedTransactionTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/NestedTransactionScopedTransactionTest.java new file mode 100644 index 0000000..a160c1c --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/NestedTransactionScopedTransactionTest.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.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.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 NestedTransactionScopedTransactionTest +{ + @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, "nestedTransactionScopedTransaction.jar") + .addPackage(ArchiveUtils.SHARED_PACKAGE) + .addPackage(NestedTransactionScopedTransactionTest.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 nestedTransactionScopedTransaction() + { + this.firstLevelTransactionBean.executeInTransaction(); + + TestEntityTransaction testTransaction = + (TestEntityTransaction)this.entityManagerProducer.getFirstEntityManager().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/nested/TestEntityManagerProducer.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/TestEntityManagerProducer.java new file mode 100644 index 0000000..b5a8e33 --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/nested/TestEntityManagerProducer.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.deltaspike.test.jpa.api.transactionscoped.nested; + +import org.apache.deltaspike.jpa.api.TransactionScoped; +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.Disposes; +import javax.enterprise.inject.Produces; +import javax.persistence.EntityManager; + +@RequestScoped +public class TestEntityManagerProducer +{ + private TestEntityManager firstEntityManager; + + private int closeEntityManagerCount = 0; + + @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"); + } + + protected void closeEntityManager(@Disposes @First EntityManager entityManager) + { + if (entityManager.isOpen()) + { + entityManager.close(); + } + this.closeEntityManagerCount++; + } + + public int getCloseEntityManagerCount() + { + return closeEntityManagerCount; + } + + 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/transactionscoped/stereotype/Repository.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/Repository.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/Repository.java new file mode 100644 index 0000000..be47d6f --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/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.transactionscoped.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/transactionscoped/stereotype/StereotypeTransactionScopedTransactionalTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/StereotypeTransactionScopedTransactionalTest.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/StereotypeTransactionScopedTransactionalTest.java new file mode 100644 index 0000000..5a1ca9a --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/StereotypeTransactionScopedTransactionalTest.java @@ -0,0 +1,88 @@ +/* + * 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.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.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 StereotypeTransactionScopedTransactionalTest +{ + @Inject + private TransactionalBean transactionalBean; + + @Inject + private TestEntityManagerProducer entityManagerProducer; + + @Inject + private TestEntityTransactionHolder testEntityTransactionHolder; + + @Deployment + public static WebArchive deploy() + { + new BeanManagerProvider() + { + @Override + public void setTestMode() + { + super.setTestMode(); + } + }.setTestMode(); + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "stereotypeTransactionScopedTransactionalTest.jar") + .addPackage(ArchiveUtils.SHARED_PACKAGE) + .addPackage(StereotypeTransactionScopedTransactionalTest.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 transactionalBeanViaStereotypeInTransactionScoped() + { + this.transactionalBean.executeInTransaction(); + + TestEntityTransaction testTransaction = this.testEntityTransactionHolder.getTestEntityTransaction(); + + 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/stereotype/TestEntityManagerProducer.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TestEntityManagerProducer.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TestEntityManagerProducer.java new file mode 100644 index 0000000..ef8cbf9 --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TestEntityManagerProducer.java @@ -0,0 +1,62 @@ +/* + * 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.stereotype; + +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; + } +} 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/stereotype/TestEntityTransactionHolder.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TestEntityTransactionHolder.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TestEntityTransactionHolder.java new file mode 100644 index 0000000..f4e4528 --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TestEntityTransactionHolder.java @@ -0,0 +1,39 @@ +/* + * 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.stereotype; + +import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction; + +import javax.enterprise.context.RequestScoped; + +@RequestScoped +public class TestEntityTransactionHolder +{ + private TestEntityTransaction testEntityTransaction; + + public TestEntityTransaction getTestEntityTransaction() + { + return testEntityTransaction; + } + + public void setTestEntityTransaction(TestEntityTransaction testEntityTransaction) + { + this.testEntityTransaction = testEntityTransaction; + } +} 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/stereotype/TransactionalBean.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TransactionalBean.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TransactionalBean.java new file mode 100644 index 0000000..644101a --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/jpa/api/transactionscoped/stereotype/TransactionalBean.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.stereotype; + +import org.apache.deltaspike.test.jpa.api.shared.TestEntityTransaction; + +import javax.inject.Inject; +import javax.persistence.EntityManager; + +@Repository +public class TransactionalBean +{ + @Inject + private EntityManager entityManager; + + //we can't provide a simple getter because it would be intercepted as well and + //would break the check we have to perform in the test + @Inject + private TestEntityTransactionHolder testEntityTransactionHolder; + + public void executeInTransaction() + { + this.testEntityTransactionHolder.setTestEntityTransaction( + (TestEntityTransaction)this.entityManager.getTransaction()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ArchiveUtils.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ArchiveUtils.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ArchiveUtils.java new file mode 100644 index 0000000..98b9692 --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ArchiveUtils.java @@ -0,0 +1,55 @@ +/* + * 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.util; + +import org.apache.deltaspike.test.jpa.api.shared.TestEntityManager; +import org.jboss.shrinkwrap.api.asset.Asset; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +/** + * This class contains helpers for building frequently used archives + */ +public class ArchiveUtils +{ + public static final String SHARED_PACKAGE = TestEntityManager.class.getPackage().getName(); + + public static JavaArchive[] getDeltaSpikeCoreAndJpaArchive() + { + return ShrinkWrapArchiveUtil.getArchives( + null, + "META-INF/beans.xml", + new String[]{"org.apache.deltaspike.core", "org.apache.deltaspike.jpa"}, + null); + } + + public static Asset getBeansXml() + { + @SuppressWarnings("UnnecessaryLocalVariable") + Asset beansXml = new StringAsset( + "" + + "" + + "org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor" + + "" + + "" + ); + + return beansXml; + } +} http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java new file mode 100644 index 0000000..a9424f6 --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/java/org/apache/deltaspike/test/util/ShrinkWrapArchiveUtil.java @@ -0,0 +1,317 @@ +/* + * 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.util; + +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarInputStream; +import java.util.logging.Logger; +import java.util.zip.ZipEntry; + +/** + * Lots of neat little helpers to more easily create JavaArchives from marker files on the classpath. + * This should finally get moved to ShrinkWrap core! + * + * @deprecated This class should get moved to ShrinkWrap itself! + */ +public class ShrinkWrapArchiveUtil +{ + private static final Logger LOG = Logger.getLogger(ShrinkWrapArchiveUtil.class.getName()); + /** + * Resolve all markerFiles from the current ClassPath and package the root nodes + * into a JavaArchive. + * @param classLoader to use + * @param markerFile + * @param includeIfPackageExists if not null, we will only create JavaArchives if the given package exists + * @param excludeIfPackageExists if not null, we will not create JavaArchives if the given package exists. + * This has a higher precedence than includeIfPackageExists. + * @return + */ + public static JavaArchive[] getArchives(ClassLoader classLoader, + String markerFile, + String[] includeIfPackageExists, + String[] excludeIfPackageExists) + { + if (classLoader == null) { + classLoader = ShrinkWrapArchiveUtil.class.getClassLoader(); + } + + try { + Enumeration foundFiles = classLoader.getResources(markerFile); + + List archives = new ArrayList(); + + while (foundFiles.hasMoreElements()) { + URL foundFile = foundFiles.nextElement(); + LOG.fine("Evaluating Java ClassPath URL " + foundFile.toExternalForm()); + + JavaArchive archive = createArchive(foundFile, markerFile, includeIfPackageExists, excludeIfPackageExists); + if (archive != null) { + LOG.info("Adding Java ClassPath URL as JavaArchive " + foundFile.toExternalForm()); + archives.add(archive); + } + } + + return archives.toArray(new JavaArchive[archives.size()]); + } + catch (IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + private static JavaArchive createArchive(URL foundFile, String markerFile, + String[] includeIfPackageExists, String[] excludeIfPackageExists) + throws IOException { + String urlString = foundFile.toString(); + int idx = urlString.lastIndexOf(markerFile); + urlString = urlString.substring(0, idx); + + String jarUrlPath = isJarUrl(urlString); + if (jarUrlPath != null) + { + final JavaArchive foundJar = ShrinkWrap.createFromZipFile(JavaArchive.class, new File(URI.create(jarUrlPath))); + + if (excludeIfPackageExists != null) + { + for (String excludePackage : excludeIfPackageExists) + { + if (foundJar.contains(excludePackage.replaceAll("\\.", "\\/"))) { + return null; + } + } + } + if (includeIfPackageExists != null) + { + for (String includePackage : includeIfPackageExists) + { + if (foundJar.contains(includePackage.replaceAll("\\.", "\\/"))) + { + return foundJar; + } + } + } + return null; // couldn't find any jar + } + else + { + File f = new File( (new URL(ensureCorrectUrlFormat(urlString))).getFile() ); + if (!f.exists()) + { + // try a fallback if the URL contains %20 -> spaces + if (urlString.contains("%20")) + { + urlString = urlString.replaceAll("%20", " "); + f = new File( (new URL(ensureCorrectUrlFormat(urlString))).getFile() ); + } + + } + + return addFileArchive(f, includeIfPackageExists, excludeIfPackageExists); + } + } + + private static JavaArchive addJarArchive(InputStream inputStream, + String[] includeIfPackageExists, + String[] excludeIfPackageExists) + throws IOException + { + JavaArchive ret = null; + JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class); + + if (includeIfPackageExists == null) { + // no include rule, thus add it immediately + ret = javaArchive; + } + + JarInputStream jar = new JarInputStream(inputStream); + try { + for (ZipEntry jarEntry = jar.getNextEntry(); jarEntry != null; jarEntry = jar.getNextEntry()) { + String entryName = jarEntry.getName(); + + if (jarEntry.isDirectory()) { + // exclude rule + if (excludeIfPackageExists(entryName, excludeIfPackageExists)) { + return null; + } + + if (ret == null && includeIfPackageExists(entryName, includeIfPackageExists)) { + ret = javaArchive; + } + + continue; + } + + if (entryName.endsWith(".class")) { + String className = pathToClassName(entryName.substring(0, entryName.length()-(".class".length()))); + javaArchive.addClass(className); + } + else { + javaArchive.addAsResource(entryName); + } + } + } + finally { + try { + jar.close(); + } + catch (IOException ignored) { + // all fine + } + } + + return ret; + } + + private static JavaArchive addFileArchive(File archiveBasePath, + String[] includeIfPackageExists, + String[] excludeIfPackageExists) + throws IOException { + if (!archiveBasePath.exists()) { + return null; + } + + JavaArchive ret = null; + JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class); + + if (includeIfPackageExists == null) { + // no include rule, thus add it immediately + ret = javaArchive; + } + + int basePathLength = archiveBasePath.getAbsolutePath().length() + 1; + + for (File archiveEntry : collectArchiveEntries(archiveBasePath) ) { + String entryName = archiveEntry.getAbsolutePath().substring(basePathLength); + + // exclude rule + if (excludeIfPackageExists(entryName, excludeIfPackageExists)) { + continue; + } + + // include rule + if (ret == null && includeIfPackageExists(entryName, includeIfPackageExists)) { + ret = javaArchive; + } + + if (entryName.endsWith(".class")) { + String className = pathToClassName(entryName.substring(0, entryName.length()-(".class".length()))); + + javaArchive.addClass(className); + } + else { + javaArchive.addAsResource(entryName.replace('\\', '/')); + } + } + + return ret; + } + + private static List collectArchiveEntries(File archiveBasePath) + { + if (archiveBasePath.isDirectory()) { + List archiveEntries = new ArrayList(); + File[] files = archiveBasePath.listFiles(); + + for (File file : files) { + if (file.isDirectory()) { + archiveEntries.addAll(collectArchiveEntries(file)); + } + else { + archiveEntries.add(file); + } + } + + return archiveEntries; + } + + return Collections.EMPTY_LIST; + } + + + private static boolean excludeIfPackageExists(String jarEntryName, String[] excludeOnPackages) { + if (excludeOnPackages != null) { + String packageName = pathToClassName(jarEntryName); + + for (String excludeOnPackage : excludeOnPackages) { + if (packageName.startsWith(excludeOnPackage)) { + return true; + } + } + } + + return false; + } + + private static boolean includeIfPackageExists(String jarEntryName, String[] includeOnPackages) { + if (includeOnPackages == null ) { + return true; + } + + String packageName = pathToClassName(jarEntryName); + + for (String includeOnPackage : includeOnPackages) { + if (packageName.startsWith(includeOnPackage)) { + return true; + } + } + + return false; + } + + /** + * check if the given url path is a Jar + * @param urlPath + * @return + */ + private static String isJarUrl(String urlPath) { + // common prefixes of the url are: jar: (tomcat), zip: (weblogic) and wsjar: (websphere) + final int jarColon = urlPath.indexOf(':'); + if (urlPath.endsWith("!/") && jarColon > 0) { + urlPath = urlPath.substring(jarColon + 1, urlPath.length() - 2); + return urlPath; + } + + return null; + } + + private static String ensureCorrectUrlFormat(String url) { + //fix for wls + if(!url.startsWith("file:/")) { + url = "file:/" + url; + } + return url; + } + + private static String pathToClassName(String pathName) { + return pathName.replace('/', '.').replace('\\', '.'); // replace unix and windows separators + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/impl/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/impl/src/test/resources/META-INF/beans.xml b/deltaspike/modules/jpa/impl/src/test/resources/META-INF/beans.xml new file mode 100644 index 0000000..0eaf52c --- /dev/null +++ b/deltaspike/modules/jpa/impl/src/test/resources/META-INF/beans.xml @@ -0,0 +1,24 @@ + + + + + http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/jpa/pom.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/jpa/pom.xml b/deltaspike/modules/jpa/pom.xml new file mode 100644 index 0000000..df08b4c --- /dev/null +++ b/deltaspike/modules/jpa/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + + org.apache.deltaspike.modules + modules-project + 0.3-incubating-SNAPSHOT + + + org.apache.deltaspike.modules + jpa-module-project + 0.3-incubating-SNAPSHOT + pom + + Apache DeltaSpike JPA-Module + + + api + impl + + + + + + org.apache.geronimo.specs + geronimo-jpa_2.0_spec + + + http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/modules/pom.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/pom.xml b/deltaspike/modules/pom.xml index 35652c4..5be5208 100644 --- a/deltaspike/modules/pom.xml +++ b/deltaspike/modules/pom.xml @@ -36,6 +36,7 @@ security + jpa http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/38960400/deltaspike/parent/pom.xml ---------------------------------------------------------------------- diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml index 5f4a08e..fcce5f8 100644 --- a/deltaspike/parent/pom.xml +++ b/deltaspike/parent/pom.xml @@ -346,6 +346,20 @@ runtime + + org.apache.deltaspike.modules + deltaspike-jpa-module-api + ${project.version} + provided + + + + org.apache.deltaspike.modules + deltaspike-jpa-module-impl + ${project.version} + runtime + + org.apache.deltaspike.cdictrl