[Jboss-cvs] JBossAS SVN: r56168 - in trunk/ejb3/src/test/org/jboss/ejb3/test/timer: . unit

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 23 04:20:32 EDT 2006


Author: wolfc
Date: 2006-08-23 04:20:24 -0400 (Wed, 23 Aug 2006)
New Revision: 56168

Added:
   trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TransactionalTimerTesterBean.java
Modified:
   trunk/ejb3/src/test/org/jboss/ejb3/test/timer/BaseTimerTesterBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TimerTester.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java
Log:
EJBTHREE-400: testing

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/timer/BaseTimerTesterBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timer/BaseTimerTesterBean.java	2006-08-23 08:05:49 UTC (rev 56167)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timer/BaseTimerTesterBean.java	2006-08-23 08:20:24 UTC (rev 56168)
@@ -27,6 +27,8 @@
 import javax.ejb.SessionContext;
 import javax.ejb.Timer;
 import javax.ejb.TimerService;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
 
 import org.jboss.logging.Logger;
 
@@ -47,11 +49,17 @@
 
    private @Resource TimerService timerService;
 
-   private @Resource SessionContext ctx;
+   protected @Resource SessionContext ctx;
    
    // TODO: fix this state in the stateless bean
    private static Timer timer;
 
+   @TransactionAttribute(TransactionAttributeType.MANDATORY)
+   public void checkMandatoryTransaction()
+   {
+      
+   }
+   
    public void startTimer(long pPeriod)
    {
       timerCalled = false;

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TimerTester.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TimerTester.java	2006-08-23 08:05:49 UTC (rev 56167)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TimerTester.java	2006-08-23 08:20:24 UTC (rev 56168)
@@ -31,6 +31,8 @@
  */
 public interface TimerTester
 {
+   void checkMandatoryTransaction();
+   
    void startTimer(long pPeriod);
 
    boolean isTimerCalled();

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TransactionalTimerTesterBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TransactionalTimerTesterBean.java	2006-08-23 08:05:49 UTC (rev 56167)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timer/TransactionalTimerTesterBean.java	2006-08-23 08:20:24 UTC (rev 56168)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.ejb3.test.timer;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(TimerTester.class)
+public class TransactionalTimerTesterBean extends BaseTimerTesterBean
+{
+   private static final Logger log = Logger.getLogger(TransactionalTimerTesterBean.class);
+   
+   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+   @Timeout
+   public void timeoutHandler(Timer timer)
+   {
+      log.info("EJB TIMEOUT!!!!");
+      timerCalled = true;
+      
+      TimerTester me = (TimerTester) ctx.getBusinessObject(TimerTester.class);
+      me.checkMandatoryTransaction();
+   }
+}

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java	2006-08-23 08:05:49 UTC (rev 56167)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java	2006-08-23 08:20:24 UTC (rev 56168)
@@ -47,6 +47,15 @@
 
    }
 
+   public void testNewTransaction() throws Exception
+   {
+      TimerTester test = (TimerTester) getInitialContext().lookup("TransactionalTimerTesterBean/remote");
+      test.startTimer(5000);
+      test.accessTimer();
+      Thread.sleep(6000);
+      assertTrue(test.isTimerCalled());
+   }
+   
    public void testService() throws Exception
    {
       TimerTester test = (TimerTester) getInitialContext().lookup("TimerTesterService/remote");




More information about the jboss-cvs-commits mailing list