1 Reply Latest reply on Feb 23, 2016 6:34 AM by El Arbi Abou

    Adding a delay to wait for EJB3 Timers

    El Arbi Abou Newbie

      Hi,

       

      I'm using Arquillian 1.0.0.Alpha1 foe remote testing on Wildfly 8.2.1.

      How can I test a method marked as @Timeout ?

      I want to be able to make my test wait for some seconds for ex.

      Since the test are in container tests I must not use Thread.sleep. So how can I do that ?

       

      This is an excerpt of my service under test :

       

       

      @Stateless

      public class PublicationService {

       

           @Resource

          TimerService timerService;

         

          /**

           * Publish a player for a certain period of time

           * @param player

           * @param periodInMillis

           * @return

           */

          public Publication publish(Player player, long periodInMillis) {

         

              Publication publication = playerRepository.createPublicationForPlayer(player);

              Timer time = timerService.createSingleActionTimer(periodInMillis, new TimerConfig(player, true));

              return publication;

             

          }

       

          @Timeout

          public void retract(Timer timer) {

           //do some domain stuffs...

          }

      }

       

       

       

      Thanks for your help.