java - How to invoke shutdown hooks of a program running in another thread -


i writing automated tests swing application using jemmy framework.

my test suite run application invoking main method of main class in new thread.

i have written lot of gui-related tests have got more complex task.

i need check if tested application clean of folders when being closed. action executed shutdown hook. somehow possible invoke shutdown hooks of application without calling system.exit(0)?

when command called both threads terminated. want thread tests continue running after tested application closed can check if folders still exist or not. somehow possible invoke shutdown hooks without changing architecture of test suite?

i found this, didn't test it:

applicationshutdownhooks.hook().run(); // jre 6 applicationshutdownhooks.runhooks();   // jre 7 

as can see, names of methods changed on time, means shouldn't this. however, think should job, class private. using reflection, force execution of it.

// jre 7 try {     class cl = class.forname("java.lang.applicationshutdownhooks");     method m = cl.getdeclaredmethod("runhooks");     m.setaccessible(true);     m.invoke(null); } catch (exception e) {     e.printstacktrace(system.out); } 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -