Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 166790 - Maven ignores src/test/resources when starting single-file-test
Maven ignores src/test/resources when starting single-file-test
Status: VERIFIED FIXED
Product: java
Classification: Unclassified
Component: Source
6.x
All Linux
: P2 (vote)
: 6.x
Assigned To: Rastislav Komara
issues@java
67patch1-verified
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-09 16:09 UTC by lorien
Modified: 2009-07-16 16:31 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lorien 2009-06-09 16:09:07 UTC
I am using NetBeans 6.7 RC2, Spring and this directory structure:
src/main/java
src/main/webapp
src/main/resources
src/test/java
src/test/resources

For my test environment I have a special applicationContext.xml in src/test/resources. This file is called if I start
the test by testing the whole project, but not if I start testing a single TestCase (it seems using src/main/resources
in this case).
Comment 1 lorien 2009-06-09 16:14:01 UTC
The project I was using while the error occured:
http://github.com/MCS/badminton-ladder/tree/master
Testing the whole project works fine, testing "LadderServiceImplTest,java" fails.
Comment 2 Milos Kleint 2009-06-10 11:48:49 UTC
possible workaround is to disable "compile on save" for tests in project properties.
Comment 3 Milos Kleint 2009-06-10 13:05:50 UTC
http://hg.netbeans.org/main/rev/cb1e43c6aa24 should fix it, it reverses the order of output folders, test output folder
comes first now, please test after it reaches the daily builds (automated message will be added to the issue).
I was not able to verify as your project could not build out of the box (missing dependencies)
Comment 4 lorien 2009-06-11 08:50:32 UTC
Where can I download a version including your fix?
Alternatively, I updated my Git project to run out-of-the-box (now it's using just standard dependencies). Maybe you
might try the test with the updated version.
Comment 5 Quality Engineering 2009-06-11 08:53:30 UTC
Integrated into 'main-golden', will be available in build *200906110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/cb1e43c6aa24
User: Milos Kleint <mkleint@netbeans.org>
Log: #166790 test output folder comes before the regular output folder
Comment 6 lorien 2009-06-12 10:48:12 UTC
Sorry, the bug is just partly fixed (tested with nightly 2009-06-11_14-01-07).
Please download the current version of my project:
http://github.com/MCS/badminton-ladder/tree/master
The spring context is now included, but the hibernate schema creation is not done when testing a single file instead of
the whole project. Worked fine in NB 6.5
Comment 7 Milos Kleint 2009-06-16 10:27:05 UTC
a workaround is to disable Compile on Save for tests. Then single test execution is also performed via maven execution
and passed.

I'm somewhat clueless with regard how to debug the problem. I'm not fluent with Spring or Hibernate. Where is the
hibernate schema creation happening? is it part of the build process? or part of the test codebase?
Comment 8 lorien 2009-06-16 12:06:20 UTC
It is part of the build process, implicitly done by Hibernate on startup.
When starting the global test, the Maven command executed by Netbeans is printed into the output console. This does not
happen on single-test execution. Has the called command changed from 6.5 to 6.7?
Comment 9 Milos Kleint 2009-06-16 13:30:31 UTC
The problem is in the way the JavaRunner implementation translates the execution classpath passed to it. What we do at
maven side is to pass the test output folder (target/test-classes) and application output folder (target/classes)
followed by the binary dependencies of the project (jars in local repository).

Then the method
org.netbeans.modules.java.source.ant.TranslateClassPath.translateEntry(String path) 
seems to take that classpath and for each of the output folders append the source folders (src/main/java,
src/main/resources for the application output and src/test/java, src/test/resources for the test output folder) to the
classpath.
Doing that breaks the test execution in this project. There is no way for me in maven projects to suppress this
behavior. Reassigning to java team.

related bugfix in maven codebase:
http://hg.netbeans.org/main/rev/72d08b52cadd
the proper jdk used in the project was not passed to javarunner, if IDE was running on 1.5, but project required 1.6,
there was an error when running.
Comment 10 Quality Engineering 2009-06-17 08:30:03 UTC
Integrated into 'main-golden', will be available in build *200906170201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/72d08b52cadd
User: Milos Kleint <mkleint@netbeans.org>
Log: #166790 use the correct jdk as assigned with the project when using JavaRunner
Comment 11 lorien 2009-06-17 11:06:46 UTC
I am very glad that you really try to fix the bug, but it is sadly still present. At least, with the newest nb version I
get an error window with the following exception:

Annotation: while loading from {service=org.netbeans.modules.websvc.project.spi.WebServiceDataProvider,
class=org.netbeans.modules.websvc.core.jaxws.projects.AntJaxWsServicesProvider,
instanceCreate=org.netbeans.modules.projectapi.LazyLookupProviders$1@19a6445}
while loading from {service=org.netbeans.modules.websvc.project.spi.WebServiceDataProvider,
class=org.netbeans.modules.websvc.core.jaxws.projects.AntJaxWsServicesProvider,
instanceCreate=org.netbeans.modules.projectapi.LazyLookupProviders$1@19a6445}
Caused by: java.lang.ClassNotFoundException: org.netbeans.modules.websvc.core.jaxws.projects.AntJaxWsServicesProvider
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at org.apache.tools.ant.module.bridge.AntBridge$MainClassLoader.findClass(AntBridge.java:622)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	at org.netbeans.modules.projectapi.LazyLookupProviders.loadPSPInstance(LazyLookupProviders.java:98)
	at org.netbeans.modules.projectapi.LazyLookupProviders.access$000(LazyLookupProviders.java:64)
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:80)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:645)
	at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:518)
	at org.openide.util.lookup.ProxyLookup$R.allInstances(ProxyLookup.java:489)
	at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:548)
	at org.openide.util.lookup.ProxyLookup$R.allInstances(ProxyLookup.java:489)
	at
