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: 44
Registered: June 2010
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
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 194
Registered: January 2012
Senior Member

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.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Dependency Injection in Abstract Classes
Next Topic:Toolbar Contribution
Goto Forum:
  


Current Time: Thu Nov 27 08:22:42 GMT 2014

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

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