tim-group / test-driven-detectors4findbugs

Test-Driven Detectors For FindBugs. Utility project to ease the development of custom plugin detectors for FindBugs.
Other
17 stars 17 forks source link

RuntimeException: Failed to setup FindBugs dependencies for testing caused by FileNotFoundException #5

Closed heuermh closed 12 years ago

heuermh commented 12 years ago

If I run

$ mvn test

on

https://github.com/tomfitzhenry/findbugs-guice

in cygwin, several unit tests fail/error with

Caused by: java.lang.RuntimeException: Failed to setup FindBugs dependencies for testing. at com.youdevise.fbplugins.tdd4fb.DetectorRunner.(DetectorRunner.java:70) at com.youdevise.fbplugins.tdd4fb.DetectorRunner.(DetectorRunner.java:56) at com.youdevise.fbplugins.tdd4fb.DetectorRunner$Singleton.(DetectorRunner.java:63) ... 34 more Caused by: java.io.FileNotFoundException: C:\cygwin\home\xxx\working\findbugs-guice\C (The system cannot find the file specified) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.(ZipFile.java:127) at java.util.zip.ZipFile.(ZipFile.java:143) at edu.umd.cs.findbugs.classfile.impl.ZipFileCodeBase.(ZipFileCodeBase.java:53) at edu.umd.cs.findbugs.classfile.impl.ZipCodeBaseFactory.countUsingZipFile(ZipCodeBaseFactory.java:92) at edu.umd.cs.findbugs.classfile.impl.ZipCodeBaseFactory.makeZipCodeBase(ZipCodeBaseFactory.java:46) at edu.umd.cs.findbugs.classfile.impl.ClassFactory.createFilesystemCodeBase(ClassFactory.java:97) at edu.umd.cs.findbugs.classfile.impl.FilesystemCodeBaseLocator.openCodeBase(FilesystemCodeBaseLocator.java:75) at com.youdevise.fbplugins.tdd4fb.DetectorRunner.addAuxCodeBasesFromClassPath(DetectorRunner.java:111) at com.youdevise.fbplugins.tdd4fb.DetectorRunner.setUpStaticDependenciesWithinFindBugs(DetectorRunner.java:92) at com.youdevise.fbplugins.tdd4fb.DetectorRunner.(DetectorRunner.java:68) ... 36 more

nonFinalFieldInjectionIsNotReported(uk.me.tom_fitzhenry.findbugs.guice.FinalFieldInjectionDetectorTest) Time elapsed: 0 sec <<< ERROR! java.lang.NoClassDefFoundError: Could not initialize class com.youdevise.fbplugins.tdd4fb.DetectorRunner$Singleton

It appears that FilesystemCodeBaseLocator.openCodeBase is attempting to create an invalid path.

$ mvn -v Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600) Maven home: C:\cygwin\home\xxx\bin\apache-maven-3.0.3 Java version: 1.6.0_30, vendor: Sun Microsystems Inc. Java home: C:\jdk1.6.0_30\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"

heuermh commented 12 years ago

Works fine for me on linux

$ mvn -v Apache Maven 2.2.1 (rdebian-6) Java version: 1.6.0_23 Java home: /usr/lib/jvm/java-6-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "3.0.0-12-generic" arch: "i386" Family: "unix"

Grundlefleck commented 12 years ago

Hi,

This is a quick ACK to let you know I'm aware of this. I'll get back in touch ASAP with more details when I take a look at the code. I may need some iterations to get feedback about it working on Windows, as I may not be able to get hold of a Windows environment.

Regards, Graham

heuermh commented 12 years ago

Very cool. I will help where I can.

Since this is only a problem on Windows (and possibly only Windows+cygwin) it is not a showstopper for me.

Grundlefleck commented 12 years ago

Hi,

It looks like it's a trivial mistake, so it should be no problem to fix. Could you please test out an updated jar from here:

https://github.com/downloads/youdevise/test-driven-detectors4findbugs/test-driven-detectors4findbugs-0.2.1-SNAPSHOT.jar

And let me know if that works?

Regards, Graham

P.S. Just in case you're not familiar with maven, I think the easiest way to do that is to create a directory, in the base of the project, named 'lib', download the jar linked to above into the lib directory, and change the dependency info to:

<dependency>
            <groupId>com.youdevise</groupId>
            <artifactId>test-driven-detectors4findbugs</artifactId>
            <version>0.2.1</version>
            <scope>system</scope>
            <systemPath>${basedir}/lib/test-driven-detectors4findbugs-0.2.1-SNAPSHOT.jar</systemPath>
</dependency>

And try 'mvn test' again. If you know a better way, using a snapshot repository, that's available here: https://oss.sonatype.org/content/repositories/snapshots/com/youdevise/test-driven-detectors4findbugs/0.2.1-SNAPSHOT/

That would just be a temporary step, if that works I'll publish a new version to maven central.

heuermh commented 12 years ago

That works for me, thank you. Feel free to close this issue when it gets to maven central.

Grundlefleck commented 12 years ago

The updated version has been released and should be synced to maven central in the next couple of hours.