[jboss-cvs] JBossAS SVN: r87560 - in branches/Branch_5_x/testsuite/src: main/org/jboss/test/timer/test and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 20 05:35:08 EDT 2009


Author: galder.zamarreno at jboss.com
Date: 2009-04-20 05:35:07 -0400 (Mon, 20 Apr 2009)
New Revision: 87560

Added:
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExt.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExtHome.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/test/TimerCleanUpUnitTestCase.java
Modified:
   branches/Branch_5_x/testsuite/src/resources/timer/ejb/ejb-jar.xml
   branches/Branch_5_x/testsuite/src/resources/timer/ejb/jboss.xml
Log:
[JBAS-6677] After cancellation or expiration of single action timer, timedObjectId to TimerServiceImpl mapping is cleaned up to avoid leaks leading from entities not being removed via the EJB container.

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExt.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExt.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExt.java	2009-04-20 09:35:07 UTC (rev 87560)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.timer.interfaces;
+
+/**
+ * TimerEntityExt.
+ * 
+ * @author Galder Zamarreño
+ */
+public interface TimerEntityExt extends TimerEntity
+{
+   boolean hasTimerService(String jndi) throws java.rmi.RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExtHome.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExtHome.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/interfaces/TimerEntityExtHome.java	2009-04-20 09:35:07 UTC (rev 87560)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.timer.interfaces;
+
+/**
+ * TimerEntityExt.
+ * 
+ * @author Galder Zamarreño
+ */
+public interface TimerEntityExtHome extends javax.ejb.EJBHome
+{
+   public org.jboss.test.timer.interfaces.TimerEntityExt create(java.lang.Integer pk)
+   throws javax.ejb.CreateException,java.rmi.RemoteException;
+
+   public org.jboss.test.timer.interfaces.TimerEntityExt findByPrimaryKey(java.lang.Integer pk)
+   throws javax.ejb.FinderException,java.rmi.RemoteException;
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/test/TimerCleanUpUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/test/TimerCleanUpUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/timer/test/TimerCleanUpUnitTestCase.java	2009-04-20 09:35:07 UTC (rev 87560)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.timer.test;
+
+import javax.ejb.EJBHome;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.timer.interfaces.TimerEntityExt;
+import org.jboss.test.timer.interfaces.TimerEntityExtHome;
+
+/**
+ * RemovalAfterPassivationTimerUnitTestCase.
+ * 
+ * @author Galder Zamarreño
+ */
+public class TimerCleanUpUnitTestCase extends JBossTestCase
+{
+   private static final String EJB_TIMER_XAR = "ejb-timer.ear";
+
+   private static final int SHORT_PERIOD = 1 * 1000; // 1s
+
+   public TimerCleanUpUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Setup the test suite.
+    */
+   public static Test suite() throws Exception
+   {
+      return JBossTestCase.getDeploySetup(TimerCleanUpUnitTestCase.class, EJB_TIMER_XAR);
+   }
+   
+   public void testEntityBeanTimerHasTimerServiceAfterCancellationStd() throws Exception
+   {
+      String jndi = "ejb/test/timer/TimerEntityExtStd";
+      TimerEntityExtHome home = (TimerEntityExtHome) getEJBHome("ejb/test/timer/TimerEntityExtStd");
+      TimerEntityExt entity = home.create(new Integer(333));
+      entity.startTimer(SHORT_PERIOD);
+      Thread.sleep(12 * SHORT_PERIOD);
+      assertTrue("Timer service should be associated with bean." , entity.hasTimerService(jndi));
+      entity.stopTimer();
+      int lCount = entity.getTimeoutCount();
+      assertTrue("Timeout was expected to be called at least 10 times but was "
+         + "only called: " + lCount + " times",
+         lCount >= 10);
+      Thread.sleep(5 * SHORT_PERIOD);
+      int lCount2 = entity.getTimeoutCount();
+      assertTrue("After the timer was stopped no timeout should happen but "
+         + "it was called " + (lCount2 - lCount) + " more times",
+         lCount == lCount2);
+      assertFalse("Timer service should have been passivated and timer service association removed." 
+            , entity.hasTimerService(jndi));
+      entity.remove();
+   }
+   
+   public void testEntityBeanSingleTimerHasTimerServiceAfterExpirationStd() throws Exception
+   {
+      String jndi = "ejb/test/timer/TimerEntityExtStd";
+      TimerEntityExtHome home = (TimerEntityExtHome) getEJBHome("ejb/test/timer/TimerEntityExtStd");
+      TimerEntityExt entity = home.create(new Integer(444));
+      entity.startSingleTimer(SHORT_PERIOD);
+      Thread.sleep(5 * SHORT_PERIOD);
+      assertFalse("Timer service should be associated with bean." , entity.hasTimerService(jndi));
+      int lCount = entity.getTimeoutCount();
+      assertTrue("Timeout was expected to be called only once but was called: "
+         + lCount + " times",
+         lCount == 1);
+      entity.remove();
+   }
+
+   public void testEntityBeanTimerHasTimerServiceAfterCancellationInstPerTx() throws Exception
+   {
+      String jndi = "ejb/test/timer/TimerEntityExtInstPerTx";
+      TimerEntityExtHome home = (TimerEntityExtHome) getEJBHome(jndi);
+      TimerEntityExt entity = home.create(new Integer(555));
+      entity.startTimer(SHORT_PERIOD);
+      Thread.sleep(12 * SHORT_PERIOD);
+      assertTrue("Timer service should be associated with bean." , entity.hasTimerService(jndi));
+      entity.stopTimer();
+      int lCount = entity.getTimeoutCount();
+      assertTrue("Timeout was expected to be called at least 10 times but was "
+         + "only called: " + lCount + " times",
+         lCount >= 10);
+      Thread.sleep(5 * SHORT_PERIOD);
+      int lCount2 = entity.getTimeoutCount();
+      assertTrue("After the timer was stopped no timeout should happen but "
+         + "it was called " + (lCount2 - lCount) + " more times",
+         lCount == lCount2);
+      assertFalse("Timer service should have been passivated and timer service association removed." 
+            , entity.hasTimerService(jndi));
+      entity.remove();
+   }
+   
+   public void testEntityBeanSingleTimerHasTimerServiceAfterExpirationInstPerTx() throws Exception
+   {
+      String jndi = "ejb/test/timer/TimerEntityExtInstPerTx";
+      TimerEntityExtHome home = (TimerEntityExtHome) getEJBHome(jndi);
+      TimerEntityExt entity = home.create(new Integer(666));
+      entity.startSingleTimer(SHORT_PERIOD);
+      Thread.sleep(5 * SHORT_PERIOD);
+      assertFalse("Timer service should be associated with bean." , entity.hasTimerService(jndi));
+      int lCount = entity.getTimeoutCount();
+      assertTrue("Timeout was expected to be called only once but was called: "
+         + lCount + " times",
+         lCount == 1);
+      assertFalse("Timer service should have been passivated and timer service association removed." 
+            , entity.hasTimerService(jndi));
+      entity.remove();
+   }   
+   
+   private EJBHome getEJBHome(String pJNDIName) throws NamingException
+   {
+      InitialContext lContext = new InitialContext();
+      return (EJBHome) lContext.lookup(pJNDIName);
+   }
+}

Modified: branches/Branch_5_x/testsuite/src/resources/timer/ejb/ejb-jar.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/timer/ejb/ejb-jar.xml	2009-04-20 09:28:06 UTC (rev 87559)
+++ branches/Branch_5_x/testsuite/src/resources/timer/ejb/ejb-jar.xml	2009-04-20 09:35:07 UTC (rev 87560)
@@ -35,6 +35,28 @@
          <prim-key-class>java.lang.Integer</prim-key-class>
          <reentrant>false</reentrant>
       </entity>
+      <entity>
+         <description>Extended Entity Bean Timer Standard Container</description>
+         <display-name>Timer in Extended Entity Bean Standard Container</display-name>
+         <ejb-name>TimerEntityExtStd</ejb-name>
+         <home>org.jboss.test.timer.interfaces.TimerEntityExtHome</home>
+         <remote>org.jboss.test.timer.interfaces.TimerEntityExt</remote>
+         <ejb-class>org.jboss.test.timer.ejb.TimerEntityExtBean</ejb-class>
+         <persistence-type>Bean</persistence-type>
+         <prim-key-class>java.lang.Integer</prim-key-class>
+         <reentrant>false</reentrant>
+      </entity>
+      <entity>
+         <description>Extended Entity Bean Timer Instance Per Tx</description>
+         <display-name>Timer in Extended Entity Bean Instance Per Tx</display-name>
+         <ejb-name>TimerEntityExtInstPerTx</ejb-name>
+         <home>org.jboss.test.timer.interfaces.TimerEntityExtHome</home>
+         <remote>org.jboss.test.timer.interfaces.TimerEntityExt</remote>
+         <ejb-class>org.jboss.test.timer.ejb.TimerEntityExtBean</ejb-class>
+         <persistence-type>Bean</persistence-type>
+         <prim-key-class>java.lang.Integer</prim-key-class>
+         <reentrant>false</reentrant>
+      </entity>
 
       <session>
          <description>Secured Stateless Session Bean Timer Test</description>

Modified: branches/Branch_5_x/testsuite/src/resources/timer/ejb/jboss.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/timer/ejb/jboss.xml	2009-04-20 09:28:06 UTC (rev 87559)
+++ branches/Branch_5_x/testsuite/src/resources/timer/ejb/jboss.xml	2009-04-20 09:35:07 UTC (rev 87560)
@@ -15,6 +15,17 @@
          <jndi-name>ejb/test/timer/TimerEntity</jndi-name>
          <timer-persistence>false</timer-persistence>         
       </entity>
+      <entity>
+         <ejb-name>TimerEntityExtStd</ejb-name>
+         <jndi-name>ejb/test/timer/TimerEntityExtStd</jndi-name>
+         <timer-persistence>false</timer-persistence>         
+      </entity>
+      <entity>
+         <ejb-name>TimerEntityExtInstPerTx</ejb-name>
+         <jndi-name>ejb/test/timer/TimerEntityExtInstPerTx</jndi-name>
+         <timer-persistence>false</timer-persistence> 
+         <configuration-name>Instance Per Transaction BMP EntityBean</configuration-name>        
+      </entity>      
       <session>
          <ejb-name>TimerSLSB</ejb-name>
          <jndi-name>ejb/test/timer/TimerSLSB</jndi-name>




More information about the jboss-cvs-commits mailing list