1 22 package org.jboss.test.txtimer.test; 23 24 import javax.ejb.TimedObject ; 25 import javax.ejb.TimerService ; 26 import javax.management.ObjectName ; 27 28 import junit.framework.TestCase; 29 30 import org.jboss.ejb.AllowedOperationsAssociation; 31 import org.jboss.ejb.txtimer.EJBTimerService; 32 import org.jboss.ejb.txtimer.EJBTimerServiceLocator; 33 import org.jboss.ejb.txtimer.TimedObjectId; 34 35 39 public abstract class TimerTestBase extends TestCase 40 { 41 protected EJBTimerService ejbTimerService; 42 43 protected TimerTestBase(String name) 44 { 45 super(name); 46 } 47 48 52 protected void setUp() throws Exception 53 { 54 super.setUp(); 55 ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); 56 57 AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_BUSINESS_METHOD); 61 } 62 63 67 protected void tearDown() throws Exception 68 { 69 super.tearDown(); 70 AllowedOperationsAssociation.popInMethodFlag(); 71 } 72 73 protected TimerService createTimerService(TimedObject timedObject) 74 { 75 SimpleTimedObjectInvoker invoker = new SimpleTimedObjectInvoker(); 76 TimedObjectId timedObjectId = invoker.addTimedObject(timedObject); 77 ObjectName containerId = timedObjectId.getContainerId(); 78 Object instancePk = timedObjectId.getInstancePk(); 79 return ejbTimerService.createTimerService(containerId, instancePk, invoker); 80 } 81 82 protected void sleep(long interval) throws InterruptedException 83 { 84 synchronized (this) 85 { 86 wait(interval); 87 } 88 } 89 } 90 | Popular Tags |