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 68685 - Bad classpath returned for unit test root
Summary: Bad classpath returned for unit test root
Status: VERIFIED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-14 20:00 UTC by _ tball
Modified: 2011-04-14 08: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 _ tball 2005-11-14 20:00:29 UTC
I am trying to build a compile classpath for a specified project, by getting the
project's Sources, then the Sources SourceGroups, then getting each group's root
folder, then calling ClassPath.getClassPath(root, ClassPath.COMPILE).  This
works for J2SE projects.  

With a NBM project type (I'm testing with openide/util), the classpath comes
back incorrectly as:

ClassPath[Entry[jar:file:/work/src/netbeans/nb_all/nbbuild/netbeans/platform6/lib/org-openide-util.jar!/],
Entry[jar:file:/work/src/netbeans/nb_all/nbbuild/netbeans/ide6/modules/ext/junit-3.8.1.jar!/],
Entry[jar:file:/work/src/netbeans/nb_all/nbbuild/netbeans/testtools/modules/org-netbeans-modules-nbjunit.jar!/],
Entry[jar:file:/work/src/netbeans/nb_all/performance/insanelib/dist/insanelib.jar!/]]

The org-netbeans-modules-nbjunit.jar doesn't exist at the specified location. 
The module's unit tests work from Ant, however, but it uses a different
classpath (I am using "Run Unit Tests", not "Run Unit Tests using XTest"):  

/work/src/netbeans/nb_all/openide/util/build/test/unit/classes:\
/work/src/netbeans/nb_all/nbbuild/netbeans/platform6/lib/org-openide-util.jar:\
/work/src/netbeans/nb_all/xtest/lib/junit.jar:\
/work/src/netbeans/nb_all/xtest/lib/nbjunit.jar:\
/work/src/netbeans/nb_all/xtest/lib/nbjunit-ide.jar:\
/work/src/netbeans/nb_all/xtest/lib/insanelib.jar'

Shouldn't the COMPILE classpath used for the unit test root match the one Ant
uses to build the unit tests?  And how should I get the real COMPILE path?
Comment 1 Jesse Glick 2005-11-14 22:29:40 UTC
The call is correct... you just need to exclude roots which do not exist. The
problem is that there is no very standard way in which nbjunit.jar can be found.
For netbeans.org modules w/ xtest checked out, xtest/lib/nbjunit.jar is OK. But
in general, for other modules, if you want to use the nbjunit extensions you
have to download (or build) the module from AU which bundles this JAR. Since
XTest is not officially supported by the apisupport harness, neither is the
nbjunit extension - it is not included in the harness and may or may not be
available in a particular user's IDE installation. If it's not, they can't use
tests which make use of it. No plans to really clean this up for 5.0 (would
prefer that nbjunit just go away or be packaged differently, really), but can
probably tweak the effective classpath for NBM projects to be *more likely to*
produce a valid JAR location than it currently does.
Comment 2 Jesse Glick 2005-11-16 01:50:55 UTC
Working on it...
Comment 3 Jesse Glick 2005-11-16 05:00:19 UTC
Actually it turns out that there was a reason I was using a different CP in the
project evaluator - because the actual Ant CP is no good for code completion; no
source associations. So fix will be a bit more complicated.
Comment 4 _ tball 2005-11-16 05:02:09 UTC
I don't mind using a different query than code-completion, if that option makes
sense.
Comment 5 Jesse Glick 2005-11-16 05:13:58 UTC
No, CP.getCP(COMPILE) is correct, it's just going to be tricky to fix right and
make a unit test for that isn't overly sensitive to details of your build dir
(already a problem for apisupport tests checking netbeans.org module behavior).
A sampler: for code completion on junit.jar, you have to include the version of
junit.jar which is found in the running IDE installation, to get its Javadoc
association; for completion on nbjunit.jar, you actually have to use
org-netbeans-modules-nbjunit.jar (a module which refers to nbjunit.jar) to get
the reference to xtest/nbjunit/src. Can be hacked to work in a different way,
probably. I'll see.
Comment 6 Jesse Glick 2005-11-19 01:10:47 UTC
committed   * Up-To-Date  1.130      
apisupport/project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
committed   * Up-To-Date  1.6        
apisupport/project/src/org/netbeans/modules/apisupport/project/queries/GlobalJavadocForBinaryImpl.java
committed   * Up-To-Date  1.5        
apisupport/project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java
committed   * Up-To-Date  1.24       
apisupport/project/test/unit/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImplTest.java
Comment 7 _ tball 2005-11-20 22:42:56 UTC
Works exactly as expected -- thanks for your prompt response.
Comment 8 Quality Engineering 2011-04-14 08:37:26 UTC
Integrated into 'main-golden', will be available in build *201104140401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/02742b70e24b
User: Jesse Glick <jglick@netbeans.org>
Log: #68685 fix looks to be long obsolete; removing.