[jboss-cvs] JBossAS SVN: r95828 - in branches/Branch_5_x/testsuite: src/main/org/jboss/test/ejb3/ejbthree7376 and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 30 10:09:56 EDT 2009
Author: wolfc
Date: 2009-10-30 10:09:56 -0400 (Fri, 30 Oct 2009)
New Revision: 95828
Added:
branches/Branch_5_x/testsuite/src/resources/ejb3/ejbthree7376/META-INF/ejb-jar.xml
Modified:
branches/Branch_5_x/testsuite/.classpath
branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerBean.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerFacadeBean.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/unit/JPAUnitTestCase.java
Log:
JBAS-7376: modified test to use container managed EM and made ConstraintViolationException an app exception
Modified: branches/Branch_5_x/testsuite/.classpath
===================================================================
--- branches/Branch_5_x/testsuite/.classpath 2009-10-30 14:09:24 UTC (rev 95827)
+++ branches/Branch_5_x/testsuite/.classpath 2009-10-30 14:09:56 UTC (rev 95828)
@@ -63,5 +63,6 @@
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-api/lib/jboss-bootstrap-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-api-as/lib/jboss-bootstrap-api-as.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-bootstrap-api-mc/lib/jboss-bootstrap-api-mc.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/validation-api/lib/validation-api.jar" sourcepath="/thirdparty/validation-api/lib/validation-api-sources.jar"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerBean.java 2009-10-30 14:09:24 UTC (rev 95827)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerBean.java 2009-10-30 14:09:56 UTC (rev 95828)
@@ -21,37 +21,21 @@
*/
package org.jboss.test.ejb3.ejbthree7376;
-import javax.ejb.*;
-import javax.persistence.*;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.LockModeType;
+import javax.persistence.PersistenceContext;
/**
* @author Scott Marlow
*
*/
@Stateless(mappedName="ejb3/ejbthree7376/Soccer")
- at TransactionManagement(TransactionManagementType.CONTAINER)
public class SoccerBean implements Soccer
{
-
- @PersistenceUnit
- private EntityManagerFactory emf;
- EntityManager em;
+ @PersistenceContext
+ private EntityManager em;
-
- @PostConstruct
- public void init()
- {
- em = emf.createEntityManager();
- }
-
- @PreDestroy
- public void destroy()
- {
- em.close();
- }
-
public void addPlayer(int id, String name, String team, int goals)
{
@@ -68,7 +52,6 @@
public Player getPlayerReadLock(int id)
{
- em.joinTransaction();
Player p = em.find(Player.class, id);
if(p != null)
em.lock(p, LockModeType.READ);
@@ -77,7 +60,6 @@
public Player getPlayerOptimisticLock(int id)
{
- em.joinTransaction();
Player p = em.find(Player.class, id);
if(p != null)
em.lock(p, LockModeType.OPTIMISTIC);
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerFacadeBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerFacadeBean.java 2009-10-30 14:09:24 UTC (rev 95827)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/SoccerFacadeBean.java 2009-10-30 14:09:56 UTC (rev 95828)
@@ -21,10 +21,8 @@
*/
package org.jboss.test.ejb3.ejbthree7376;
-import javax.ejb.*;
-import javax.naming.InitialContext;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
/**
@@ -32,54 +30,28 @@
*
*/
@Stateless(mappedName="ejb3/ejbthree7376/SoccerFacade")
- at TransactionManagement(TransactionManagementType.CONTAINER)
public class SoccerFacadeBean implements SoccerFacade
{
- InitialContext ctx=null;
- Soccer stats = null;
+ @EJB
+ private Soccer stats = null;
- @PostConstruct
- public void init()
- {
-
- try {
- ctx = new InitialContext();
- stats = (Soccer) ctx.lookup("ejb3/ejbthree7376/Soccer");
- }
- catch(Throwable e) {
- e.printStackTrace();
- }
- }
-
- @PreDestroy
- public void destroy()
- {
- ctx = null;
- }
-
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
public void addPlayer(int id, String name, String team, int goals)
{
stats.addPlayer(id, name, team, goals);
}
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
public Player getPlayer(int id)
{
return stats.getPlayer(id);
}
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
public Player getPlayerReadLock(int id)
{
return stats.getPlayerReadLock(id);
}
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
public Player getPlayerOptimisticLock(int id)
{
return stats.getPlayerOptimisticLock(id);
}
-
-
}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/unit/JPAUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/unit/JPAUnitTestCase.java 2009-10-30 14:09:24 UTC (rev 95827)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/ejb3/ejbthree7376/unit/JPAUnitTestCase.java 2009-10-30 14:09:56 UTC (rev 95828)
@@ -27,9 +27,8 @@
import junit.framework.Test;
import org.jboss.test.JBossTestCase;
-import org.jboss.test.ejb3.ejbthree7376.Soccer;
-import org.jboss.test.ejb3.ejbthree7376.SoccerFacade;
import org.jboss.test.ejb3.ejbthree7376.Player;
+import org.jboss.test.ejb3.ejbthree7376.SoccerFacade;
/**
Added: branches/Branch_5_x/testsuite/src/resources/ejb3/ejbthree7376/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/ejb3/ejbthree7376/META-INF/ejb-jar.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/ejb3/ejbthree7376/META-INF/ejb-jar.xml 2009-10-30 14:09:56 UTC (rev 95828)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+ <assembly-descriptor>
+ <application-exception>
+ <exception-class>javax.validation.ConstraintViolationException</exception-class>
+ <rollback>true</rollback>
+ </application-exception>
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list