org.netbeans.modules.websvc.project.spi.LookupMergerSupport$WebServiceDataProviderImpl.setLookup(LookupMergerSupport.java:107)
	at
org.netbeans.modules.websvc.project.spi.LookupMergerSupport$WebServiceDataProviderImpl.access$200(LookupMergerSupport.java:86)
	at
org.netbeans.modules.websvc.project.spi.LookupMergerSupport$WebServiceDataProviderMerger.merge(LookupMergerSupport.java:81)
	at
org.netbeans.modules.websvc.project.spi.LookupMergerSupport$WebServiceDataProviderMerger.merge(LookupMergerSupport.java:70)
	at org.netbeans.spi.project.support.LookupProviderSupport$DelegatingLookupImpl.doDelegate(LookupProviderSupport.java:223)
	at org.netbeans.spi.project.support.LookupProviderSupport$DelegatingLookupImpl.<init>(LookupProviderSupport.java:130)
	at org.netbeans.spi.project.support.LookupProviderSupport$DelegatingLookupImpl.<init>(LookupProviderSupport.java:118)
	at org.netbeans.spi.project.support.LookupProviderSupport.createCompositeLookup(LookupProviderSupport.java:89)
	at org.netbeans.modules.web.project.WebProject.createLookup(WebProject.java:541)
	at org.netbeans.modules.web.project.WebProject.<init>(WebProject.java:370)
	at org.netbeans.modules.web.project.WebProjectType.createProject(WebProjectType.java:83)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.netbeans.modules.project.ant.AntBasedGenericType.createProject(AntBasedGenericType.java:119)
	at org.netbeans.modules.project.ant.AntBasedProjectFactorySingleton.loadProject(AntBasedProjectFactorySingleton.java:240)
	at org.netbeans.api.project.ProjectManager.createProject(ProjectManager.java:354)
	at org.netbeans.api.project.ProjectManager.access$300(ProjectManager.java:80)
	at org.netbeans.api.project.ProjectManager$2.run(ProjectManager.java:275)
	at org.netbeans.api.project.ProjectManager$2.run(ProjectManager.java:227)
	at org.openide.util.Mutex.readAccess(Mutex.java:327)
	at org.netbeans.api.project.ProjectManager.findProject(ProjectManager.java:227)
	at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:129)
	at org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation.getOwner(SimpleFileOwnerQueryImplementation.java:95)
	at org.netbeans.api.project.FileOwnerQuery.getOwner(FileOwnerQuery.java:147)
	at org.netbeans.modules.java.project.ProjectSourceForBinaryQuery.findSourceRoots(ProjectSourceForBinaryQuery.java:64)
	at org.netbeans.api.java.queries.SourceForBinaryQuery.findSourceRoots(SourceForBinaryQuery.java:90)
	at org.netbeans.api.java.classpath.GlobalPathRegistry.getSourceRoots(GlobalPathRegistry.java:328)
	at org.netbeans.api.java.classpath.GlobalPathRegistry.findResource(GlobalPathRegistry.java:377)
	at org.netbeans.modules.java.project.JavaAntLogger.messageLogged(JavaAntLogger.java:236)
	at org.apache.tools.ant.module.bridge.impl.NbBuildLogger.messageLogged(NbBuildLogger.java:607)
	at org.apache.tools.ant.Project.fireMessageLoggedEvent(Project.java:2200)
	at org.apache.tools.ant.Project.fireMessageLogged(Project.java:2300)
	at org.apache.tools.ant.Project.log(Project.java:455)
	at org.apache.tools.ant.Task.log(Task.java:294)
	at org.apache.tools.ant.taskdefs.LogOutputStream.processLine(LogOutputStream.java:100)
	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask$JUnitLogOutputStream.processLine(JUnitTask.java:1931)
	at org.apache.tools.ant.taskdefs.LogOutputStream.processLine(LogOutputStream.java:90)
	at org.apache.tools.ant.util.LineOrientedOutputStream.processBuffer(LineOrientedOutputStream.java:82)
	at org.apache.tools.ant.taskdefs.LogOutputStream.processBuffer(LogOutputStream.java:77)
	at org.apache.tools.ant.util.LineOrientedOutputStream.write(LineOrientedOutputStream.java:57)
	at org.apache.tools.ant.util.LineOrientedOutputStream.write(LineOrientedOutputStream.java:132)
	at org.apache.tools.ant.taskdefs.StreamPumper.run(StreamPumper.java:93)
	at java.lang.Thread.run(Thread.java:619)
