You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/09/16 21:38:37 UTC
svn commit: r1171747 - in /myfaces/extensions/cdi/trunk: ./
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/
core/impl/
core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/util/
jee-modules/jpa-module/api/src/ma...
Author: struberg
Date: Fri Sep 16 19:38:36 2011
New Revision: 1171747
URL: http://svn.apache.org/viewvc?rev=1171747&view=rev
Log:
EXTCDI-223 EXTCDI-225 unit tests for jpa module
+ upgrade to myfaces-parent-11-SNAPSHOT
+ TransactionScoped (initial annotation version)
Added:
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jpa/api/TransactionScoped.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/DefaultEntityManagerProducer.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestEntity.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestServiceImpl.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TransactionInterceptorTest.java (with props)
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/beans.xml (with props)
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/persistence.xml (with props)
Modified:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfigEntry.java
myfaces/extensions/cdi/trunk/core/impl/pom.xml
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/util/ContainerTestBase.java
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/pom.xml
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/DefaultTransactionalInterceptorStrategy.java
myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/TransactionalInterceptor.java
myfaces/extensions/cdi/trunk/pom.xml
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfigEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfigEntry.java?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfigEntry.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfigEntry.java Fri Sep 16 19:38:36 2011
@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
Modified: myfaces/extensions/cdi/trunk/core/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/pom.xml?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/core/impl/pom.xml Fri Sep 16 19:38:36 2011
@@ -37,31 +37,21 @@
<artifactId>myfaces-extcdi-core-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.openwebbeans.test</groupId>
- <artifactId>cditest</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openwebbeans.test</groupId>
- <artifactId>cditest-owb</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!--
- We currently need this for the CDI test container to emulate the @SessionScoped.
- TODO: Finally this should not be necessary anymore.
- -->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-el_2.2_spec</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/util/ContainerTestBase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/util/ContainerTestBase.java?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/util/ContainerTestBase.java (original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/util/ContainerTestBase.java Fri Sep 16 19:38:36 2011
@@ -30,6 +30,7 @@ import java.lang.annotation.Annotation;
import java.util.logging.Logger;
/**
+ * Base class for CDI container based tests
*/
public class ContainerTestBase
{
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jpa/api/TransactionScoped.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jpa/api/TransactionScoped.java?rev=1171747&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jpa/api/TransactionScoped.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jpa/api/TransactionScoped.java Fri Sep 16 19:38:36 2011
@@ -0,0 +1,68 @@
+/*
+ * 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.myfaces.extensions.cdi.jpa.api;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.enterprise.context.NormalScope;
+
+/**
+ * <p>A @TransactionScoped contextual instance will unique for a given
+ * CODI-managed Transaction. The context will get started when the outermost
+ * {@link Transactional} method gets invoked and will get closed when
+ * the call chain leaves the outermost {@link Transactional} method.</p>
+ *
+ * <p>The classic use-case is for producing JPA EntityManagers.
+ * <pre>
+ * @RequestScoped
+ * public class EntityManagerProducer
+ * {
+ * private @PersistenceUnit EntityManagerFactory emf;
+ *
+ * @Produces @TransactionScoped @Core
+ * public EntityManager createEntityManager()
+ * {
+ * return emf.createEntityManager();
+ * }
+ *
+ * public void dispose(@Disposes EntityManager entityManager)
+ * {
+ * entityManager.close();
+ * }
+ *
+ * }
+ * </pre>
+ * </p>
+ *
+ *
+ * @see Transactional
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.TYPE, ElementType.METHOD, ElementType.FIELD } )
+@NormalScope(passivating = false)
+public @interface TransactionScoped
+{
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jpa/api/TransactionScoped.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/pom.xml?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/pom.xml Fri Sep 16 19:38:36 2011
@@ -42,14 +42,48 @@
<groupId>org.apache.myfaces.extensions.cdi.core</groupId>
<artifactId>myfaces-extcdi-core-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
+ <artifactId>myfaces-extcdi-core-impl</artifactId>
+ <version>${project.version}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <!-- JPA API -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jpa_1.0_spec</artifactId>
- <version>1.1.2</version>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-resource</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
+ <!-- for our unit tests we need a full JPA environment -->
+ <!-- OpenJPA -->
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.1.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- HSQLDB -->
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <scope>test</scope>
+ </dependency>
+
+
</dependencies>
<build>
Modified: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/DefaultTransactionalInterceptorStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/DefaultTransactionalInterceptorStrategy.java?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/DefaultTransactionalInterceptorStrategy.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/DefaultTransactionalInterceptorStrategy.java Fri Sep 16 19:38:36 2011
@@ -45,8 +45,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
/**
- * @author Mark Struberg
- * @author Gerhard Petracek
+ *
*/
@Dependent
public class DefaultTransactionalInterceptorStrategy implements PersistenceStrategy
@@ -56,9 +55,7 @@ public class DefaultTransactionalInterce
//don't use final in interceptors
private static String noFieldMarker = TransactionalInterceptor.class.getName() + ":DEFAULT_FIELD";
- //all implementations will be serializable
- @Inject
- private BeanManager beanManager;
+ private @Inject BeanManager beanManager;
private static transient ThreadLocal<AtomicInteger> refCount = new ThreadLocal<AtomicInteger>();
@@ -72,11 +69,6 @@ public class DefaultTransactionalInterce
persistenceContextMetaEntries =
new ConcurrentHashMap<ClassLoader, Map<String, PersistenceContextMetaEntry>>();
- //TODO for mark
- /** 1 ms in nanoTime ticks */
- //static final long LONG_MILLISECOND = 1000000L;
- //static final long LONG_RUNNING_THRESHOLD = 300L * LONG_MILLISECOND;
-
/**
* {@inheritDoc}
*/
@@ -114,8 +106,8 @@ public class DefaultTransactionalInterce
}
else
{
- entityManager = (EntityManager) this.beanManager.getReference(entityManagerBean, EntityManager.class,
- this.beanManager.createCreationalContext(entityManagerBean));
+ entityManager = (EntityManager) beanManager.getReference(entityManagerBean, EntityManager.class,
+ beanManager.createCreationalContext(entityManagerBean));
}
if (entityManagerMap.get() == null)
@@ -123,7 +115,6 @@ public class DefaultTransactionalInterce
entityManagerMap.set(new HashMap<String, EntityManager>());
}
entityManagerMap.get().put(entityManagerId, entityManager);
- // log.info("growing: " + ems.get().size());
if (refCount.get() == null)
{
Modified: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/TransactionalInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/TransactionalInterceptor.java?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/TransactionalInterceptor.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jpa/impl/TransactionalInterceptor.java Fri Sep 16 19:38:36 2011
@@ -30,7 +30,6 @@ import java.io.Serializable;
/**
* Interceptor for wrapping transactional database requests.
*
- * @author Gerhard Petracek
*/
@Interceptor
@Transactional
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/DefaultEntityManagerProducer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/DefaultEntityManagerProducer.java?rev=1171747&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/DefaultEntityManagerProducer.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/DefaultEntityManagerProducer.java Fri Sep 16 19:38:36 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.myfaces.extensions.cdi.jpa.test;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ * producer for a simple @Default EntityManager
+ */
+public class DefaultEntityManagerProducer {
+
+ private @PersistenceContext(unitName = "test") EntityManager entityManager;
+
+ public @Produces @RequestScoped EntityManager createEntityManager()
+ {
+ return entityManager;
+ }
+
+ public void closeEntityManager(@Disposes EntityManager em)
+ {
+ em.close();
+ }
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/DefaultEntityManagerProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestEntity.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestEntity.java?rev=1171747&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestEntity.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestEntity.java Fri Sep 16 19:38:36 2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.jpa.test;
+
+import javax.persistence.*;
+
+/**
+ * just a dumb test entity...
+ */
+@Entity
+public class TestEntity
+{
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @Column(length=100)
+ private String name;
+
+ @Version
+ private int version;
+
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestEntity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestServiceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestServiceImpl.java?rev=1171747&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestServiceImpl.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestServiceImpl.java Fri Sep 16 19:38:36 2011
@@ -0,0 +1,46 @@
+/*
+ * 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.myfaces.extensions.cdi.jpa.test;
+
+import org.apache.myfaces.extensions.cdi.jpa.api.Transactional;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+@Transactional
+public class TestServiceImpl
+{
+ private @Inject EntityManager entityManager;
+
+ public String doThis()
+ {
+ if (entityManager == null || entityManager.getTransaction() == null)
+ {
+ throw new RuntimeException("EntityManager must not be null!");
+ }
+ return "this";
+ }
+
+ public String doThat()
+ {
+ doThis();
+ return "that";
+ }
+
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TestServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TransactionInterceptorTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TransactionInterceptorTest.java?rev=1171747&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TransactionInterceptorTest.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TransactionInterceptorTest.java Fri Sep 16 19:38:36 2011
@@ -0,0 +1,49 @@
+/*
+ * 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.myfaces.extensions.cdi.jpa.test;
+
+
+import org.apache.myfaces.extensions.cdi.core.test.util.ContainerTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
+
+/**
+ * Test for @Transactional interceptor
+ */
+public class TransactionInterceptorTest extends ContainerTestBase
+{
+ @Test
+ public void testTransactionInterceptor()
+ {
+ TestServiceImpl testService = getBeanInstance(TestServiceImpl.class);
+ Assert.assertNotNull(testService);
+
+ Assert.assertEquals(testService.doThis(), "this");
+ Assert.assertEquals(testService.doThat(), "that");
+
+ EntityManager em = getBeanInstance(EntityManager.class);
+ Assert.assertNotNull(em);
+ EntityTransaction trans = em.getTransaction();
+ Assert.assertNotNull(trans);
+ }
+}
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jpa/test/TransactionInterceptorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/beans.xml?rev=1171747&view=auto
==============================================================================
(empty)
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/beans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/persistence.xml?rev=1171747&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/persistence.xml (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/persistence.xml Fri Sep 16 19:38:36 2011
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+ 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.
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+
+ <persistence-unit name="test" >
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+
+ <class>org.apache.myfaces.extensions.cdi.jpa.test.TestEntity</class>
+
+ <properties>
+ <property name="openjpa.jdbc.DBDictionary" value="hsql" />
+ <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
+ <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:test" />
+ <property name="openjpa.ConnectionUserName" value="sa" />
+ <property name="openjpa.ConnectionPassword" value="" />
+ <property name="openjpa.Log" value="DefaultLevel=TRACE"/>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+
+ <!-- Enhancement via subclassing. This is not suggested for production! -->
+ <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+ </properties>
+
+ </persistence-unit>
+</persistence>
Propchange: myfaces/extensions/cdi/trunk/jee-modules/jpa-module/impl/src/test/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/extensions/cdi/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/pom.xml?rev=1171747&r1=1171746&r2=1171747&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/pom.xml (original)
+++ myfaces/extensions/cdi/trunk/pom.xml Fri Sep 16 19:38:36 2011
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces</groupId>
<artifactId>myfaces</artifactId>
- <version>9</version>
+ <version>11-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.extensions.cdi</groupId>
@@ -131,6 +131,11 @@
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-resource</artifactId>
+ <version>${owb.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
<version>${owb.version}</version>
</dependency>
@@ -420,6 +425,30 @@
<version>5.14.10</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans.test</groupId>
+ <artifactId>cditest</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans.test</groupId>
+ <artifactId>cditest-owb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ We currently need this for the CDI test container to emulate the @SessionScoped.
+ TODO: Finally this should not be necessary anymore.
+ -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_2.2_spec</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
@@ -495,7 +524,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.2</version>
<executions>
<execution>
<id>verify-style</id>
@@ -575,8 +603,8 @@
<version>2.3</version>
<configuration>
<rulesets>
- <ruleset>/rulesets/basic.xml</ruleset>
- <ruleset>/rulesets/unusedcode.xml</ruleset>
+ <ruleset>rulesets/basic.xml</ruleset>
+ <ruleset>rulesets/unusedcode.xml</ruleset>
</rulesets>
<minimumTokens>100</minimumTokens>
<targetJdk>1.5</targetJdk>
@@ -585,7 +613,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.2</version>
<configuration>
<configLocation>default/myfaces-checks-standard.xml</configLocation>
<headerLocation>default/myfaces-header.txt</headerLocation>