Seam SVN: r13723 - modules/persistence/trunk.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-09-06 06:00:00 -0400 (Mon, 06 Sep 2010)
New Revision: 13723
Modified:
modules/persistence/trunk/pom.xml
Log:
oops
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-09-06 09:53:11 UTC (rev 13722)
+++ modules/persistence/trunk/pom.xml 2010-09-06 10:00:00 UTC (rev 13723)
@@ -29,7 +29,7 @@
<module>api</module>
<module>impl</module>
<module>tests-base</module>
- <module>tests-weld-se</module>
+ <!-- <module>tests-weld-se</module> -->
</modules>
<properties>
14 years, 2 months
Seam SVN: r13722 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-09-06 05:53:11 -0400 (Mon, 06 Sep 2010)
New Revision: 13722
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SePersistenceContextExtension.java
Log:
add warning to SePersistenceContextExtension
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SePersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SePersistenceContextExtension.java 2010-09-06 09:48:22 UTC (rev 13721)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SePersistenceContextExtension.java 2010-09-06 09:53:11 UTC (rev 13722)
@@ -65,6 +65,12 @@
* unit (naturally).
* </p>
*
+ * <b>WARNING</b>
+ *
+ * If this is used to Bootstrap @PersistenceContext injection you will end up
+ * with a @Dependent scoped application manager, rather than a transaction
+ * scoped container managed entity manager.
+ *
* @author Gavin King
* @author Dan Allen
*/
14 years, 2 months
Seam SVN: r13721 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence and 6 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-09-06 05:48:22 -0400 (Mon, 06 Sep 2010)
New Revision: 13721
Added:
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
modules/persistence/trunk/pom.xml
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java
modules/persistence/trunk/tests-jboss/pom.xml
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml
Log:
SEAMPERSIST-9 Allow SMPC to be defined using @Resource
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Set;
+import javax.annotation.Resource;
import javax.enterprise.context.Dependent;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Alternative;
@@ -95,7 +96,7 @@
{
// look for a seam managed persistence unit declaration on EE resource
// producer fields
- if (f.isAnnotationPresent(SeamManaged.class) && f.isAnnotationPresent(PersistenceUnit.class) && f.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(f.getJavaMember().getType()))
+ if (f.isAnnotationPresent(SeamManaged.class) && (f.isAnnotationPresent(PersistenceUnit.class) || f.isAnnotationPresent(Resource.class)) && f.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(f.getJavaMember().getType()))
{
if (modifiedType == null)
{
@@ -127,6 +128,7 @@
modifiedType.removeFromField(f.getJavaMember(), scope);
}
registerManagedPersistenceContext(qualifiers, scope, f.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), f);
+ log.info("Configuring Seam Managed Persistence Context from producer field " + f.getDeclaringType().getJavaClass().getName() + "." + f.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
// now look for producer methods that produce an EntityManagerFactory.
// This allows the user to manually configure an EntityManagerFactory
@@ -167,6 +169,7 @@
modifiedType.removeFromMethod(m.getJavaMember(), scope);
modifiedType.addToMethod(m.getJavaMember(), ApplicationScopedLiteral.INSTANCE);
registerManagedPersistenceContext(qualifiers, scope, m.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), m);
+ log.info("Configuring Seam Managed Persistence Context from producer method " + m.getDeclaringType().getJavaClass().getName() + "." + m.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
}
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/pom.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -37,7 +37,7 @@
<jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
<weld.extensions.version>1.0.0-SNAPSHOT</weld.extensions.version>
<hibernate.search.version>3.2.1.Final</hibernate.search.version>
- <arquillian.version>1.0.0.Alpha3</arquillian.version>
+ <arquillian.version>1.0.0.Alpha4</arquillian.version>
<jboss.server.manager.version>1.0.3.GA</jboss.server.manager.version>
<jboss-as-client.version>6.0.0.20100721-M4</jboss-as-client.version>
</properties>
Modified: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -34,7 +34,6 @@
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
-import org.jboss.seam.transactions.test.util.IndexedHotel;
import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
import org.junit.Assert;
import org.junit.Test;
Modified: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -40,12 +40,11 @@
import org.junit.Assert;
import org.junit.Test;
-
public class HibernateSearchTestBase
{
public static Class<?>[] getTestClasses()
{
- return new Class[] { HibernateSearchTestBase.class, IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class };
+ return new Class[] { IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class, HibernateSearchTestBase.class };
}
@Inject
Modified: modules/persistence/trunk/tests-jboss/pom.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/pom.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/pom.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -33,6 +33,11 @@
</dependency>
<dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>provided</scope>
@@ -142,7 +147,6 @@
<skip>true</skip>
</configuration>
</plugin>
-
</plugins>
</build>
Modified: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -48,6 +48,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+
war.addClasses(getTestClasses());
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
war.addWebResource("META-INF/persistence-orm.xml", "classes/META-INF/persistence.xml");
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.ManagedPersistenceContextTestBase;
+import org.jboss.seam.persistence.transaction.test.util.JNDIManagedPersistenceContextProvider;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class JNDIManagedPersistenceContextTest extends ManagedPersistenceContextTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(new Class[] { ManagedPersistenceContextTestBase.class, Hotel.class, JNDIManagedPersistenceContextProvider.class, HelloService.class });
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transaction.test.util;
+
+import javax.annotation.Resource;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.seam.persistence.SeamManaged;
+
+public class JNDIManagedPersistenceContextProvider
+{
+ @Resource(mappedName = "java:EntityManagerFactory")
+ @RequestScoped
+ @Produces
+ @SeamManaged
+ EntityManagerFactory emf;
+}
Modified: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -15,13 +15,6 @@
<properties>
<!-- Properties for Hibernate (default provider for JBoss AS) -->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
- <property name="hibernate.show_sql" value="true"/>
- <!-- Only format when you need to debug, because it slows things down -->
- <property name="hibernate.format_sql" value="false"/>
-
- <!-- Properties for EclipseLink (default provider for GlassFish) -->
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
- <property name="eclipselink.logging.level" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
Modified: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -21,6 +21,7 @@
<!-- Properties for EclipseLink (default provider for GlassFish) -->
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level" value="FINE"/>
+ <property name="jboss.entity.manager.factory.jndi.name" value="java:EntityManagerFactory"/>
</properties>
</persistence-unit>
</persistence>
14 years, 2 months
Seam SVN: r13719 - modules/servlet/trunk.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-09-03 13:22:16 -0400 (Fri, 03 Sep 2010)
New Revision: 13719
Modified:
modules/servlet/trunk/pom.xml
Log:
switch to jboss repo
Modified: modules/servlet/trunk/pom.xml
===================================================================
--- modules/servlet/trunk/pom.xml 2010-09-03 16:49:24 UTC (rev 13718)
+++ modules/servlet/trunk/pom.xml 2010-09-03 17:22:16 UTC (rev 13719)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.jboss.seam</groupId>
<artifactId>seam-parent</artifactId>
- <version>2</version>
+ <version>3</version>
</parent>
<artifactId>seam-servlet-parent</artifactId>
@@ -153,6 +153,45 @@
<module>dist</module>
</modules>
</profile>
+ <profile>
+ <id>jboss-public-repository</id>
+ <activation>
+ <property>
+ <name>jboss-public-repository</name>
+ <value>!false</value>
+ </property>
+ </activation>
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>http://repository.jboss.org/nexus/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
</profiles>
<scm>
14 years, 2 months
Seam SVN: r13718 - in modules/servlet/trunk: impl/src/main/java/org/jboss/seam/servlet/event and 1 other directories.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-09-03 12:49:24 -0400 (Fri, 03 Sep 2010)
New Revision: 13718
Added:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/AbstractServletEventBridge.java
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/Servlet3EventBridge.java
Modified:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java
modules/servlet/trunk/impl/src/main/resources/META-INF/web-fragment.xml
modules/servlet/trunk/pom.xml
Log:
SEAMSERVLET-10, and gracefully degrade if BeanManager is not available
Added: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/AbstractServletEventBridge.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/AbstractServletEventBridge.java (rev 0)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/AbstractServletEventBridge.java 2010-09-03 16:49:24 UTC (rev 13718)
@@ -0,0 +1,33 @@
+package org.jboss.seam.servlet.event;
+
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+
+import org.jboss.weld.extensions.beanManager.BeanManagerAware;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AbstractServletEventBridge extends BeanManagerAware
+{
+
+ private transient Logger log = LoggerFactory.getLogger(AbstractServletEventBridge.class);
+
+ protected void fireEvent(final Object payload, final Annotation... qualifiers)
+ {
+ if (isBeanManagerAvailable())
+ {
+ /*
+ * We can't always guarantee the BeanManager will be available,
+ * especially in environemnts where we don't control bootstrap order
+ * that well (e.g. Servlet containers)
+ */
+ log.trace("Firing event #0 with qualifiers #1", payload, Arrays.asList(qualifiers));
+ getBeanManager().fireEvent(payload, qualifiers);
+ }
+ else
+ {
+ log.debug("BeanManager can't be found so not sending event " + payload + " with qualifiers " + Arrays.asList(qualifiers));
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/AbstractServletEventBridge.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/Servlet3EventBridge.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/Servlet3EventBridge.java (rev 0)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/Servlet3EventBridge.java 2010-09-03 16:49:24 UTC (rev 13718)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.servlet.event;
+
+import java.io.IOException;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletRequestAttributeEvent;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.jboss.seam.servlet.event.qualifier.Added;
+import org.jboss.seam.servlet.event.qualifier.Attribute;
+import org.jboss.seam.servlet.event.qualifier.Bound;
+import org.jboss.seam.servlet.event.qualifier.Completed;
+import org.jboss.seam.servlet.event.qualifier.Created;
+import org.jboss.seam.servlet.event.qualifier.Destroyed;
+import org.jboss.seam.servlet.event.qualifier.DidActivate;
+import org.jboss.seam.servlet.event.qualifier.Error;
+import org.jboss.seam.servlet.event.qualifier.Initialized;
+import org.jboss.seam.servlet.event.qualifier.Removed;
+import org.jboss.seam.servlet.event.qualifier.Replaced;
+import org.jboss.seam.servlet.event.qualifier.StartAsync;
+import org.jboss.seam.servlet.event.qualifier.Timeout;
+import org.jboss.seam.servlet.event.qualifier.Unbound;
+import org.jboss.seam.servlet.event.qualifier.Value;
+import org.jboss.seam.servlet.event.qualifier.WillPassivate;
+
+/**
+ * A servlet listener that propagates the events to the current CDI Bean Manager
+ * event queue.
+ *
+ * This interface handles listeners that were added in Servlet 3 to preserve
+ * compatibility with Servlet 2.5
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class Servlet3EventBridge extends AbstractServletEventBridge implements AsyncListener
+{
+ /**
+ * Asynchronous events
+ */
+
+ public void onComplete(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, COMPLETED);
+ }
+
+ public void onError(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, ERROR);
+ }
+
+ public void onStartAsync(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, STARTASYNCH);
+ }
+
+ public void onTimeout(final AsyncEvent e) throws IOException
+ {
+ fireEvent(e, TIMEOUT);
+ }
+
+ private static final AnnotationLiteral<Completed> COMPLETED = new AnnotationLiteral<Completed>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Error> ERROR = new AnnotationLiteral<Error>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<StartAsync> STARTASYNCH = new AnnotationLiteral<StartAsync>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+
+ private static final AnnotationLiteral<Timeout> TIMEOUT = new AnnotationLiteral<Timeout>()
+ {
+ private static final long serialVersionUID = -1610281796509557441L;
+ };
+}
Property changes on: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/Servlet3EventBridge.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java
===================================================================
--- modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java 2010-09-03 11:43:41 UTC (rev 13717)
+++ modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/event/ServletEventBridge.java 2010-09-03 16:49:24 UTC (rev 13718)
@@ -21,14 +21,7 @@
*/
package org.jboss.seam.servlet.event;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-
-import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-import javax.servlet.AsyncEvent;
-import javax.servlet.AsyncListener;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
@@ -47,20 +40,15 @@
import org.jboss.seam.servlet.event.qualifier.Added;
import org.jboss.seam.servlet.event.qualifier.Attribute;
import org.jboss.seam.servlet.event.qualifier.Bound;
-import org.jboss.seam.servlet.event.qualifier.Completed;
import org.jboss.seam.servlet.event.qualifier.Created;
import org.jboss.seam.servlet.event.qualifier.Destroyed;
import org.jboss.seam.servlet.event.qualifier.DidActivate;
-import org.jboss.seam.servlet.event.qualifier.Error;
import org.jboss.seam.servlet.event.qualifier.Initialized;
import org.jboss.seam.servlet.event.qualifier.Removed;
import org.jboss.seam.servlet.event.qualifier.Replaced;
-import org.jboss.seam.servlet.event.qualifier.StartAsync;
-import org.jboss.seam.servlet.event.qualifier.Timeout;
import org.jboss.seam.servlet.event.qualifier.Unbound;
import org.jboss.seam.servlet.event.qualifier.Value;
import org.jboss.seam.servlet.event.qualifier.WillPassivate;
-import org.slf4j.Logger;
/**
* A servlet listener that propagates the events to the current CDI Bean Manager
@@ -69,18 +57,9 @@
* @author Nicklas Karlsson
*
*/
-public class ServletEventBridge implements HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener, AsyncListener
+public class ServletEventBridge extends AbstractServletEventBridge implements HttpSessionActivationListener, HttpSessionAttributeListener, HttpSessionBindingListener, HttpSessionListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
{
- @Inject
- private BeanManager beanManager;
- @Inject
- private Logger log;
-
- public ServletEventBridge()
- {
- }
-
/**
* Session activated / passivated events
*/
@@ -204,36 +183,6 @@
fireEvent(e, REPLACED, new AttributeLiteral(e.getName()));
}
- /**
- * Asynchronous events
- */
-
- public void onComplete(final AsyncEvent e) throws IOException
- {
- fireEvent(e, COMPLETED);
- }
-
- public void onError(final AsyncEvent e) throws IOException
- {
- fireEvent(e, ERROR);
- }
-
- public void onStartAsync(final AsyncEvent e) throws IOException
- {
- fireEvent(e, STARTASYNCH);
- }
-
- public void onTimeout(final AsyncEvent e) throws IOException
- {
- fireEvent(e, TIMEOUT);
- }
-
- private void fireEvent(final Object payload, final Annotation... qualifiers)
- {
- log.trace("Firing event #0 with qualifiers #1", payload, qualifiers);
- beanManager.fireEvent(payload, qualifiers);
- }
-
/*
* Annotation Literal Constants
*/
@@ -287,26 +236,6 @@
private static final long serialVersionUID = -1610281796509557441L;
};
- private static final AnnotationLiteral<Completed> COMPLETED = new AnnotationLiteral<Completed>()
- {
- private static final long serialVersionUID = -1610281796509557441L;
- };
-
- private static final AnnotationLiteral<Error> ERROR = new AnnotationLiteral<Error>()
- {
- private static final long serialVersionUID = -1610281796509557441L;
- };
-
- private static final AnnotationLiteral<StartAsync> STARTASYNCH = new AnnotationLiteral<StartAsync>()
- {
- private static final long serialVersionUID = -1610281796509557441L;
- };
-
- private static final AnnotationLiteral<Timeout> TIMEOUT = new AnnotationLiteral<Timeout>()
- {
- private static final long serialVersionUID = -1610281796509557441L;
- };
-
private class AttributeLiteral extends AnnotationLiteral<Attribute> implements Attribute
{
private static final long serialVersionUID = -7137081215123043985L;
Modified: modules/servlet/trunk/impl/src/main/resources/META-INF/web-fragment.xml
===================================================================
--- modules/servlet/trunk/impl/src/main/resources/META-INF/web-fragment.xml 2010-09-03 11:43:41 UTC (rev 13717)
+++ modules/servlet/trunk/impl/src/main/resources/META-INF/web-fragment.xml 2010-09-03 16:49:24 UTC (rev 13718)
@@ -7,5 +7,9 @@
<listener>
<listener-class>org.jboss.seam.servlet.event.ServletEventBridge</listener-class>
</listener>
+
+ <listener>
+ <listener-class>org.jboss.seam.servlet.event.Servlet3EventBridge</listener-class>
+ </listener>
</web-fragment>
Modified: modules/servlet/trunk/pom.xml
===================================================================
--- modules/servlet/trunk/pom.xml 2010-09-03 11:43:41 UTC (rev 13717)
+++ modules/servlet/trunk/pom.xml 2010-09-03 16:49:24 UTC (rev 13718)
@@ -53,6 +53,12 @@
<artifactId>seam-servlet-api</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</dependencyManagement>
14 years, 2 months
Seam SVN: r13717 - in branches/community/Seam_2_2/src/test/ftest/examples: spring and 1 other directory.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-09-03 07:43:41 -0400 (Fri, 03 Sep 2010)
New Revision: 13717
Modified:
branches/community/Seam_2_2/src/test/ftest/examples/blog/build.xml
branches/community/Seam_2_2/src/test/ftest/examples/spring/build.xml
Log:
Use new jboss42 ant targets properly in ftests
Modified: branches/community/Seam_2_2/src/test/ftest/examples/blog/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/blog/build.xml 2010-09-03 03:53:49 UTC (rev 13716)
+++ branches/community/Seam_2_2/src/test/ftest/examples/blog/build.xml 2010-09-03 11:43:41 UTC (rev 13717)
@@ -23,6 +23,8 @@
<project name="blog.ftest.build" basedir="." default="build">
<property name="example.name" value="blog" />
<property name="jboss4.deploy.target" value="jboss42" />
+ <property name="jboss5.deploy.target" value="deploy" />
+
<import file="../build.xml" />
</project>
Modified: branches/community/Seam_2_2/src/test/ftest/examples/spring/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/examples/spring/build.xml 2010-09-03 03:53:49 UTC (rev 13716)
+++ branches/community/Seam_2_2/src/test/ftest/examples/spring/build.xml 2010-09-03 11:43:41 UTC (rev 13717)
@@ -25,6 +25,7 @@
<property name="jboss4.deploy.target" value="jboss42" />
<property name="jboss4.undeploy.target" value="jbosswar.undeploy" />
<property name="jboss4.context.path" value="/jboss-seam-spring" />
+ <property name="jboss5.deploy.target" value="jbosswar" />
<import file="../build.xml" />
</project>
14 years, 2 months
Seam SVN: r13716 - in modules/persistence/trunk: api/src/main/java/org/jboss/seam/persistence and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-09-02 23:53:49 -0400 (Thu, 02 Sep 2010)
New Revision: 13716
Added:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/hibernate/
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/hibernate/SeamManagedHibernateSessionCreated.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextProxyHandler.java
Modified:
modules/persistence/trunk/pom.xml
Log:
add start of managed hibernate managed sessions
Added: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/hibernate/SeamManagedHibernateSessionCreated.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/hibernate/SeamManagedHibernateSessionCreated.java (rev 0)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/hibernate/SeamManagedHibernateSessionCreated.java 2010-09-03 03:53:49 UTC (rev 13716)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.hibernate;
+
+import org.hibernate.Session;
+
+/**
+ * event that is fired when the hibernate session is created. This allows you to
+ * configure the session before it is used, e.g. by enabling filters
+ *
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ */
+public class SeamManagedHibernateSessionCreated
+{
+ private final Session session;
+
+ public SeamManagedHibernateSessionCreated(Session session)
+ {
+ this.session = session;
+ }
+
+ public Session getSession()
+ {
+ return session;
+ }
+
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextBeanLifecycle.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextBeanLifecycle.java 2010-09-03 03:53:49 UTC (rev 13716)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.hibernate;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.Set;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.jboss.seam.persistence.HibernatePersistenceProvider;
+import org.jboss.seam.persistence.ManagedPersistenceContext;
+import org.jboss.seam.persistence.PersistenceContexts;
+import org.jboss.weld.extensions.bean.BeanLifecycle;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * lifecycle for seam managed hibernate sessions
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class HibernateManagedPersistenceContextBeanLifecycle implements BeanLifecycle<Session>
+{
+ private static final Logger log = LoggerFactory.getLogger(HibernateManagedPersistenceContextBeanLifecycle.class);
+
+ private final Class<?> proxyClass;
+
+ private final Constructor<?> proxyConstructor;
+
+ private HibernatePersistenceProvider persistenceProvider = new HibernatePersistenceProvider();
+
+ private PersistenceContexts persistenceContexts;
+
+ protected final Annotation[] qualifiers;
+
+ protected final BeanManager manager;
+
+ private SessionFactory sessionFactory;
+
+ public HibernateManagedPersistenceContextBeanLifecycle(Set<Annotation> qualifiers, ClassLoader loader, BeanManager manager)
+ {
+ this.manager = manager;
+ Set<Class<?>> additionalinterfaces = persistenceProvider.getAdditionalSessionInterfaces();
+ Class<?>[] interfaces = new Class[additionalinterfaces.size() + 3];
+ int count = 0;
+ for (Class<?> i : additionalinterfaces)
+ {
+ interfaces[count++] = i;
+ }
+
+ interfaces[count++] = Session.class;
+ interfaces[count++] = Serializable.class;
+ interfaces[count++] = ManagedPersistenceContext.class;
+ proxyClass = Proxy.getProxyClass(loader, interfaces);
+ try
+ {
+ proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ this.qualifiers = new Annotation[qualifiers.size()];
+ int i = 0;
+ for (Annotation a : qualifiers)
+ {
+ this.qualifiers[i++] = a;
+ }
+ }
+
+ /**
+ * creates the proxy
+ */
+ public Session create(Bean<Session> bean, CreationalContext<Session> arg0)
+ {
+ try
+ {
+ SessionFactory sf = getSessionFactory();
+ Session session = sf.openSession();
+ session = (Session) persistenceProvider.proxyDelegate(session);
+ HibernateManagedPersistenceContextProxyHandler handler = new HibernateManagedPersistenceContextProxyHandler(session, manager, bean.getQualifiers(), getPersistenceContexts(), persistenceProvider);
+ Session proxy = (Session) proxyConstructor.newInstance(handler);
+ ((ManagedPersistenceContext) proxy).changeFlushMode(getPersistenceContexts().getFlushMode());
+ manager.fireEvent(new SeamManagedHibernateSessionCreated(proxy), qualifiers);
+
+ return proxy;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void destroy(Bean<Session> bean, Session session, CreationalContext<Session> arg1)
+ {
+ ((ManagedPersistenceContext) session).closeAfterTransaction();
+ arg1.release();
+ try
+ {
+ getPersistenceContexts().untouch((ManagedPersistenceContext) session);
+ }
+ catch (ContextNotActiveException e)
+ {
+ log.debug("Could not untouch PersistenceContext as conversation scope not active");
+ }
+ }
+
+ private PersistenceContexts getPersistenceContexts()
+ {
+ if (persistenceContexts == null)
+ {
+ Bean<PersistenceContexts> bean = (Bean) manager.resolve(manager.getBeans(PersistenceContexts.class, DefaultLiteral.INSTANCE));
+ if (bean == null)
+ {
+ throw new RuntimeException("Could not find PersistenceContexts bean");
+ }
+ CreationalContext<PersistenceContexts> ctx = manager.createCreationalContext(bean);
+ persistenceContexts = (PersistenceContexts) manager.getReference(bean, PersistenceContexts.class, ctx);
+ }
+ return persistenceContexts;
+ }
+
+ /**
+ * lazily resolve the relevant EMF
+ */
+ protected SessionFactory getSessionFactory()
+ {
+ if (sessionFactory == null)
+ {
+ Bean<SessionFactory> bean = (Bean) manager.resolve(manager.getBeans(SessionFactory.class, qualifiers));
+ if (bean == null)
+ {
+ throw new RuntimeException("Could not find SessionFactory bean with qualifiers" + qualifiers);
+ }
+ CreationalContext<SessionFactory> ctx = manager.createCreationalContext(bean);
+ sessionFactory = (SessionFactory) manager.getReference(bean, SessionFactory.class, ctx);
+ }
+ return sessionFactory;
+ }
+
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextExtension.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextExtension.java 2010-09-03 03:53:49 UTC (rev 13716)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.hibernate;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import org.hibernate.Session;
+import org.jboss.seam.persistence.HibernatePersistenceProvider;
+import org.jboss.seam.persistence.ManagedPersistenceContext;
+import org.jboss.seam.persistence.SeamManaged;
+import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.bean.BeanBuilder;
+import org.jboss.weld.extensions.literal.AnyLiteral;
+import org.jboss.weld.extensions.literal.ApplicationScopedLiteral;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Extension the wraps producer methods/fields that produce an entity manager to
+ * turn them into Seam Managed Persistence Contexts.
+ *
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class HibernateManagedPersistenceContextExtension implements Extension
+{
+
+ Set<Bean<?>> beans = new HashSet<Bean<?>>();
+
+ private static final Logger log = LoggerFactory.getLogger(HibernateManagedPersistenceContextExtension.class);
+
+ private final HibernatePersistenceProvider provider = new HibernatePersistenceProvider();
+
+ /**
+ * loops through the fields on an AnnotatedType looking for a SessionFactory
+ * producer that is annotated {@link SeamManaged}. Then a corresponding smpc
+ * bean is created and registered. The producers scope will be changed to
+ * ApplicationScoped (or @Dependent if it is created using resource
+ * injection) to ensure that the SMPC is only created once
+ *
+ */
+ public <T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> event, BeanManager manager)
+ {
+ AnnotatedTypeBuilder<T> modifiedType = null;
+ for (AnnotatedField<? super T> f : event.getAnnotatedType().getFields())
+ {
+ // look for a seam managed persistence unit declaration on EE resource
+ // producer fields
+ if (f.isAnnotationPresent(SeamManaged.class) && f.isAnnotationPresent(PersistenceUnit.class) && f.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(f.getJavaMember().getType()))
+ {
+ if (modifiedType == null)
+ {
+ modifiedType = new AnnotatedTypeBuilder().readFromType(event.getAnnotatedType());
+ }
+ Set<Annotation> qualifiers = new HashSet<Annotation>();
+ Class<? extends Annotation> scope = Dependent.class;
+ // get the qualifier and scope for the new bean
+ for (Annotation a : f.getAnnotations())
+ {
+ if (manager.isQualifier(a.annotationType()))
+ {
+ qualifiers.add(a);
+ }
+ else if (manager.isScope(a.annotationType()))
+ {
+ scope = a.annotationType();
+ }
+ }
+ if (qualifiers.isEmpty())
+ {
+ qualifiers.add(new DefaultLiteral());
+ }
+ qualifiers.add(AnyLiteral.INSTANCE);
+ // we need to remove the scope, they are not nessesarily supported
+ // on producer fields
+ if (scope != Dependent.class)
+ {
+ modifiedType.removeFromField(f.getJavaMember(), scope);
+ }
+ registerManagedPersistenceContext(qualifiers, scope, manager, event.getAnnotatedType().getJavaClass().getClassLoader());
+ }
+ // now look for producer methods that produce an EntityManagerFactory.
+ // This allows the user to manually configure an EntityManagerFactory
+ // and return it from a producer method
+ }
+ // now look for SMPC's that are configured programatically via a producer
+ // method. This looks for both EMF's and SessionFactories
+ // The producer method has its scope changes to application scoped
+ // this allows for programatic config of the SMPC
+ for (AnnotatedMethod<? super T> m : event.getAnnotatedType().getMethods())
+ {
+ if (m.isAnnotationPresent(SeamManaged.class) && m.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(m.getJavaMember().getReturnType()))
+ {
+ if (modifiedType == null)
+ {
+ modifiedType = new AnnotatedTypeBuilder().readFromType(event.getAnnotatedType());
+ }
+ Set<Annotation> qualifiers = new HashSet<Annotation>();
+ Class<? extends Annotation> scope = Dependent.class;
+ // get the qualifier and scope for the new bean
+ for (Annotation a : m.getAnnotations())
+ {
+ if (manager.isQualifier(a.annotationType()))
+ {
+ qualifiers.add(a);
+ }
+ else if (manager.isScope(a.annotationType()))
+ {
+ scope = a.annotationType();
+ }
+ }
+ if (qualifiers.isEmpty())
+ {
+ qualifiers.add(new DefaultLiteral());
+ }
+ qualifiers.add(AnyLiteral.INSTANCE);
+ // we need to change the scope to application scoped
+ modifiedType.removeFromMethod(m.getJavaMember(), scope);
+ modifiedType.addToMethod(m.getJavaMember(), ApplicationScopedLiteral.INSTANCE);
+ registerManagedPersistenceContext(qualifiers, scope, manager, event.getAnnotatedType().getJavaClass().getClassLoader());
+ }
+ }
+
+ if (modifiedType != null)
+ {
+ event.setAnnotatedType(modifiedType.create());
+ }
+ }
+
+ private void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, BeanManager manager, ClassLoader loader)
+ {
+ // we need to add all additional interfaces from our
+ // SeamPersistenceProvider to the bean as at this stage we have no way of
+ // knowing which persistence provider is actually in use this only time
+ // that this may cause slightly odd behavior is if two providers are on
+ // the class path, in which case the entity manager may be assignable to
+ // additional interfaces that it does not support.
+ Set<Class<?>> additionalInterfaces = new HashSet<Class<?>>();
+
+ additionalInterfaces.addAll(provider.getAdditionalEntityManagerInterfaces());
+
+ // create the new bean to be registered later
+ HibernateManagedPersistenceContextBeanLifecycle lifecycle = new HibernateManagedPersistenceContextBeanLifecycle(qualifiers, loader, manager);
+ AnnotatedTypeBuilder<Session> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(Session.class);
+ BeanBuilder<Session> builder = new BeanBuilder<Session>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
+ builder.setQualifiers(qualifiers);
+ builder.setScope(scope);
+ builder.getTypes().add(ManagedPersistenceContext.class);
+ builder.getTypes().addAll(additionalInterfaces);
+ builder.getTypes().add(Object.class);
+ builder.setBeanLifecycle(lifecycle);
+ beans.add(builder.create());
+ }
+
+ public void afterBeanDiscovery(@Observes AfterBeanDiscovery event)
+ {
+ for (Bean<?> i : beans)
+ {
+ event.addBean(i);
+ }
+ }
+
+}
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextProxyHandler.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/hibernate/HibernateManagedPersistenceContextProxyHandler.java 2010-09-03 03:53:49 UTC (rev 13716)
@@ -0,0 +1,209 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.hibernate;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+
+import org.hibernate.FlushMode;
+import org.hibernate.Session;
+import org.jboss.seam.persistence.FlushModeType;
+import org.jboss.seam.persistence.ManagedPersistenceContext;
+import org.jboss.seam.persistence.PersistenceContexts;
+import org.jboss.seam.persistence.SeamPersistenceProvider;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
+import org.jboss.seam.persistence.util.InstanceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Proxy handler for the seam managed Hibernate session. This handler makes sure
+ * that the EntityManager is enrolled in the current transaction before passing
+ * the call through to the delegate
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class HibernateManagedPersistenceContextProxyHandler implements InvocationHandler, Serializable, Synchronization
+{
+
+ private static final long serialVersionUID = -6539267789786229774L;
+
+ private final Session delegate;
+
+ private final Instance<SeamTransaction> userTransactionInstance;
+
+ private transient boolean synchronizationRegistered;
+
+ private final PersistenceContexts persistenceContexts;
+
+ private final Set<Annotation> qualifiers;
+
+ private final SeamPersistenceProvider provider;
+
+ private boolean persistenceContextsTouched = false;
+
+ private boolean closeOnTransactionCommit = false;
+
+ static final Logger log = LoggerFactory.getLogger(HibernateManagedPersistenceContextProxyHandler.class);
+
+ public HibernateManagedPersistenceContextProxyHandler(Session delegate, BeanManager beanManager, Set<Annotation> qualifiers, PersistenceContexts persistenceContexts, SeamPersistenceProvider provider)
+ {
+ this.qualifiers = qualifiers;
+ this.provider = provider;
+ this.delegate = delegate;
+ this.userTransactionInstance = InstanceResolver.getInstance(SeamTransaction.class, beanManager, DefaultTransactionLiteral.INSTANCE);
+ this.persistenceContexts = persistenceContexts;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ if (!synchronizationRegistered)
+ {
+ joinTransaction();
+ }
+ touch((ManagedPersistenceContext) proxy);
+ if ("changeFlushMode".equals(method.getName()) && method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(FlushModeType.class))
+ {
+ changeFushMode((FlushModeType) args[0]);
+ return null;
+ }
+ if ("getBeanType".equals(method.getName()) && method.getParameterTypes().length == 0)
+ {
+ return EntityManager.class;
+ }
+ if ("getQualifiers".equals(method.getName()) && method.getParameterTypes().length == 0)
+ {
+ return Collections.unmodifiableSet(qualifiers);
+ }
+ if ("getPersistenceProvider".equals(method.getName()) && method.getParameterTypes().length == 0)
+ {
+ return provider;
+ }
+ if ("closeAfterTransaction".equals(method.getName()) && method.getParameterTypes().length == 0)
+ {
+ closeAfterTransaction();
+ return null;
+ }
+ return method.invoke(delegate, args);
+ }
+
+ private void joinTransaction() throws SystemException
+ {
+ SeamTransaction transaction = userTransactionInstance.get();
+ if (transaction.isActive())
+ {
+ delegate.isOpen();
+ try
+ {
+ transaction.registerSynchronization(this);
+ synchronizationRegistered = true;
+ }
+ catch (Exception e)
+ {
+ // synchronizationRegistered =
+ // PersistenceProvider.instance().registerSynchronization(this,
+ // entityManager);
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void closeAfterTransaction() throws SystemException
+ {
+ SeamTransaction transaction = userTransactionInstance.get();
+ if (transaction.isActive())
+ {
+ closeOnTransactionCommit = true;
+ }
+ else
+ {
+ if (delegate.isOpen())
+ {
+ delegate.close();
+ }
+ }
+ }
+
+ private void changeFushMode(FlushModeType flushModeType)
+ {
+ switch (flushModeType)
+ {
+ case AUTO:
+ delegate.setFlushMode(FlushMode.AUTO);
+ break;
+ case MANUAL:
+ delegate.setFlushMode(FlushMode.MANUAL);
+ break;
+ case COMMIT:
+ delegate.setFlushMode(FlushMode.COMMIT);
+ break;
+ default:
+ throw new RuntimeException("Unkown flush mode: " + flushModeType);
+ }
+ }
+
+ void touch(ManagedPersistenceContext delegate)
+ {
+ if (!persistenceContextsTouched)
+ {
+ try
+ {
+ // we need to do this first to prevent an infinite loop
+ persistenceContextsTouched = true;
+ persistenceContexts.touch(delegate);
+ }
+ catch (ContextNotActiveException e)
+ {
+ persistenceContextsTouched = false;
+ log.debug("Not touching pc " + this + "as conversation scope not active");
+ }
+ }
+ }
+
+ public void afterCompletion(int status)
+ {
+ synchronizationRegistered = false;
+ if (closeOnTransactionCommit && delegate.isOpen())
+ {
+ delegate.close();
+ }
+ }
+
+ public void beforeCompletion()
+ {
+
+ }
+
+}
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-09-03 01:01:19 UTC (rev 13715)
+++ modules/persistence/trunk/pom.xml 2010-09-03 03:53:49 UTC (rev 13716)
@@ -29,6 +29,7 @@
<module>api</module>
<module>impl</module>
<module>tests-base</module>
+ <module>tests-weld-se</module>
</modules>
<properties>
@@ -114,6 +115,13 @@
<artifactId>arquillian-jbossas-remote-6</artifactId>
<version>${arquillian.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-weld-se-embedded-1</artifactId>
+ <version>${arquillian.version}</version>
+ </dependency>
+
<!-- Jboss dependencies -->
<dependency>
<groupId>org.jboss.jbossas</groupId>
@@ -128,7 +136,7 @@
<type>pom</type>
</dependency>
</dependencies>
-
+
</dependencyManagement>
<profiles>
14 years, 2 months
Seam SVN: r13715 - in modules/persistence/trunk: api and 37 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-09-02 21:01:19 -0400 (Thu, 02 Sep 2010)
New Revision: 13715
Added:
modules/persistence/trunk/tests-base/
modules/persistence/trunk/tests-base/pom.xml
modules/persistence/trunk/tests-base/src/
modules/persistence/trunk/tests-base/src/main/
modules/persistence/trunk/tests-base/src/main/java/
modules/persistence/trunk/tests-base/src/main/java/org/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HotelNameProducer.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextCreatedEventTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedObject.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/UserTransactionTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/DontRollBackException.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/HelloService.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/Hotel.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/IndexedHotel.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextObserver.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextProvider.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
modules/persistence/trunk/tests-base/src/main/resources/
modules/persistence/trunk/tests-base/src/test/
modules/persistence/trunk/tests-base/src/test/java/
modules/persistence/trunk/tests-base/src/test/resources/
modules/persistence/trunk/tests-jboss/
modules/persistence/trunk/tests-jboss/pom.xml
modules/persistence/trunk/tests-jboss/src/
modules/persistence/trunk/tests-jboss/src/main/
modules/persistence/trunk/tests-jboss/src/main/java/
modules/persistence/trunk/tests-jboss/src/main/resources/
modules/persistence/trunk/tests-jboss/src/test/
modules/persistence/trunk/tests-jboss/src/test/java/
modules/persistence/trunk/tests-jboss/src/test/java/org/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JbossHibernateSearchTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextCreatedEventTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextELTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextFlushModeTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionAttributeInterceptorTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionInterceptorTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionScopedTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/UserTransactionTest.java
modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/
modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/jndi.properties
modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/seam-transactions-test-ds.xml
modules/persistence/trunk/tests-jboss/src/test/resources/
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/orm.xml
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-search.xml
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml
modules/persistence/trunk/tests-jboss/src/test/resources/arquillian.xml
Removed:
modules/persistence/trunk/impl/src/test/java/org/
modules/persistence/trunk/impl/src/test/resources-jbossas/
modules/persistence/trunk/impl/src/test/resources/META-INF/
modules/persistence/trunk/impl/src/test/resources/arquillian.xml
Modified:
modules/persistence/trunk/api/pom.xml
modules/persistence/trunk/impl/pom.xml
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
modules/persistence/trunk/pom.xml
Log:
refactor test structure into multi module configuration
Modified: modules/persistence/trunk/api/pom.xml
===================================================================
--- modules/persistence/trunk/api/pom.xml 2010-09-02 21:20:44 UTC (rev 13714)
+++ modules/persistence/trunk/api/pom.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -34,6 +34,12 @@
<type>pom</type>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-09-02 21:20:44 UTC (rev 13714)
+++ modules/persistence/trunk/impl/pom.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -146,6 +146,9 @@
<profiles>
<profile>
<id>jbossas-managed-60</id>
+ <activation>
+
+ </activation>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
@@ -373,9 +376,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/persistence/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/persistence/trunk</developerConnection>
- <url>http://fisheye.jboss.org/browse/Seam/modules/persistence/trunk</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/persistence/trunk/impl</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/persistence/trunk/impl</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Seam/modules/persistence/trunk/impl</url>
</scm>
</project>
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2010-09-02 21:20:44 UTC (rev 13714)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -29,6 +29,7 @@
{
private static Logger log = LoggerFactory.getLogger(HibernatePersistenceProvider.class);
+ private static Class<?> FULL_TEXT_SESSION;
private static Method FULL_TEXT_SESSION_CONSTRUCTOR;
private static Method FULL_TEXT_ENTITYMANAGER_CONSTRUCTOR;
private static Class<?> FULL_TEXT_ENTITYMANAGER;
@@ -59,6 +60,7 @@
log.debug("org.hibernate.search.Search.getFullTextSession(Session) not found, trying deprecated method name createFullTextSession");
FULL_TEXT_SESSION_CONSTRUCTOR = searchClass.getDeclaredMethod("createFullTextSession", Session.class);
}
+ FULL_TEXT_SESSION = Reflections.classForName("org.hibernate.search.FullTextSession");
Class<?> jpaSearchClass = Reflections.classForName("org.hibernate.search.jpa.Search");
try
{
@@ -270,6 +272,15 @@
return (Set) Collections.singleton(FULL_TEXT_ENTITYMANAGER);
}
+ public Set<Class<?>> getAdditionalSessionInterfaces()
+ {
+ if (FULL_TEXT_SESSION == null)
+ {
+ return Collections.emptySet();
+ }
+ return (Set) Collections.singleton(FULL_TEXT_SESSION);
+ }
+
/**
* Occurs when Hibernate is in the classpath, but this particular
* EntityManager is not from Hibernate
Deleted: modules/persistence/trunk/impl/src/test/resources/arquillian.xml
===================================================================
--- modules/persistence/trunk/impl/src/test/resources/arquillian.xml 2010-09-02 21:20:44 UTC (rev 13714)
+++ modules/persistence/trunk/impl/src/test/resources/arquillian.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<arquillian xmlns="http://jboss.com/arquillian"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:gfembedded="urn:arq:org.jboss.arquillian.glassfish.embedded30"
- xmlns:gfremote="urn:arq:org.jboss.arquillian.container.glassfish.remote30"
- xmlns:jbossmanaged="urn:arq:org.jboss.arquillian.container.jbossas.managed_6">
-
- <engine>
- <deploymentExportPath>/tmp/</deploymentExportPath>
- </engine>
-
- <gfremote:container>
- <gfremote:remoteServerHttpPort>7070</gfremote:remoteServerHttpPort>
- </gfremote:container>
-
- <gfembedded:container>
- <gfembedded:sunResourcesXml>src/test/resources-glassfish/sun-resources.xml</gfembedded:sunResourcesXml>
- </gfembedded:container>
- <jbossmanaged:container>
- <javaVmArguments>-Xmx512m -XX:MaxPermSize=256m</javaVmArguments>
- </jbossmanaged:container>
-</arquillian>
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-09-02 21:20:44 UTC (rev 13714)
+++ modules/persistence/trunk/pom.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -27,11 +28,17 @@
<modules>
<module>api</module>
<module>impl</module>
+ <module>tests-base</module>
</modules>
<properties>
<seam.version>3.0.0.b01</seam.version>
<jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
+ <weld.extensions.version>1.0.0-SNAPSHOT</weld.extensions.version>
+ <hibernate.search.version>3.2.1.Final</hibernate.search.version>
+ <arquillian.version>1.0.0.Alpha3</arquillian.version>
+ <jboss.server.manager.version>1.0.3.GA</jboss.server.manager.version>
+ <jboss-as-client.version>6.0.0.20100721-M4</jboss-as-client.version>
</properties>
<dependencyManagement>
@@ -45,28 +52,83 @@
<type>pom</type>
</dependency>
- <!-- Need to use dependencyManagement to override org.jboss.seam:seam for submodules -->
+ <!--
+ Need to use dependencyManagement to override
+ org.jboss.seam:seam for submodules
+ -->
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence-api</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>${jboss-javaee6-spec.version}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
+
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-tests-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>${weld.extensions.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search</artifactId>
+ <version>${hibernate.search.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss-javaee6-spec.version}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
<version>${project.version}</version>
</dependency>
-
+
+ <!-- Arquillian -->
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-managed-6</artifactId>
+ <version>${arquillian.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-6</artifactId>
+ <version>${arquillian.version}</version>
+ </dependency>
+ <!-- Jboss dependencies -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-server-manager</artifactId>
+ <version>${jboss.server.manager.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${jboss-as-client.version}</version>
+ <type>pom</type>
+ </dependency>
</dependencies>
+
</dependencyManagement>
<profiles>
@@ -130,7 +192,27 @@
</pluginRepository>
</pluginRepositories>
</profile>
-
+ <profile>
+ <!-- all tests using managed containers -->
+ <id>all</id>
+ <modules>
+ <module>tests-jboss</module>
+ </modules>
+ </profile>
+ <profile>
+ <!-- jboss remote profile-->
+ <id>jbossas-remote-6</id>
+ <modules>
+ <module>tests-jboss</module>
+ </modules>
+ </profile>
+ <profile>
+ <!-- jboss managed profile-->
+ <id>jbossas-managed-6</id>
+ <modules>
+ <module>tests-jboss</module>
+ </modules>
+ </profile>
</profiles>
<developers>
Property changes on: modules/persistence/trunk/tests-base
___________________________________________________________________
Name: svn:ignore
+ .classpath
.settings
.project
Added: modules/persistence/trunk/tests-base/pom.xml
===================================================================
--- modules/persistence/trunk/tests-base/pom.xml (rev 0)
+++ modules/persistence/trunk/tests-base/pom.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,141 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>seam-persistence-parent</artifactId>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-tests-base</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>Seam Persistence Test Base</name>
+
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+
+ <dependencies>
+ <!-- all scopes are listed as provided, so the sub modules can pull in what they actually need -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.interceptor</groupId>
+ <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-impl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search</artifactId>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!--
+ skip unit test run, tests to be executed during
+ integration-test
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/persistence/trunk/tes...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/persistence/trunk/tests-...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Seam/modules/persistence/trunk/tests-base</url>
+ </scm>
+
+</project>
+
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.IndexedHotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests that injection is working for JPA entities
+ *
+ * @author Stuart Douglas
+ *
+ */
+
+public class EntityInjectionTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { HibernateSearchTestBase.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class, EntityInjectionTestBase.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ EntityManagerFactory emf;
+
+ @Test
+ public void testInjectionIntoEntity() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ EntityManager em = null;
+ try
+ {
+ em = emf.createEntityManager();
+ transaction.begin();
+ em.joinTransaction();
+ Hotel h = new Hotel("Hilton", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+ em.close();
+ transaction.begin();
+ em = emf.createEntityManager();
+ em.joinTransaction();
+
+ h = (Hotel) em.createQuery("select h from Hotel h where h.name='Hilton'").getSingleResult();
+ Assert.assertTrue(h.isInitalizerCalled());
+ Assert.assertEquals(h.sayHello(), "Hello");
+ }
+ finally
+ {
+ em.close();
+ transaction.rollback();
+ }
+
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.inject.Inject;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.hibernate.search.jpa.FullTextEntityManager;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.IndexedHotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class HibernateSearchTestBase
+{
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { HibernateSearchTestBase.class, IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ FullTextEntityManager em;
+
+ @Test
+ public void testFullTextEntityManager() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ Assert.assertTrue(em instanceof FullTextEntityManager);
+ }
+
+ @Test
+ public void testSearchingForHotel() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException, ParseException
+ {
+ transaction.begin();
+ IndexedHotel h = new IndexedHotel("Hilton", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ h = new IndexedHotel("Other Hotel", "Real St ", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ String[] fields = new String[] { "name" };
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ org.apache.lucene.search.Query query = parser.parse("Other");
+
+ // wrap Lucene query in a javax.persistence.Query
+ javax.persistence.Query persistenceQuery = em.createFullTextQuery(query, IndexedHotel.class);
+ IndexedHotel hotel = (IndexedHotel) persistenceQuery.getSingleResult();
+ Assert.assertTrue(hotel.getName().equals("Other Hotel"));
+ transaction.commit();
+
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HotelNameProducer.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HotelNameProducer.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HotelNameProducer.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,14 @@
+package org.jboss.seam.persistence.test;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+public class HotelNameProducer
+{
+ @Produces
+ @Named("hotelName")
+ public String getHotelName()
+ {
+ return "Hilton";
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextCreatedEventTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextCreatedEventTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextCreatedEventTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.FlushModeType;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextObserver;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.junit.Test;
+
+public class ManagedPersistenceContextCreatedEventTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { ManagedPersistenceContextCreatedEventTestBase.class, ManagedPersistenceContextObserver.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ EntityManager em;
+
+ @Inject
+ ManagedPersistenceContextObserver observer;
+
+ @Test
+ public void testSMPCCreationObserved() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ em.isOpen(); // need to make a call on the EM to force creation
+
+ Assert.assertTrue(observer.isObserverRun());
+ Assert.assertEquals(FlushModeType.COMMIT, em.getFlushMode());
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextELTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { ManagedPersistenceContextELTestBase.class, Hotel.class, ManagedPersistenceContextProvider.class, HotelNameProducer.class, HelloService.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ EntityManager em;
+
+ @Test
+ public void testELInInquery() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ transaction.begin();
+ Hotel h = new Hotel("Hilton", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ h = new Hotel("Other Hotel", "Real St ", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ Hotel hilton = (Hotel) em.createQuery("select h from Hotel h where h.name=#{hotelName}").getSingleResult();
+ Assert.assertTrue(hilton.getName().equals("Hilton"));
+ Assert.assertTrue(hilton.getAddress().equals("Fake St"));
+ transaction.commit();
+
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextFlushModeTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.hibernate.FlushMode;
+import org.hibernate.Session;
+import org.jboss.seam.persistence.FlushModeManager;
+import org.jboss.seam.persistence.FlushModeType;
+import org.jboss.seam.persistence.ManagedPersistenceContext;
+import org.jboss.seam.persistence.PersistenceContexts;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.junit.Test;
+
+public class ManagedPersistenceContextFlushModeTestBase
+{
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { ManagedPersistenceContextFlushModeTestBase.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class };
+ }
+
+ @Inject
+ FlushModeManager manager;
+
+ @Inject
+ EntityManager em;
+
+ @Inject
+ ManagedPersistenceContext context;
+
+ @Inject
+ PersistenceContexts pc;
+
+ @Inject
+ BeanManager bm;
+
+ @Test
+ public void testPersistenceContextDefaultFlushMode() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ manager.setFlushModeType(FlushModeType.MANUAL);
+ Assert.assertEquals(FlushMode.MANUAL, ((Session) em.getDelegate()).getFlushMode());
+ }
+
+ @Test
+ public void testChangedTouchedPersistenceContextFlushMode()
+ {
+ try
+ {
+ em.setFlushMode(javax.persistence.FlushModeType.AUTO);
+ pc.changeFlushMode(FlushModeType.MANUAL);
+ Assert.assertEquals(FlushMode.MANUAL, ((Session) em.getDelegate()).getFlushMode());
+ }
+ finally
+ {
+ em.setFlushMode(javax.persistence.FlushModeType.AUTO);
+ }
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.junit.Test;
+
+public class ManagedPersistenceContextTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { ManagedPersistenceContextTestBase.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ EntityManager em;
+
+ @Test
+ public void testManagedPsersistenceContext() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ transaction.begin();
+ Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+
+ transaction.begin();
+ h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.rollback();
+
+ transaction.begin();
+ List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
+ Assert.assertTrue(hotels.size() == 1);
+ transaction.rollback();
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TransactionRequiredException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.junit.Test;
+
+/**
+ * Tests the @TransactionAttribute interceptor for non ee beans.
+ *
+ * TODO: refactor the tests to share a common superclass
+ *
+ * @author stuart
+ *
+ */
+public class TransactionAttributeInterceptorTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { TransactionAttributeInterceptorTestBase.class, TransactionAttributeManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class };
+ }
+
+ @Inject
+ TransactionAttributeManagedBean bean;
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @PersistenceContext
+ EntityManager em;
+
+ @Test
+ public void testTransactionInterceptor() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ bean.addHotel();
+ assertHotels(1);
+ try
+ {
+ bean.failToAddHotel();
+ }
+ catch (Exception e)
+ {
+ }
+ assertHotels(1);
+ try
+ {
+ bean.addHotelWithApplicationException();
+ }
+ catch (DontRollBackException e)
+ {
+ }
+ assertHotels(2);
+ }
+
+ @Test(expected = TransactionRequiredException.class)
+ public void testTransactionInterceptorMethodOverrides()
+ {
+ bean.tryAndAddHotelWithNoTransaction();
+ }
+
+ public void assertHotels(int count) throws NotSupportedException, SystemException
+ {
+ transaction.begin();
+ em.joinTransaction();
+ List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
+ Assert.assertTrue("Wrong number of hotels: " + hotels.size(), hotels.size() == count);
+ transaction.rollback();
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeManagedBean.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.Hotel;
+
+(a)TransactionAttribute(TransactionAttributeType.REQUIRED)
+public class TransactionAttributeManagedBean
+{
+
+ @Inject
+ EntityManager entityManager;
+
+ public void addHotel()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
+ public void failToAddHotel()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ throw new RuntimeException("Roll back transaction");
+ }
+
+ public void addHotelWithApplicationException() throws DontRollBackException
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ throw new DontRollBackException();
+ }
+
+ @TransactionAttribute(TransactionAttributeType.NEVER)
+ public void tryAndAddHotelWithNoTransaction()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TransactionRequiredException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.junit.Test;
+
+/**
+ * Tests the @Transactional interceptor
+ *
+ * TODO: refactor the tests to share a common superclass
+ *
+ * @author stuart
+ *
+ */
+public class TransactionInterceptorTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { TransactionInterceptorTestBase.class, TransactionManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class };
+ }
+
+ @Inject
+ TransactionManagedBean bean;
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @PersistenceContext
+ EntityManager em;
+
+ @Test
+ public void testTransactionInterceptor() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ bean.addHotel();
+ assertHotels(1);
+ try
+ {
+ bean.failToAddHotel();
+ }
+ catch (Exception e)
+ {
+ }
+ assertHotels(1);
+ try
+ {
+ bean.addHotelWithApplicationException();
+ }
+ catch (DontRollBackException e)
+ {
+ }
+ assertHotels(2);
+ }
+
+ @Test(expected = TransactionRequiredException.class)
+ public void testTransactionInterceptorMethodOverrides()
+ {
+ bean.tryAndAddHotelWithNoTransaction();
+ }
+
+ public void assertHotels(int count) throws NotSupportedException, SystemException
+ {
+ transaction.begin();
+ em.joinTransaction();
+ List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
+ Assert.assertTrue("Wrong number of hotels: " + hotels.size(), hotels.size() == count);
+ transaction.rollback();
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionManagedBean.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.persistence.transaction.TransactionPropagation;
+import org.jboss.seam.persistence.transaction.Transactional;
+import org.jboss.seam.transactions.test.util.DontRollBackException;
+import org.jboss.seam.transactions.test.util.Hotel;
+
+(a)Transactional(TransactionPropagation.REQUIRED)
+public class TransactionManagedBean
+{
+
+ @Inject
+ EntityManager entityManager;
+
+ public void addHotel()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
+ public void failToAddHotel()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ throw new RuntimeException("Roll back transaction");
+ }
+
+ public void addHotelWithApplicationException() throws DontRollBackException
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ throw new DontRollBackException();
+ }
+
+ @Transactional(TransactionPropagation.NEVER)
+ public void tryAndAddHotelWithNoTransaction()
+ {
+ entityManager.joinTransaction();
+ Hotel h = new Hotel("test3", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ entityManager.persist(h);
+ entityManager.flush();
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedObject.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedObject.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedObject.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import org.jboss.seam.persistence.transaction.TransactionScoped;
+
+@TransactionScoped
+public class TransactionScopedObject
+{
+ int value = 0;
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ public void setValue(int value)
+ {
+ this.value = value;
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.junit.Test;
+
+public class TransactionScopedTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { TransactionScopedTestBase.class, Hotel.class, HelloService.class, TransactionScopedObject.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @PersistenceUnit
+ EntityManagerFactory emf;
+
+ @Inject
+ TransactionScopedObject transactionScopedObject;
+
+ @Test
+ public void transactionScopeTest() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ transaction.begin();
+ transactionScopedObject.setValue(10);
+ Assert.assertTrue(transactionScopedObject.getValue() == 10);
+ transaction.commit();
+
+ transaction.begin();
+ Assert.assertTrue(transactionScopedObject.getValue() == 0);
+ transactionScopedObject.setValue(20);
+ Assert.assertTrue(transactionScopedObject.getValue() == 20);
+ transaction.rollback();
+
+ transaction.begin();
+ Assert.assertTrue(transactionScopedObject.getValue() == 0);
+ transaction.rollback();
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/UserTransactionTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/UserTransactionTestBase.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/transactions/test/UserTransactionTestBase.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transactions.test;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class UserTransactionTestBase
+{
+
+ public static Class<?>[] getTestClasses()
+ {
+ return new Class[] { UserTransactionTestBase.class, Hotel.class, HelloService.class };
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @PersistenceContext
+ EntityManager em;
+
+ @Test
+ public void userTransactionTest() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ transaction.begin();
+ em.joinTransaction();
+ Hotel h = new Hotel("test", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+ em.clear();
+
+ transaction.begin();
+ em.joinTransaction();
+ h = new Hotel("test2", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.rollback();
+ em.clear();
+
+ transaction.begin();
+ em.joinTransaction();
+ List<Hotel> hotels = em.createQuery("select h from Hotel h").getResultList();
+ Assert.assertTrue(hotels.size() == 1);
+ transaction.rollback();
+ em.clear();
+
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ArtifactNames.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ArtifactNames.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,12 @@
+package org.jboss.seam.transactions.test.util;
+
+public class ArtifactNames
+{
+ public static final String WELD_EXTENSIONS = "org.jboss.weld:weld-extensions";
+ public static final String SEAM_PERSISTENCE_API = "org.jboss.seam.persistence:seam-persistence-api";
+ public static final String SEAM_PERSISTENCE_IMPL = "org.jboss.seam.persistence:seam-persistence-impl";
+ public static final String HIBERNATE_SEARCH = "org.hibernate:hibernate-search";
+ public static final String LUCENE_CORE = "org.apache.lucene:lucene-core";
+ public static final String LUCENE_ANALYZERS = "org.apache.lucene:lucene-analyzers";
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/DontRollBackException.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/DontRollBackException.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/DontRollBackException.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,9 @@
+package org.jboss.seam.transactions.test.util;
+
+import javax.ejb.ApplicationException;
+
+@ApplicationException(rollback = false)
+public class DontRollBackException extends Exception
+{
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/EntityManagerProvider.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class EntityManagerProvider
+{
+ @PersistenceContext
+ @Produces
+ EntityManager em;
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/HelloService.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/HelloService.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/HelloService.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+public class HelloService
+{
+ public String sayHello()
+ {
+ return "Hello";
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/Hotel.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/Hotel.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/Hotel.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.inject.Inject;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.jboss.weld.extensions.core.Veto;
+
+/**
+ * <p>
+ * <strong>Hotel</strong> is the model/entity class that represents a hotel.
+ * </p>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+@Entity
+@Table(name = "hotel")
+@Veto
+public class Hotel implements Serializable
+{
+ private Long id;
+ private String name;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+ private Integer stars;
+ private BigDecimal price;
+
+ @Inject
+ private HelloService helloService;
+
+ private boolean initalizerCalled = false;
+
+ public Hotel()
+ {
+ }
+
+ @Inject
+ public void create()
+ {
+ initalizerCalled = true;
+ }
+
+ public String sayHello()
+ {
+ return helloService.sayHello();
+ }
+
+ public Hotel(final String name, final String address, final String city, final String state, final String zip, final String country)
+ {
+ this.name = name;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ public Hotel(final int price, final int stars, final String name, final String address, final String city, final String state, final String zip, final String country)
+ {
+ this.price = new BigDecimal(price);
+ this.stars = stars;
+ this.name = name;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(final Long id)
+ {
+ this.id = id;
+ }
+
+ @Size(max = 50)
+ @NotNull
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(final String name)
+ {
+ this.name = name;
+ }
+
+ @Size(max = 100)
+ @NotNull
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public void setAddress(final String address)
+ {
+ this.address = address;
+ }
+
+ @Size(max = 40)
+ @NotNull
+ public String getCity()
+ {
+ return city;
+ }
+
+ public void setCity(final String city)
+ {
+ this.city = city;
+ }
+
+ @Size(min = 3, max = 6)
+ @NotNull
+ public String getZip()
+ {
+ return zip;
+ }
+
+ public void setZip(final String zip)
+ {
+ this.zip = zip;
+ }
+
+ @Size(min = 2, max = 10)
+ public String getState()
+ {
+ return state;
+ }
+
+ public void setState(final String state)
+ {
+ this.state = state;
+ }
+
+ @Size(min = 2, max = 40)
+ @NotNull
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public void setCountry(final String country)
+ {
+ this.country = country;
+ }
+
+ @Min(1)
+ @Max(5)
+ public Integer getStars()
+ {
+ return stars;
+ }
+
+ public void setStars(final Integer stars)
+ {
+ this.stars = stars;
+ }
+
+ @Column(precision = 6, scale = 2)
+ public BigDecimal getPrice()
+ {
+ return price;
+ }
+
+ public void setPrice(final BigDecimal price)
+ {
+ this.price = price;
+ }
+
+ @Transient
+ public String getLocation()
+ {
+ return city + ", " + state + ", " + country;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
+ }
+
+ @Transient
+ public boolean isInitalizerCalled()
+ {
+ return initalizerCalled;
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/IndexedHotel.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/IndexedHotel.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/IndexedHotel.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.inject.Inject;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Store;
+import org.jboss.weld.extensions.core.Veto;
+
+/**
+ * <p>
+ * <strong>Hotel</strong> is the model/entity class that represents a hotel.
+ * </p>
+ *
+ * @author Gavin King
+ * @author Dan Allen
+ */
+@Entity
+@Table(name = "hotel")
+@Indexed
+@Veto
+public class IndexedHotel implements Serializable
+{
+ private Long id;
+ private String name;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+ private Integer stars;
+ private BigDecimal price;
+
+ @Inject
+ private HelloService helloService;
+
+ private boolean initalizerCalled = false;
+
+ public IndexedHotel()
+ {
+ }
+
+ @Inject
+ public void create()
+ {
+ initalizerCalled = true;
+ }
+
+ public String sayHello()
+ {
+ return helloService.sayHello();
+ }
+
+ public IndexedHotel(final String name, final String address, final String city, final String state, final String zip, final String country)
+ {
+ this.name = name;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ public IndexedHotel(final int price, final int stars, final String name, final String address, final String city, final String state, final String zip, final String country)
+ {
+ this.price = new BigDecimal(price);
+ this.stars = stars;
+ this.name = name;
+ this.address = address;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ this.country = country;
+ }
+
+ @Id
+ @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(final Long id)
+ {
+ this.id = id;
+ }
+
+ @Size(max = 50)
+ @NotNull
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(final String name)
+ {
+ this.name = name;
+ }
+
+ @Size(max = 100)
+ @NotNull
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public void setAddress(final String address)
+ {
+ this.address = address;
+ }
+
+ @Size(max = 40)
+ @NotNull
+ public String getCity()
+ {
+ return city;
+ }
+
+ public void setCity(final String city)
+ {
+ this.city = city;
+ }
+
+ @Size(min = 3, max = 6)
+ @NotNull
+ public String getZip()
+ {
+ return zip;
+ }
+
+ public void setZip(final String zip)
+ {
+ this.zip = zip;
+ }
+
+ @Size(min = 2, max = 10)
+ public String getState()
+ {
+ return state;
+ }
+
+ public void setState(final String state)
+ {
+ this.state = state;
+ }
+
+ @Size(min = 2, max = 40)
+ @NotNull
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public void setCountry(final String country)
+ {
+ this.country = country;
+ }
+
+ @Min(1)
+ @Max(5)
+ public Integer getStars()
+ {
+ return stars;
+ }
+
+ public void setStars(final Integer stars)
+ {
+ this.stars = stars;
+ }
+
+ @Column(precision = 6, scale = 2)
+ public BigDecimal getPrice()
+ {
+ return price;
+ }
+
+ public void setPrice(final BigDecimal price)
+ {
+ this.price = price;
+ }
+
+ @Transient
+ public String getLocation()
+ {
+ return city + ", " + state + ", " + country;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
+ }
+
+ @Transient
+ public boolean isInitalizerCalled()
+ {
+ return initalizerCalled;
+ }
+
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextObserver.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextObserver.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextObserver.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Default;
+import javax.persistence.FlushModeType;
+
+import org.jboss.seam.persistence.SeamManagedPersistenceContextCreated;
+
+@ApplicationScoped
+public class ManagedPersistenceContextObserver
+{
+ private boolean observerRun = false;
+
+ public void observe(@Observes @Default SeamManagedPersistenceContextCreated event)
+ {
+ observerRun = true;
+ event.getEntityManager().setFlushMode(FlushModeType.COMMIT);
+ }
+
+ public boolean isObserverRun()
+ {
+ return observerRun;
+ }
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextProvider.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextProvider.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/ManagedPersistenceContextProvider.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+
+import org.jboss.seam.persistence.SeamManaged;
+
+public class ManagedPersistenceContextProvider
+{
+ @PersistenceUnit
+ @RequestScoped
+ @Produces
+ @SeamManaged
+ EntityManagerFactory emf;
+}
Added: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java (rev 0)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/transactions/test/util/MavenArtifactResolver.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,164 @@
+package org.jboss.seam.transactions.test.util;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Resolves a maven artifact present on the test classpath.
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class MavenArtifactResolver
+{
+
+ public static File resolve(String groupId, String artifactId)
+ {
+ if (groupId == null)
+ {
+ throw new IllegalArgumentException("groupId cannot be null");
+ }
+ if (artifactId == null)
+ {
+ throw new IllegalArgumentException("artifactId cannot be null");
+ }
+ String path = new MavenArtifactResolver(groupId.trim(), artifactId.trim(), System.getProperty("java.class.path"), File.pathSeparatorChar, File.separatorChar).resolve();
+ if (path == null)
+ {
+ throw new IllegalArgumentException("Cannot locate artifact for " + groupId + ":" + artifactId);
+ }
+ return new File(path);
+ }
+
+ public static File resolve(String qualifiedArtifactId)
+ {
+ String[] segments = qualifiedArtifactId.split(":");
+ if (segments.length == 2)
+ {
+ return resolve(segments[0], segments[1]);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unable to parse " + qualifiedArtifactId + " as a groupId:artifactId");
+ }
+ }
+
+ private final String classPathSeparatorRegex;
+ private final char fileSeparator;
+ private final String groupId;
+ private final String artifactId;
+ private final String classPath;
+
+ MavenArtifactResolver(String groupId, String artifactId, String classPath, char pathSeparator, char fileSeparator)
+ {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.classPath = classPath;
+ this.classPathSeparatorRegex = "[^" + pathSeparator + "]*";
+ this.fileSeparator = fileSeparator;
+ }
+
+ String resolve()
+ {
+ Matcher matches = createFullyQualifiedMatcher();
+ if (!matches.find())
+ {
+ matches = createUnqualifiedMatcher();
+ if (!matches.find())
+ {
+ matches = createTargetClassesMatcher();
+ if (!matches.find())
+ {
+ return null;
+ }
+ else
+ {
+ String fileName = scanForArtifact(matches);
+ if (fileName == null)
+ {
+ return null;
+ }
+ else
+ {
+ return fileName;
+ }
+ }
+ }
+ }
+ return matches.group(0);
+ }
+
+ private String scanForArtifact(Matcher targetClassesMatcher)
+ {
+ // Locate all target/classes in classpath and store the path to all files target/
+ List<String> paths = new ArrayList<String>();
+ do
+ {
+ String path = targetClassesMatcher.group();
+ File target = new File(path.substring(0, path.length() - 8));
+ if (target.exists())
+ {
+ if (!target.isDirectory())
+ {
+ throw new IllegalStateException("Found ${project.dir}/target/ but it is not a directory!");
+ }
+ for (File file : target.listFiles())
+ {
+ paths.add(file.getPath());
+ }
+ }
+ }
+ while (targetClassesMatcher.find());
+ return scanForArtifact(paths);
+ }
+
+ String scanForArtifact(List<String> paths)
+ {
+ Pattern pattern = Pattern.compile(artifactId + "-[\\d+\\.]+(?:[\\-\\.]\\p{Alpha}*)?.jar$");
+ for (String path : paths)
+ {
+ if (pattern.matcher(path).find())
+ {
+ return path;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates a matcher that returns any fully qualified matches of the form
+ * <code>com/acme/acme-core/1.0/acme-core-1.0.jar</code>. This will match
+ * artifacts on the classpath from the Maven repo.
+ */
+ private Matcher createFullyQualifiedMatcher()
+ {
+ String pathString = groupId.replace('.', fileSeparator) + fileSeparator + artifactId;
+ Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote(pathString) + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE);
+ return p.matcher(classPath);
+ }
+
+ /**
+ * Creates a matcher that returns any unqualified matches of the form
+ * <code>target/acme-foo-1.0.jar</code>. This will match artifacts on the
+ * classpath from the reactor.
+ */
+ private Matcher createUnqualifiedMatcher()
+ {
+ Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote("target" + fileSeparator + artifactId) + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE);
+ return p.matcher(classPath);
+ }
+
+ /**
+ * Creates a matcher that returns any unqualified matches of the form
+ * <code>target/acme-foo-1.0.jar</code>. This locates all
+ *
+ */
+ private Matcher createTargetClassesMatcher()
+ {
+ Pattern p = Pattern.compile(classPathSeparatorRegex + Pattern.quote("target" + fileSeparator + "classes") + classPathSeparatorRegex, Pattern.CASE_INSENSITIVE);
+ return p.matcher(classPath);
+ }
+}
Property changes on: modules/persistence/trunk/tests-jboss
___________________________________________________________________
Name: svn:ignore
+ .project
.settings
.classpath
Added: modules/persistence/trunk/tests-jboss/pom.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/pom.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/pom.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,287 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>seam-persistence-parent</artifactId>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-tests-jboss</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0-SNAPSHOT</version>
+ <name>Seam Persistence Jboss Tests</name>
+
+ <properties>
+ <jboss.home>${env.JBOSS_HOME}</jboss.home>
+ <jboss.domain>default</jboss.domain>
+ </properties>
+
+ <prerequisites>
+ <maven>3.0</maven>
+ </prerequisites>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.interceptor</groupId>
+ <artifactId>jboss-interceptors-api_1.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.arquillian</groupId>
+ <artifactId>arquillian-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-tests-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!--
+ skip unit test run, tests to be executed during
+ integration-test
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>jbossas-managed-6</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-managed-6</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-server-manager</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-property</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireProperty>
+ <property>jboss.home</property>
+ </requireProperty>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>jbossas-remote-6</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-jbossas-remote-6</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- need for org.jnp.interfaces.NamingContextFactory -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources-jbossas</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/persistence/trunk/tes...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/persistence/trunk/tests-...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/Seam/modules/persistence/trunk/tests-jboss</url>
+ </scm>
+
+</project>
+
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.EntityInjectionTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests that injection is working for JPA entities
+ *
+ * @author Stuart Douglas
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class EntityInjectionTest extends EntityInjectionTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ war.addWebResource("META-INF/persistence-orm.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource("META-INF/orm.xml", "classes/META-INF/orm.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JbossHibernateSearchTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JbossHibernateSearchTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JbossHibernateSearchTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.HibernateSearchTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class JbossHibernateSearchTest extends HibernateSearchTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.HIBERNATE_SEARCH));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.LUCENE_ANALYZERS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.LUCENE_CORE));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence-search.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ war.addWebResource("META-INF/services/org.jboss.seam.persistence.SeamPersistenceProvider", "classes/META-INF/services/org.jboss.seam.persistence.SeamPersistenceProvider");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextCreatedEventTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextCreatedEventTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextCreatedEventTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.ManagedPersistenceContextCreatedEventTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextCreatedEventTest extends ManagedPersistenceContextCreatedEventTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextELTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextELTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextELTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.ManagedPersistenceContextELTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextELTest extends ManagedPersistenceContextELTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextFlushModeTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextFlushModeTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextFlushModeTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.ManagedPersistenceContextFlushModeTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextFlushModeTest extends ManagedPersistenceContextFlushModeTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ war.addWebResource("META-INF/services/org.jboss.seam.persistence.SeamPersistenceProvider", "classes/META-INF/services/org.jboss.seam.persistence.SeamPersistenceProvider");
+ return war;
+ }
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/ManagedPersistenceContextTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.ManagedPersistenceContextTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class ManagedPersistenceContextTest extends ManagedPersistenceContextTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionAttributeInterceptorTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionAttributeInterceptorTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionAttributeInterceptorTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transaction.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transaction.TransactionInterceptor;
+import org.jboss.seam.persistence.transactions.test.TransactionAttributeInterceptorTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the @TransactionAttribute interceptor for non ee beans.
+ *
+ * TODO: refactor the tests to share a common superclass
+ *
+ * @author stuart
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class TransactionAttributeInterceptorTest extends TransactionAttributeInterceptorTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionInterceptorTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionInterceptorTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.transaction.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transaction.TransactionInterceptor;
+import org.jboss.seam.persistence.transactions.test.TransactionInterceptorTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the @Transactional interceptor
+ *
+ * TODO: refactor the tests to share a common superclass
+ *
+ * @author stuart
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class TransactionInterceptorTest extends TransactionInterceptorTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionScopedTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/TransactionScopedTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,31 @@
+package org.jboss.seam.persistence.transaction.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transactions.test.TransactionScopedTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class TransactionScopedTest extends TransactionScopedTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/UserTransactionTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/jboss/UserTransactionTest.java 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,31 @@
+package org.jboss.seam.persistence.transaction.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.transactions.test.UserTransactionTestBase;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+(a)RunWith(Arquillian.class)
+public class UserTransactionTest extends UserTransactionTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(getTestClasses());
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+
+}
Added: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/orm.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/orm.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/orm.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+ version="1.0"
+ >
+ <persistence-unit-metadata >
+ <persistence-unit-defaults >
+ <entity-listeners>
+ <entity-listener class="org.jboss.seam.persistence.InjectionEventListener" >
+ <post-load method-name="load" />
+ </entity-listener>
+ </entity-listeners>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+
+</entity-mappings>
\ No newline at end of file
Added: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="seamPersistencePu">
+ <!--
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ -->
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <mapping-file>META-INF/orm.xml</mapping-file>
+ <class>org.jboss.seam.transactions.test.util.Hotel</class>
+ <exclude-unlisted-classes/>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- Only format when you need to debug, because it slows things down -->
+ <property name="hibernate.format_sql" value="false"/>
+
+ <!-- Properties for EclipseLink (default provider for GlassFish) -->
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="FINE"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-search.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-search.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-search.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="seamPersistencePu">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <class>org.jboss.seam.transactions.test.util.IndexedHotel</class>
+ <exclude-unlisted-classes/>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- Only format when you need to debug, because it slows things down -->
+ <property name="hibernate.format_sql" value="false"/>
+ <property name="hibernate.search.default.directory_provider"
+ value="org.hibernate.search.store.RAMDirectoryProvider"/>
+
+ </properties>
+ </persistence-unit>
+</persistence>
Added: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="seamPersistencePu">
+ <!--
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ -->
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <class>org.jboss.seam.transactions.test.util.Hotel</class>
+ <exclude-unlisted-classes/>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- Only format when you need to debug, because it slows things down -->
+ <property name="hibernate.format_sql" value="false"/>
+
+ <!-- Properties for EclipseLink (default provider for GlassFish) -->
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="FINE"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: modules/persistence/trunk/tests-jboss/src/test/resources/arquillian.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/arquillian.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/arquillian.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<arquillian xmlns="http://jboss.com/arquillian"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:gfembedded="urn:arq:org.jboss.arquillian.glassfish.embedded30"
+ xmlns:gfremote="urn:arq:org.jboss.arquillian.container.glassfish.remote30"
+ xmlns:jbossmanaged="urn:arq:org.jboss.arquillian.container.jbossas.managed_6">
+
+ <engine>
+ <deploymentExportPath>/tmp/</deploymentExportPath>
+ </engine>
+
+ <jbossmanaged:container>
+ <javaVmArguments>-Xmx512m -XX:MaxPermSize=256m</javaVmArguments>
+ </jbossmanaged:container>
+</arquillian>
Added: modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/jndi.properties
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/jndi.properties (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/jndi.properties 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099
Added: modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/seam-transactions-test-ds.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/seam-transactions-test-ds.xml (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/resources-jbossas/seam-transactions-test-ds.xml 2010-09-03 01:01:19 UTC (rev 13715)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE datasources
+ PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>jdbc/__default</jndi-name>
+ <use-java-context>false</use-java-context>
+ <connection-url>jdbc:hsqldb:.</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ </local-tx-datasource>
+</datasources>
14 years, 2 months
Seam SVN: r13714 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-09-02 17:20:44 -0400 (Thu, 02 Sep 2010)
New Revision: 13714
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
Log:
set bean class appropriately for producers
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-09-02 21:20:25 UTC (rev 13713)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-09-02 21:20:44 UTC (rev 13714)
@@ -195,6 +195,7 @@
BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
builder.setQualifiers(qualifiers);
builder.setScope(scope);
+ builder.setBeanClass(member.getDeclaringType().getJavaClass());
builder.getTypes().add(ManagedPersistenceContext.class);
builder.getTypes().addAll(additionalInterfaces);
builder.getTypes().add(Object.class);
14 years, 2 months