while loading from {service=org.netbeans.modules.websvc.project.spi.WebServiceDataProvider,
class=org.netbeans.modules.websvc.core.jaxws.projects.AntJaxWsServicesProvider,
instanceCreate=org.netbeans.modules.projectapi.LazyLookupProviders$1@19a6445}

Testing the whole project still works fine.

Hope that helps,
Marcus
Comment 12 Milos Kleint 2009-06-17 11:18:11 UTC
the last exception is probably unrelated to the problem in this report, please file separately, with steps to reproduce.
Comment 13 lorien 2009-06-17 12:26:42 UTC
Okay, created ticket here:
http://statistics.netbeans.org/analytics/exception.do?id=216644

But the single-testfile problem is still existing in the dev-build 200906170201.
Comment 14 lorien 2009-06-27 16:19:37 UTC
I don't know what happened, but with RC3 the problem seems to be fixed: Single-file-tests seem to work now.
Just one wish: Please re-enable the "Test" option when right-clicking into an open testfile in edit-mode. But that is
just a very little nice-to-have feature; Ctrl+F6 already works fine.

Thanks for the great work! Netbeans continues to be my favourite Java IDE for more than 6 months - it almost never
disappointed me :-)
Comment 15 Petr Blaha 2009-07-02 13:12:51 UTC
Based on report's feedback closing as verified.
Comment 16 pgebauer 2009-07-03 15:00:22 UTC
The fix has been ported into the release67_fixes repository.
http://hg.netbeans.org/release67_fixes/rev/a5a21f2e7ad3
Comment 17 Jiri Prox 2009-07-16 16:31:21 UTC
v. in 6.7.1


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo