Hi all,

How does one initialize the FileObject machinery properly in a unit test?

When I try to convert a plain java.io.File's to FileObject, this is what happens:

a) If I do this on a static initializer things work properly:

static {
        File file = ...
        FileObject fileObject = FileUtil.toFileObject(file);
}

b) If I don't, i.e., if I do the FileUtil.toFileObject(file) conversion inside a @Test then I think there're some threading issues somehow, and I get a problem when FileUtil.toFileObject invokes MetaInfServices.lookup which in turn invokes sun.net.www.MimeEntry.setImageFileName which fails.

I've already added MimeLookup API to the test dependencies (and the Master Filesystem in my desperation), shall I add any implementation for these as well? Shall I run a lock or initialize a FileSystem or something before invoking FileUtil.toFileObject? Any examples I can take a look at?

Thanks in advance,
Antonio


P.S.: This happens both with NbUnitTestCase and with plain JUNit 4 tests cases.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to