Examples of TimerEntity


Examples of org.jboss.test.timer.interfaces.TimerEntity

    */
   public void testEntityBeanSingleTimer()
      throws Exception
   {
      TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(222));
      entity.startSingleTimer(SHORT_PERIOD);
      Thread.sleep(5 * SHORT_PERIOD);
      int lCount = entity.getTimeoutCount();
      assertTrue("Timeout was expected to be called only once but was called: "
         + lCount + " times",
         lCount == 1);
      try
      {
         entity.stopTimer();
         fail("A single timer should expire after the first event and therefore this "
            + "has to throw an NoSuchObjectLocalException");
      }
      catch (RemoteException re)
      {
         Throwable lCause = re.detail;
         if (lCause instanceof ServerException)
         {
            lCause = ((ServerException) lCause).detail;
            if (lCause instanceof NoSuchObjectLocalException)
            {
               // This exception is expected -> ignore
            }
            else
            {
               throw re;
            }
         }
      }
      entity.remove();
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

      List timerHandles = pp.listTimerHandles();
      assertEquals("unexpected handle count", 0, timerHandles.size());

      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome)iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(1));
      try
      {
         entity.createTimer(500, 0, null);

         timerHandles = pp.listTimerHandles();
         assertEquals("unexpected handle count", 1, timerHandles.size());

         sleep(1000);
         assertEquals("unexpected call count", 1, entity.getCallCount());

         timerHandles = pp.listTimerHandles();
         assertEquals("unexpected handle count", 0, timerHandles.size());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

      List timerHandles = pp.listTimerHandles();
      assertEquals("unexpected handle count", 0, timerHandles.size());

      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome)iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(1));
      try
      {
         // insert a timer into the db
         ObjectName oname = ObjectNameFactory.create("jboss.j2ee:jndiName=test/txtimer/TimerEntity,service=EJB");
         TimedObjectId targetId = new TimedObjectId(oname, new Integer(1));
         pp.insertTimer("pk1", targetId, new Date(), 0, null);
         sleep(500);

         timerHandles = pp.listTimerHandles();
         assertEquals("unexpected handle count", 1, timerHandles.size());

         // fake restore on server startup
         // we cannot test that the PersistencePolicy is notified after startup
         try
         {
            getServer().invoke(
                  EJBTimerService.OBJECT_NAME,
                  "restoreTimers",
                  new Object[] { oname, null },
                  new String[]{"javax.management.ObjectName", "java.lang.ClassLoader" }
                  );
         }
         catch (Exception e)
         {
            log.warn("Could not restore ejb timers", e);
         }
         sleep(500);
         assertEquals("unexpected call count", 1, entity.getCallCount());

         timerHandles = pp.listTimerHandles();
         assertEquals("unexpected handle count", 0, timerHandles.size());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

    */
   public void testSingleEventDuration() throws Exception
   {
      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(1));
      try
      {
         entity.createTimer(500, 0, null);
         sleep(1000);
         assertEquals("unexpected call count", 1, entity.getCallCount());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

    */
   public void testInstanceAsscociation() throws Exception
   {
      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity1 = home.create(new Integer(1));
      TimerEntity entity2 = home.create(new Integer(2));

      try
      {
         entity1.createTimer(500, 1000, null);
         entity2.createTimer(500, 1000, null);
         sleep(1000);
         assertEquals("unexpected call count", 1, entity1.getCallCount());
         assertEquals("unexpected call count", 1, entity2.getCallCount());
      }
      finally
      {
         entity1.remove();
         entity2.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

      MBeanServerConnection server = getServer();
      String defaultPrincipal = (String) server.getAttribute(new ObjectName("jboss.security:service=JaasSecurityManager"), "DefaultUnauthenticatedPrincipal");

      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(1));
      try
      {
         entity.createTimer(500, 0, null);
         sleep(1000);
         assertEquals("unexpected call count", 1, entity.getCallCount());

         Principal callerPrincipal = entity.getEjbTimeoutCaller();
         assertEquals("unexpected principal", defaultPrincipal, callerPrincipal.getName());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

    */
   public void testReturnTimerHandle() throws Exception
   {
      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(1));
      try
      {

         try
         {
            TimerHandle handle = (TimerHandle) entity.createTimerReturnHandle(500);
            fail("TimerHandle should not pass through the remote interface: " + handle);
         }
         catch (Exception e)
         {
            assertTrue("Timer list should be empty", entity.getTimers().size() == 0);
            sleep(1000);
            assertEquals("unexpected call count", 0, entity.getCallCount());
         }

         try
         {
            TimerHandle handle = TimerHandleImpl.parse("[[id=jboss.j2ee:jndiName=test/txtimer/TimerEntity,service=EJB,pk=1],created=10-Apr-2004 20:16:11.000,first=10-Apr-2004 20:16:11.000,periode=0]");
            String retStr = entity.passTimerHandle(handle);
            fail("TimerHandle should not pass through the remote interface: " + retStr);
         }
         catch (Exception e)
         {
            assertTrue("Timer list should be empty", entity.getTimers().size() == 0);
            sleep(1000);
            assertEquals("unexpected call count", 0, entity.getCallCount());
         }
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

    */
   public void testRollbackAfterCreate() throws Exception
   {
      InitialContext iniCtx = getInitialContext();
      TimerEntityHome entityHome = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = entityHome.create(new Integer(1));

      TimerFacadeHome facadeHome = (TimerFacadeHome) iniCtx.lookup(TimerFacadeHome.JNDI_NAME);
      TimerFacade facade = facadeHome.create();
      try
      {
         facade.rollbackAfterCreateEntity(500);
         assertTrue("Timer list should be empty", entity.getTimers().size() == 0);
         sleep(1000);
         assertEquals("unexpected call count", 0, entity.getCallCount());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

    */
   public void testRollbackAfterCancel() throws Exception
   {
      InitialContext iniCtx = getInitialContext();
      TimerEntityHome entityHome = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = entityHome.create(new Integer(1));

      TimerFacadeHome facadeHome = (TimerFacadeHome) iniCtx.lookup(TimerFacadeHome.JNDI_NAME);
      TimerFacade facade = facadeHome.create();
      try
      {
         entity.createTimer(500, 0, null);
         facade.rollbackAfterCancelEntity();
         sleep(1000);
         assertEquals("unexpected call count", 1, entity.getCallCount());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerEntity

    */
   public void testRetryAfterRollback() throws Exception
   {
      InitialContext iniCtx = getInitialContext();
      TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(1));

      try
      {
         Properties props = new Properties();
         props.setProperty("rollback", "true");

         entity.createTimer(500, 0, props);
         sleep(1000);

         // The timer is expected to retry the invocation to ejbTimeout at least once
         // Note, due to bean sepuku the instance for retry should be another one as for the first attempt
         assertEquals("unexpected call count", 1, entity.getCallCount());
      }
      finally
      {
         entity.remove();
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.