You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by antonio <an...@vieiro.net> on 2021/05/17 20:49:55 UTC
Lookup, MIMEResolver and unit tests?
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: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: Lookup, MIMEResolver and unit tests?
Posted by antonio <an...@vieiro.net>.
These ones helped:
https://netbeans.apache.org/wiki/TestingThingsThatUseFileObjectDataObjectDataFolder.asciidoc
https://netbeans.apache.org/wiki/DevFaqTestDataObject.asciidoc
Thanks,
Antonio
El 17/5/21 a las 22:49, antonio escribió:
> 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: dev-unsubscribe@netbeans.apache.org
For additional commands, e-mail: dev-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists