[jboss-cvs] JBossAS SVN: r62130 - in branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp: interfaces and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 5 10:41:12 EDT 2007


Author: adrian at jboss.org
Date: 2007-04-05 10:41:12 -0400 (Thu, 05 Apr 2007)
New Revision: 62130

Modified:
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/beans/SimpleBMPBean.java
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/interfaces/SimpleBMP.java
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/test/BmpUnitTestCase.java
Log:
[JBAS-4304] - Test for ejbStore() getting invoked during ejbPostCreate() when
it executes a finder.

Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/beans/SimpleBMPBean.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/beans/SimpleBMPBean.java	2007-04-05 14:36:11 UTC (rev 62129)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/beans/SimpleBMPBean.java	2007-04-05 14:41:12 UTC (rev 62130)
@@ -40,6 +40,7 @@
 import javax.sql.DataSource;
 
 import org.jboss.logging.Logger;
+import org.jboss.test.bmp.interfaces.SimpleBMPHome;
 
 public class SimpleBMPBean implements EntityBean
 {
@@ -53,6 +54,8 @@
    // bmp fields
    Integer id;
    String name;
+   boolean ejbStoreInvoked = false;
+   boolean tempEjbStoreInvoked = false;
    
    public Integer ejbCreate (int _id, String _name)
       throws CreateException, RemoteException
@@ -162,6 +165,19 @@
       throws CreateException, RemoteException
    {
       log.debug ("ejbPostCreate (int, String) called");
+      
+      tempEjbStoreInvoked = false;
+      // Do a find all to see whether ejbStore gets invoked
+      SimpleBMPHome home = (SimpleBMPHome) ctx.getEJBHome();
+      try
+      {
+         home.findAll();
+      }
+      catch (FinderException e)
+      {
+         throw new RemoteException("Unexpected error invoking findAll", e);
+      }
+      ejbStoreInvoked = tempEjbStoreInvoked;
    }
    
    public void ejbPostCreateMETHOD (int _id, String _name)
@@ -209,6 +225,7 @@
    public void ejbStore ()
    {
       log.debug ("ejbStore () called " + this);
+      tempEjbStoreInvoked = true;
 
       Connection con = null;
       try
@@ -405,5 +422,8 @@
       return name;
    }
    
-   
+   public boolean isEjbStoreInvoked()
+   {
+      return ejbStoreInvoked;
+   }
 }

Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/interfaces/SimpleBMP.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/interfaces/SimpleBMP.java	2007-04-05 14:36:11 UTC (rev 62129)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/interfaces/SimpleBMP.java	2007-04-05 14:41:12 UTC (rev 62130)
@@ -30,4 +30,5 @@
    public void setName (String _name) throws RemoteException;
    public String getName () throws RemoteException;
    Integer getIdViaEJBObject() throws RemoteException;
+   boolean isEjbStoreInvoked() throws RemoteException;
 }

Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/test/BmpUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/test/BmpUnitTestCase.java	2007-04-05 14:36:11 UTC (rev 62129)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/bmp/test/BmpUnitTestCase.java	2007-04-05 14:41:12 UTC (rev 62130)
@@ -134,6 +134,9 @@
          it = home.findAll ().iterator ();
          while (it.hasNext ())
             ((SimpleBMP)it.next ()).remove ();
+         
+         SimpleBMP b2 = home.create(200, "Dave");
+         assertFalse("ejbStore() should not be invoked during ejbPostCreate()", b2.isEjbStoreInvoked());
       }
       finally
       {




More information about the jboss-cvs-commits mailing list