[forge-dev] Interesting behavior of CommandController (bug or feature ; ))

Ivan St. Ivanov ivan.st.ivanov at gmail.com
Fri Jul 3 08:36:33 EDT 2015

Hi everybody,

Believe it or not, but I resumed my work on the Servlet Security addon for
Forge (https://issues.jboss.org/browse/FORGEPLUGINS-152) :)

And I found something that I don't know whether is a bug or a feature. If
my Command class implements the PrerequisiteCommandsProvider and if I try
to use the CommandController in my integration test, then I have a problem.
Here is a sample code:

try (CommandController commandController = testHarness
         commandController.setValueFor("securityRealm", realm);
         commandController.setValueFor("authMethod", authenticationMethod);

This code fails at the setValueFor method simply because the UI was not
initialized in the initialize method above it and there are no such inputs
like securityRealm and authMethod.

I did some debugging and found that if SecuritySetupCommand implements the
PrerequisiteCommandsProvider interface, the
commandController.initialize() method does not
call PrerequisiteCommandsProvider#initializeUI method. Instead it
triggeres PrerequisiteCommandTransformer.DelegateWizard#initializeUI. Which
is empty and does nothing. And that's the reason why there are no
securityRealm and authMethod controls.

I guess that it is caused by some CDI "magic"? So I wonder is it a bug or a
feature? Can I use CommandController to test commands that implement

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20150703/f7f9f713/attachment.html 

More information about the forge-dev mailing list