This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
After #35755 was integrated newTemplateAction called in tests stopped to work. It used to be called this way: String className = "org.openide.actions.NewTemplateAction"; final Class systemActionClass = Class.forName(className); SystemAction.get(systemActionClass).actionPerformed(new ActionEvent(new Container(), 0, null)); Now it is invoked in dispatch thread: EventQueue.invokeAndWait(new Runnable() { public void run() { SystemAction.get(systemActionClass).actionPerformed( new ActionEvent(new Container(), 0, null)); } }); So, why doesn't it work executed by internal executor in IDE?
Created attachment 11433 [details] Test case
NewTemplateAction is a NodeAction, meaning it is enabled iff some condition holds on its selected nodes; see NTA.enable(Node[]) for details. If you call it with an action event just passing some Component, and do not set up a global node selection, it will not be enabled; it will just beep (turn up your computer's volume). This is as designed. I am not sure what it was doing before, but it was probably wrong. A corrected version of the test is attached. Note that you should run: System.setProperty("org.openide.util.actions.CallableSystemAction.synchronousByDefault", "true"); inside the VM, early (before any actions have been run, or using -D on the cmd line) if you want actions to run synch - otherwise Finished will be printed immediately, before the action has really finished. This system property should be considered temporary; there is currently no infrastructure or API in NB for running a particular task to completion and waiting for it, unless you are given an org.openide.util.Task object, or the documentation for a method explicitly states that something will have been done by the time the method returns. In particular, there is no guarantee made as to how much (if any) of an action has been "done" when its actionPerformed method returns; it is an implementation detail of the action, which may require periodic adjustment of tests.
Created attachment 11448 [details] Corrected version of test case using NTCA
OK, I see. BTW, to know when an action finished I can check the result of action, e.g. new wizard is open for NewTemplateAction.
Yes, if you have some independent way of telling what the result of an action should be, that is best.