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 110064 - Navigate Test is hardcoded for Java
Summary: Navigate Test is hardcoded for Java
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Marian Petras
URL:
Keywords:
Depends on:
Blocks: 108599
  Show dependency tree
 
Reported: 2007-07-17 20:08 UTC by Torbjorn Norbye
Modified: 2007-10-11 17:14 UTC (History)
3 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Separating navigate-to-test action from navigate-to-test search implementations (24.16 KB, application/x-compressed)
2007-07-17 20:09 UTC, Torbjorn Norbye
Details
CVS diff for modified files (does not include new files) (14.12 KB, patch)
2007-10-05 19:45 UTC, Marian Petras
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Torbjorn Norbye 2007-07-17 20:08:17 UTC
The "Test" action in the Navigate menu is hardcoded for Java/JUnit. This is causing bugs like issue 108599.

The "Test" action should really be added by a module which delegates to specific test implementations.  JUnit would plug into this.

I've made the necessary changes. I'll attach them as a zip to this issue. It contains two parts:

utilities/gototest:

A simple module which has an SPI class (TestLocator).  TestLocator is an interface implemented by services which can locate tests (or tested files from 
tests).  The utilities/gototest module registers the action, menu item and keyboard shortcut for Go To Test.  Its implementation uses lookup to find test 
locators, and delegates to these to perform its logic (computing the Navigate menu item text, locating the test, or computing an appropriate error 
message).

