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.

Bug 35775 - NewTemplateAction stopped to work in tests
Summary: NewTemplateAction stopped to work in tests
Status: VERIFIED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 3.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords: T9Y
Depends on:
Blocks:
 
Reported: 2003-08-26 13:24 UTC by Jiri Skrivanek
Modified: 2008-12-22 20:57 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test case (755 bytes, text/plain)
2003-08-26 13:25 UTC, Jiri Skrivanek
Details
Corrected version of test case using NTCA (561 bytes, text/plain)
2003-08-26 17:34 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Skrivanek 2003-08-26 13:24:00 UTC
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?
Comment 1 Jiri Skrivanek 2003-08-26 13:25:02 UTC
Created attachment 11433 [details]
Test case
Comment 2 Jesse Glick 2003-08-26 17:34:09 UTC
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.
Comment 3 Jesse Glick 2003-08-26 17:34:51 UTC
Created attachment 11448 [details]
Corrected version of test case using NTCA
Comment 4 Jiri Skrivanek 2003-08-26 19:46:37 UTC
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.
Comment 5 Jesse Glick 2003-08-26 21:55:04 UTC
Yes, if you have some independent way of telling what the result of an
action should be, that is best.