Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » ServerTestApplication, JUnitServerJob and scheduling...
ServerTestApplication, JUnitServerJob and scheduling... [message #1175001] Thu, 07 November 2013 13:04 Go to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
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.
Re: ServerTestApplication, JUnitServerJob and scheduling... [message #1175190 is a reply to message #1175001] Thu, 07 November 2013 15:35 Go to previous messageGo to next message
Matthias Villiger is currently offline Matthias VilligerFriend
Messages: 232
Registered: September 2011
Senior Member
Hi Jérémie,

1/ Using job.join() is the correct solution.
2/ You can also use sysout but this also has some impact. I prefer using the breakpoints and manually release thread by thread to ensure I reproduce the situation I want to.

regards,
m
Re: ServerTestApplication, JUnitServerJob and scheduling... [message #1175210 is a reply to message #1175190] Thu, 07 November 2013 15:48 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I just had a look at the JavaDoc of the IApplication#stop() method.

Maybe I should put the join() call there...
Re: ServerTestApplication, JUnitServerJob and scheduling... [message #1175222 is a reply to message #1175210] Thu, 07 November 2013 15:56 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Ok, IApplication#start(IApplicationContext) seems also to be better:
"this method must not exit until the application is finished and is ready to exit."

Previous Topic:Not sure if we've found an SDK bug
Next Topic:Force RadioButtonGroup to re-read its values from LookupCall
Goto Forum:
  


Current Time: Thu Apr 18 18:45:44 GMT 2024

Powered by FUDForum. Page generated in 0.03258 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top