The second part are some changes to the junit module. These are pretty straightforward. I've modified the GoToOppositeAction such that instead of being a 
CallableSystemAction, it just implements the TestLocator interface. I ripped out code related to finding the current fileobject from the registry etc. The rest 
is self explanatory I think.  I also modified the layer to remove reigstration of the test action (since that's now done by the gototest module), and finally I 
made the junit module depend on the utilities/gototest module. 

The final diff adds utilities/gototest to the ide cluster right next to utilities/jumpto.
Comment 1 Torbjorn Norbye 2007-07-17 20:09:49 UTC
Created attachment 45253 [details]
Separating navigate-to-test action from navigate-to-test search implementations
Comment 2 Petr Jiricka 2007-10-05 13:54:23 UTC
Tomas/Marian, any update on this issue? Thanks.
Comment 3 Marian Petras 2007-10-05 19:45:44 UTC
Created attachment 50286 [details]
CVS diff for modified files (does not include new files)
Comment 4 Marian Petras 2007-10-05 19:51:02 UTC
I attached a diff file containing differences against the current source base. New files are not included.
Comment 5 Marian Petras 2007-10-05 20:21:40 UTC
Tor, I am sorry I have not pay attention to this task for such a long time (I only observed bugs and a couple of
requests for enhancements).

I looked over your changes, applied them to the current source base (modified licenses, etc.) and quickly verified they
work. I think it is a really straightforward (or, ad-hoc) solution for the concrete problem so I agree it is applied for
NB 6.0. I would like to make a proper solution for the next release as I do not like the current solution much (action
Go to Test delegates to GoToOppositeAction in JUnit which then delegates to some implementation of JUnitPlugin).

So I agree with the integration. I just do not know whether it is OK to add a new module without any reviews. I let it
up to you to negotiate it - is it OK?
Comment 6 Petr Jiricka 2007-10-05 23:02:20 UTC
Thanks Marian.

> I just do not know whether it is OK to add a new module without any reviews. 

If it is needed for a bugfix, then it is ok.
Comment 7 Torbjorn Norbye 2007-10-10 04:31:30 UTC
Hi Marian,
It sounds like Petr agrees, so go for it. (We've also added some similar modules in 6.0, such as the "Open Type" private
api in utilities/jumpto. As long as it's friend only, I think it's okay.)
Comment 8 Marian Petras 2007-10-10 14:22:48 UTC
Done - committed to the trunk.

New and modified files:
    junit/src/org/netbeans/modules/junit/GoToOppositeAction.java   (1.16)
    junit/src/org/netbeans/modules/junit/resources/layer.xml   (1.62)
    junit/src/META-INF/services/org.netbeans.spi.gototest.TestLocator   (1.1 - new)
    junit/nbproject/project.xml   (1.27)
    utilities/gototest/src/org/netbeans/modules/gototest/Bundle.properties   (1.1 - new)
    utilities/gototest/src/org/netbeans/modules/gototest/GotoOppositeAction.java   (1.1 - new)
    utilities/gototest/src/org/netbeans/modules/gototest/resources/Bundle.properties   (1.1 - new)
    utilities/gototest/src/org/netbeans/modules/gototest/resources/layer.xml   (1.1 - new)
    utilities/gototest/src/org/netbeans/spi/gototest/TestLocator.java   (1.1 - new)
    utilities/gototest/.cvsignore   (1.1 - new)
    utilities/gototest/manifest.mf   (1.1 - new)
    utilities/gototest/build.xml   (1.1 - new)
    utilities/gototest/nbproject/.cvsignore   (1.1 - new)
    utilities/gototest/nbproject/project.xml   (1.1 - new)
    utilities/gototest/nbproject/project.properties   (1.1 - new)
    nbbuild/cluster.properties   (1.432)

Diffs:
http://deadlock.netbeans.org/fisheye/browse/netbeans/junit/src/org/netbeans/modules/junit/GoToOppositeAction.java?r1=1.15&r2=1.16
http://deadlock.netbeans.org/fisheye/browse/netbeans/junit/src/org/netbeans/modules/junit/resources/layer.xml?r1=1.61&r2=1.62
http://deadlock.netbeans.org/fisheye/browse/netbeans/junit/src/META-INF/services/org.netbeans.spi.gototest.TestLocator?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/junit/nbproject/project.xml?r1=1.26&r2=1.27
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/src/org/netbeans/modules/gototest/Bundle.properties?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/src/org/netbeans/modules/gototest/GotoOppositeAction.java?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/src/org/netbeans/modules/gototest/resources/Bundle.properties?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/src/org/netbeans/modules/gototest/resources/layer.xml?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/src/org/netbeans/spi/gototest/TestLocator.java?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/.cvsignore?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/manifest.mf?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/build.xml?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/nbproject/.cvsignore?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/nbproject/project.xml?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/gototest/nbproject/project.properties?r=1.1
http://deadlock.netbeans.org/fisheye/browse/netbeans/nbbuild/cluster.properties?r1=1.431&r2=1.432
Comment 9 Torbjorn Norbye 2007-10-10 18:07:11 UTC
Marian, thanks a lot for applying this!

One final issue: I notice that the context menu for "Go To Test" is "Test", but all other context menu actions for
navigation start with "Go to". 

I've added the GotoTestAction to my editorkit's Navigate popup menu, and it contains

Go to Declaration
Go to Action/View
Test

Similarly, in my Java files I see
Go to Source
Go to Declaration
Go to Super Implementation

Do you mind if I change the context menu label from "Test" to "Go to Test" ?

The constructor contains some logic around "trimmed text" that I don't fully understand (it puts "trimmed-text" into the
properties of the action etc.) so I want to make sure I don't break something:

        String trimmedName = NbBundle.getMessage(
                GotoOppositeAction.class,
                "LBL_Action_GoToTest_trimmed"); //NOI18N
        putValue("PopupMenuText", trimmedName); //NOI18N
        putValue("trimmed-text", trimmedName); //NOI18N

If "trimmed-text" is indeed used, I'd like to just change this to

        String trimmedName = NbBundle.getMessage(
                GotoOppositeAction.class,
                "LBL_Action_GoToTest_trimmed"); //NOI18N
        putValue("trimmed-text", trimmedName); //NOI18N

        String name = NbBundle.getMessage(
                GotoOppositeAction.class,
                "LBL_Action_GoToTest"); //NOI18N
        putValue("PopupMenuText", name); //NOI18N
Comment 10 Marian Petras 2007-10-11 17:14:58 UTC
I do not mind if you change the context menu label from "Test" to "Go to Test".

I do not know nothing about "trimmed-text" - it was not me who wrote that part of code. I will look at it but not now -
I am in hurry at the moment.