[jboss-cvs] JBossAS SVN: r65473 - in trunk/testsuite: src/main/org/jboss/test/txtimer/test and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 19 09:52:17 EDT 2007


Author: adrian at jboss.org
Date: 2007-09-19 09:52:17 -0400 (Wed, 19 Sep 2007)
New Revision: 65473

Added:
   trunk/testsuite/src/resources/txtimer/test/
   trunk/testsuite/src/resources/txtimer/test/META-INF/
   trunk/testsuite/src/resources/txtimer/test/META-INF/ejb-jar.xml
   trunk/testsuite/src/resources/txtimer/test/META-INF/jboss.xml
Modified:
   trunk/testsuite/imports/sections/timer.xml
   trunk/testsuite/src/main/org/jboss/test/txtimer/test/TransactionalTimerTestCase.java
Log:
JBAS-4520 Make the txtimer test run in the appserver

Modified: trunk/testsuite/imports/sections/timer.xml
===================================================================
--- trunk/testsuite/imports/sections/timer.xml	2007-09-19 13:51:04 UTC (rev 65472)
+++ trunk/testsuite/imports/sections/timer.xml	2007-09-19 13:52:17 UTC (rev 65473)
@@ -33,6 +33,24 @@
             <include name="ejb-timer.war"/>
          </zipfileset>
       </zip>
+
+      <jar destfile="${build.lib}/transactional-timer-test.jar">
+         <fileset dir="${build.classes}">
+            <patternset refid="common.test.client.classes"/>
+            <include name="org/jboss/test/txtimer/**"/>
+            <include name="org/jboss/test/util/ejb/*"/>
+         </fileset>
+         <fileset dir="${build.resources}/txtimer/test">
+            <include name="**/*.*"/>
+         </fileset>
+         <zipfileset src="${junit.junit.lib}/junit.jar">
+            <patternset refid="ejbrunner.set"/>
+         </zipfileset>
+         <zipfileset src="${jboss.test.lib}/jboss-test.jar">
+            <patternset refid="jboss.test.set"/>
+         </zipfileset>
+      </jar>
+
    </target>
    
 </project>

Modified: trunk/testsuite/src/main/org/jboss/test/txtimer/test/TransactionalTimerTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/txtimer/test/TransactionalTimerTestCase.java	2007-09-19 13:51:04 UTC (rev 65472)
+++ trunk/testsuite/src/main/org/jboss/test/txtimer/test/TransactionalTimerTestCase.java	2007-09-19 13:52:17 UTC (rev 65473)
@@ -1,8 +1,8 @@
 /*
- * 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.
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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
@@ -21,10 +21,20 @@
  */
 package org.jboss.test.txtimer.test;
 
+import javax.ejb.TimedObject;
 import javax.ejb.Timer;
 import javax.ejb.TimerService;
+import javax.management.ObjectName;
 import javax.transaction.TransactionManager;
 
+import junit.framework.Test;
+
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.ejb.txtimer.EJBTimerServiceLocator;
+import org.jboss.ejb.txtimer.TimedObjectId;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.util.ejb.EJBTestCase;
 import org.jboss.tm.TransactionManagerLocator;
 
 /**
@@ -32,15 +42,59 @@
  * @author Dimitris.Andreadis at jboss.org
  * @version $Revision$
  */
-public class TransactionalTimerTestCase extends TimerTestBase
+public class TransactionalTimerTestCase extends EJBTestCase
 {
    protected static TransactionManager txManager = TransactionManagerLocator.getInstance().locate();
 
+   protected EJBTimerService ejbTimerService;
+
    public TransactionalTimerTestCase(String name)
    {
       super(name);
    }
 
+   /**
+    * Sets up the fixture, for example, open a network connection.
+    * This method is called before a test is executed.
+    */
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      ejbTimerService = EJBTimerServiceLocator.getEjbTimerService();
+
+      // when the timer runs inside JBoss, this is taken care of by the container
+      // is standalone mode, we fake the context for timer operations, so the timer thinks we are inside a EJB
+      // business method, and does not refuse the operations
+      AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_BUSINESS_METHOD);
+   }
+
+   /**
+    * Tears down the fixture, for example, close a network connection.
+    * This method is called after a test is executed.
+    */
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      AllowedOperationsAssociation.popInMethodFlag();
+   }
+
+   protected TimerService createTimerService(TimedObject timedObject)
+   {
+      SimpleTimedObjectInvoker invoker = new SimpleTimedObjectInvoker();
+      TimedObjectId timedObjectId = invoker.addTimedObject(timedObject);
+      ObjectName containerId = timedObjectId.getContainerId();
+      Object instancePk = timedObjectId.getInstancePk();
+      return ejbTimerService.createTimerService(containerId, instancePk, invoker);
+   }
+
+   protected void sleep(long interval) throws InterruptedException
+   {
+      synchronized (this)
+      {
+         wait(interval);
+      }
+   }
+
    public void testRollbackBeforeExpire() throws Exception
    {
       txManager.begin();
@@ -99,4 +153,9 @@
       assertEquals("TimedObject called", 1, to.getCallCount());
       assertEquals("Expected no txtimer", 0, service.getTimers().size());
    }
+
+   public static Test suite() throws Exception
+   {
+      return JBossTestCase.getDeploySetup(TransactionalTimerTestCase.class, "transactional-timer-test.jar");
+   }
 }

Added: trunk/testsuite/src/resources/txtimer/test/META-INF/ejb-jar.xml
===================================================================
--- trunk/testsuite/src/resources/txtimer/test/META-INF/ejb-jar.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/txtimer/test/META-INF/ejb-jar.xml	2007-09-19 13:52:17 UTC (rev 65473)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE ejb-jar PUBLIC
+   "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+   "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+   <enterprise-beans>
+      <session>
+         <description>JUnit Session Bean Test Runner</description>
+         <ejb-name>EJBTestRunnerEJB</ejb-name>
+         <home>org.jboss.test.util.ejb.EJBTestRunnerHome</home>
+         <remote>org.jboss.test.util.ejb.EJBTestRunner</remote>
+         <ejb-class>org.jboss.test.util.ejb.EJBTestRunnerBean</ejb-class>
+         <session-type>Stateless</session-type>
+         <transaction-type>Bean</transaction-type>
+         <env-entry>
+            <env-entry-name>NO_USER_TRANSACTION</env-entry-name>
+            <env-entry-type>java.lang.String</env-entry-type>
+            <env-entry-value>true</env-entry-value>
+         </env-entry>
+      </session>
+   </enterprise-beans>
+</ejb-jar>

Added: trunk/testsuite/src/resources/txtimer/test/META-INF/jboss.xml
===================================================================
--- trunk/testsuite/src/resources/txtimer/test/META-INF/jboss.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/txtimer/test/META-INF/jboss.xml	2007-09-19 13:52:17 UTC (rev 65473)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE jboss PUBLIC
+   "-//JBoss//DTD JBOSS 3.2//EN"
+   "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
+
+<jboss>
+   <enterprise-beans>
+      <session>
+         <ejb-name>EJBTestRunnerEJB</ejb-name>
+         <jndi-name>ejb/EJBTestRunner</jndi-name>
+      </session>
+   </enterprise-beans>
+</jboss>




More information about the jboss-cvs-commits mailing list