Shutting down Quartz cleanly at end of testing using the eclipse testng plugin

358 views
Skip to first unread message

Ben Walding

unread,
Jun 24, 2005, 9:26:14 PM6/24/05
to testng...@googlegroups.com
At present, we setup a common Quartz scheduler to run for the lifetime
of all our tests (setup by Spring as part of our application).

Its main thread is a non-daemon thread, and so at the end of execution
the jvm stays alive with two threads running -

1) Thread[main,5,main]
2)
Thread[QuartzScheduler_QuartzSchedulerThread,5,QuartzScheduler:QuartzScheduler]

The only way to shutdown thread #2 is to stop the scheduler. However is
there a clean way to do this using testng? i.e. a post testing shutdown
hook?

At the moment we fake it using a test that shuts it down, but we can't
guarantee when it will run, and if we only run failed tests, then it
isn't run anyway.
(Also note: all our actual jobs are run using daemon threads via the
org.quartz.threadPool.makeThreadsDaemons option)




Cheers,

Ben

Alexandru Popescu

unread,
Jun 25, 2005, 10:35:19 AM6/25/05
to testng...@googlegroups.com
#: by Ben Walding's words the mind was *winged* :#
Not very sure i have understood the scenario, but the impression i got is that the @Configuration
afterTest or even later @Configuration afterSuite methods may help you.

pls let us know if i completely missed your question.

:alex |.::the_mindstorm::.|

Ben Walding

unread,
Jun 25, 2005, 10:32:27 AM6/25/05
to testng...@googlegroups.com
Alexandru Popescu wrote:

>#:
>
>>The gist of my problem was that I needed a way to run a method at the end of all testing that could shut down some pieces of code. I also needed something that would run irrespective of whether we were only running failed tests or not.
>>
>
>Not very sure i have understood the scenario, but the impression i got is that the @Configuration
>afterTest or even later @Configuration afterSuite methods may help you.
>
>pls let us know if i completely missed your question.
>
>
>
Excellent. I just grabbed the latest version and found the afterSuite
method which was sorely lacking from my version (I was still languishing
at 2.2).

FYI: The online javadoc is out of date -
http://www.testng.org/javadocs/com/beust/testng/annotations/Configuration.html
does not show an afterSuite method which would have probably jogged my
brain into action.


Thanks,

Ben
Reply all
Reply to author
Forward
0 new messages