Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » problem with org.eclipse.ui.internal.MakeHandlersGo
problem with org.eclipse.ui.internal.MakeHandlersGo [message #782375] Mon, 23 January 2012 16:10 Go to next message
Vincent Lorenzo is currently offline Vincent LorenzoFriend
Messages: 249
Registered: June 2010
Location: Paris Saclay, France
Senior Member
Hi all,
On Eclipse indigo, I wrote JUnit tests to tests the handler activation :
org.eclipse.core.commands.Command testedCommand = ...
IHandler handler = testedCommand.getHandler();
if(handler instanceof HandlerProxy) {
handler = ((HandlerProxy)currentHandler).getHandler();
}
Assert.isTrue(handler instanceof myOwnHandler);
Assert.isTrue(handler.isEnabled());
...

Now, testedCommand.getHandler() returns an MakeHandlersGo and not the handler declared in the plugin.xml...
Do you have a solution to adapt my code to E4, but it continues to work on Eclipse 3.8 ?

Is a Layer Compatibility bug?

Regards,

Re: problem with org.eclipse.ui.internal.MakeHandlersGo [message #783507 is a reply to message #782375] Wed, 25 January 2012 21:11 Go to previous message
Eclipse UserFriend
vincent lorenzo wrote on Mon, 23 January 2012 11:10

Is a Layer Compatibility bug?


No. Your test is relying on an implementation detail.

There's no guarantee in Command.getHandler() that the handler returned is the actual handler object to be executed. But calling execute() on that returned handler object will cause the handler to be executed.

(In E4, handlers can be POJOs; the compat layer wraps these handlers in an IHandler wrapper.)

vincent lorenzo wrote on Mon, 23 January 2012 11:10

Do you have a solution to adapt my code to E4, but it continues to work on Eclipse 3.8 ?


Not really.

What are you actually trying to test? That your handler will be executed? (What if there are other handlers for the command?) That its activeWhen expression is correct? Perhaps associate a dummy handler with the same expression that sets a value on execution, and then actually execute it.
Previous Topic:Dependency Injection in Abstract Classes
Next Topic:Toolbar Contribution
Goto Forum:
  


Current Time: Thu Apr 25 22:25:17 GMT 2024

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

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

Back to the top