2005-12-12

Eclipse: Testing the multi-thread code.

A short snippet:

public void setUp() throws Exception {
finished = false;
}

public void testSomething() throws Exception{
new Thread(){
try{
doSomethingLongAndLogIt();
} finally { finished = true; }
}.start();

while(!finished && !Display.getCurrent().readAndDispatch()){
display.sleep();
}
}


There, it seems to be the full Eclipse emulation. Now one can be sure that inside doSomethingLongAndLogIt() method all communications with UI are going within Display thread.

Can't do without 'while' because the workbench might be already closed before it comes to UI calls.

No comments:

Post a Comment