### Eclipse Workspace Patch 1.0
#P jboss-ejb3-testsuite
Index: src/test/java/org/jboss/ejb3/test/ejbthree1701/ServiceUsingTimers.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1701/ServiceUsingTimers.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1701/ServiceUsingTimers.java	(revision 0)
@@ -0,0 +1,62 @@
+package org.jboss.ejb3.test.ejbthree1701;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.SessionContext;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+
+import org.jboss.ejb3.annotation.Management;
+import org.jboss.ejb3.annotation.Service;
+
+@Service
+@Management(IServiceManagement.class)
+@Remote(ServiceUsingTimersRemote.class)
+public class ServiceUsingTimers implements ServiceUsingTimersRemote, IServiceManagement
+{
+	@Resource
+	SessionContext ctx;
+	
+	boolean started = false;
+	
+	public void start()
+	{
+		System.out.println("ServiceUsingTimers start()");
+		// Fails in JBoss 5.0.0.GA, works in 4.2.x
+		cancelAllTimers(); 
+		initialize();
+		started = true;
+	}
+	
+	private void cancelAllTimers()
+	{
+		Collection timers = ctx.getTimerService().getTimers();
+		for (Iterator it = timers.iterator();it.hasNext();)
+		{
+			Timer t = (Timer)it.next();
+			t.cancel();
+		}   
+	}
+	
+	private void initialize()
+	{
+		TimerService service = ctx.getTimerService();
+		service.createTimer(30000, 30000, "EVERY_30_SECONDS");
+	}
+	
+	public boolean isStartedOK()
+	{
+		System.out.println("ServiceUsingTimers: Call to isStartedOK()");
+		return started;
+	}
+	
+	public void stop() {}
+	
+	@Timeout
+	public void handleTimeout(Timer timer) {}
+	
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1701/IServiceManagement.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1701/IServiceManagement.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1701/IServiceManagement.java	(revision 0)
@@ -0,0 +1,8 @@
+package org.jboss.ejb3.test.ejbthree1701;
+
+public interface IServiceManagement {
+	void start();
+	void stop();
+	//void create() throws Exception;
+	//void destroy() throws Exception;
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1701/unit/TimerSetupInServiceLifecycleTestCase.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1701/unit/TimerSetupInServiceLifecycleTestCase.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1701/unit/TimerSetupInServiceLifecycleTestCase.java	(revision 0)
@@ -0,0 +1,47 @@
+package org.jboss.ejb3.test.ejbthree1701.unit;
+
+import java.util.logging.Logger;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1701.ServiceUsingTimersRemote;
+import org.jboss.ejb3.test.ejbthree712.unit.InjectionTesterUnitTestCase;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * EJBTHREE-1701.
+ * 
+ * Setting up timers in Service lifecycle methods fails
+ * in JBoss 5.0.0.GA, worked in 4.2.x.
+ *
+ * @author Matt Carter
+ * @version $Revision: $
+ */
+public class TimerSetupInServiceLifecycleTestCase extends JBossTestCase
+{
+
+	private static Logger logger = Logger.getLogger(
+			TimerSetupInServiceLifecycleTestCase.class.getName());
+	
+	public TimerSetupInServiceLifecycleTestCase(String name)
+	{
+		super(name);
+		System.out.println("Ctr TimerSetupInServiceLifecycleTestCase");
+	}
+
+	public void testServiceStarted() throws Exception
+	{
+		System.out.println("Running testServiceStarted()");
+		ServiceUsingTimersRemote session = 
+			(ServiceUsingTimersRemote) getInitialContext().lookup("ServiceUsingTimers/remote");
+		assertNotNull(session);
+		assertTrue(session.isStartedOK());
+	}
+
+	public static Test suite() throws Exception
+	{
+		System.out.println("Suite TimerSetupInServiceLifecycleTestCase");
+		return getDeploySetup(TimerSetupInServiceLifecycleTestCase.class, "ejbthree1701.jar");
+	}
+}
+
Index: build-test.xml
===================================================================
--- build-test.xml	(revision 83577)
+++ build-test.xml	(working copy)
@@ -2420,14 +2420,15 @@
       <build-simple-jar name="ejbthree1624"/>
    </target>
 	
-	 <target name="ejbthree1647">
-	    <build-simple-jar name="ejbthree1647"/>
-	 </target>
+   <target name="ejbthree1647">
+      <build-simple-jar name="ejbthree1647"/>
+   </target>
 	
-   <target name="jbas4489"
-      description="Builds a simple jar files."
-      >
-      
+   <target name="ejbthree1701">
+      <build-simple-jar name="ejbthree1701"/>
+   </target>
+	
+   <target name="jbas4489" description="Builds a simple jar files.">
       <build-simple-jar name="jbas4489"/>
    </target>
    
@@ -4246,7 +4247,7 @@
       timer, benchmark, entity, joininheritance, singletable, tableperclass, dependent, mdb, manytomany, regression,
       composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
       localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
-      statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671"/>
+      statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671, ejbthree1701"/>
 
    <target name="test" depends="init" if="test"
       description="Execute all tests in the given test directory.">
@@ -4686,6 +4687,9 @@
    </target>
 
    <target name="no-start-jboss-ejb-tests" depends="init" description="Execute all tests">
+ 	  <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1701"/>
+ 	  </antcall>
 	  <antcall target="test" inheritRefs="true">
          <param name="test" value="ejbthree1090"/>
       </antcall>
Index: src/test/java/org/jboss/ejb3/test/ejbthree1701/ServiceUsingTimersRemote.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1701/ServiceUsingTimersRemote.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1701/ServiceUsingTimersRemote.java	(revision 0)
@@ -0,0 +1,5 @@
+package org.jboss.ejb3.test.ejbthree1701;
+
+public interface ServiceUsingTimersRemote {
+	boolean isStartedOK(); 
+}
