[jboss-cvs] JBossAS SVN: r107174 - in branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer: interfaces and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 28 16:55:52 EDT 2010


Author: jaikiran
Date: 2010-07-28 16:55:51 -0400 (Wed, 28 Jul 2010)
New Revision: 107174

Modified:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/NoTimedObjectBean.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/TimerSLSBean.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/interfaces/TimerSLSB.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/servlet/InitTimerServlet.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/BasicTimerUnitTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/SecureTimerUnitTestCase.java
Log:
JBPAPP-4681 Fix the timer related testcase

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/NoTimedObjectBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/NoTimedObjectBean.java	2010-07-28 20:41:54 UTC (rev 107173)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/NoTimedObjectBean.java	2010-07-28 20:55:51 UTC (rev 107174)
@@ -21,8 +21,9 @@
  */
 package org.jboss.test.timer.ejb;
 
-import java.io.Serializable;
 import java.util.Date;
+import java.util.HashMap;
+
 import javax.ejb.EJBException;
 import javax.ejb.SessionBean;
 import javax.ejb.SessionContext;
@@ -41,51 +42,51 @@
 {
    private SessionContext context;
 
-   public byte[] startSingleTimer(long pPeriod)
+   public void startSingleTimer(String timerName, long pPeriod)
    {
-      return startSingleTimer(pPeriod,"TimerSLSBean.startSingleTimer");
+      startSingleTimer(timerName, pPeriod, new HashMap());
    }
 
-   public byte[] startSingleTimer(long pPeriod, Serializable info)
+   public void startSingleTimer(String timerName, long pPeriod, HashMap info)
    {
       TimerService ts = context.getTimerService();
       throw new EJBException("startSingleTimer.getTimerService should have failed");
    }
 
-   public byte[] startTimer(long pPeriod)
+   public void startTimer(String timerName, long pPeriod)
    {
       TimerService ts = context.getTimerService();
       throw new EJBException("startSingleTimer.getTimerService should have failed");
    }
 
-   public byte[] startTimer(long pPeriod, Serializable info)
+   public void startTimer(String timerName, long pPeriod, HashMap info)
    {
       TimerService ts = context.getTimerService();
       throw new EJBException("startSingleTimer.getTimerService should have failed");
    }
 
-   public void stopTimer(byte[] handle)
+   public void stopTimer(String timerName)
    {
       TimerService ts = context.getTimerService();
       throw new EJBException("startSingleTimer.getTimerService should have failed");
    }
 
-   public int getTimeoutCount(byte[] handle)
+   public int getTimeoutCount(String timerName)
    {
       return 0;
    }
 
-   public Date getNextTimeout(byte[] handle)
+   public Date getNextTimeout(String timerName)
    {
       return null;
    }
 
-   public long getTimeRemaining(byte[] handle)
+   public long getTimeRemaining(String timerName)
    {
       return 0;
    }
 
-   public Object getInfo(byte[] handle)
+   public Object getInfo(String timerName)
    {
       return null;
    }

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/TimerSLSBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/TimerSLSBean.java	2010-07-28 20:41:54 UTC (rev 107173)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/ejb/TimerSLSBean.java	2010-07-28 20:55:51 UTC (rev 107174)
@@ -21,22 +21,28 @@
  */
 package org.jboss.test.timer.ejb;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
-import java.util.List;
-import java.io.*;
 
+import javax.ejb.EJBException;
+import javax.ejb.NoSuchObjectLocalException;
 import javax.ejb.SessionBean;
 import javax.ejb.SessionContext;
 import javax.ejb.TimedObject;
 import javax.ejb.Timer;
 import javax.ejb.TimerHandle;
 import javax.ejb.TimerService;
-import javax.ejb.EJBException;
-import javax.ejb.NoSuchObjectLocalException;
+import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
-import javax.management.MBeanServer;
 
 import org.jboss.logging.Logger;
 import org.jboss.test.timer.interfaces.TimerSLSB;
@@ -65,6 +71,7 @@
    // -------------------------------------------------------------------------
    private static HashMap timeoutCounts = new HashMap();
    private static Logger log = Logger.getLogger(TimerSLSBean.class);
+   private static final String TIMER_NAME_KEY = "TimerNameKey";
 
    // -------------------------------------------------------------------------
    // Members
@@ -83,9 +90,9 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public byte[] startSingleTimer(long pPeriod)
+   public void startSingleTimer(String timerName, long pPeriod)
    {
-      return startSingleTimer(pPeriod,"TimerSLSBean.startSingleTimer");
+      this.startSingleTimer(timerName, pPeriod,new HashMap());
    }
 
     /**
@@ -96,15 +103,18 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public byte[] startSingleTimer(long pPeriod, Serializable info)
+   public void startSingleTimer(String timerName, long pPeriod, HashMap info)
    {
       log.info("TimerSLSBean.startSingleTimer(), try to get a Timer Service from the Session Context");
       TimerService ts = context.getTimerService();
       long exp = System.currentTimeMillis() + pPeriod;
+      if (info == null)
+      {
+         info = new HashMap();
+      }
+      info.put(TIMER_NAME_KEY, timerName);
       Timer timer = ts.createTimer(new Date(exp), info);
       log.info("TimerSLSBean.startSingleTimer(), create a timer: "+timer);
-      byte[] handle = getHandle(timer);
-      return handle;
    }
 
    /**
@@ -116,9 +126,9 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public byte[] startTimer(long pPeriod)
+   public void startTimer(String timerName, long pPeriod)
    {
-      return startTimer(pPeriod, "TimerSLSBean.startTimer");
+      this.startTimer(timerName, pPeriod, new HashMap());
    }
 
      /**
@@ -130,42 +140,43 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public byte[] startTimer(long pPeriod, Serializable info)
+   public void startTimer(String timerName, long pPeriod, HashMap info)
    {
       log.info("TimerSLSBean.startTimer(), try to get a Timer Service from the Session Context");
       TimerService ts = context.getTimerService();
       long exp = System.currentTimeMillis() + pPeriod;
+      if (info == null)
+      {
+         info = new HashMap();
+      }
+      info.put(TIMER_NAME_KEY, timerName);
       Timer timer = ts.createTimer(new Date(exp), pPeriod, info);
       log.info("TimerSLSBean.startTimer(), create a timer: "+timer);
-      byte[] handle = getHandle(timer);
-      return handle;
    }
 
    /**
     * @ejb:interface-method view-type="remote"
     **/
-   public void stopTimer(byte[] handle)
+   public void stopTimer(String timerName)
    {
-      Timer timer = getTimer(handle);
+      Timer timer = getTimer(timerName);
       timer.cancel();
       log.info("TimerSLSBean.stopTimer(), create a timer: "+timer);
       synchronized( TimerSLSBean.class )
       {
-         Long key = getKey(handle);
-         timeoutCounts.remove(key);
+         timeoutCounts.remove(timerName);
       }
    }
 
    /**
     * @ejb:interface-method view-type="remote"
     **/
-   public int getTimeoutCount(byte[] handle)
+   public int getTimeoutCount(String timerName)
    {
       Integer count = null;
       try
       {
-         Long key = getKey(handle);         
-         count = (Integer) timeoutCounts.get(key);
+         count = (Integer) timeoutCounts.get(timerName);
       }
       catch(NoSuchObjectLocalException e)
       {
@@ -180,9 +191,9 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public Date getNextTimeout(byte[] handle)
+   public Date getNextTimeout(String timerName)
    {
-      Timer timer = getTimer(handle);
+      Timer timer = getTimer(timerName);
       return timer.getNextTimeout();
    }
 
@@ -191,9 +202,9 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public long getTimeRemaining(byte[] handle)
+   public long getTimeRemaining(String timerName)
    {
-      Timer timer = getTimer(handle);
+      Timer timer = getTimer(timerName);
       return timer.getTimeRemaining();
    }
 
@@ -202,10 +213,21 @@
     *
     * @ejb:interface-method view-type="remote"
     **/
-   public Object getInfo(byte[] handle)
+   public Object getInfo(String timerName)
    {
-      Timer timer = getTimer(handle);
-      return timer.getInfo();
+      Timer timer = getTimer(timerName);
+      Serializable info = timer.getInfo();
+      // this shouldn't happen, because we always are dealing with HashMap in this
+      // testcase
+      if (!(info instanceof HashMap))
+      {
+         // just return the info, and let the testcase handle it
+         return info;
+      }
+      // remove the key/value pair that this bean had inserted
+      // so that the testcase is remains unaware of it
+      ((HashMap)info).remove(TIMER_NAME_KEY);
+      return info;
    }
 
    /**
@@ -221,22 +243,21 @@
    public void ejbTimeout(Timer timer)
    {
       Integer count = null;
-      Long key = null;
+      String timerName = null; 
       synchronized( TimerSLSBean.class )
       {
          log.debug("ejbTimeout(): Timer State:" + timer);
-         byte[] handle = getHandle(timer);
-         key = getKey(handle);
-         count = (Integer) timeoutCounts.get(key);
+         timerName = this.getTimerName(timer);
+         count = (Integer) timeoutCounts.get(timerName);
          if( count == null )
             count = new Integer(1);
          else
             count = new Integer(1 + count.intValue());
-         timeoutCounts.put(key, count);
-         log.info("ejbTimeout(): count for timer handle " + key + " is " + count);
+         timeoutCounts.put(timerName, count);
+         log.info("ejbTimeout(): count for timerName " + timerName + " is " + count);
       }
 
-      log.info("ejbTimeout(), timer: " + timer+", key: "+key+", count: "+count);
+      log.info("ejbTimeout(), timer: " + timer+", name: "+timerName+", count: "+count);
 
       Object info = timer.getInfo();
       if(info instanceof Map) {
@@ -298,52 +319,41 @@
    {
    }
 
-   private Long getKey(byte[] handle)
-   {
-      long key = 0;
-      for(int n = 0; n < handle.length; n ++)
-         key += handle[n];
-      log.info("HandleKey: "+key);
-      return new Long(key);
-   }
-   private byte[] getHandle(Timer timer)
+   private String getTimerName(Timer timer)
       throws EJBException
    {
-      try
+      Serializable info = timer.getInfo();
+      if (info != null && info instanceof HashMap)
       {
-         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-         ObjectOutputStream oos = new ObjectOutputStream(baos);
-         oos.writeObject(timer.getHandle());
-         oos.close();
-         byte[] handle = baos.toByteArray();
-         return handle;
+         String timerName = (String) ((HashMap) info).get(TIMER_NAME_KEY);
+         if (timerName != null)
+         {
+            return timerName;
+         }
       }
-      catch (Exception e)
-      {
-         throw new EJBException("Failed to get timer from handle", e);
-      }
+      throw new EJBException("Could not find internal timerName from timer " + timer);
    }
-   private Timer getTimer(byte[] handle)
+   
+   private Timer getTimer(String timerName)
       throws NoSuchObjectLocalException, EJBException
    {
-      try
+      TimerService ts = context.getTimerService();
+      Collection timers = ts.getTimers();
+      Iterator timersIterator = timers.iterator();
+      while (timersIterator.hasNext())
       {
-         ByteArrayInputStream bais = new ByteArrayInputStream(handle);
-         ObjectInputStream ois = new ObjectInputStream(bais);
-         TimerHandle th = null;
-         th = (TimerHandle) ois.readObject();
-         ois.close();
-         Timer timer = th.getTimer();
-         return timer;
+         Timer timer = (Timer) timersIterator.next();
+         Serializable info = timer.getInfo();
+         if (info != null && info instanceof HashMap)
+         {
+            String name = (String) ((HashMap) info).get(TIMER_NAME_KEY);
+            if (timerName.equals(name))
+            {
+               return timer;
+            }
+         }
       }
-      catch(NoSuchObjectLocalException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new EJBException("Failed to get timer from handle", e);
-      }
+      throw new NoSuchObjectLocalException("Timer with name " + timerName + " isn't available");
    }
 
    /**

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/interfaces/TimerSLSB.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/interfaces/TimerSLSB.java	2010-07-28 20:41:54 UTC (rev 107173)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/interfaces/TimerSLSB.java	2010-07-28 20:55:51 UTC (rev 107174)
@@ -21,7 +21,7 @@
  */
 package org.jboss.test.timer.interfaces;
 
-import java.io.Serializable;
+import java.util.HashMap;
 
 /**
  * Remote interface for test/timer/TimerSLSB.
@@ -53,7 +53,7 @@
     * This method uses an implementation defined default value for the timer info.
     * @param pPeriod Time that will elapse between now and the timed event in milliseconds
     */
-   public byte[] startSingleTimer( long pPeriod )
+   public void startSingleTimer( String timerName, long pPeriod )
       throws java.rmi.RemoteException;
 
    /**
@@ -62,7 +62,7 @@
    * @param pPeriod Time that will elapse between now and the timed event in milliseconds
    * @param info an object to be used as the info for the timer.
    **/
-   public byte[] startSingleTimer(long pPeriod, Serializable info)
+   public void startSingleTimer(String timerName, long pPeriod, HashMap info)
       throws java.rmi.RemoteException;
 
    /**
@@ -70,7 +70,7 @@
     * This method uses an implementation defined default value for the timer info.
     * @param pPeriod Time that will elapse between two events in milliseconds
     */
-   public byte[] startTimer( long pPeriod )
+   public void startTimer(String timerName, long pPeriod )
       throws java.rmi.RemoteException;
 
    /**
@@ -79,22 +79,22 @@
     * @param pPeriod Time that will elapse between two events in milliseconds
     * @param info an object to be used as the info for the timer.
     */
-   public byte[] startTimer( long pPeriod, Serializable info )
+   public void startTimer(String timerName, long pPeriod, HashMap info )
       throws java.rmi.RemoteException;
 
-   public void stopTimer(byte[] handle)
+   public void stopTimer(String timerName)
       throws java.rmi.RemoteException;
 
-   public int getTimeoutCount(byte[] handle)
+   public int getTimeoutCount(String timerName)
       throws java.rmi.RemoteException;
 
-   public java.util.Date getNextTimeout(byte[] handle)
+   public java.util.Date getNextTimeout(String timerName)
       throws java.rmi.RemoteException;
 
-   public long getTimeRemaining(byte[] handle)
+   public long getTimeRemaining(String timerName)
       throws java.rmi.RemoteException;
 
-   public Object getInfo(byte[] handle)
+   public Object getInfo(String timerName)
       throws java.rmi.RemoteException;
 
    /**

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/servlet/InitTimerServlet.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/servlet/InitTimerServlet.java	2010-07-28 20:41:54 UTC (rev 107173)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/servlet/InitTimerServlet.java	2010-07-28 20:55:51 UTC (rev 107174)
@@ -45,7 +45,7 @@
 public class InitTimerServlet extends HttpServlet
 {
    private static Logger log = Logger.getLogger(InitTimerServlet.class);
-   private static byte[] handle;
+   private static final String TIMER_NAME = "InitTimerServlet";
 
    /**
     * Start an ejb timer from within the init method.
@@ -63,7 +63,7 @@
          InitialContext ctx = new InitialContext();
          TimerSLSBHome home = (TimerSLSBHome) ctx.lookup("java:/comp/env/ejb/TimerSLSBHome");
          TimerSLSB bean = home.create();
-         handle = bean.startTimer(60000);
+         bean.startTimer(TIMER_NAME,60000);
       }
       catch(Exception e)
       {
@@ -79,9 +79,9 @@
          InitialContext ctx = new InitialContext();
          TimerSLSBHome home = (TimerSLSBHome) ctx.lookup("java:/comp/env/ejb/TimerSLSBHome");
          TimerSLSB bean = home.create();
-         int timeoutCount = bean.getTimeoutCount(handle);
-         Date nextTimeout = bean.getNextTimeout(handle);
-         long timeRemaining = bean.getTimeRemaining(handle);
+         int timeoutCount = bean.getTimeoutCount(TIMER_NAME);
+         Date nextTimeout = bean.getNextTimeout(TIMER_NAME);
+         long timeRemaining = bean.getTimeRemaining(TIMER_NAME);
          PrintWriter pw = response.getWriter();
          pw.println("<html><head><title>InitTimerServlet</title></head><body>");
          pw.println("<h1>Timer Info</h1>");

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/BasicTimerUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/BasicTimerUnitTestCase.java	2010-07-28 20:41:54 UTC (rev 107173)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/BasicTimerUnitTestCase.java	2010-07-28 20:55:51 UTC (rev 107174)
@@ -156,15 +156,16 @@
    {
       TimerSLSBHome home = (TimerSLSBHome) getEJBHome(TimerSLSBHome.JNDI_NAME);
       TimerSLSB bean = home.create();
-      byte[] handle = bean.startTimer(SHORT_PERIOD);
+      String timerName = "testStatelessSessionBeanTimer";
+      bean.startTimer(timerName, SHORT_PERIOD);
       Thread.sleep(12 * SHORT_PERIOD + SHORT_PERIOD);
-      int count = bean.getTimeoutCount(handle);
-      bean.stopTimer(handle);
+      int count = bean.getTimeoutCount(timerName);
+      bean.stopTimer(timerName);
       assertTrue("Timeout was expected to be called at least 10 times but was "
          + "only called: " + count + " times",
          count >= 10);
       Thread.sleep(5 * SHORT_PERIOD);
-      int count2 = bean.getTimeoutCount(handle);
+      int count2 = bean.getTimeoutCount(timerName);
       assertTrue("After the timer was stopped no timeout should happen but "
          + "it was called " + count2 + " more times",
          count2 == 0);
@@ -191,6 +192,7 @@
       // We need to make sure that the next timer interval occurs
       // while the retry timeout is STILL running in order to test JBAS-1926
       final long retryMs = bean.getRetryTimeoutPeriod();
+      String timerName = "testStatelessSessionBeanTimerRetry";
       log.info("testStatelessSessionBeanTimerRetry():GOT RETRY TIME:" + retryMs);
       assertFalse("Failed to get valid retry timeout!", retryMs == -1);
       final HashMap info = new HashMap();
@@ -203,13 +205,13 @@
       final int taskTime = SHORT_PERIOD * 2;
       info.put(TimerSLSB.INFO_TASK_RUNTIME,new Integer(taskTime)); // the time is takes to execute the task
 
-      final byte[] handle = bean.startTimer(SHORT_PERIOD,info);
+      bean.startTimer(timerName, SHORT_PERIOD,info);
       // Wait for 1 SHORT_PERIOD for the first firing
       // Another retryMs for the amount of time it takes for the retry to happen
       // and finally the amount of time that it takes to execute the task and 200ms to be safe.
       Thread.sleep(SHORT_PERIOD  + retryMs + taskTime + 200);
-      int count = bean.getTimeoutCount(handle);
-      bean.stopTimer(handle);
+      int count = bean.getTimeoutCount(timerName);
+      bean.stopTimer(timerName);
       assertEquals("Timeout was called too many times. Should have been once for the initial" +
             ", and once for the retry during the time allotted.",2,count);
 
@@ -227,15 +229,16 @@
    {
       TimerSLSBHome home = (TimerSLSBHome) getEJBHome(TimerSLSBHome.JNDI_NAME);
       TimerSLSB bean = home.create();
-      byte[] handle = bean.startSingleTimer(SHORT_PERIOD);
+      final String timerName = "testStatelessSessionBeanSingleTimer";
+      bean.startSingleTimer(timerName, SHORT_PERIOD);
       Thread.sleep(5 * SHORT_PERIOD);
-      int lCount = bean.getTimeoutCount(handle);
+      int lCount = bean.getTimeoutCount(timerName);
       assertTrue("Timeout was expected to be called only once but was called: "
          + lCount + " times",
          lCount == 1);
       try
       {
-         bean.stopTimer(handle);
+         bean.stopTimer(timerName);
          fail("A single timer should expire after the first event and therefore this "
             + "has to throw an NoSuchObjectLocalException");
       }
@@ -263,10 +266,10 @@
       log.info("testStatelessSessionBeanSingleTimer(): Testing retry on timer.");
       final HashMap info = new HashMap(1);
       info.put(TimerSLSB.INFO_EXEC_FAIL_COUNT,new Integer(1));
-      handle = bean.startSingleTimer(SHORT_PERIOD,info);
+      bean.startSingleTimer(timerName, SHORT_PERIOD,info);
       Thread.sleep(5 * SHORT_PERIOD);
       assertEquals("Timeout was expected to be called twice, once inititially, one once for the retry.",
-               2,bean.getTimeoutCount(handle));
+               2,bean.getTimeoutCount(timerName));
 
 
    }
@@ -568,20 +571,17 @@
    {
       TimerSLSBHome home = (TimerSLSBHome) getEJBHome(TimerSLSBHome.JNDI_NAME);
       TimerSLSB bean = home.create();
-      byte[] handle = bean.startTimer(LONG_PERIOD);
-      Date lNextEvent = bean.getNextTimeout(handle);
+      String timerName = "testTimerImplementation";
+      bean.startTimer(timerName, LONG_PERIOD);
+      Date lNextEvent = bean.getNextTimeout(timerName);
       long lUntilNextEvent = lNextEvent.getTime() - new Date().getTime();
       Thread.sleep(SHORT_PERIOD);
-      long lTimeRemaining = bean.getTimeRemaining(handle);
-      Object info = bean.getInfo(handle);
+      long lTimeRemaining = bean.getTimeRemaining(timerName);
       assertTrue("Date of the next event must be greater than 0", lUntilNextEvent > 0);
       assertTrue("Period until next event must be greater than 0", lTimeRemaining > 0);
       assertTrue("Period until next event must be smaller than time until next even because it "
          + "it is called later", lUntilNextEvent > lTimeRemaining);
-      assertTrue("Info("+info+") must be 'TimerSLSBean.startTimer'",
-         "TimerSLSBean.startTimer".equals(info));
-      assertTrue("Must be able to get a handle", handle != null);
-      bean.stopTimer(handle);
+      bean.stopTimer(timerName);
    }
 
    /**
@@ -597,7 +597,7 @@
       TimerSLSB bean = home.create();
       try
       {
-         bean.startTimer(SHORT_PERIOD);
+         bean.startTimer("testBadStatelessSessionBeanTimer", SHORT_PERIOD);
          fail("Was able to call NoTimedObjectBean.startTimer");
       }
       catch(RemoteException e)

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/SecureTimerUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/SecureTimerUnitTestCase.java	2010-07-28 20:41:54 UTC (rev 107173)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/timer/test/SecureTimerUnitTestCase.java	2010-07-28 20:55:51 UTC (rev 107174)
@@ -117,16 +117,17 @@
       login();
       TimerSLSBHome home = (TimerSLSBHome) getEJBHome(TimerSLSBHome.SECURED_JNDI_NAME);
       TimerSLSB bean = home.create();
-      byte[] handle = bean.startTimer(SHORT_PERIOD);
+      String timerName = "testSecuredStatelessSessionBeanTimer";
+      bean.startTimer(timerName, SHORT_PERIOD);
       // Sleep for 20x the timer interval and expect at least 10 events
       Thread.sleep(20 * SHORT_PERIOD);
-      int count = bean.getTimeoutCount(handle);
-      bean.stopTimer(handle);
+      int count = bean.getTimeoutCount(timerName);
+      bean.stopTimer(timerName);
       assertTrue("Timeout was expected to be called at least 10 times but was "
          + "only called: " + count + " times",
          count >= 10);
       Thread.sleep(5 * SHORT_PERIOD);
-      int count2 = bean.getTimeoutCount(handle);
+      int count2 = bean.getTimeoutCount(timerName);
       assertTrue("After the timer was stopped no timeout should happen but "
          + "it was called " + count2 + " more times",
          count2 == 0);
@@ -145,15 +146,16 @@
       login();
       TimerSLSBHome home = (TimerSLSBHome) getEJBHome(TimerSLSBHome.SECURED_JNDI_NAME);
       TimerSLSB bean = home.create();
-      byte[] handle = bean.startSingleTimer(SHORT_PERIOD);
+      String timerName = "testSecuredStatelessSessionBeanSingleTimer";
+      bean.startSingleTimer(timerName, SHORT_PERIOD);
       Thread.sleep(5 * SHORT_PERIOD);
-      int count = bean.getTimeoutCount(handle);
+      int count = bean.getTimeoutCount(timerName);
       assertTrue("Timeout was expected to be called only once but was called: "
          + count + " times",
          count == 1);
       try
       {
-         bean.stopTimer(handle);
+         bean.stopTimer(timerName);
          fail("A single timer should expire after the first event and therefore this "
             + "has to throw an NoSuchObjectLocalException");
       }



More information about the jboss-cvs-commits mailing list