1 Reply Latest reply on Aug 19, 2009 4:30 AM by Nikolay Elenkov

    catching exceptions while testing @Asynchronous methods?

    Jean Luc Apprentice

      I'm wondering if anyone has some ideas about the following scenario:



      1. a test (TestNG) calling some methods on EJBs/Seam components

      2. the tested code also calls some @Asynchronous methods on another component

      3. the @Asynchronous methods are executed (on a different thread, of course) but throw exceptions

      4. the testing thread is not aware of the exceptions on the other thread and may succeed unless something is done about this.



      One obvious and fair approach is not to rely on the automatic failure caused by an unhandled exception but by verifying (after some sleep time) the results afterwards (i.e. has the @Asynchronous method actually been executed completely).


      I'm curious if there are other ways to be more direct in detecting the exception and failing the tests.


      Thanks,
      -jl