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 165098 - Unit Test Dependency May Not Set Classpath Correctly
Summary: Unit Test Dependency May Not Set Classpath Correctly
Status: VERIFIED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: rmichalsky
URL:
Keywords:
: 165444 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-05-13 18:11 UTC by tomwheeler
Modified: 2009-05-22 22:37 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomwheeler 2009-05-13 18:11:48 UTC
I am finally getting a chance to test a recent 6.7 build.  I've created a simple suite with a few simple modules.

What I expected: 
One of these modules does not use the Utilities API, but I wanted to use a public class (Lookup) from Utilities API in
my unit test.  I right-clicked Unit Test Library, chose "Add Unit Test Dependency," selected Utilities API and clicked
OK.  I expected this would allow me to use that class in my unit test.

What I found:
I tried to call Lookup.getDefault(), but this reference gave "red squigglies" in the source editor for my unit test. 
The Quick Fix suggestion was to create a class called Lookup, rather then to import the one from the Utilities API. 
Sometimes it takes the editor a second or two to catch up, os I waited and tried again, but it still did not give me the
option of importing this class. I rebuilt the module and then the entire suite, but this did not fix it either, nor
could I manually type the class name in as an import statemen (doing so showed "red squigglies" on the import statement
as if this API's JAR file was not in the compile-time classpath). 

Eventually I tried adding a regular dependency on the Utilities API from my module (i.e. not a unit test dependency as
before).  This allowed me to import the Lookup class in my unit test.  I removed the regular dependency from my module,
but left the unit test dependency.  This still allowed me to use the class.

I was later able to reproduce this by adding a unit test dependency on the Window System API and attempting to use the
TopComponent class in my unit test, when the module containing the test did not have a regular dependency on the Window
System API.


Here are the relevant details of the configuration under which I experienced this:

Product Version: NetBeans IDE Dev (Build 200905120201)
Java: 1.6.0_12; Java HotSpot(TM) Client VM 11.2-b01
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Comment 1 tomwheeler 2009-05-13 18:34:38 UTC
I have also found that restarting the IDE will correct the classpath (i.e. let me use the reference without "red
squigglies") without having the add the regular dependency to my module and then remove it again.  Both of these
workarounds are annoying (particularly for someone who writes a lot of tests), but they do seem to work in all cases.
Comment 2 tomwheeler 2009-05-13 20:37:50 UTC
This also seems to affect qa-functional tests as well; see this issue for more details:

   http://www.netbeans.org/issues/show_bug.cgi?id=165109
Comment 3 rmichalsky 2009-05-18 21:47:15 UTC
*** Issue 165444 has been marked as a duplicate of this issue. ***
Comment 4 rmichalsky 2009-05-21 15:35:58 UTC
core-main #7448ebb20b8a
issue #165712 remains when removing library.
Comment 5 rmichalsky 2009-05-21 15:41:13 UTC
impl. note: adding test dep was probably redundantly performed under project write lock, removing it seems safe:
1) code works with its own copy of project.xml fragment and putConfigurationData() enters write lock itself
2) adding regular dep works in the same manner without the lock
3) it doesn't break any test :)
Comment 6 Quality Engineering 2009-05-22 07:20:59 UTC
Integrated into 'main-golden', will be available in build *200905220201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/7448ebb20b8a
User: Richard Michalsky <rmichalsky@netbeans.org>
Log: #165098: fixing propagation of unit test classpath change
Comment 7 tomwheeler 2009-05-22 22:37:25 UTC
Verified in JavaSE version of nightly build #200905221401