ServerTestApplication, JUnitServerJob and scheduling... [message #1175001] |
Thu, 07 November 2013 08:04  |
Eclipse User |
|
|
|
I have a MyAppServerTestApplication with follwing code:
public class MyServerTestApplication implements IApplication {
@Override
public Object start(IApplicationContext context) throws Exception {
//perform test and exist:
new JUnitServerJob().schedule();
return IApplication.EXIT_OK;
}
@Override
public void stop() {
}
}
As recommended by the Javadoc of JUnitServerJob.
When I try to run my test application, I get a null pointer exception at:
JUnitTestClassBrowser:105 - Corresponding line:
for (Bundle bundle : Activator.getDefault().getBundle().getBundleContext().getBundles()) {
The complete stack trace is visible in the some INIT xml file in the test result folder.
---
It seems to me the thread that executes the tests comes too late. The main thread (where the application is started) does not wait enough, and one of the call (getBundleContext() or getBundles() returns null)...
Because I do not know the Eclipse Jobs very well, I have modified the code of the ServerTest application:
@Override
public Object start(IApplicationContext context) throws Exception {
//perform test and exist:
JUnitServerJob job = new JUnitServerJob();
job.schedule();
job.join();
return IApplication.EXIT_OK;
}
1/ is this a good idea to add a join() call?
2/ how can I debug (without influencing the execution with my breakpoints)?
Thanks in advance.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.41323 seconds